mutation.go 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748
  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/compapiasynctask"
  19. "wechat-api/ent/contact"
  20. "wechat-api/ent/creditbalance"
  21. "wechat-api/ent/creditusage"
  22. "wechat-api/ent/custom_types"
  23. "wechat-api/ent/employee"
  24. "wechat-api/ent/employeeconfig"
  25. "wechat-api/ent/label"
  26. "wechat-api/ent/labelrelationship"
  27. "wechat-api/ent/labeltagging"
  28. "wechat-api/ent/message"
  29. "wechat-api/ent/messagerecords"
  30. "wechat-api/ent/msg"
  31. "wechat-api/ent/payrecharge"
  32. "wechat-api/ent/predicate"
  33. "wechat-api/ent/server"
  34. "wechat-api/ent/sopnode"
  35. "wechat-api/ent/sopstage"
  36. "wechat-api/ent/soptask"
  37. "wechat-api/ent/token"
  38. "wechat-api/ent/tutorial"
  39. "wechat-api/ent/usagedetail"
  40. "wechat-api/ent/usagestatisticday"
  41. "wechat-api/ent/usagestatistichour"
  42. "wechat-api/ent/usagestatisticmonth"
  43. "wechat-api/ent/usagetotal"
  44. "wechat-api/ent/whatsapp"
  45. "wechat-api/ent/whatsappchannel"
  46. "wechat-api/ent/workexperience"
  47. "wechat-api/ent/wpchatroom"
  48. "wechat-api/ent/wpchatroommember"
  49. "wechat-api/ent/wx"
  50. "wechat-api/ent/wxcard"
  51. "wechat-api/ent/wxcarduser"
  52. "wechat-api/ent/wxcardvisit"
  53. "entgo.io/ent"
  54. "entgo.io/ent/dialect/sql"
  55. )
  56. const (
  57. // Operation types.
  58. OpCreate = ent.OpCreate
  59. OpDelete = ent.OpDelete
  60. OpDeleteOne = ent.OpDeleteOne
  61. OpUpdate = ent.OpUpdate
  62. OpUpdateOne = ent.OpUpdateOne
  63. // Node types.
  64. TypeAgent = "Agent"
  65. TypeAgentBase = "AgentBase"
  66. TypeAliyunAvatar = "AliyunAvatar"
  67. TypeAllocAgent = "AllocAgent"
  68. TypeApiKey = "ApiKey"
  69. TypeBatchMsg = "BatchMsg"
  70. TypeCategory = "Category"
  71. TypeChatRecords = "ChatRecords"
  72. TypeChatSession = "ChatSession"
  73. TypeCompapiAsynctask = "CompapiAsynctask"
  74. TypeContact = "Contact"
  75. TypeCreditBalance = "CreditBalance"
  76. TypeCreditUsage = "CreditUsage"
  77. TypeEmployee = "Employee"
  78. TypeEmployeeConfig = "EmployeeConfig"
  79. TypeLabel = "Label"
  80. TypeLabelRelationship = "LabelRelationship"
  81. TypeLabelTagging = "LabelTagging"
  82. TypeMessage = "Message"
  83. TypeMessageRecords = "MessageRecords"
  84. TypeMsg = "Msg"
  85. TypePayRecharge = "PayRecharge"
  86. TypeServer = "Server"
  87. TypeSopNode = "SopNode"
  88. TypeSopStage = "SopStage"
  89. TypeSopTask = "SopTask"
  90. TypeToken = "Token"
  91. TypeTutorial = "Tutorial"
  92. TypeUsageDetail = "UsageDetail"
  93. TypeUsageStatisticDay = "UsageStatisticDay"
  94. TypeUsageStatisticHour = "UsageStatisticHour"
  95. TypeUsageStatisticMonth = "UsageStatisticMonth"
  96. TypeUsageTotal = "UsageTotal"
  97. TypeWhatsapp = "Whatsapp"
  98. TypeWhatsappChannel = "WhatsappChannel"
  99. TypeWorkExperience = "WorkExperience"
  100. TypeWpChatroom = "WpChatroom"
  101. TypeWpChatroomMember = "WpChatroomMember"
  102. TypeWx = "Wx"
  103. TypeWxCard = "WxCard"
  104. TypeWxCardUser = "WxCardUser"
  105. TypeWxCardVisit = "WxCardVisit"
  106. )
  107. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  108. type AgentMutation struct {
  109. config
  110. op Op
  111. typ string
  112. id *uint64
  113. created_at *time.Time
  114. updated_at *time.Time
  115. deleted_at *time.Time
  116. name *string
  117. role *string
  118. status *int
  119. addstatus *int
  120. background *string
  121. examples *string
  122. organization_id *uint64
  123. addorganization_id *int64
  124. dataset_id *string
  125. collection_id *string
  126. model *string
  127. api_base *string
  128. api_key *string
  129. _type *int
  130. add_type *int
  131. clearedFields map[string]struct{}
  132. wx_agent map[uint64]struct{}
  133. removedwx_agent map[uint64]struct{}
  134. clearedwx_agent bool
  135. token_agent map[uint64]struct{}
  136. removedtoken_agent map[uint64]struct{}
  137. clearedtoken_agent bool
  138. wa_agent map[uint64]struct{}
  139. removedwa_agent map[uint64]struct{}
  140. clearedwa_agent bool
  141. key_agent map[uint64]struct{}
  142. removedkey_agent map[uint64]struct{}
  143. clearedkey_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. // ClearRole clears the value of the "role" field.
  410. func (m *AgentMutation) ClearRole() {
  411. m.role = nil
  412. m.clearedFields[agent.FieldRole] = struct{}{}
  413. }
  414. // RoleCleared returns if the "role" field was cleared in this mutation.
  415. func (m *AgentMutation) RoleCleared() bool {
  416. _, ok := m.clearedFields[agent.FieldRole]
  417. return ok
  418. }
  419. // ResetRole resets all changes to the "role" field.
  420. func (m *AgentMutation) ResetRole() {
  421. m.role = nil
  422. delete(m.clearedFields, agent.FieldRole)
  423. }
  424. // SetStatus sets the "status" field.
  425. func (m *AgentMutation) SetStatus(i int) {
  426. m.status = &i
  427. m.addstatus = nil
  428. }
  429. // Status returns the value of the "status" field in the mutation.
  430. func (m *AgentMutation) Status() (r int, exists bool) {
  431. v := m.status
  432. if v == nil {
  433. return
  434. }
  435. return *v, true
  436. }
  437. // OldStatus returns the old "status" field's value of the Agent entity.
  438. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  440. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  441. if !m.op.Is(OpUpdateOne) {
  442. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  443. }
  444. if m.id == nil || m.oldValue == nil {
  445. return v, errors.New("OldStatus requires an ID field in the mutation")
  446. }
  447. oldValue, err := m.oldValue(ctx)
  448. if err != nil {
  449. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  450. }
  451. return oldValue.Status, nil
  452. }
  453. // AddStatus adds i to the "status" field.
  454. func (m *AgentMutation) AddStatus(i int) {
  455. if m.addstatus != nil {
  456. *m.addstatus += i
  457. } else {
  458. m.addstatus = &i
  459. }
  460. }
  461. // AddedStatus returns the value that was added to the "status" field in this mutation.
  462. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  463. v := m.addstatus
  464. if v == nil {
  465. return
  466. }
  467. return *v, true
  468. }
  469. // ClearStatus clears the value of the "status" field.
  470. func (m *AgentMutation) ClearStatus() {
  471. m.status = nil
  472. m.addstatus = nil
  473. m.clearedFields[agent.FieldStatus] = struct{}{}
  474. }
  475. // StatusCleared returns if the "status" field was cleared in this mutation.
  476. func (m *AgentMutation) StatusCleared() bool {
  477. _, ok := m.clearedFields[agent.FieldStatus]
  478. return ok
  479. }
  480. // ResetStatus resets all changes to the "status" field.
  481. func (m *AgentMutation) ResetStatus() {
  482. m.status = nil
  483. m.addstatus = nil
  484. delete(m.clearedFields, agent.FieldStatus)
  485. }
  486. // SetBackground sets the "background" field.
  487. func (m *AgentMutation) SetBackground(s string) {
  488. m.background = &s
  489. }
  490. // Background returns the value of the "background" field in the mutation.
  491. func (m *AgentMutation) Background() (r string, exists bool) {
  492. v := m.background
  493. if v == nil {
  494. return
  495. }
  496. return *v, true
  497. }
  498. // OldBackground returns the old "background" field's value of the Agent entity.
  499. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  501. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  502. if !m.op.Is(OpUpdateOne) {
  503. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  504. }
  505. if m.id == nil || m.oldValue == nil {
  506. return v, errors.New("OldBackground requires an ID field in the mutation")
  507. }
  508. oldValue, err := m.oldValue(ctx)
  509. if err != nil {
  510. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  511. }
  512. return oldValue.Background, nil
  513. }
  514. // ClearBackground clears the value of the "background" field.
  515. func (m *AgentMutation) ClearBackground() {
  516. m.background = nil
  517. m.clearedFields[agent.FieldBackground] = struct{}{}
  518. }
  519. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  520. func (m *AgentMutation) BackgroundCleared() bool {
  521. _, ok := m.clearedFields[agent.FieldBackground]
  522. return ok
  523. }
  524. // ResetBackground resets all changes to the "background" field.
  525. func (m *AgentMutation) ResetBackground() {
  526. m.background = nil
  527. delete(m.clearedFields, agent.FieldBackground)
  528. }
  529. // SetExamples sets the "examples" field.
  530. func (m *AgentMutation) SetExamples(s string) {
  531. m.examples = &s
  532. }
  533. // Examples returns the value of the "examples" field in the mutation.
  534. func (m *AgentMutation) Examples() (r string, exists bool) {
  535. v := m.examples
  536. if v == nil {
  537. return
  538. }
  539. return *v, true
  540. }
  541. // OldExamples returns the old "examples" field's value of the Agent entity.
  542. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  544. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  545. if !m.op.Is(OpUpdateOne) {
  546. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  547. }
  548. if m.id == nil || m.oldValue == nil {
  549. return v, errors.New("OldExamples requires an ID field in the mutation")
  550. }
  551. oldValue, err := m.oldValue(ctx)
  552. if err != nil {
  553. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  554. }
  555. return oldValue.Examples, nil
  556. }
  557. // ClearExamples clears the value of the "examples" field.
  558. func (m *AgentMutation) ClearExamples() {
  559. m.examples = nil
  560. m.clearedFields[agent.FieldExamples] = struct{}{}
  561. }
  562. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  563. func (m *AgentMutation) ExamplesCleared() bool {
  564. _, ok := m.clearedFields[agent.FieldExamples]
  565. return ok
  566. }
  567. // ResetExamples resets all changes to the "examples" field.
  568. func (m *AgentMutation) ResetExamples() {
  569. m.examples = nil
  570. delete(m.clearedFields, agent.FieldExamples)
  571. }
  572. // SetOrganizationID sets the "organization_id" field.
  573. func (m *AgentMutation) SetOrganizationID(u uint64) {
  574. m.organization_id = &u
  575. m.addorganization_id = nil
  576. }
  577. // OrganizationID returns the value of the "organization_id" field in the mutation.
  578. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  579. v := m.organization_id
  580. if v == nil {
  581. return
  582. }
  583. return *v, true
  584. }
  585. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  586. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  588. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  589. if !m.op.Is(OpUpdateOne) {
  590. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  591. }
  592. if m.id == nil || m.oldValue == nil {
  593. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  594. }
  595. oldValue, err := m.oldValue(ctx)
  596. if err != nil {
  597. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  598. }
  599. return oldValue.OrganizationID, nil
  600. }
  601. // AddOrganizationID adds u to the "organization_id" field.
  602. func (m *AgentMutation) AddOrganizationID(u int64) {
  603. if m.addorganization_id != nil {
  604. *m.addorganization_id += u
  605. } else {
  606. m.addorganization_id = &u
  607. }
  608. }
  609. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  610. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  611. v := m.addorganization_id
  612. if v == nil {
  613. return
  614. }
  615. return *v, true
  616. }
  617. // ResetOrganizationID resets all changes to the "organization_id" field.
  618. func (m *AgentMutation) ResetOrganizationID() {
  619. m.organization_id = nil
  620. m.addorganization_id = nil
  621. }
  622. // SetDatasetID sets the "dataset_id" field.
  623. func (m *AgentMutation) SetDatasetID(s string) {
  624. m.dataset_id = &s
  625. }
  626. // DatasetID returns the value of the "dataset_id" field in the mutation.
  627. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  628. v := m.dataset_id
  629. if v == nil {
  630. return
  631. }
  632. return *v, true
  633. }
  634. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  635. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  637. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  638. if !m.op.Is(OpUpdateOne) {
  639. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  640. }
  641. if m.id == nil || m.oldValue == nil {
  642. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  643. }
  644. oldValue, err := m.oldValue(ctx)
  645. if err != nil {
  646. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  647. }
  648. return oldValue.DatasetID, nil
  649. }
  650. // ResetDatasetID resets all changes to the "dataset_id" field.
  651. func (m *AgentMutation) ResetDatasetID() {
  652. m.dataset_id = nil
  653. }
  654. // SetCollectionID sets the "collection_id" field.
  655. func (m *AgentMutation) SetCollectionID(s string) {
  656. m.collection_id = &s
  657. }
  658. // CollectionID returns the value of the "collection_id" field in the mutation.
  659. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  660. v := m.collection_id
  661. if v == nil {
  662. return
  663. }
  664. return *v, true
  665. }
  666. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  667. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  669. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  670. if !m.op.Is(OpUpdateOne) {
  671. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  672. }
  673. if m.id == nil || m.oldValue == nil {
  674. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  675. }
  676. oldValue, err := m.oldValue(ctx)
  677. if err != nil {
  678. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  679. }
  680. return oldValue.CollectionID, nil
  681. }
  682. // ResetCollectionID resets all changes to the "collection_id" field.
  683. func (m *AgentMutation) ResetCollectionID() {
  684. m.collection_id = nil
  685. }
  686. // SetModel sets the "model" field.
  687. func (m *AgentMutation) SetModel(s string) {
  688. m.model = &s
  689. }
  690. // Model returns the value of the "model" field in the mutation.
  691. func (m *AgentMutation) Model() (r string, exists bool) {
  692. v := m.model
  693. if v == nil {
  694. return
  695. }
  696. return *v, true
  697. }
  698. // OldModel returns the old "model" field's value of the Agent entity.
  699. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  701. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  702. if !m.op.Is(OpUpdateOne) {
  703. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  704. }
  705. if m.id == nil || m.oldValue == nil {
  706. return v, errors.New("OldModel requires an ID field in the mutation")
  707. }
  708. oldValue, err := m.oldValue(ctx)
  709. if err != nil {
  710. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  711. }
  712. return oldValue.Model, nil
  713. }
  714. // ClearModel clears the value of the "model" field.
  715. func (m *AgentMutation) ClearModel() {
  716. m.model = nil
  717. m.clearedFields[agent.FieldModel] = struct{}{}
  718. }
  719. // ModelCleared returns if the "model" field was cleared in this mutation.
  720. func (m *AgentMutation) ModelCleared() bool {
  721. _, ok := m.clearedFields[agent.FieldModel]
  722. return ok
  723. }
  724. // ResetModel resets all changes to the "model" field.
  725. func (m *AgentMutation) ResetModel() {
  726. m.model = nil
  727. delete(m.clearedFields, agent.FieldModel)
  728. }
  729. // SetAPIBase sets the "api_base" field.
  730. func (m *AgentMutation) SetAPIBase(s string) {
  731. m.api_base = &s
  732. }
  733. // APIBase returns the value of the "api_base" field in the mutation.
  734. func (m *AgentMutation) APIBase() (r string, exists bool) {
  735. v := m.api_base
  736. if v == nil {
  737. return
  738. }
  739. return *v, true
  740. }
  741. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  742. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  744. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  745. if !m.op.Is(OpUpdateOne) {
  746. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  747. }
  748. if m.id == nil || m.oldValue == nil {
  749. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  750. }
  751. oldValue, err := m.oldValue(ctx)
  752. if err != nil {
  753. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  754. }
  755. return oldValue.APIBase, nil
  756. }
  757. // ClearAPIBase clears the value of the "api_base" field.
  758. func (m *AgentMutation) ClearAPIBase() {
  759. m.api_base = nil
  760. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  761. }
  762. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  763. func (m *AgentMutation) APIBaseCleared() bool {
  764. _, ok := m.clearedFields[agent.FieldAPIBase]
  765. return ok
  766. }
  767. // ResetAPIBase resets all changes to the "api_base" field.
  768. func (m *AgentMutation) ResetAPIBase() {
  769. m.api_base = nil
  770. delete(m.clearedFields, agent.FieldAPIBase)
  771. }
  772. // SetAPIKey sets the "api_key" field.
  773. func (m *AgentMutation) SetAPIKey(s string) {
  774. m.api_key = &s
  775. }
  776. // APIKey returns the value of the "api_key" field in the mutation.
  777. func (m *AgentMutation) APIKey() (r string, exists bool) {
  778. v := m.api_key
  779. if v == nil {
  780. return
  781. }
  782. return *v, true
  783. }
  784. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  785. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  787. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  788. if !m.op.Is(OpUpdateOne) {
  789. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  790. }
  791. if m.id == nil || m.oldValue == nil {
  792. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  793. }
  794. oldValue, err := m.oldValue(ctx)
  795. if err != nil {
  796. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  797. }
  798. return oldValue.APIKey, nil
  799. }
  800. // ClearAPIKey clears the value of the "api_key" field.
  801. func (m *AgentMutation) ClearAPIKey() {
  802. m.api_key = nil
  803. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  804. }
  805. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  806. func (m *AgentMutation) APIKeyCleared() bool {
  807. _, ok := m.clearedFields[agent.FieldAPIKey]
  808. return ok
  809. }
  810. // ResetAPIKey resets all changes to the "api_key" field.
  811. func (m *AgentMutation) ResetAPIKey() {
  812. m.api_key = nil
  813. delete(m.clearedFields, agent.FieldAPIKey)
  814. }
  815. // SetType sets the "type" field.
  816. func (m *AgentMutation) SetType(i int) {
  817. m._type = &i
  818. m.add_type = nil
  819. }
  820. // GetType returns the value of the "type" field in the mutation.
  821. func (m *AgentMutation) GetType() (r int, exists bool) {
  822. v := m._type
  823. if v == nil {
  824. return
  825. }
  826. return *v, true
  827. }
  828. // OldType returns the old "type" field's value of the Agent entity.
  829. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  831. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  832. if !m.op.Is(OpUpdateOne) {
  833. return v, errors.New("OldType is only allowed on UpdateOne operations")
  834. }
  835. if m.id == nil || m.oldValue == nil {
  836. return v, errors.New("OldType requires an ID field in the mutation")
  837. }
  838. oldValue, err := m.oldValue(ctx)
  839. if err != nil {
  840. return v, fmt.Errorf("querying old value for OldType: %w", err)
  841. }
  842. return oldValue.Type, nil
  843. }
  844. // AddType adds i to the "type" field.
  845. func (m *AgentMutation) AddType(i int) {
  846. if m.add_type != nil {
  847. *m.add_type += i
  848. } else {
  849. m.add_type = &i
  850. }
  851. }
  852. // AddedType returns the value that was added to the "type" field in this mutation.
  853. func (m *AgentMutation) AddedType() (r int, exists bool) {
  854. v := m.add_type
  855. if v == nil {
  856. return
  857. }
  858. return *v, true
  859. }
  860. // ClearType clears the value of the "type" field.
  861. func (m *AgentMutation) ClearType() {
  862. m._type = nil
  863. m.add_type = nil
  864. m.clearedFields[agent.FieldType] = struct{}{}
  865. }
  866. // TypeCleared returns if the "type" field was cleared in this mutation.
  867. func (m *AgentMutation) TypeCleared() bool {
  868. _, ok := m.clearedFields[agent.FieldType]
  869. return ok
  870. }
  871. // ResetType resets all changes to the "type" field.
  872. func (m *AgentMutation) ResetType() {
  873. m._type = nil
  874. m.add_type = nil
  875. delete(m.clearedFields, agent.FieldType)
  876. }
  877. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  878. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  879. if m.wx_agent == nil {
  880. m.wx_agent = make(map[uint64]struct{})
  881. }
  882. for i := range ids {
  883. m.wx_agent[ids[i]] = struct{}{}
  884. }
  885. }
  886. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  887. func (m *AgentMutation) ClearWxAgent() {
  888. m.clearedwx_agent = true
  889. }
  890. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  891. func (m *AgentMutation) WxAgentCleared() bool {
  892. return m.clearedwx_agent
  893. }
  894. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  895. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  896. if m.removedwx_agent == nil {
  897. m.removedwx_agent = make(map[uint64]struct{})
  898. }
  899. for i := range ids {
  900. delete(m.wx_agent, ids[i])
  901. m.removedwx_agent[ids[i]] = struct{}{}
  902. }
  903. }
  904. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  905. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  906. for id := range m.removedwx_agent {
  907. ids = append(ids, id)
  908. }
  909. return
  910. }
  911. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  912. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  913. for id := range m.wx_agent {
  914. ids = append(ids, id)
  915. }
  916. return
  917. }
  918. // ResetWxAgent resets all changes to the "wx_agent" edge.
  919. func (m *AgentMutation) ResetWxAgent() {
  920. m.wx_agent = nil
  921. m.clearedwx_agent = false
  922. m.removedwx_agent = nil
  923. }
  924. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  925. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  926. if m.token_agent == nil {
  927. m.token_agent = make(map[uint64]struct{})
  928. }
  929. for i := range ids {
  930. m.token_agent[ids[i]] = struct{}{}
  931. }
  932. }
  933. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  934. func (m *AgentMutation) ClearTokenAgent() {
  935. m.clearedtoken_agent = true
  936. }
  937. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  938. func (m *AgentMutation) TokenAgentCleared() bool {
  939. return m.clearedtoken_agent
  940. }
  941. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  942. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  943. if m.removedtoken_agent == nil {
  944. m.removedtoken_agent = make(map[uint64]struct{})
  945. }
  946. for i := range ids {
  947. delete(m.token_agent, ids[i])
  948. m.removedtoken_agent[ids[i]] = struct{}{}
  949. }
  950. }
  951. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  952. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  953. for id := range m.removedtoken_agent {
  954. ids = append(ids, id)
  955. }
  956. return
  957. }
  958. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  959. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  960. for id := range m.token_agent {
  961. ids = append(ids, id)
  962. }
  963. return
  964. }
  965. // ResetTokenAgent resets all changes to the "token_agent" edge.
  966. func (m *AgentMutation) ResetTokenAgent() {
  967. m.token_agent = nil
  968. m.clearedtoken_agent = false
  969. m.removedtoken_agent = nil
  970. }
  971. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  972. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  973. if m.wa_agent == nil {
  974. m.wa_agent = make(map[uint64]struct{})
  975. }
  976. for i := range ids {
  977. m.wa_agent[ids[i]] = struct{}{}
  978. }
  979. }
  980. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  981. func (m *AgentMutation) ClearWaAgent() {
  982. m.clearedwa_agent = true
  983. }
  984. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  985. func (m *AgentMutation) WaAgentCleared() bool {
  986. return m.clearedwa_agent
  987. }
  988. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  989. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  990. if m.removedwa_agent == nil {
  991. m.removedwa_agent = make(map[uint64]struct{})
  992. }
  993. for i := range ids {
  994. delete(m.wa_agent, ids[i])
  995. m.removedwa_agent[ids[i]] = struct{}{}
  996. }
  997. }
  998. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  999. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  1000. for id := range m.removedwa_agent {
  1001. ids = append(ids, id)
  1002. }
  1003. return
  1004. }
  1005. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  1006. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  1007. for id := range m.wa_agent {
  1008. ids = append(ids, id)
  1009. }
  1010. return
  1011. }
  1012. // ResetWaAgent resets all changes to the "wa_agent" edge.
  1013. func (m *AgentMutation) ResetWaAgent() {
  1014. m.wa_agent = nil
  1015. m.clearedwa_agent = false
  1016. m.removedwa_agent = nil
  1017. }
  1018. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  1019. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  1020. if m.key_agent == nil {
  1021. m.key_agent = make(map[uint64]struct{})
  1022. }
  1023. for i := range ids {
  1024. m.key_agent[ids[i]] = struct{}{}
  1025. }
  1026. }
  1027. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  1028. func (m *AgentMutation) ClearKeyAgent() {
  1029. m.clearedkey_agent = true
  1030. }
  1031. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  1032. func (m *AgentMutation) KeyAgentCleared() bool {
  1033. return m.clearedkey_agent
  1034. }
  1035. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  1036. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  1037. if m.removedkey_agent == nil {
  1038. m.removedkey_agent = make(map[uint64]struct{})
  1039. }
  1040. for i := range ids {
  1041. delete(m.key_agent, ids[i])
  1042. m.removedkey_agent[ids[i]] = struct{}{}
  1043. }
  1044. }
  1045. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  1046. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  1047. for id := range m.removedkey_agent {
  1048. ids = append(ids, id)
  1049. }
  1050. return
  1051. }
  1052. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  1053. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  1054. for id := range m.key_agent {
  1055. ids = append(ids, id)
  1056. }
  1057. return
  1058. }
  1059. // ResetKeyAgent resets all changes to the "key_agent" edge.
  1060. func (m *AgentMutation) ResetKeyAgent() {
  1061. m.key_agent = nil
  1062. m.clearedkey_agent = false
  1063. m.removedkey_agent = nil
  1064. }
  1065. // Where appends a list predicates to the AgentMutation builder.
  1066. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  1067. m.predicates = append(m.predicates, ps...)
  1068. }
  1069. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  1070. // users can use type-assertion to append predicates that do not depend on any generated package.
  1071. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  1072. p := make([]predicate.Agent, len(ps))
  1073. for i := range ps {
  1074. p[i] = ps[i]
  1075. }
  1076. m.Where(p...)
  1077. }
  1078. // Op returns the operation name.
  1079. func (m *AgentMutation) Op() Op {
  1080. return m.op
  1081. }
  1082. // SetOp allows setting the mutation operation.
  1083. func (m *AgentMutation) SetOp(op Op) {
  1084. m.op = op
  1085. }
  1086. // Type returns the node type of this mutation (Agent).
  1087. func (m *AgentMutation) Type() string {
  1088. return m.typ
  1089. }
  1090. // Fields returns all fields that were changed during this mutation. Note that in
  1091. // order to get all numeric fields that were incremented/decremented, call
  1092. // AddedFields().
  1093. func (m *AgentMutation) Fields() []string {
  1094. fields := make([]string, 0, 15)
  1095. if m.created_at != nil {
  1096. fields = append(fields, agent.FieldCreatedAt)
  1097. }
  1098. if m.updated_at != nil {
  1099. fields = append(fields, agent.FieldUpdatedAt)
  1100. }
  1101. if m.deleted_at != nil {
  1102. fields = append(fields, agent.FieldDeletedAt)
  1103. }
  1104. if m.name != nil {
  1105. fields = append(fields, agent.FieldName)
  1106. }
  1107. if m.role != nil {
  1108. fields = append(fields, agent.FieldRole)
  1109. }
  1110. if m.status != nil {
  1111. fields = append(fields, agent.FieldStatus)
  1112. }
  1113. if m.background != nil {
  1114. fields = append(fields, agent.FieldBackground)
  1115. }
  1116. if m.examples != nil {
  1117. fields = append(fields, agent.FieldExamples)
  1118. }
  1119. if m.organization_id != nil {
  1120. fields = append(fields, agent.FieldOrganizationID)
  1121. }
  1122. if m.dataset_id != nil {
  1123. fields = append(fields, agent.FieldDatasetID)
  1124. }
  1125. if m.collection_id != nil {
  1126. fields = append(fields, agent.FieldCollectionID)
  1127. }
  1128. if m.model != nil {
  1129. fields = append(fields, agent.FieldModel)
  1130. }
  1131. if m.api_base != nil {
  1132. fields = append(fields, agent.FieldAPIBase)
  1133. }
  1134. if m.api_key != nil {
  1135. fields = append(fields, agent.FieldAPIKey)
  1136. }
  1137. if m._type != nil {
  1138. fields = append(fields, agent.FieldType)
  1139. }
  1140. return fields
  1141. }
  1142. // Field returns the value of a field with the given name. The second boolean
  1143. // return value indicates that this field was not set, or was not defined in the
  1144. // schema.
  1145. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1146. switch name {
  1147. case agent.FieldCreatedAt:
  1148. return m.CreatedAt()
  1149. case agent.FieldUpdatedAt:
  1150. return m.UpdatedAt()
  1151. case agent.FieldDeletedAt:
  1152. return m.DeletedAt()
  1153. case agent.FieldName:
  1154. return m.Name()
  1155. case agent.FieldRole:
  1156. return m.Role()
  1157. case agent.FieldStatus:
  1158. return m.Status()
  1159. case agent.FieldBackground:
  1160. return m.Background()
  1161. case agent.FieldExamples:
  1162. return m.Examples()
  1163. case agent.FieldOrganizationID:
  1164. return m.OrganizationID()
  1165. case agent.FieldDatasetID:
  1166. return m.DatasetID()
  1167. case agent.FieldCollectionID:
  1168. return m.CollectionID()
  1169. case agent.FieldModel:
  1170. return m.Model()
  1171. case agent.FieldAPIBase:
  1172. return m.APIBase()
  1173. case agent.FieldAPIKey:
  1174. return m.APIKey()
  1175. case agent.FieldType:
  1176. return m.GetType()
  1177. }
  1178. return nil, false
  1179. }
  1180. // OldField returns the old value of the field from the database. An error is
  1181. // returned if the mutation operation is not UpdateOne, or the query to the
  1182. // database failed.
  1183. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1184. switch name {
  1185. case agent.FieldCreatedAt:
  1186. return m.OldCreatedAt(ctx)
  1187. case agent.FieldUpdatedAt:
  1188. return m.OldUpdatedAt(ctx)
  1189. case agent.FieldDeletedAt:
  1190. return m.OldDeletedAt(ctx)
  1191. case agent.FieldName:
  1192. return m.OldName(ctx)
  1193. case agent.FieldRole:
  1194. return m.OldRole(ctx)
  1195. case agent.FieldStatus:
  1196. return m.OldStatus(ctx)
  1197. case agent.FieldBackground:
  1198. return m.OldBackground(ctx)
  1199. case agent.FieldExamples:
  1200. return m.OldExamples(ctx)
  1201. case agent.FieldOrganizationID:
  1202. return m.OldOrganizationID(ctx)
  1203. case agent.FieldDatasetID:
  1204. return m.OldDatasetID(ctx)
  1205. case agent.FieldCollectionID:
  1206. return m.OldCollectionID(ctx)
  1207. case agent.FieldModel:
  1208. return m.OldModel(ctx)
  1209. case agent.FieldAPIBase:
  1210. return m.OldAPIBase(ctx)
  1211. case agent.FieldAPIKey:
  1212. return m.OldAPIKey(ctx)
  1213. case agent.FieldType:
  1214. return m.OldType(ctx)
  1215. }
  1216. return nil, fmt.Errorf("unknown Agent field %s", name)
  1217. }
  1218. // SetField sets the value of a field with the given name. It returns an error if
  1219. // the field is not defined in the schema, or if the type mismatched the field
  1220. // type.
  1221. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1222. switch name {
  1223. case agent.FieldCreatedAt:
  1224. v, ok := value.(time.Time)
  1225. if !ok {
  1226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1227. }
  1228. m.SetCreatedAt(v)
  1229. return nil
  1230. case agent.FieldUpdatedAt:
  1231. v, ok := value.(time.Time)
  1232. if !ok {
  1233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1234. }
  1235. m.SetUpdatedAt(v)
  1236. return nil
  1237. case agent.FieldDeletedAt:
  1238. v, ok := value.(time.Time)
  1239. if !ok {
  1240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1241. }
  1242. m.SetDeletedAt(v)
  1243. return nil
  1244. case agent.FieldName:
  1245. v, ok := value.(string)
  1246. if !ok {
  1247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1248. }
  1249. m.SetName(v)
  1250. return nil
  1251. case agent.FieldRole:
  1252. v, ok := value.(string)
  1253. if !ok {
  1254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1255. }
  1256. m.SetRole(v)
  1257. return nil
  1258. case agent.FieldStatus:
  1259. v, ok := value.(int)
  1260. if !ok {
  1261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1262. }
  1263. m.SetStatus(v)
  1264. return nil
  1265. case agent.FieldBackground:
  1266. v, ok := value.(string)
  1267. if !ok {
  1268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1269. }
  1270. m.SetBackground(v)
  1271. return nil
  1272. case agent.FieldExamples:
  1273. v, ok := value.(string)
  1274. if !ok {
  1275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1276. }
  1277. m.SetExamples(v)
  1278. return nil
  1279. case agent.FieldOrganizationID:
  1280. v, ok := value.(uint64)
  1281. if !ok {
  1282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1283. }
  1284. m.SetOrganizationID(v)
  1285. return nil
  1286. case agent.FieldDatasetID:
  1287. v, ok := value.(string)
  1288. if !ok {
  1289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1290. }
  1291. m.SetDatasetID(v)
  1292. return nil
  1293. case agent.FieldCollectionID:
  1294. v, ok := value.(string)
  1295. if !ok {
  1296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1297. }
  1298. m.SetCollectionID(v)
  1299. return nil
  1300. case agent.FieldModel:
  1301. v, ok := value.(string)
  1302. if !ok {
  1303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1304. }
  1305. m.SetModel(v)
  1306. return nil
  1307. case agent.FieldAPIBase:
  1308. v, ok := value.(string)
  1309. if !ok {
  1310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1311. }
  1312. m.SetAPIBase(v)
  1313. return nil
  1314. case agent.FieldAPIKey:
  1315. v, ok := value.(string)
  1316. if !ok {
  1317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1318. }
  1319. m.SetAPIKey(v)
  1320. return nil
  1321. case agent.FieldType:
  1322. v, ok := value.(int)
  1323. if !ok {
  1324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1325. }
  1326. m.SetType(v)
  1327. return nil
  1328. }
  1329. return fmt.Errorf("unknown Agent field %s", name)
  1330. }
  1331. // AddedFields returns all numeric fields that were incremented/decremented during
  1332. // this mutation.
  1333. func (m *AgentMutation) AddedFields() []string {
  1334. var fields []string
  1335. if m.addstatus != nil {
  1336. fields = append(fields, agent.FieldStatus)
  1337. }
  1338. if m.addorganization_id != nil {
  1339. fields = append(fields, agent.FieldOrganizationID)
  1340. }
  1341. if m.add_type != nil {
  1342. fields = append(fields, agent.FieldType)
  1343. }
  1344. return fields
  1345. }
  1346. // AddedField returns the numeric value that was incremented/decremented on a field
  1347. // with the given name. The second boolean return value indicates that this field
  1348. // was not set, or was not defined in the schema.
  1349. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1350. switch name {
  1351. case agent.FieldStatus:
  1352. return m.AddedStatus()
  1353. case agent.FieldOrganizationID:
  1354. return m.AddedOrganizationID()
  1355. case agent.FieldType:
  1356. return m.AddedType()
  1357. }
  1358. return nil, false
  1359. }
  1360. // AddField adds the value to the field with the given name. It returns an error if
  1361. // the field is not defined in the schema, or if the type mismatched the field
  1362. // type.
  1363. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1364. switch name {
  1365. case agent.FieldStatus:
  1366. v, ok := value.(int)
  1367. if !ok {
  1368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1369. }
  1370. m.AddStatus(v)
  1371. return nil
  1372. case agent.FieldOrganizationID:
  1373. v, ok := value.(int64)
  1374. if !ok {
  1375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1376. }
  1377. m.AddOrganizationID(v)
  1378. return nil
  1379. case agent.FieldType:
  1380. v, ok := value.(int)
  1381. if !ok {
  1382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1383. }
  1384. m.AddType(v)
  1385. return nil
  1386. }
  1387. return fmt.Errorf("unknown Agent numeric field %s", name)
  1388. }
  1389. // ClearedFields returns all nullable fields that were cleared during this
  1390. // mutation.
  1391. func (m *AgentMutation) ClearedFields() []string {
  1392. var fields []string
  1393. if m.FieldCleared(agent.FieldDeletedAt) {
  1394. fields = append(fields, agent.FieldDeletedAt)
  1395. }
  1396. if m.FieldCleared(agent.FieldRole) {
  1397. fields = append(fields, agent.FieldRole)
  1398. }
  1399. if m.FieldCleared(agent.FieldStatus) {
  1400. fields = append(fields, agent.FieldStatus)
  1401. }
  1402. if m.FieldCleared(agent.FieldBackground) {
  1403. fields = append(fields, agent.FieldBackground)
  1404. }
  1405. if m.FieldCleared(agent.FieldExamples) {
  1406. fields = append(fields, agent.FieldExamples)
  1407. }
  1408. if m.FieldCleared(agent.FieldModel) {
  1409. fields = append(fields, agent.FieldModel)
  1410. }
  1411. if m.FieldCleared(agent.FieldAPIBase) {
  1412. fields = append(fields, agent.FieldAPIBase)
  1413. }
  1414. if m.FieldCleared(agent.FieldAPIKey) {
  1415. fields = append(fields, agent.FieldAPIKey)
  1416. }
  1417. if m.FieldCleared(agent.FieldType) {
  1418. fields = append(fields, agent.FieldType)
  1419. }
  1420. return fields
  1421. }
  1422. // FieldCleared returns a boolean indicating if a field with the given name was
  1423. // cleared in this mutation.
  1424. func (m *AgentMutation) FieldCleared(name string) bool {
  1425. _, ok := m.clearedFields[name]
  1426. return ok
  1427. }
  1428. // ClearField clears the value of the field with the given name. It returns an
  1429. // error if the field is not defined in the schema.
  1430. func (m *AgentMutation) ClearField(name string) error {
  1431. switch name {
  1432. case agent.FieldDeletedAt:
  1433. m.ClearDeletedAt()
  1434. return nil
  1435. case agent.FieldRole:
  1436. m.ClearRole()
  1437. return nil
  1438. case agent.FieldStatus:
  1439. m.ClearStatus()
  1440. return nil
  1441. case agent.FieldBackground:
  1442. m.ClearBackground()
  1443. return nil
  1444. case agent.FieldExamples:
  1445. m.ClearExamples()
  1446. return nil
  1447. case agent.FieldModel:
  1448. m.ClearModel()
  1449. return nil
  1450. case agent.FieldAPIBase:
  1451. m.ClearAPIBase()
  1452. return nil
  1453. case agent.FieldAPIKey:
  1454. m.ClearAPIKey()
  1455. return nil
  1456. case agent.FieldType:
  1457. m.ClearType()
  1458. return nil
  1459. }
  1460. return fmt.Errorf("unknown Agent nullable field %s", name)
  1461. }
  1462. // ResetField resets all changes in the mutation for the field with the given name.
  1463. // It returns an error if the field is not defined in the schema.
  1464. func (m *AgentMutation) ResetField(name string) error {
  1465. switch name {
  1466. case agent.FieldCreatedAt:
  1467. m.ResetCreatedAt()
  1468. return nil
  1469. case agent.FieldUpdatedAt:
  1470. m.ResetUpdatedAt()
  1471. return nil
  1472. case agent.FieldDeletedAt:
  1473. m.ResetDeletedAt()
  1474. return nil
  1475. case agent.FieldName:
  1476. m.ResetName()
  1477. return nil
  1478. case agent.FieldRole:
  1479. m.ResetRole()
  1480. return nil
  1481. case agent.FieldStatus:
  1482. m.ResetStatus()
  1483. return nil
  1484. case agent.FieldBackground:
  1485. m.ResetBackground()
  1486. return nil
  1487. case agent.FieldExamples:
  1488. m.ResetExamples()
  1489. return nil
  1490. case agent.FieldOrganizationID:
  1491. m.ResetOrganizationID()
  1492. return nil
  1493. case agent.FieldDatasetID:
  1494. m.ResetDatasetID()
  1495. return nil
  1496. case agent.FieldCollectionID:
  1497. m.ResetCollectionID()
  1498. return nil
  1499. case agent.FieldModel:
  1500. m.ResetModel()
  1501. return nil
  1502. case agent.FieldAPIBase:
  1503. m.ResetAPIBase()
  1504. return nil
  1505. case agent.FieldAPIKey:
  1506. m.ResetAPIKey()
  1507. return nil
  1508. case agent.FieldType:
  1509. m.ResetType()
  1510. return nil
  1511. }
  1512. return fmt.Errorf("unknown Agent field %s", name)
  1513. }
  1514. // AddedEdges returns all edge names that were set/added in this mutation.
  1515. func (m *AgentMutation) AddedEdges() []string {
  1516. edges := make([]string, 0, 4)
  1517. if m.wx_agent != nil {
  1518. edges = append(edges, agent.EdgeWxAgent)
  1519. }
  1520. if m.token_agent != nil {
  1521. edges = append(edges, agent.EdgeTokenAgent)
  1522. }
  1523. if m.wa_agent != nil {
  1524. edges = append(edges, agent.EdgeWaAgent)
  1525. }
  1526. if m.key_agent != nil {
  1527. edges = append(edges, agent.EdgeKeyAgent)
  1528. }
  1529. return edges
  1530. }
  1531. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1532. // name in this mutation.
  1533. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1534. switch name {
  1535. case agent.EdgeWxAgent:
  1536. ids := make([]ent.Value, 0, len(m.wx_agent))
  1537. for id := range m.wx_agent {
  1538. ids = append(ids, id)
  1539. }
  1540. return ids
  1541. case agent.EdgeTokenAgent:
  1542. ids := make([]ent.Value, 0, len(m.token_agent))
  1543. for id := range m.token_agent {
  1544. ids = append(ids, id)
  1545. }
  1546. return ids
  1547. case agent.EdgeWaAgent:
  1548. ids := make([]ent.Value, 0, len(m.wa_agent))
  1549. for id := range m.wa_agent {
  1550. ids = append(ids, id)
  1551. }
  1552. return ids
  1553. case agent.EdgeKeyAgent:
  1554. ids := make([]ent.Value, 0, len(m.key_agent))
  1555. for id := range m.key_agent {
  1556. ids = append(ids, id)
  1557. }
  1558. return ids
  1559. }
  1560. return nil
  1561. }
  1562. // RemovedEdges returns all edge names that were removed in this mutation.
  1563. func (m *AgentMutation) RemovedEdges() []string {
  1564. edges := make([]string, 0, 4)
  1565. if m.removedwx_agent != nil {
  1566. edges = append(edges, agent.EdgeWxAgent)
  1567. }
  1568. if m.removedtoken_agent != nil {
  1569. edges = append(edges, agent.EdgeTokenAgent)
  1570. }
  1571. if m.removedwa_agent != nil {
  1572. edges = append(edges, agent.EdgeWaAgent)
  1573. }
  1574. if m.removedkey_agent != nil {
  1575. edges = append(edges, agent.EdgeKeyAgent)
  1576. }
  1577. return edges
  1578. }
  1579. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1580. // the given name in this mutation.
  1581. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1582. switch name {
  1583. case agent.EdgeWxAgent:
  1584. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1585. for id := range m.removedwx_agent {
  1586. ids = append(ids, id)
  1587. }
  1588. return ids
  1589. case agent.EdgeTokenAgent:
  1590. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1591. for id := range m.removedtoken_agent {
  1592. ids = append(ids, id)
  1593. }
  1594. return ids
  1595. case agent.EdgeWaAgent:
  1596. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1597. for id := range m.removedwa_agent {
  1598. ids = append(ids, id)
  1599. }
  1600. return ids
  1601. case agent.EdgeKeyAgent:
  1602. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1603. for id := range m.removedkey_agent {
  1604. ids = append(ids, id)
  1605. }
  1606. return ids
  1607. }
  1608. return nil
  1609. }
  1610. // ClearedEdges returns all edge names that were cleared in this mutation.
  1611. func (m *AgentMutation) ClearedEdges() []string {
  1612. edges := make([]string, 0, 4)
  1613. if m.clearedwx_agent {
  1614. edges = append(edges, agent.EdgeWxAgent)
  1615. }
  1616. if m.clearedtoken_agent {
  1617. edges = append(edges, agent.EdgeTokenAgent)
  1618. }
  1619. if m.clearedwa_agent {
  1620. edges = append(edges, agent.EdgeWaAgent)
  1621. }
  1622. if m.clearedkey_agent {
  1623. edges = append(edges, agent.EdgeKeyAgent)
  1624. }
  1625. return edges
  1626. }
  1627. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1628. // was cleared in this mutation.
  1629. func (m *AgentMutation) EdgeCleared(name string) bool {
  1630. switch name {
  1631. case agent.EdgeWxAgent:
  1632. return m.clearedwx_agent
  1633. case agent.EdgeTokenAgent:
  1634. return m.clearedtoken_agent
  1635. case agent.EdgeWaAgent:
  1636. return m.clearedwa_agent
  1637. case agent.EdgeKeyAgent:
  1638. return m.clearedkey_agent
  1639. }
  1640. return false
  1641. }
  1642. // ClearEdge clears the value of the edge with the given name. It returns an error
  1643. // if that edge is not defined in the schema.
  1644. func (m *AgentMutation) ClearEdge(name string) error {
  1645. switch name {
  1646. }
  1647. return fmt.Errorf("unknown Agent unique edge %s", name)
  1648. }
  1649. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1650. // It returns an error if the edge is not defined in the schema.
  1651. func (m *AgentMutation) ResetEdge(name string) error {
  1652. switch name {
  1653. case agent.EdgeWxAgent:
  1654. m.ResetWxAgent()
  1655. return nil
  1656. case agent.EdgeTokenAgent:
  1657. m.ResetTokenAgent()
  1658. return nil
  1659. case agent.EdgeWaAgent:
  1660. m.ResetWaAgent()
  1661. return nil
  1662. case agent.EdgeKeyAgent:
  1663. m.ResetKeyAgent()
  1664. return nil
  1665. }
  1666. return fmt.Errorf("unknown Agent edge %s", name)
  1667. }
  1668. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1669. type AgentBaseMutation struct {
  1670. config
  1671. op Op
  1672. typ string
  1673. id *string
  1674. q *string
  1675. a *string
  1676. chunk_index *uint64
  1677. addchunk_index *int64
  1678. indexes *[]string
  1679. appendindexes []string
  1680. dataset_id *string
  1681. collection_id *string
  1682. source_name *string
  1683. can_write *[]bool
  1684. appendcan_write []bool
  1685. is_owner *[]bool
  1686. appendis_owner []bool
  1687. clearedFields map[string]struct{}
  1688. wx_agent map[uint64]struct{}
  1689. removedwx_agent map[uint64]struct{}
  1690. clearedwx_agent bool
  1691. done bool
  1692. oldValue func(context.Context) (*AgentBase, error)
  1693. predicates []predicate.AgentBase
  1694. }
  1695. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1696. // agentbaseOption allows management of the mutation configuration using functional options.
  1697. type agentbaseOption func(*AgentBaseMutation)
  1698. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1699. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1700. m := &AgentBaseMutation{
  1701. config: c,
  1702. op: op,
  1703. typ: TypeAgentBase,
  1704. clearedFields: make(map[string]struct{}),
  1705. }
  1706. for _, opt := range opts {
  1707. opt(m)
  1708. }
  1709. return m
  1710. }
  1711. // withAgentBaseID sets the ID field of the mutation.
  1712. func withAgentBaseID(id string) agentbaseOption {
  1713. return func(m *AgentBaseMutation) {
  1714. var (
  1715. err error
  1716. once sync.Once
  1717. value *AgentBase
  1718. )
  1719. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1720. once.Do(func() {
  1721. if m.done {
  1722. err = errors.New("querying old values post mutation is not allowed")
  1723. } else {
  1724. value, err = m.Client().AgentBase.Get(ctx, id)
  1725. }
  1726. })
  1727. return value, err
  1728. }
  1729. m.id = &id
  1730. }
  1731. }
  1732. // withAgentBase sets the old AgentBase of the mutation.
  1733. func withAgentBase(node *AgentBase) agentbaseOption {
  1734. return func(m *AgentBaseMutation) {
  1735. m.oldValue = func(context.Context) (*AgentBase, error) {
  1736. return node, nil
  1737. }
  1738. m.id = &node.ID
  1739. }
  1740. }
  1741. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1742. // executed in a transaction (ent.Tx), a transactional client is returned.
  1743. func (m AgentBaseMutation) Client() *Client {
  1744. client := &Client{config: m.config}
  1745. client.init()
  1746. return client
  1747. }
  1748. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1749. // it returns an error otherwise.
  1750. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1751. if _, ok := m.driver.(*txDriver); !ok {
  1752. return nil, errors.New("ent: mutation is not running in a transaction")
  1753. }
  1754. tx := &Tx{config: m.config}
  1755. tx.init()
  1756. return tx, nil
  1757. }
  1758. // SetID sets the value of the id field. Note that this
  1759. // operation is only accepted on creation of AgentBase entities.
  1760. func (m *AgentBaseMutation) SetID(id string) {
  1761. m.id = &id
  1762. }
  1763. // ID returns the ID value in the mutation. Note that the ID is only available
  1764. // if it was provided to the builder or after it was returned from the database.
  1765. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1766. if m.id == nil {
  1767. return
  1768. }
  1769. return *m.id, true
  1770. }
  1771. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1772. // That means, if the mutation is applied within a transaction with an isolation level such
  1773. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1774. // or updated by the mutation.
  1775. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1776. switch {
  1777. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1778. id, exists := m.ID()
  1779. if exists {
  1780. return []string{id}, nil
  1781. }
  1782. fallthrough
  1783. case m.op.Is(OpUpdate | OpDelete):
  1784. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1785. default:
  1786. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1787. }
  1788. }
  1789. // SetQ sets the "q" field.
  1790. func (m *AgentBaseMutation) SetQ(s string) {
  1791. m.q = &s
  1792. }
  1793. // Q returns the value of the "q" field in the mutation.
  1794. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1795. v := m.q
  1796. if v == nil {
  1797. return
  1798. }
  1799. return *v, true
  1800. }
  1801. // OldQ returns the old "q" field's value of the AgentBase entity.
  1802. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1804. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1805. if !m.op.Is(OpUpdateOne) {
  1806. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1807. }
  1808. if m.id == nil || m.oldValue == nil {
  1809. return v, errors.New("OldQ requires an ID field in the mutation")
  1810. }
  1811. oldValue, err := m.oldValue(ctx)
  1812. if err != nil {
  1813. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1814. }
  1815. return oldValue.Q, nil
  1816. }
  1817. // ClearQ clears the value of the "q" field.
  1818. func (m *AgentBaseMutation) ClearQ() {
  1819. m.q = nil
  1820. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1821. }
  1822. // QCleared returns if the "q" field was cleared in this mutation.
  1823. func (m *AgentBaseMutation) QCleared() bool {
  1824. _, ok := m.clearedFields[agentbase.FieldQ]
  1825. return ok
  1826. }
  1827. // ResetQ resets all changes to the "q" field.
  1828. func (m *AgentBaseMutation) ResetQ() {
  1829. m.q = nil
  1830. delete(m.clearedFields, agentbase.FieldQ)
  1831. }
  1832. // SetA sets the "a" field.
  1833. func (m *AgentBaseMutation) SetA(s string) {
  1834. m.a = &s
  1835. }
  1836. // A returns the value of the "a" field in the mutation.
  1837. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1838. v := m.a
  1839. if v == nil {
  1840. return
  1841. }
  1842. return *v, true
  1843. }
  1844. // OldA returns the old "a" field's value of the AgentBase entity.
  1845. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1847. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1848. if !m.op.Is(OpUpdateOne) {
  1849. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1850. }
  1851. if m.id == nil || m.oldValue == nil {
  1852. return v, errors.New("OldA requires an ID field in the mutation")
  1853. }
  1854. oldValue, err := m.oldValue(ctx)
  1855. if err != nil {
  1856. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1857. }
  1858. return oldValue.A, nil
  1859. }
  1860. // ClearA clears the value of the "a" field.
  1861. func (m *AgentBaseMutation) ClearA() {
  1862. m.a = nil
  1863. m.clearedFields[agentbase.FieldA] = struct{}{}
  1864. }
  1865. // ACleared returns if the "a" field was cleared in this mutation.
  1866. func (m *AgentBaseMutation) ACleared() bool {
  1867. _, ok := m.clearedFields[agentbase.FieldA]
  1868. return ok
  1869. }
  1870. // ResetA resets all changes to the "a" field.
  1871. func (m *AgentBaseMutation) ResetA() {
  1872. m.a = nil
  1873. delete(m.clearedFields, agentbase.FieldA)
  1874. }
  1875. // SetChunkIndex sets the "chunk_index" field.
  1876. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1877. m.chunk_index = &u
  1878. m.addchunk_index = nil
  1879. }
  1880. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1881. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1882. v := m.chunk_index
  1883. if v == nil {
  1884. return
  1885. }
  1886. return *v, true
  1887. }
  1888. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1889. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1891. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1892. if !m.op.Is(OpUpdateOne) {
  1893. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1894. }
  1895. if m.id == nil || m.oldValue == nil {
  1896. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1897. }
  1898. oldValue, err := m.oldValue(ctx)
  1899. if err != nil {
  1900. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1901. }
  1902. return oldValue.ChunkIndex, nil
  1903. }
  1904. // AddChunkIndex adds u to the "chunk_index" field.
  1905. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1906. if m.addchunk_index != nil {
  1907. *m.addchunk_index += u
  1908. } else {
  1909. m.addchunk_index = &u
  1910. }
  1911. }
  1912. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1913. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1914. v := m.addchunk_index
  1915. if v == nil {
  1916. return
  1917. }
  1918. return *v, true
  1919. }
  1920. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1921. func (m *AgentBaseMutation) ResetChunkIndex() {
  1922. m.chunk_index = nil
  1923. m.addchunk_index = nil
  1924. }
  1925. // SetIndexes sets the "indexes" field.
  1926. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1927. m.indexes = &s
  1928. m.appendindexes = nil
  1929. }
  1930. // Indexes returns the value of the "indexes" field in the mutation.
  1931. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1932. v := m.indexes
  1933. if v == nil {
  1934. return
  1935. }
  1936. return *v, true
  1937. }
  1938. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1939. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1941. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1942. if !m.op.Is(OpUpdateOne) {
  1943. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1944. }
  1945. if m.id == nil || m.oldValue == nil {
  1946. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1947. }
  1948. oldValue, err := m.oldValue(ctx)
  1949. if err != nil {
  1950. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1951. }
  1952. return oldValue.Indexes, nil
  1953. }
  1954. // AppendIndexes adds s to the "indexes" field.
  1955. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1956. m.appendindexes = append(m.appendindexes, s...)
  1957. }
  1958. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1959. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1960. if len(m.appendindexes) == 0 {
  1961. return nil, false
  1962. }
  1963. return m.appendindexes, true
  1964. }
  1965. // ClearIndexes clears the value of the "indexes" field.
  1966. func (m *AgentBaseMutation) ClearIndexes() {
  1967. m.indexes = nil
  1968. m.appendindexes = nil
  1969. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1970. }
  1971. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1972. func (m *AgentBaseMutation) IndexesCleared() bool {
  1973. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1974. return ok
  1975. }
  1976. // ResetIndexes resets all changes to the "indexes" field.
  1977. func (m *AgentBaseMutation) ResetIndexes() {
  1978. m.indexes = nil
  1979. m.appendindexes = nil
  1980. delete(m.clearedFields, agentbase.FieldIndexes)
  1981. }
  1982. // SetDatasetID sets the "dataset_id" field.
  1983. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1984. m.dataset_id = &s
  1985. }
  1986. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1987. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1988. v := m.dataset_id
  1989. if v == nil {
  1990. return
  1991. }
  1992. return *v, true
  1993. }
  1994. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1995. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1997. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1998. if !m.op.Is(OpUpdateOne) {
  1999. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  2000. }
  2001. if m.id == nil || m.oldValue == nil {
  2002. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  2003. }
  2004. oldValue, err := m.oldValue(ctx)
  2005. if err != nil {
  2006. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  2007. }
  2008. return oldValue.DatasetID, nil
  2009. }
  2010. // ClearDatasetID clears the value of the "dataset_id" field.
  2011. func (m *AgentBaseMutation) ClearDatasetID() {
  2012. m.dataset_id = nil
  2013. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  2014. }
  2015. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  2016. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  2017. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  2018. return ok
  2019. }
  2020. // ResetDatasetID resets all changes to the "dataset_id" field.
  2021. func (m *AgentBaseMutation) ResetDatasetID() {
  2022. m.dataset_id = nil
  2023. delete(m.clearedFields, agentbase.FieldDatasetID)
  2024. }
  2025. // SetCollectionID sets the "collection_id" field.
  2026. func (m *AgentBaseMutation) SetCollectionID(s string) {
  2027. m.collection_id = &s
  2028. }
  2029. // CollectionID returns the value of the "collection_id" field in the mutation.
  2030. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  2031. v := m.collection_id
  2032. if v == nil {
  2033. return
  2034. }
  2035. return *v, true
  2036. }
  2037. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  2038. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2040. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  2041. if !m.op.Is(OpUpdateOne) {
  2042. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  2043. }
  2044. if m.id == nil || m.oldValue == nil {
  2045. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  2046. }
  2047. oldValue, err := m.oldValue(ctx)
  2048. if err != nil {
  2049. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  2050. }
  2051. return oldValue.CollectionID, nil
  2052. }
  2053. // ClearCollectionID clears the value of the "collection_id" field.
  2054. func (m *AgentBaseMutation) ClearCollectionID() {
  2055. m.collection_id = nil
  2056. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  2057. }
  2058. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  2059. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  2060. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  2061. return ok
  2062. }
  2063. // ResetCollectionID resets all changes to the "collection_id" field.
  2064. func (m *AgentBaseMutation) ResetCollectionID() {
  2065. m.collection_id = nil
  2066. delete(m.clearedFields, agentbase.FieldCollectionID)
  2067. }
  2068. // SetSourceName sets the "source_name" field.
  2069. func (m *AgentBaseMutation) SetSourceName(s string) {
  2070. m.source_name = &s
  2071. }
  2072. // SourceName returns the value of the "source_name" field in the mutation.
  2073. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  2074. v := m.source_name
  2075. if v == nil {
  2076. return
  2077. }
  2078. return *v, true
  2079. }
  2080. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  2081. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2083. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  2084. if !m.op.Is(OpUpdateOne) {
  2085. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  2086. }
  2087. if m.id == nil || m.oldValue == nil {
  2088. return v, errors.New("OldSourceName requires an ID field in the mutation")
  2089. }
  2090. oldValue, err := m.oldValue(ctx)
  2091. if err != nil {
  2092. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  2093. }
  2094. return oldValue.SourceName, nil
  2095. }
  2096. // ClearSourceName clears the value of the "source_name" field.
  2097. func (m *AgentBaseMutation) ClearSourceName() {
  2098. m.source_name = nil
  2099. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  2100. }
  2101. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  2102. func (m *AgentBaseMutation) SourceNameCleared() bool {
  2103. _, ok := m.clearedFields[agentbase.FieldSourceName]
  2104. return ok
  2105. }
  2106. // ResetSourceName resets all changes to the "source_name" field.
  2107. func (m *AgentBaseMutation) ResetSourceName() {
  2108. m.source_name = nil
  2109. delete(m.clearedFields, agentbase.FieldSourceName)
  2110. }
  2111. // SetCanWrite sets the "can_write" field.
  2112. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  2113. m.can_write = &b
  2114. m.appendcan_write = nil
  2115. }
  2116. // CanWrite returns the value of the "can_write" field in the mutation.
  2117. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  2118. v := m.can_write
  2119. if v == nil {
  2120. return
  2121. }
  2122. return *v, true
  2123. }
  2124. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  2125. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2127. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  2128. if !m.op.Is(OpUpdateOne) {
  2129. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  2130. }
  2131. if m.id == nil || m.oldValue == nil {
  2132. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  2133. }
  2134. oldValue, err := m.oldValue(ctx)
  2135. if err != nil {
  2136. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  2137. }
  2138. return oldValue.CanWrite, nil
  2139. }
  2140. // AppendCanWrite adds b to the "can_write" field.
  2141. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  2142. m.appendcan_write = append(m.appendcan_write, b...)
  2143. }
  2144. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  2145. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  2146. if len(m.appendcan_write) == 0 {
  2147. return nil, false
  2148. }
  2149. return m.appendcan_write, true
  2150. }
  2151. // ClearCanWrite clears the value of the "can_write" field.
  2152. func (m *AgentBaseMutation) ClearCanWrite() {
  2153. m.can_write = nil
  2154. m.appendcan_write = nil
  2155. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  2156. }
  2157. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  2158. func (m *AgentBaseMutation) CanWriteCleared() bool {
  2159. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  2160. return ok
  2161. }
  2162. // ResetCanWrite resets all changes to the "can_write" field.
  2163. func (m *AgentBaseMutation) ResetCanWrite() {
  2164. m.can_write = nil
  2165. m.appendcan_write = nil
  2166. delete(m.clearedFields, agentbase.FieldCanWrite)
  2167. }
  2168. // SetIsOwner sets the "is_owner" field.
  2169. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2170. m.is_owner = &b
  2171. m.appendis_owner = nil
  2172. }
  2173. // IsOwner returns the value of the "is_owner" field in the mutation.
  2174. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2175. v := m.is_owner
  2176. if v == nil {
  2177. return
  2178. }
  2179. return *v, true
  2180. }
  2181. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2182. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2184. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2185. if !m.op.Is(OpUpdateOne) {
  2186. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2187. }
  2188. if m.id == nil || m.oldValue == nil {
  2189. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2190. }
  2191. oldValue, err := m.oldValue(ctx)
  2192. if err != nil {
  2193. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2194. }
  2195. return oldValue.IsOwner, nil
  2196. }
  2197. // AppendIsOwner adds b to the "is_owner" field.
  2198. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2199. m.appendis_owner = append(m.appendis_owner, b...)
  2200. }
  2201. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2202. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2203. if len(m.appendis_owner) == 0 {
  2204. return nil, false
  2205. }
  2206. return m.appendis_owner, true
  2207. }
  2208. // ClearIsOwner clears the value of the "is_owner" field.
  2209. func (m *AgentBaseMutation) ClearIsOwner() {
  2210. m.is_owner = nil
  2211. m.appendis_owner = nil
  2212. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2213. }
  2214. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2215. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2216. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2217. return ok
  2218. }
  2219. // ResetIsOwner resets all changes to the "is_owner" field.
  2220. func (m *AgentBaseMutation) ResetIsOwner() {
  2221. m.is_owner = nil
  2222. m.appendis_owner = nil
  2223. delete(m.clearedFields, agentbase.FieldIsOwner)
  2224. }
  2225. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2226. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2227. if m.wx_agent == nil {
  2228. m.wx_agent = make(map[uint64]struct{})
  2229. }
  2230. for i := range ids {
  2231. m.wx_agent[ids[i]] = struct{}{}
  2232. }
  2233. }
  2234. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2235. func (m *AgentBaseMutation) ClearWxAgent() {
  2236. m.clearedwx_agent = true
  2237. }
  2238. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2239. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2240. return m.clearedwx_agent
  2241. }
  2242. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2243. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2244. if m.removedwx_agent == nil {
  2245. m.removedwx_agent = make(map[uint64]struct{})
  2246. }
  2247. for i := range ids {
  2248. delete(m.wx_agent, ids[i])
  2249. m.removedwx_agent[ids[i]] = struct{}{}
  2250. }
  2251. }
  2252. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2253. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2254. for id := range m.removedwx_agent {
  2255. ids = append(ids, id)
  2256. }
  2257. return
  2258. }
  2259. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2260. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2261. for id := range m.wx_agent {
  2262. ids = append(ids, id)
  2263. }
  2264. return
  2265. }
  2266. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2267. func (m *AgentBaseMutation) ResetWxAgent() {
  2268. m.wx_agent = nil
  2269. m.clearedwx_agent = false
  2270. m.removedwx_agent = nil
  2271. }
  2272. // Where appends a list predicates to the AgentBaseMutation builder.
  2273. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2274. m.predicates = append(m.predicates, ps...)
  2275. }
  2276. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2277. // users can use type-assertion to append predicates that do not depend on any generated package.
  2278. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2279. p := make([]predicate.AgentBase, len(ps))
  2280. for i := range ps {
  2281. p[i] = ps[i]
  2282. }
  2283. m.Where(p...)
  2284. }
  2285. // Op returns the operation name.
  2286. func (m *AgentBaseMutation) Op() Op {
  2287. return m.op
  2288. }
  2289. // SetOp allows setting the mutation operation.
  2290. func (m *AgentBaseMutation) SetOp(op Op) {
  2291. m.op = op
  2292. }
  2293. // Type returns the node type of this mutation (AgentBase).
  2294. func (m *AgentBaseMutation) Type() string {
  2295. return m.typ
  2296. }
  2297. // Fields returns all fields that were changed during this mutation. Note that in
  2298. // order to get all numeric fields that were incremented/decremented, call
  2299. // AddedFields().
  2300. func (m *AgentBaseMutation) Fields() []string {
  2301. fields := make([]string, 0, 9)
  2302. if m.q != nil {
  2303. fields = append(fields, agentbase.FieldQ)
  2304. }
  2305. if m.a != nil {
  2306. fields = append(fields, agentbase.FieldA)
  2307. }
  2308. if m.chunk_index != nil {
  2309. fields = append(fields, agentbase.FieldChunkIndex)
  2310. }
  2311. if m.indexes != nil {
  2312. fields = append(fields, agentbase.FieldIndexes)
  2313. }
  2314. if m.dataset_id != nil {
  2315. fields = append(fields, agentbase.FieldDatasetID)
  2316. }
  2317. if m.collection_id != nil {
  2318. fields = append(fields, agentbase.FieldCollectionID)
  2319. }
  2320. if m.source_name != nil {
  2321. fields = append(fields, agentbase.FieldSourceName)
  2322. }
  2323. if m.can_write != nil {
  2324. fields = append(fields, agentbase.FieldCanWrite)
  2325. }
  2326. if m.is_owner != nil {
  2327. fields = append(fields, agentbase.FieldIsOwner)
  2328. }
  2329. return fields
  2330. }
  2331. // Field returns the value of a field with the given name. The second boolean
  2332. // return value indicates that this field was not set, or was not defined in the
  2333. // schema.
  2334. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2335. switch name {
  2336. case agentbase.FieldQ:
  2337. return m.Q()
  2338. case agentbase.FieldA:
  2339. return m.A()
  2340. case agentbase.FieldChunkIndex:
  2341. return m.ChunkIndex()
  2342. case agentbase.FieldIndexes:
  2343. return m.Indexes()
  2344. case agentbase.FieldDatasetID:
  2345. return m.DatasetID()
  2346. case agentbase.FieldCollectionID:
  2347. return m.CollectionID()
  2348. case agentbase.FieldSourceName:
  2349. return m.SourceName()
  2350. case agentbase.FieldCanWrite:
  2351. return m.CanWrite()
  2352. case agentbase.FieldIsOwner:
  2353. return m.IsOwner()
  2354. }
  2355. return nil, false
  2356. }
  2357. // OldField returns the old value of the field from the database. An error is
  2358. // returned if the mutation operation is not UpdateOne, or the query to the
  2359. // database failed.
  2360. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2361. switch name {
  2362. case agentbase.FieldQ:
  2363. return m.OldQ(ctx)
  2364. case agentbase.FieldA:
  2365. return m.OldA(ctx)
  2366. case agentbase.FieldChunkIndex:
  2367. return m.OldChunkIndex(ctx)
  2368. case agentbase.FieldIndexes:
  2369. return m.OldIndexes(ctx)
  2370. case agentbase.FieldDatasetID:
  2371. return m.OldDatasetID(ctx)
  2372. case agentbase.FieldCollectionID:
  2373. return m.OldCollectionID(ctx)
  2374. case agentbase.FieldSourceName:
  2375. return m.OldSourceName(ctx)
  2376. case agentbase.FieldCanWrite:
  2377. return m.OldCanWrite(ctx)
  2378. case agentbase.FieldIsOwner:
  2379. return m.OldIsOwner(ctx)
  2380. }
  2381. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2382. }
  2383. // SetField sets the value of a field with the given name. It returns an error if
  2384. // the field is not defined in the schema, or if the type mismatched the field
  2385. // type.
  2386. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2387. switch name {
  2388. case agentbase.FieldQ:
  2389. v, ok := value.(string)
  2390. if !ok {
  2391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2392. }
  2393. m.SetQ(v)
  2394. return nil
  2395. case agentbase.FieldA:
  2396. v, ok := value.(string)
  2397. if !ok {
  2398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2399. }
  2400. m.SetA(v)
  2401. return nil
  2402. case agentbase.FieldChunkIndex:
  2403. v, ok := value.(uint64)
  2404. if !ok {
  2405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2406. }
  2407. m.SetChunkIndex(v)
  2408. return nil
  2409. case agentbase.FieldIndexes:
  2410. v, ok := value.([]string)
  2411. if !ok {
  2412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2413. }
  2414. m.SetIndexes(v)
  2415. return nil
  2416. case agentbase.FieldDatasetID:
  2417. v, ok := value.(string)
  2418. if !ok {
  2419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2420. }
  2421. m.SetDatasetID(v)
  2422. return nil
  2423. case agentbase.FieldCollectionID:
  2424. v, ok := value.(string)
  2425. if !ok {
  2426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2427. }
  2428. m.SetCollectionID(v)
  2429. return nil
  2430. case agentbase.FieldSourceName:
  2431. v, ok := value.(string)
  2432. if !ok {
  2433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2434. }
  2435. m.SetSourceName(v)
  2436. return nil
  2437. case agentbase.FieldCanWrite:
  2438. v, ok := value.([]bool)
  2439. if !ok {
  2440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2441. }
  2442. m.SetCanWrite(v)
  2443. return nil
  2444. case agentbase.FieldIsOwner:
  2445. v, ok := value.([]bool)
  2446. if !ok {
  2447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2448. }
  2449. m.SetIsOwner(v)
  2450. return nil
  2451. }
  2452. return fmt.Errorf("unknown AgentBase field %s", name)
  2453. }
  2454. // AddedFields returns all numeric fields that were incremented/decremented during
  2455. // this mutation.
  2456. func (m *AgentBaseMutation) AddedFields() []string {
  2457. var fields []string
  2458. if m.addchunk_index != nil {
  2459. fields = append(fields, agentbase.FieldChunkIndex)
  2460. }
  2461. return fields
  2462. }
  2463. // AddedField returns the numeric value that was incremented/decremented on a field
  2464. // with the given name. The second boolean return value indicates that this field
  2465. // was not set, or was not defined in the schema.
  2466. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2467. switch name {
  2468. case agentbase.FieldChunkIndex:
  2469. return m.AddedChunkIndex()
  2470. }
  2471. return nil, false
  2472. }
  2473. // AddField adds the value to the field with the given name. It returns an error if
  2474. // the field is not defined in the schema, or if the type mismatched the field
  2475. // type.
  2476. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2477. switch name {
  2478. case agentbase.FieldChunkIndex:
  2479. v, ok := value.(int64)
  2480. if !ok {
  2481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2482. }
  2483. m.AddChunkIndex(v)
  2484. return nil
  2485. }
  2486. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2487. }
  2488. // ClearedFields returns all nullable fields that were cleared during this
  2489. // mutation.
  2490. func (m *AgentBaseMutation) ClearedFields() []string {
  2491. var fields []string
  2492. if m.FieldCleared(agentbase.FieldQ) {
  2493. fields = append(fields, agentbase.FieldQ)
  2494. }
  2495. if m.FieldCleared(agentbase.FieldA) {
  2496. fields = append(fields, agentbase.FieldA)
  2497. }
  2498. if m.FieldCleared(agentbase.FieldIndexes) {
  2499. fields = append(fields, agentbase.FieldIndexes)
  2500. }
  2501. if m.FieldCleared(agentbase.FieldDatasetID) {
  2502. fields = append(fields, agentbase.FieldDatasetID)
  2503. }
  2504. if m.FieldCleared(agentbase.FieldCollectionID) {
  2505. fields = append(fields, agentbase.FieldCollectionID)
  2506. }
  2507. if m.FieldCleared(agentbase.FieldSourceName) {
  2508. fields = append(fields, agentbase.FieldSourceName)
  2509. }
  2510. if m.FieldCleared(agentbase.FieldCanWrite) {
  2511. fields = append(fields, agentbase.FieldCanWrite)
  2512. }
  2513. if m.FieldCleared(agentbase.FieldIsOwner) {
  2514. fields = append(fields, agentbase.FieldIsOwner)
  2515. }
  2516. return fields
  2517. }
  2518. // FieldCleared returns a boolean indicating if a field with the given name was
  2519. // cleared in this mutation.
  2520. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2521. _, ok := m.clearedFields[name]
  2522. return ok
  2523. }
  2524. // ClearField clears the value of the field with the given name. It returns an
  2525. // error if the field is not defined in the schema.
  2526. func (m *AgentBaseMutation) ClearField(name string) error {
  2527. switch name {
  2528. case agentbase.FieldQ:
  2529. m.ClearQ()
  2530. return nil
  2531. case agentbase.FieldA:
  2532. m.ClearA()
  2533. return nil
  2534. case agentbase.FieldIndexes:
  2535. m.ClearIndexes()
  2536. return nil
  2537. case agentbase.FieldDatasetID:
  2538. m.ClearDatasetID()
  2539. return nil
  2540. case agentbase.FieldCollectionID:
  2541. m.ClearCollectionID()
  2542. return nil
  2543. case agentbase.FieldSourceName:
  2544. m.ClearSourceName()
  2545. return nil
  2546. case agentbase.FieldCanWrite:
  2547. m.ClearCanWrite()
  2548. return nil
  2549. case agentbase.FieldIsOwner:
  2550. m.ClearIsOwner()
  2551. return nil
  2552. }
  2553. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2554. }
  2555. // ResetField resets all changes in the mutation for the field with the given name.
  2556. // It returns an error if the field is not defined in the schema.
  2557. func (m *AgentBaseMutation) ResetField(name string) error {
  2558. switch name {
  2559. case agentbase.FieldQ:
  2560. m.ResetQ()
  2561. return nil
  2562. case agentbase.FieldA:
  2563. m.ResetA()
  2564. return nil
  2565. case agentbase.FieldChunkIndex:
  2566. m.ResetChunkIndex()
  2567. return nil
  2568. case agentbase.FieldIndexes:
  2569. m.ResetIndexes()
  2570. return nil
  2571. case agentbase.FieldDatasetID:
  2572. m.ResetDatasetID()
  2573. return nil
  2574. case agentbase.FieldCollectionID:
  2575. m.ResetCollectionID()
  2576. return nil
  2577. case agentbase.FieldSourceName:
  2578. m.ResetSourceName()
  2579. return nil
  2580. case agentbase.FieldCanWrite:
  2581. m.ResetCanWrite()
  2582. return nil
  2583. case agentbase.FieldIsOwner:
  2584. m.ResetIsOwner()
  2585. return nil
  2586. }
  2587. return fmt.Errorf("unknown AgentBase field %s", name)
  2588. }
  2589. // AddedEdges returns all edge names that were set/added in this mutation.
  2590. func (m *AgentBaseMutation) AddedEdges() []string {
  2591. edges := make([]string, 0, 1)
  2592. if m.wx_agent != nil {
  2593. edges = append(edges, agentbase.EdgeWxAgent)
  2594. }
  2595. return edges
  2596. }
  2597. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2598. // name in this mutation.
  2599. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2600. switch name {
  2601. case agentbase.EdgeWxAgent:
  2602. ids := make([]ent.Value, 0, len(m.wx_agent))
  2603. for id := range m.wx_agent {
  2604. ids = append(ids, id)
  2605. }
  2606. return ids
  2607. }
  2608. return nil
  2609. }
  2610. // RemovedEdges returns all edge names that were removed in this mutation.
  2611. func (m *AgentBaseMutation) RemovedEdges() []string {
  2612. edges := make([]string, 0, 1)
  2613. if m.removedwx_agent != nil {
  2614. edges = append(edges, agentbase.EdgeWxAgent)
  2615. }
  2616. return edges
  2617. }
  2618. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2619. // the given name in this mutation.
  2620. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2621. switch name {
  2622. case agentbase.EdgeWxAgent:
  2623. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2624. for id := range m.removedwx_agent {
  2625. ids = append(ids, id)
  2626. }
  2627. return ids
  2628. }
  2629. return nil
  2630. }
  2631. // ClearedEdges returns all edge names that were cleared in this mutation.
  2632. func (m *AgentBaseMutation) ClearedEdges() []string {
  2633. edges := make([]string, 0, 1)
  2634. if m.clearedwx_agent {
  2635. edges = append(edges, agentbase.EdgeWxAgent)
  2636. }
  2637. return edges
  2638. }
  2639. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2640. // was cleared in this mutation.
  2641. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2642. switch name {
  2643. case agentbase.EdgeWxAgent:
  2644. return m.clearedwx_agent
  2645. }
  2646. return false
  2647. }
  2648. // ClearEdge clears the value of the edge with the given name. It returns an error
  2649. // if that edge is not defined in the schema.
  2650. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2651. switch name {
  2652. }
  2653. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2654. }
  2655. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2656. // It returns an error if the edge is not defined in the schema.
  2657. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2658. switch name {
  2659. case agentbase.EdgeWxAgent:
  2660. m.ResetWxAgent()
  2661. return nil
  2662. }
  2663. return fmt.Errorf("unknown AgentBase edge %s", name)
  2664. }
  2665. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2666. type AliyunAvatarMutation struct {
  2667. config
  2668. op Op
  2669. typ string
  2670. id *uint64
  2671. created_at *time.Time
  2672. updated_at *time.Time
  2673. deleted_at *time.Time
  2674. user_id *uint64
  2675. adduser_id *int64
  2676. biz_id *string
  2677. access_key_id *string
  2678. access_key_secret *string
  2679. app_id *string
  2680. tenant_id *uint64
  2681. addtenant_id *int64
  2682. response *string
  2683. token *string
  2684. session_id *string
  2685. clearedFields map[string]struct{}
  2686. done bool
  2687. oldValue func(context.Context) (*AliyunAvatar, error)
  2688. predicates []predicate.AliyunAvatar
  2689. }
  2690. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2691. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2692. type aliyunavatarOption func(*AliyunAvatarMutation)
  2693. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2694. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2695. m := &AliyunAvatarMutation{
  2696. config: c,
  2697. op: op,
  2698. typ: TypeAliyunAvatar,
  2699. clearedFields: make(map[string]struct{}),
  2700. }
  2701. for _, opt := range opts {
  2702. opt(m)
  2703. }
  2704. return m
  2705. }
  2706. // withAliyunAvatarID sets the ID field of the mutation.
  2707. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2708. return func(m *AliyunAvatarMutation) {
  2709. var (
  2710. err error
  2711. once sync.Once
  2712. value *AliyunAvatar
  2713. )
  2714. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2715. once.Do(func() {
  2716. if m.done {
  2717. err = errors.New("querying old values post mutation is not allowed")
  2718. } else {
  2719. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2720. }
  2721. })
  2722. return value, err
  2723. }
  2724. m.id = &id
  2725. }
  2726. }
  2727. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2728. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2729. return func(m *AliyunAvatarMutation) {
  2730. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2731. return node, nil
  2732. }
  2733. m.id = &node.ID
  2734. }
  2735. }
  2736. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2737. // executed in a transaction (ent.Tx), a transactional client is returned.
  2738. func (m AliyunAvatarMutation) Client() *Client {
  2739. client := &Client{config: m.config}
  2740. client.init()
  2741. return client
  2742. }
  2743. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2744. // it returns an error otherwise.
  2745. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2746. if _, ok := m.driver.(*txDriver); !ok {
  2747. return nil, errors.New("ent: mutation is not running in a transaction")
  2748. }
  2749. tx := &Tx{config: m.config}
  2750. tx.init()
  2751. return tx, nil
  2752. }
  2753. // SetID sets the value of the id field. Note that this
  2754. // operation is only accepted on creation of AliyunAvatar entities.
  2755. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2756. m.id = &id
  2757. }
  2758. // ID returns the ID value in the mutation. Note that the ID is only available
  2759. // if it was provided to the builder or after it was returned from the database.
  2760. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2761. if m.id == nil {
  2762. return
  2763. }
  2764. return *m.id, true
  2765. }
  2766. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2767. // That means, if the mutation is applied within a transaction with an isolation level such
  2768. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2769. // or updated by the mutation.
  2770. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2771. switch {
  2772. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2773. id, exists := m.ID()
  2774. if exists {
  2775. return []uint64{id}, nil
  2776. }
  2777. fallthrough
  2778. case m.op.Is(OpUpdate | OpDelete):
  2779. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2780. default:
  2781. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2782. }
  2783. }
  2784. // SetCreatedAt sets the "created_at" field.
  2785. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2786. m.created_at = &t
  2787. }
  2788. // CreatedAt returns the value of the "created_at" field in the mutation.
  2789. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2790. v := m.created_at
  2791. if v == nil {
  2792. return
  2793. }
  2794. return *v, true
  2795. }
  2796. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2797. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2799. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2800. if !m.op.Is(OpUpdateOne) {
  2801. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2802. }
  2803. if m.id == nil || m.oldValue == nil {
  2804. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2805. }
  2806. oldValue, err := m.oldValue(ctx)
  2807. if err != nil {
  2808. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2809. }
  2810. return oldValue.CreatedAt, nil
  2811. }
  2812. // ResetCreatedAt resets all changes to the "created_at" field.
  2813. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2814. m.created_at = nil
  2815. }
  2816. // SetUpdatedAt sets the "updated_at" field.
  2817. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2818. m.updated_at = &t
  2819. }
  2820. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2821. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2822. v := m.updated_at
  2823. if v == nil {
  2824. return
  2825. }
  2826. return *v, true
  2827. }
  2828. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2829. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2831. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2832. if !m.op.Is(OpUpdateOne) {
  2833. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2834. }
  2835. if m.id == nil || m.oldValue == nil {
  2836. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2837. }
  2838. oldValue, err := m.oldValue(ctx)
  2839. if err != nil {
  2840. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2841. }
  2842. return oldValue.UpdatedAt, nil
  2843. }
  2844. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2845. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2846. m.updated_at = nil
  2847. }
  2848. // SetDeletedAt sets the "deleted_at" field.
  2849. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2850. m.deleted_at = &t
  2851. }
  2852. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2853. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2854. v := m.deleted_at
  2855. if v == nil {
  2856. return
  2857. }
  2858. return *v, true
  2859. }
  2860. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2861. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2863. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2864. if !m.op.Is(OpUpdateOne) {
  2865. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2866. }
  2867. if m.id == nil || m.oldValue == nil {
  2868. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2869. }
  2870. oldValue, err := m.oldValue(ctx)
  2871. if err != nil {
  2872. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2873. }
  2874. return oldValue.DeletedAt, nil
  2875. }
  2876. // ClearDeletedAt clears the value of the "deleted_at" field.
  2877. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2878. m.deleted_at = nil
  2879. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2880. }
  2881. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2882. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2883. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2884. return ok
  2885. }
  2886. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2887. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2888. m.deleted_at = nil
  2889. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2890. }
  2891. // SetUserID sets the "user_id" field.
  2892. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2893. m.user_id = &u
  2894. m.adduser_id = nil
  2895. }
  2896. // UserID returns the value of the "user_id" field in the mutation.
  2897. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2898. v := m.user_id
  2899. if v == nil {
  2900. return
  2901. }
  2902. return *v, true
  2903. }
  2904. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2905. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2907. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2908. if !m.op.Is(OpUpdateOne) {
  2909. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2910. }
  2911. if m.id == nil || m.oldValue == nil {
  2912. return v, errors.New("OldUserID requires an ID field in the mutation")
  2913. }
  2914. oldValue, err := m.oldValue(ctx)
  2915. if err != nil {
  2916. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2917. }
  2918. return oldValue.UserID, nil
  2919. }
  2920. // AddUserID adds u to the "user_id" field.
  2921. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2922. if m.adduser_id != nil {
  2923. *m.adduser_id += u
  2924. } else {
  2925. m.adduser_id = &u
  2926. }
  2927. }
  2928. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2929. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2930. v := m.adduser_id
  2931. if v == nil {
  2932. return
  2933. }
  2934. return *v, true
  2935. }
  2936. // ResetUserID resets all changes to the "user_id" field.
  2937. func (m *AliyunAvatarMutation) ResetUserID() {
  2938. m.user_id = nil
  2939. m.adduser_id = nil
  2940. }
  2941. // SetBizID sets the "biz_id" field.
  2942. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2943. m.biz_id = &s
  2944. }
  2945. // BizID returns the value of the "biz_id" field in the mutation.
  2946. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2947. v := m.biz_id
  2948. if v == nil {
  2949. return
  2950. }
  2951. return *v, true
  2952. }
  2953. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2954. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2956. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2957. if !m.op.Is(OpUpdateOne) {
  2958. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2959. }
  2960. if m.id == nil || m.oldValue == nil {
  2961. return v, errors.New("OldBizID requires an ID field in the mutation")
  2962. }
  2963. oldValue, err := m.oldValue(ctx)
  2964. if err != nil {
  2965. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2966. }
  2967. return oldValue.BizID, nil
  2968. }
  2969. // ResetBizID resets all changes to the "biz_id" field.
  2970. func (m *AliyunAvatarMutation) ResetBizID() {
  2971. m.biz_id = nil
  2972. }
  2973. // SetAccessKeyID sets the "access_key_id" field.
  2974. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2975. m.access_key_id = &s
  2976. }
  2977. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2978. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2979. v := m.access_key_id
  2980. if v == nil {
  2981. return
  2982. }
  2983. return *v, true
  2984. }
  2985. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2986. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2988. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2989. if !m.op.Is(OpUpdateOne) {
  2990. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2991. }
  2992. if m.id == nil || m.oldValue == nil {
  2993. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2994. }
  2995. oldValue, err := m.oldValue(ctx)
  2996. if err != nil {
  2997. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2998. }
  2999. return oldValue.AccessKeyID, nil
  3000. }
  3001. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  3002. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  3003. m.access_key_id = nil
  3004. }
  3005. // SetAccessKeySecret sets the "access_key_secret" field.
  3006. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  3007. m.access_key_secret = &s
  3008. }
  3009. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  3010. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  3011. v := m.access_key_secret
  3012. if v == nil {
  3013. return
  3014. }
  3015. return *v, true
  3016. }
  3017. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  3018. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3020. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  3021. if !m.op.Is(OpUpdateOne) {
  3022. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  3023. }
  3024. if m.id == nil || m.oldValue == nil {
  3025. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  3026. }
  3027. oldValue, err := m.oldValue(ctx)
  3028. if err != nil {
  3029. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  3030. }
  3031. return oldValue.AccessKeySecret, nil
  3032. }
  3033. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  3034. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  3035. m.access_key_secret = nil
  3036. }
  3037. // SetAppID sets the "app_id" field.
  3038. func (m *AliyunAvatarMutation) SetAppID(s string) {
  3039. m.app_id = &s
  3040. }
  3041. // AppID returns the value of the "app_id" field in the mutation.
  3042. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  3043. v := m.app_id
  3044. if v == nil {
  3045. return
  3046. }
  3047. return *v, true
  3048. }
  3049. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  3050. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3052. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  3053. if !m.op.Is(OpUpdateOne) {
  3054. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  3055. }
  3056. if m.id == nil || m.oldValue == nil {
  3057. return v, errors.New("OldAppID requires an ID field in the mutation")
  3058. }
  3059. oldValue, err := m.oldValue(ctx)
  3060. if err != nil {
  3061. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  3062. }
  3063. return oldValue.AppID, nil
  3064. }
  3065. // ClearAppID clears the value of the "app_id" field.
  3066. func (m *AliyunAvatarMutation) ClearAppID() {
  3067. m.app_id = nil
  3068. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  3069. }
  3070. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  3071. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  3072. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  3073. return ok
  3074. }
  3075. // ResetAppID resets all changes to the "app_id" field.
  3076. func (m *AliyunAvatarMutation) ResetAppID() {
  3077. m.app_id = nil
  3078. delete(m.clearedFields, aliyunavatar.FieldAppID)
  3079. }
  3080. // SetTenantID sets the "tenant_id" field.
  3081. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  3082. m.tenant_id = &u
  3083. m.addtenant_id = nil
  3084. }
  3085. // TenantID returns the value of the "tenant_id" field in the mutation.
  3086. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  3087. v := m.tenant_id
  3088. if v == nil {
  3089. return
  3090. }
  3091. return *v, true
  3092. }
  3093. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  3094. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3096. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  3097. if !m.op.Is(OpUpdateOne) {
  3098. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  3099. }
  3100. if m.id == nil || m.oldValue == nil {
  3101. return v, errors.New("OldTenantID requires an ID field in the mutation")
  3102. }
  3103. oldValue, err := m.oldValue(ctx)
  3104. if err != nil {
  3105. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  3106. }
  3107. return oldValue.TenantID, nil
  3108. }
  3109. // AddTenantID adds u to the "tenant_id" field.
  3110. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  3111. if m.addtenant_id != nil {
  3112. *m.addtenant_id += u
  3113. } else {
  3114. m.addtenant_id = &u
  3115. }
  3116. }
  3117. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  3118. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  3119. v := m.addtenant_id
  3120. if v == nil {
  3121. return
  3122. }
  3123. return *v, true
  3124. }
  3125. // ResetTenantID resets all changes to the "tenant_id" field.
  3126. func (m *AliyunAvatarMutation) ResetTenantID() {
  3127. m.tenant_id = nil
  3128. m.addtenant_id = nil
  3129. }
  3130. // SetResponse sets the "response" field.
  3131. func (m *AliyunAvatarMutation) SetResponse(s string) {
  3132. m.response = &s
  3133. }
  3134. // Response returns the value of the "response" field in the mutation.
  3135. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  3136. v := m.response
  3137. if v == nil {
  3138. return
  3139. }
  3140. return *v, true
  3141. }
  3142. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  3143. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3145. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  3146. if !m.op.Is(OpUpdateOne) {
  3147. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  3148. }
  3149. if m.id == nil || m.oldValue == nil {
  3150. return v, errors.New("OldResponse requires an ID field in the mutation")
  3151. }
  3152. oldValue, err := m.oldValue(ctx)
  3153. if err != nil {
  3154. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  3155. }
  3156. return oldValue.Response, nil
  3157. }
  3158. // ResetResponse resets all changes to the "response" field.
  3159. func (m *AliyunAvatarMutation) ResetResponse() {
  3160. m.response = nil
  3161. }
  3162. // SetToken sets the "token" field.
  3163. func (m *AliyunAvatarMutation) SetToken(s string) {
  3164. m.token = &s
  3165. }
  3166. // Token returns the value of the "token" field in the mutation.
  3167. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3168. v := m.token
  3169. if v == nil {
  3170. return
  3171. }
  3172. return *v, true
  3173. }
  3174. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3175. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3177. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3178. if !m.op.Is(OpUpdateOne) {
  3179. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3180. }
  3181. if m.id == nil || m.oldValue == nil {
  3182. return v, errors.New("OldToken requires an ID field in the mutation")
  3183. }
  3184. oldValue, err := m.oldValue(ctx)
  3185. if err != nil {
  3186. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3187. }
  3188. return oldValue.Token, nil
  3189. }
  3190. // ResetToken resets all changes to the "token" field.
  3191. func (m *AliyunAvatarMutation) ResetToken() {
  3192. m.token = nil
  3193. }
  3194. // SetSessionID sets the "session_id" field.
  3195. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3196. m.session_id = &s
  3197. }
  3198. // SessionID returns the value of the "session_id" field in the mutation.
  3199. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3200. v := m.session_id
  3201. if v == nil {
  3202. return
  3203. }
  3204. return *v, true
  3205. }
  3206. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3207. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3209. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3210. if !m.op.Is(OpUpdateOne) {
  3211. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3212. }
  3213. if m.id == nil || m.oldValue == nil {
  3214. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3215. }
  3216. oldValue, err := m.oldValue(ctx)
  3217. if err != nil {
  3218. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3219. }
  3220. return oldValue.SessionID, nil
  3221. }
  3222. // ResetSessionID resets all changes to the "session_id" field.
  3223. func (m *AliyunAvatarMutation) ResetSessionID() {
  3224. m.session_id = nil
  3225. }
  3226. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3227. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3228. m.predicates = append(m.predicates, ps...)
  3229. }
  3230. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3231. // users can use type-assertion to append predicates that do not depend on any generated package.
  3232. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3233. p := make([]predicate.AliyunAvatar, len(ps))
  3234. for i := range ps {
  3235. p[i] = ps[i]
  3236. }
  3237. m.Where(p...)
  3238. }
  3239. // Op returns the operation name.
  3240. func (m *AliyunAvatarMutation) Op() Op {
  3241. return m.op
  3242. }
  3243. // SetOp allows setting the mutation operation.
  3244. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3245. m.op = op
  3246. }
  3247. // Type returns the node type of this mutation (AliyunAvatar).
  3248. func (m *AliyunAvatarMutation) Type() string {
  3249. return m.typ
  3250. }
  3251. // Fields returns all fields that were changed during this mutation. Note that in
  3252. // order to get all numeric fields that were incremented/decremented, call
  3253. // AddedFields().
  3254. func (m *AliyunAvatarMutation) Fields() []string {
  3255. fields := make([]string, 0, 12)
  3256. if m.created_at != nil {
  3257. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3258. }
  3259. if m.updated_at != nil {
  3260. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3261. }
  3262. if m.deleted_at != nil {
  3263. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3264. }
  3265. if m.user_id != nil {
  3266. fields = append(fields, aliyunavatar.FieldUserID)
  3267. }
  3268. if m.biz_id != nil {
  3269. fields = append(fields, aliyunavatar.FieldBizID)
  3270. }
  3271. if m.access_key_id != nil {
  3272. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3273. }
  3274. if m.access_key_secret != nil {
  3275. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3276. }
  3277. if m.app_id != nil {
  3278. fields = append(fields, aliyunavatar.FieldAppID)
  3279. }
  3280. if m.tenant_id != nil {
  3281. fields = append(fields, aliyunavatar.FieldTenantID)
  3282. }
  3283. if m.response != nil {
  3284. fields = append(fields, aliyunavatar.FieldResponse)
  3285. }
  3286. if m.token != nil {
  3287. fields = append(fields, aliyunavatar.FieldToken)
  3288. }
  3289. if m.session_id != nil {
  3290. fields = append(fields, aliyunavatar.FieldSessionID)
  3291. }
  3292. return fields
  3293. }
  3294. // Field returns the value of a field with the given name. The second boolean
  3295. // return value indicates that this field was not set, or was not defined in the
  3296. // schema.
  3297. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3298. switch name {
  3299. case aliyunavatar.FieldCreatedAt:
  3300. return m.CreatedAt()
  3301. case aliyunavatar.FieldUpdatedAt:
  3302. return m.UpdatedAt()
  3303. case aliyunavatar.FieldDeletedAt:
  3304. return m.DeletedAt()
  3305. case aliyunavatar.FieldUserID:
  3306. return m.UserID()
  3307. case aliyunavatar.FieldBizID:
  3308. return m.BizID()
  3309. case aliyunavatar.FieldAccessKeyID:
  3310. return m.AccessKeyID()
  3311. case aliyunavatar.FieldAccessKeySecret:
  3312. return m.AccessKeySecret()
  3313. case aliyunavatar.FieldAppID:
  3314. return m.AppID()
  3315. case aliyunavatar.FieldTenantID:
  3316. return m.TenantID()
  3317. case aliyunavatar.FieldResponse:
  3318. return m.Response()
  3319. case aliyunavatar.FieldToken:
  3320. return m.Token()
  3321. case aliyunavatar.FieldSessionID:
  3322. return m.SessionID()
  3323. }
  3324. return nil, false
  3325. }
  3326. // OldField returns the old value of the field from the database. An error is
  3327. // returned if the mutation operation is not UpdateOne, or the query to the
  3328. // database failed.
  3329. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3330. switch name {
  3331. case aliyunavatar.FieldCreatedAt:
  3332. return m.OldCreatedAt(ctx)
  3333. case aliyunavatar.FieldUpdatedAt:
  3334. return m.OldUpdatedAt(ctx)
  3335. case aliyunavatar.FieldDeletedAt:
  3336. return m.OldDeletedAt(ctx)
  3337. case aliyunavatar.FieldUserID:
  3338. return m.OldUserID(ctx)
  3339. case aliyunavatar.FieldBizID:
  3340. return m.OldBizID(ctx)
  3341. case aliyunavatar.FieldAccessKeyID:
  3342. return m.OldAccessKeyID(ctx)
  3343. case aliyunavatar.FieldAccessKeySecret:
  3344. return m.OldAccessKeySecret(ctx)
  3345. case aliyunavatar.FieldAppID:
  3346. return m.OldAppID(ctx)
  3347. case aliyunavatar.FieldTenantID:
  3348. return m.OldTenantID(ctx)
  3349. case aliyunavatar.FieldResponse:
  3350. return m.OldResponse(ctx)
  3351. case aliyunavatar.FieldToken:
  3352. return m.OldToken(ctx)
  3353. case aliyunavatar.FieldSessionID:
  3354. return m.OldSessionID(ctx)
  3355. }
  3356. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3357. }
  3358. // SetField sets the value of a field with the given name. It returns an error if
  3359. // the field is not defined in the schema, or if the type mismatched the field
  3360. // type.
  3361. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3362. switch name {
  3363. case aliyunavatar.FieldCreatedAt:
  3364. v, ok := value.(time.Time)
  3365. if !ok {
  3366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3367. }
  3368. m.SetCreatedAt(v)
  3369. return nil
  3370. case aliyunavatar.FieldUpdatedAt:
  3371. v, ok := value.(time.Time)
  3372. if !ok {
  3373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3374. }
  3375. m.SetUpdatedAt(v)
  3376. return nil
  3377. case aliyunavatar.FieldDeletedAt:
  3378. v, ok := value.(time.Time)
  3379. if !ok {
  3380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3381. }
  3382. m.SetDeletedAt(v)
  3383. return nil
  3384. case aliyunavatar.FieldUserID:
  3385. v, ok := value.(uint64)
  3386. if !ok {
  3387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3388. }
  3389. m.SetUserID(v)
  3390. return nil
  3391. case aliyunavatar.FieldBizID:
  3392. v, ok := value.(string)
  3393. if !ok {
  3394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3395. }
  3396. m.SetBizID(v)
  3397. return nil
  3398. case aliyunavatar.FieldAccessKeyID:
  3399. v, ok := value.(string)
  3400. if !ok {
  3401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3402. }
  3403. m.SetAccessKeyID(v)
  3404. return nil
  3405. case aliyunavatar.FieldAccessKeySecret:
  3406. v, ok := value.(string)
  3407. if !ok {
  3408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3409. }
  3410. m.SetAccessKeySecret(v)
  3411. return nil
  3412. case aliyunavatar.FieldAppID:
  3413. v, ok := value.(string)
  3414. if !ok {
  3415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3416. }
  3417. m.SetAppID(v)
  3418. return nil
  3419. case aliyunavatar.FieldTenantID:
  3420. v, ok := value.(uint64)
  3421. if !ok {
  3422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3423. }
  3424. m.SetTenantID(v)
  3425. return nil
  3426. case aliyunavatar.FieldResponse:
  3427. v, ok := value.(string)
  3428. if !ok {
  3429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3430. }
  3431. m.SetResponse(v)
  3432. return nil
  3433. case aliyunavatar.FieldToken:
  3434. v, ok := value.(string)
  3435. if !ok {
  3436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3437. }
  3438. m.SetToken(v)
  3439. return nil
  3440. case aliyunavatar.FieldSessionID:
  3441. v, ok := value.(string)
  3442. if !ok {
  3443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3444. }
  3445. m.SetSessionID(v)
  3446. return nil
  3447. }
  3448. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3449. }
  3450. // AddedFields returns all numeric fields that were incremented/decremented during
  3451. // this mutation.
  3452. func (m *AliyunAvatarMutation) AddedFields() []string {
  3453. var fields []string
  3454. if m.adduser_id != nil {
  3455. fields = append(fields, aliyunavatar.FieldUserID)
  3456. }
  3457. if m.addtenant_id != nil {
  3458. fields = append(fields, aliyunavatar.FieldTenantID)
  3459. }
  3460. return fields
  3461. }
  3462. // AddedField returns the numeric value that was incremented/decremented on a field
  3463. // with the given name. The second boolean return value indicates that this field
  3464. // was not set, or was not defined in the schema.
  3465. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3466. switch name {
  3467. case aliyunavatar.FieldUserID:
  3468. return m.AddedUserID()
  3469. case aliyunavatar.FieldTenantID:
  3470. return m.AddedTenantID()
  3471. }
  3472. return nil, false
  3473. }
  3474. // AddField adds the value to the field with the given name. It returns an error if
  3475. // the field is not defined in the schema, or if the type mismatched the field
  3476. // type.
  3477. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3478. switch name {
  3479. case aliyunavatar.FieldUserID:
  3480. v, ok := value.(int64)
  3481. if !ok {
  3482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3483. }
  3484. m.AddUserID(v)
  3485. return nil
  3486. case aliyunavatar.FieldTenantID:
  3487. v, ok := value.(int64)
  3488. if !ok {
  3489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3490. }
  3491. m.AddTenantID(v)
  3492. return nil
  3493. }
  3494. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3495. }
  3496. // ClearedFields returns all nullable fields that were cleared during this
  3497. // mutation.
  3498. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3499. var fields []string
  3500. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3501. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3502. }
  3503. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3504. fields = append(fields, aliyunavatar.FieldAppID)
  3505. }
  3506. return fields
  3507. }
  3508. // FieldCleared returns a boolean indicating if a field with the given name was
  3509. // cleared in this mutation.
  3510. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3511. _, ok := m.clearedFields[name]
  3512. return ok
  3513. }
  3514. // ClearField clears the value of the field with the given name. It returns an
  3515. // error if the field is not defined in the schema.
  3516. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3517. switch name {
  3518. case aliyunavatar.FieldDeletedAt:
  3519. m.ClearDeletedAt()
  3520. return nil
  3521. case aliyunavatar.FieldAppID:
  3522. m.ClearAppID()
  3523. return nil
  3524. }
  3525. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3526. }
  3527. // ResetField resets all changes in the mutation for the field with the given name.
  3528. // It returns an error if the field is not defined in the schema.
  3529. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3530. switch name {
  3531. case aliyunavatar.FieldCreatedAt:
  3532. m.ResetCreatedAt()
  3533. return nil
  3534. case aliyunavatar.FieldUpdatedAt:
  3535. m.ResetUpdatedAt()
  3536. return nil
  3537. case aliyunavatar.FieldDeletedAt:
  3538. m.ResetDeletedAt()
  3539. return nil
  3540. case aliyunavatar.FieldUserID:
  3541. m.ResetUserID()
  3542. return nil
  3543. case aliyunavatar.FieldBizID:
  3544. m.ResetBizID()
  3545. return nil
  3546. case aliyunavatar.FieldAccessKeyID:
  3547. m.ResetAccessKeyID()
  3548. return nil
  3549. case aliyunavatar.FieldAccessKeySecret:
  3550. m.ResetAccessKeySecret()
  3551. return nil
  3552. case aliyunavatar.FieldAppID:
  3553. m.ResetAppID()
  3554. return nil
  3555. case aliyunavatar.FieldTenantID:
  3556. m.ResetTenantID()
  3557. return nil
  3558. case aliyunavatar.FieldResponse:
  3559. m.ResetResponse()
  3560. return nil
  3561. case aliyunavatar.FieldToken:
  3562. m.ResetToken()
  3563. return nil
  3564. case aliyunavatar.FieldSessionID:
  3565. m.ResetSessionID()
  3566. return nil
  3567. }
  3568. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3569. }
  3570. // AddedEdges returns all edge names that were set/added in this mutation.
  3571. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3572. edges := make([]string, 0, 0)
  3573. return edges
  3574. }
  3575. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3576. // name in this mutation.
  3577. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3578. return nil
  3579. }
  3580. // RemovedEdges returns all edge names that were removed in this mutation.
  3581. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3582. edges := make([]string, 0, 0)
  3583. return edges
  3584. }
  3585. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3586. // the given name in this mutation.
  3587. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3588. return nil
  3589. }
  3590. // ClearedEdges returns all edge names that were cleared in this mutation.
  3591. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3592. edges := make([]string, 0, 0)
  3593. return edges
  3594. }
  3595. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3596. // was cleared in this mutation.
  3597. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3598. return false
  3599. }
  3600. // ClearEdge clears the value of the edge with the given name. It returns an error
  3601. // if that edge is not defined in the schema.
  3602. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3603. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3604. }
  3605. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3606. // It returns an error if the edge is not defined in the schema.
  3607. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3608. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3609. }
  3610. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3611. type AllocAgentMutation struct {
  3612. config
  3613. op Op
  3614. typ string
  3615. id *uint64
  3616. created_at *time.Time
  3617. updated_at *time.Time
  3618. deleted_at *time.Time
  3619. user_id *string
  3620. organization_id *uint64
  3621. addorganization_id *int64
  3622. agents *[]uint64
  3623. appendagents []uint64
  3624. status *int
  3625. addstatus *int
  3626. clearedFields map[string]struct{}
  3627. done bool
  3628. oldValue func(context.Context) (*AllocAgent, error)
  3629. predicates []predicate.AllocAgent
  3630. }
  3631. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3632. // allocagentOption allows management of the mutation configuration using functional options.
  3633. type allocagentOption func(*AllocAgentMutation)
  3634. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3635. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3636. m := &AllocAgentMutation{
  3637. config: c,
  3638. op: op,
  3639. typ: TypeAllocAgent,
  3640. clearedFields: make(map[string]struct{}),
  3641. }
  3642. for _, opt := range opts {
  3643. opt(m)
  3644. }
  3645. return m
  3646. }
  3647. // withAllocAgentID sets the ID field of the mutation.
  3648. func withAllocAgentID(id uint64) allocagentOption {
  3649. return func(m *AllocAgentMutation) {
  3650. var (
  3651. err error
  3652. once sync.Once
  3653. value *AllocAgent
  3654. )
  3655. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3656. once.Do(func() {
  3657. if m.done {
  3658. err = errors.New("querying old values post mutation is not allowed")
  3659. } else {
  3660. value, err = m.Client().AllocAgent.Get(ctx, id)
  3661. }
  3662. })
  3663. return value, err
  3664. }
  3665. m.id = &id
  3666. }
  3667. }
  3668. // withAllocAgent sets the old AllocAgent of the mutation.
  3669. func withAllocAgent(node *AllocAgent) allocagentOption {
  3670. return func(m *AllocAgentMutation) {
  3671. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3672. return node, nil
  3673. }
  3674. m.id = &node.ID
  3675. }
  3676. }
  3677. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3678. // executed in a transaction (ent.Tx), a transactional client is returned.
  3679. func (m AllocAgentMutation) Client() *Client {
  3680. client := &Client{config: m.config}
  3681. client.init()
  3682. return client
  3683. }
  3684. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3685. // it returns an error otherwise.
  3686. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3687. if _, ok := m.driver.(*txDriver); !ok {
  3688. return nil, errors.New("ent: mutation is not running in a transaction")
  3689. }
  3690. tx := &Tx{config: m.config}
  3691. tx.init()
  3692. return tx, nil
  3693. }
  3694. // SetID sets the value of the id field. Note that this
  3695. // operation is only accepted on creation of AllocAgent entities.
  3696. func (m *AllocAgentMutation) SetID(id uint64) {
  3697. m.id = &id
  3698. }
  3699. // ID returns the ID value in the mutation. Note that the ID is only available
  3700. // if it was provided to the builder or after it was returned from the database.
  3701. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3702. if m.id == nil {
  3703. return
  3704. }
  3705. return *m.id, true
  3706. }
  3707. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3708. // That means, if the mutation is applied within a transaction with an isolation level such
  3709. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3710. // or updated by the mutation.
  3711. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3712. switch {
  3713. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3714. id, exists := m.ID()
  3715. if exists {
  3716. return []uint64{id}, nil
  3717. }
  3718. fallthrough
  3719. case m.op.Is(OpUpdate | OpDelete):
  3720. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3721. default:
  3722. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3723. }
  3724. }
  3725. // SetCreatedAt sets the "created_at" field.
  3726. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3727. m.created_at = &t
  3728. }
  3729. // CreatedAt returns the value of the "created_at" field in the mutation.
  3730. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3731. v := m.created_at
  3732. if v == nil {
  3733. return
  3734. }
  3735. return *v, true
  3736. }
  3737. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3738. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3740. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3741. if !m.op.Is(OpUpdateOne) {
  3742. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3743. }
  3744. if m.id == nil || m.oldValue == nil {
  3745. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3746. }
  3747. oldValue, err := m.oldValue(ctx)
  3748. if err != nil {
  3749. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3750. }
  3751. return oldValue.CreatedAt, nil
  3752. }
  3753. // ResetCreatedAt resets all changes to the "created_at" field.
  3754. func (m *AllocAgentMutation) ResetCreatedAt() {
  3755. m.created_at = nil
  3756. }
  3757. // SetUpdatedAt sets the "updated_at" field.
  3758. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3759. m.updated_at = &t
  3760. }
  3761. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3762. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3763. v := m.updated_at
  3764. if v == nil {
  3765. return
  3766. }
  3767. return *v, true
  3768. }
  3769. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3770. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3772. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3773. if !m.op.Is(OpUpdateOne) {
  3774. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3775. }
  3776. if m.id == nil || m.oldValue == nil {
  3777. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3778. }
  3779. oldValue, err := m.oldValue(ctx)
  3780. if err != nil {
  3781. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3782. }
  3783. return oldValue.UpdatedAt, nil
  3784. }
  3785. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3786. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3787. m.updated_at = nil
  3788. }
  3789. // SetDeletedAt sets the "deleted_at" field.
  3790. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3791. m.deleted_at = &t
  3792. }
  3793. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3794. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3795. v := m.deleted_at
  3796. if v == nil {
  3797. return
  3798. }
  3799. return *v, true
  3800. }
  3801. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3802. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3804. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3805. if !m.op.Is(OpUpdateOne) {
  3806. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3807. }
  3808. if m.id == nil || m.oldValue == nil {
  3809. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3810. }
  3811. oldValue, err := m.oldValue(ctx)
  3812. if err != nil {
  3813. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3814. }
  3815. return oldValue.DeletedAt, nil
  3816. }
  3817. // ClearDeletedAt clears the value of the "deleted_at" field.
  3818. func (m *AllocAgentMutation) ClearDeletedAt() {
  3819. m.deleted_at = nil
  3820. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3821. }
  3822. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3823. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3824. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3825. return ok
  3826. }
  3827. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3828. func (m *AllocAgentMutation) ResetDeletedAt() {
  3829. m.deleted_at = nil
  3830. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3831. }
  3832. // SetUserID sets the "user_id" field.
  3833. func (m *AllocAgentMutation) SetUserID(s string) {
  3834. m.user_id = &s
  3835. }
  3836. // UserID returns the value of the "user_id" field in the mutation.
  3837. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3838. v := m.user_id
  3839. if v == nil {
  3840. return
  3841. }
  3842. return *v, true
  3843. }
  3844. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3845. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3847. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3848. if !m.op.Is(OpUpdateOne) {
  3849. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3850. }
  3851. if m.id == nil || m.oldValue == nil {
  3852. return v, errors.New("OldUserID requires an ID field in the mutation")
  3853. }
  3854. oldValue, err := m.oldValue(ctx)
  3855. if err != nil {
  3856. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3857. }
  3858. return oldValue.UserID, nil
  3859. }
  3860. // ClearUserID clears the value of the "user_id" field.
  3861. func (m *AllocAgentMutation) ClearUserID() {
  3862. m.user_id = nil
  3863. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3864. }
  3865. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3866. func (m *AllocAgentMutation) UserIDCleared() bool {
  3867. _, ok := m.clearedFields[allocagent.FieldUserID]
  3868. return ok
  3869. }
  3870. // ResetUserID resets all changes to the "user_id" field.
  3871. func (m *AllocAgentMutation) ResetUserID() {
  3872. m.user_id = nil
  3873. delete(m.clearedFields, allocagent.FieldUserID)
  3874. }
  3875. // SetOrganizationID sets the "organization_id" field.
  3876. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3877. m.organization_id = &u
  3878. m.addorganization_id = nil
  3879. }
  3880. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3881. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3882. v := m.organization_id
  3883. if v == nil {
  3884. return
  3885. }
  3886. return *v, true
  3887. }
  3888. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3889. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3891. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3892. if !m.op.Is(OpUpdateOne) {
  3893. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3894. }
  3895. if m.id == nil || m.oldValue == nil {
  3896. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3897. }
  3898. oldValue, err := m.oldValue(ctx)
  3899. if err != nil {
  3900. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3901. }
  3902. return oldValue.OrganizationID, nil
  3903. }
  3904. // AddOrganizationID adds u to the "organization_id" field.
  3905. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3906. if m.addorganization_id != nil {
  3907. *m.addorganization_id += u
  3908. } else {
  3909. m.addorganization_id = &u
  3910. }
  3911. }
  3912. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3913. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3914. v := m.addorganization_id
  3915. if v == nil {
  3916. return
  3917. }
  3918. return *v, true
  3919. }
  3920. // ClearOrganizationID clears the value of the "organization_id" field.
  3921. func (m *AllocAgentMutation) ClearOrganizationID() {
  3922. m.organization_id = nil
  3923. m.addorganization_id = nil
  3924. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3925. }
  3926. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3927. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3928. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3929. return ok
  3930. }
  3931. // ResetOrganizationID resets all changes to the "organization_id" field.
  3932. func (m *AllocAgentMutation) ResetOrganizationID() {
  3933. m.organization_id = nil
  3934. m.addorganization_id = nil
  3935. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3936. }
  3937. // SetAgents sets the "agents" field.
  3938. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3939. m.agents = &u
  3940. m.appendagents = nil
  3941. }
  3942. // Agents returns the value of the "agents" field in the mutation.
  3943. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3944. v := m.agents
  3945. if v == nil {
  3946. return
  3947. }
  3948. return *v, true
  3949. }
  3950. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3951. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3953. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3954. if !m.op.Is(OpUpdateOne) {
  3955. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3956. }
  3957. if m.id == nil || m.oldValue == nil {
  3958. return v, errors.New("OldAgents requires an ID field in the mutation")
  3959. }
  3960. oldValue, err := m.oldValue(ctx)
  3961. if err != nil {
  3962. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3963. }
  3964. return oldValue.Agents, nil
  3965. }
  3966. // AppendAgents adds u to the "agents" field.
  3967. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3968. m.appendagents = append(m.appendagents, u...)
  3969. }
  3970. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3971. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3972. if len(m.appendagents) == 0 {
  3973. return nil, false
  3974. }
  3975. return m.appendagents, true
  3976. }
  3977. // ResetAgents resets all changes to the "agents" field.
  3978. func (m *AllocAgentMutation) ResetAgents() {
  3979. m.agents = nil
  3980. m.appendagents = nil
  3981. }
  3982. // SetStatus sets the "status" field.
  3983. func (m *AllocAgentMutation) SetStatus(i int) {
  3984. m.status = &i
  3985. m.addstatus = nil
  3986. }
  3987. // Status returns the value of the "status" field in the mutation.
  3988. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3989. v := m.status
  3990. if v == nil {
  3991. return
  3992. }
  3993. return *v, true
  3994. }
  3995. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3996. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3998. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3999. if !m.op.Is(OpUpdateOne) {
  4000. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4001. }
  4002. if m.id == nil || m.oldValue == nil {
  4003. return v, errors.New("OldStatus requires an ID field in the mutation")
  4004. }
  4005. oldValue, err := m.oldValue(ctx)
  4006. if err != nil {
  4007. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4008. }
  4009. return oldValue.Status, nil
  4010. }
  4011. // AddStatus adds i to the "status" field.
  4012. func (m *AllocAgentMutation) AddStatus(i int) {
  4013. if m.addstatus != nil {
  4014. *m.addstatus += i
  4015. } else {
  4016. m.addstatus = &i
  4017. }
  4018. }
  4019. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4020. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  4021. v := m.addstatus
  4022. if v == nil {
  4023. return
  4024. }
  4025. return *v, true
  4026. }
  4027. // ClearStatus clears the value of the "status" field.
  4028. func (m *AllocAgentMutation) ClearStatus() {
  4029. m.status = nil
  4030. m.addstatus = nil
  4031. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  4032. }
  4033. // StatusCleared returns if the "status" field was cleared in this mutation.
  4034. func (m *AllocAgentMutation) StatusCleared() bool {
  4035. _, ok := m.clearedFields[allocagent.FieldStatus]
  4036. return ok
  4037. }
  4038. // ResetStatus resets all changes to the "status" field.
  4039. func (m *AllocAgentMutation) ResetStatus() {
  4040. m.status = nil
  4041. m.addstatus = nil
  4042. delete(m.clearedFields, allocagent.FieldStatus)
  4043. }
  4044. // Where appends a list predicates to the AllocAgentMutation builder.
  4045. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  4046. m.predicates = append(m.predicates, ps...)
  4047. }
  4048. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  4049. // users can use type-assertion to append predicates that do not depend on any generated package.
  4050. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  4051. p := make([]predicate.AllocAgent, len(ps))
  4052. for i := range ps {
  4053. p[i] = ps[i]
  4054. }
  4055. m.Where(p...)
  4056. }
  4057. // Op returns the operation name.
  4058. func (m *AllocAgentMutation) Op() Op {
  4059. return m.op
  4060. }
  4061. // SetOp allows setting the mutation operation.
  4062. func (m *AllocAgentMutation) SetOp(op Op) {
  4063. m.op = op
  4064. }
  4065. // Type returns the node type of this mutation (AllocAgent).
  4066. func (m *AllocAgentMutation) Type() string {
  4067. return m.typ
  4068. }
  4069. // Fields returns all fields that were changed during this mutation. Note that in
  4070. // order to get all numeric fields that were incremented/decremented, call
  4071. // AddedFields().
  4072. func (m *AllocAgentMutation) Fields() []string {
  4073. fields := make([]string, 0, 7)
  4074. if m.created_at != nil {
  4075. fields = append(fields, allocagent.FieldCreatedAt)
  4076. }
  4077. if m.updated_at != nil {
  4078. fields = append(fields, allocagent.FieldUpdatedAt)
  4079. }
  4080. if m.deleted_at != nil {
  4081. fields = append(fields, allocagent.FieldDeletedAt)
  4082. }
  4083. if m.user_id != nil {
  4084. fields = append(fields, allocagent.FieldUserID)
  4085. }
  4086. if m.organization_id != nil {
  4087. fields = append(fields, allocagent.FieldOrganizationID)
  4088. }
  4089. if m.agents != nil {
  4090. fields = append(fields, allocagent.FieldAgents)
  4091. }
  4092. if m.status != nil {
  4093. fields = append(fields, allocagent.FieldStatus)
  4094. }
  4095. return fields
  4096. }
  4097. // Field returns the value of a field with the given name. The second boolean
  4098. // return value indicates that this field was not set, or was not defined in the
  4099. // schema.
  4100. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  4101. switch name {
  4102. case allocagent.FieldCreatedAt:
  4103. return m.CreatedAt()
  4104. case allocagent.FieldUpdatedAt:
  4105. return m.UpdatedAt()
  4106. case allocagent.FieldDeletedAt:
  4107. return m.DeletedAt()
  4108. case allocagent.FieldUserID:
  4109. return m.UserID()
  4110. case allocagent.FieldOrganizationID:
  4111. return m.OrganizationID()
  4112. case allocagent.FieldAgents:
  4113. return m.Agents()
  4114. case allocagent.FieldStatus:
  4115. return m.Status()
  4116. }
  4117. return nil, false
  4118. }
  4119. // OldField returns the old value of the field from the database. An error is
  4120. // returned if the mutation operation is not UpdateOne, or the query to the
  4121. // database failed.
  4122. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4123. switch name {
  4124. case allocagent.FieldCreatedAt:
  4125. return m.OldCreatedAt(ctx)
  4126. case allocagent.FieldUpdatedAt:
  4127. return m.OldUpdatedAt(ctx)
  4128. case allocagent.FieldDeletedAt:
  4129. return m.OldDeletedAt(ctx)
  4130. case allocagent.FieldUserID:
  4131. return m.OldUserID(ctx)
  4132. case allocagent.FieldOrganizationID:
  4133. return m.OldOrganizationID(ctx)
  4134. case allocagent.FieldAgents:
  4135. return m.OldAgents(ctx)
  4136. case allocagent.FieldStatus:
  4137. return m.OldStatus(ctx)
  4138. }
  4139. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  4140. }
  4141. // SetField sets the value of a field with the given name. It returns an error if
  4142. // the field is not defined in the schema, or if the type mismatched the field
  4143. // type.
  4144. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  4145. switch name {
  4146. case allocagent.FieldCreatedAt:
  4147. v, ok := value.(time.Time)
  4148. if !ok {
  4149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4150. }
  4151. m.SetCreatedAt(v)
  4152. return nil
  4153. case allocagent.FieldUpdatedAt:
  4154. v, ok := value.(time.Time)
  4155. if !ok {
  4156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4157. }
  4158. m.SetUpdatedAt(v)
  4159. return nil
  4160. case allocagent.FieldDeletedAt:
  4161. v, ok := value.(time.Time)
  4162. if !ok {
  4163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4164. }
  4165. m.SetDeletedAt(v)
  4166. return nil
  4167. case allocagent.FieldUserID:
  4168. v, ok := value.(string)
  4169. if !ok {
  4170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4171. }
  4172. m.SetUserID(v)
  4173. return nil
  4174. case allocagent.FieldOrganizationID:
  4175. v, ok := value.(uint64)
  4176. if !ok {
  4177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4178. }
  4179. m.SetOrganizationID(v)
  4180. return nil
  4181. case allocagent.FieldAgents:
  4182. v, ok := value.([]uint64)
  4183. if !ok {
  4184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4185. }
  4186. m.SetAgents(v)
  4187. return nil
  4188. case allocagent.FieldStatus:
  4189. v, ok := value.(int)
  4190. if !ok {
  4191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4192. }
  4193. m.SetStatus(v)
  4194. return nil
  4195. }
  4196. return fmt.Errorf("unknown AllocAgent field %s", name)
  4197. }
  4198. // AddedFields returns all numeric fields that were incremented/decremented during
  4199. // this mutation.
  4200. func (m *AllocAgentMutation) AddedFields() []string {
  4201. var fields []string
  4202. if m.addorganization_id != nil {
  4203. fields = append(fields, allocagent.FieldOrganizationID)
  4204. }
  4205. if m.addstatus != nil {
  4206. fields = append(fields, allocagent.FieldStatus)
  4207. }
  4208. return fields
  4209. }
  4210. // AddedField returns the numeric value that was incremented/decremented on a field
  4211. // with the given name. The second boolean return value indicates that this field
  4212. // was not set, or was not defined in the schema.
  4213. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4214. switch name {
  4215. case allocagent.FieldOrganizationID:
  4216. return m.AddedOrganizationID()
  4217. case allocagent.FieldStatus:
  4218. return m.AddedStatus()
  4219. }
  4220. return nil, false
  4221. }
  4222. // AddField adds the value to the field with the given name. It returns an error if
  4223. // the field is not defined in the schema, or if the type mismatched the field
  4224. // type.
  4225. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4226. switch name {
  4227. case allocagent.FieldOrganizationID:
  4228. v, ok := value.(int64)
  4229. if !ok {
  4230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4231. }
  4232. m.AddOrganizationID(v)
  4233. return nil
  4234. case allocagent.FieldStatus:
  4235. v, ok := value.(int)
  4236. if !ok {
  4237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4238. }
  4239. m.AddStatus(v)
  4240. return nil
  4241. }
  4242. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4243. }
  4244. // ClearedFields returns all nullable fields that were cleared during this
  4245. // mutation.
  4246. func (m *AllocAgentMutation) ClearedFields() []string {
  4247. var fields []string
  4248. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4249. fields = append(fields, allocagent.FieldDeletedAt)
  4250. }
  4251. if m.FieldCleared(allocagent.FieldUserID) {
  4252. fields = append(fields, allocagent.FieldUserID)
  4253. }
  4254. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4255. fields = append(fields, allocagent.FieldOrganizationID)
  4256. }
  4257. if m.FieldCleared(allocagent.FieldStatus) {
  4258. fields = append(fields, allocagent.FieldStatus)
  4259. }
  4260. return fields
  4261. }
  4262. // FieldCleared returns a boolean indicating if a field with the given name was
  4263. // cleared in this mutation.
  4264. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4265. _, ok := m.clearedFields[name]
  4266. return ok
  4267. }
  4268. // ClearField clears the value of the field with the given name. It returns an
  4269. // error if the field is not defined in the schema.
  4270. func (m *AllocAgentMutation) ClearField(name string) error {
  4271. switch name {
  4272. case allocagent.FieldDeletedAt:
  4273. m.ClearDeletedAt()
  4274. return nil
  4275. case allocagent.FieldUserID:
  4276. m.ClearUserID()
  4277. return nil
  4278. case allocagent.FieldOrganizationID:
  4279. m.ClearOrganizationID()
  4280. return nil
  4281. case allocagent.FieldStatus:
  4282. m.ClearStatus()
  4283. return nil
  4284. }
  4285. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4286. }
  4287. // ResetField resets all changes in the mutation for the field with the given name.
  4288. // It returns an error if the field is not defined in the schema.
  4289. func (m *AllocAgentMutation) ResetField(name string) error {
  4290. switch name {
  4291. case allocagent.FieldCreatedAt:
  4292. m.ResetCreatedAt()
  4293. return nil
  4294. case allocagent.FieldUpdatedAt:
  4295. m.ResetUpdatedAt()
  4296. return nil
  4297. case allocagent.FieldDeletedAt:
  4298. m.ResetDeletedAt()
  4299. return nil
  4300. case allocagent.FieldUserID:
  4301. m.ResetUserID()
  4302. return nil
  4303. case allocagent.FieldOrganizationID:
  4304. m.ResetOrganizationID()
  4305. return nil
  4306. case allocagent.FieldAgents:
  4307. m.ResetAgents()
  4308. return nil
  4309. case allocagent.FieldStatus:
  4310. m.ResetStatus()
  4311. return nil
  4312. }
  4313. return fmt.Errorf("unknown AllocAgent field %s", name)
  4314. }
  4315. // AddedEdges returns all edge names that were set/added in this mutation.
  4316. func (m *AllocAgentMutation) AddedEdges() []string {
  4317. edges := make([]string, 0, 0)
  4318. return edges
  4319. }
  4320. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4321. // name in this mutation.
  4322. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4323. return nil
  4324. }
  4325. // RemovedEdges returns all edge names that were removed in this mutation.
  4326. func (m *AllocAgentMutation) RemovedEdges() []string {
  4327. edges := make([]string, 0, 0)
  4328. return edges
  4329. }
  4330. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4331. // the given name in this mutation.
  4332. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4333. return nil
  4334. }
  4335. // ClearedEdges returns all edge names that were cleared in this mutation.
  4336. func (m *AllocAgentMutation) ClearedEdges() []string {
  4337. edges := make([]string, 0, 0)
  4338. return edges
  4339. }
  4340. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4341. // was cleared in this mutation.
  4342. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4343. return false
  4344. }
  4345. // ClearEdge clears the value of the edge with the given name. It returns an error
  4346. // if that edge is not defined in the schema.
  4347. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4348. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4349. }
  4350. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4351. // It returns an error if the edge is not defined in the schema.
  4352. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4353. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4354. }
  4355. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4356. type ApiKeyMutation struct {
  4357. config
  4358. op Op
  4359. typ string
  4360. id *uint64
  4361. created_at *time.Time
  4362. updated_at *time.Time
  4363. deleted_at *time.Time
  4364. title *string
  4365. key *string
  4366. organization_id *uint64
  4367. addorganization_id *int64
  4368. custom_agent_base *string
  4369. custom_agent_key *string
  4370. openai_base *string
  4371. openai_key *string
  4372. clearedFields map[string]struct{}
  4373. agent *uint64
  4374. clearedagent bool
  4375. done bool
  4376. oldValue func(context.Context) (*ApiKey, error)
  4377. predicates []predicate.ApiKey
  4378. }
  4379. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4380. // apikeyOption allows management of the mutation configuration using functional options.
  4381. type apikeyOption func(*ApiKeyMutation)
  4382. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4383. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4384. m := &ApiKeyMutation{
  4385. config: c,
  4386. op: op,
  4387. typ: TypeApiKey,
  4388. clearedFields: make(map[string]struct{}),
  4389. }
  4390. for _, opt := range opts {
  4391. opt(m)
  4392. }
  4393. return m
  4394. }
  4395. // withApiKeyID sets the ID field of the mutation.
  4396. func withApiKeyID(id uint64) apikeyOption {
  4397. return func(m *ApiKeyMutation) {
  4398. var (
  4399. err error
  4400. once sync.Once
  4401. value *ApiKey
  4402. )
  4403. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4404. once.Do(func() {
  4405. if m.done {
  4406. err = errors.New("querying old values post mutation is not allowed")
  4407. } else {
  4408. value, err = m.Client().ApiKey.Get(ctx, id)
  4409. }
  4410. })
  4411. return value, err
  4412. }
  4413. m.id = &id
  4414. }
  4415. }
  4416. // withApiKey sets the old ApiKey of the mutation.
  4417. func withApiKey(node *ApiKey) apikeyOption {
  4418. return func(m *ApiKeyMutation) {
  4419. m.oldValue = func(context.Context) (*ApiKey, error) {
  4420. return node, nil
  4421. }
  4422. m.id = &node.ID
  4423. }
  4424. }
  4425. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4426. // executed in a transaction (ent.Tx), a transactional client is returned.
  4427. func (m ApiKeyMutation) Client() *Client {
  4428. client := &Client{config: m.config}
  4429. client.init()
  4430. return client
  4431. }
  4432. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4433. // it returns an error otherwise.
  4434. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4435. if _, ok := m.driver.(*txDriver); !ok {
  4436. return nil, errors.New("ent: mutation is not running in a transaction")
  4437. }
  4438. tx := &Tx{config: m.config}
  4439. tx.init()
  4440. return tx, nil
  4441. }
  4442. // SetID sets the value of the id field. Note that this
  4443. // operation is only accepted on creation of ApiKey entities.
  4444. func (m *ApiKeyMutation) SetID(id uint64) {
  4445. m.id = &id
  4446. }
  4447. // ID returns the ID value in the mutation. Note that the ID is only available
  4448. // if it was provided to the builder or after it was returned from the database.
  4449. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4450. if m.id == nil {
  4451. return
  4452. }
  4453. return *m.id, true
  4454. }
  4455. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4456. // That means, if the mutation is applied within a transaction with an isolation level such
  4457. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4458. // or updated by the mutation.
  4459. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4460. switch {
  4461. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4462. id, exists := m.ID()
  4463. if exists {
  4464. return []uint64{id}, nil
  4465. }
  4466. fallthrough
  4467. case m.op.Is(OpUpdate | OpDelete):
  4468. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4469. default:
  4470. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4471. }
  4472. }
  4473. // SetCreatedAt sets the "created_at" field.
  4474. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4475. m.created_at = &t
  4476. }
  4477. // CreatedAt returns the value of the "created_at" field in the mutation.
  4478. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4479. v := m.created_at
  4480. if v == nil {
  4481. return
  4482. }
  4483. return *v, true
  4484. }
  4485. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4486. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4488. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4489. if !m.op.Is(OpUpdateOne) {
  4490. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4491. }
  4492. if m.id == nil || m.oldValue == nil {
  4493. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4494. }
  4495. oldValue, err := m.oldValue(ctx)
  4496. if err != nil {
  4497. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4498. }
  4499. return oldValue.CreatedAt, nil
  4500. }
  4501. // ResetCreatedAt resets all changes to the "created_at" field.
  4502. func (m *ApiKeyMutation) ResetCreatedAt() {
  4503. m.created_at = nil
  4504. }
  4505. // SetUpdatedAt sets the "updated_at" field.
  4506. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4507. m.updated_at = &t
  4508. }
  4509. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4510. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4511. v := m.updated_at
  4512. if v == nil {
  4513. return
  4514. }
  4515. return *v, true
  4516. }
  4517. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4518. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4520. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4521. if !m.op.Is(OpUpdateOne) {
  4522. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4523. }
  4524. if m.id == nil || m.oldValue == nil {
  4525. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4526. }
  4527. oldValue, err := m.oldValue(ctx)
  4528. if err != nil {
  4529. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4530. }
  4531. return oldValue.UpdatedAt, nil
  4532. }
  4533. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4534. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4535. m.updated_at = nil
  4536. }
  4537. // SetDeletedAt sets the "deleted_at" field.
  4538. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4539. m.deleted_at = &t
  4540. }
  4541. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4542. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4543. v := m.deleted_at
  4544. if v == nil {
  4545. return
  4546. }
  4547. return *v, true
  4548. }
  4549. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4550. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4552. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4553. if !m.op.Is(OpUpdateOne) {
  4554. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4555. }
  4556. if m.id == nil || m.oldValue == nil {
  4557. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4558. }
  4559. oldValue, err := m.oldValue(ctx)
  4560. if err != nil {
  4561. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4562. }
  4563. return oldValue.DeletedAt, nil
  4564. }
  4565. // ClearDeletedAt clears the value of the "deleted_at" field.
  4566. func (m *ApiKeyMutation) ClearDeletedAt() {
  4567. m.deleted_at = nil
  4568. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4569. }
  4570. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4571. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4572. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4573. return ok
  4574. }
  4575. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4576. func (m *ApiKeyMutation) ResetDeletedAt() {
  4577. m.deleted_at = nil
  4578. delete(m.clearedFields, apikey.FieldDeletedAt)
  4579. }
  4580. // SetTitle sets the "title" field.
  4581. func (m *ApiKeyMutation) SetTitle(s string) {
  4582. m.title = &s
  4583. }
  4584. // Title returns the value of the "title" field in the mutation.
  4585. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4586. v := m.title
  4587. if v == nil {
  4588. return
  4589. }
  4590. return *v, true
  4591. }
  4592. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4593. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4595. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4596. if !m.op.Is(OpUpdateOne) {
  4597. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4598. }
  4599. if m.id == nil || m.oldValue == nil {
  4600. return v, errors.New("OldTitle requires an ID field in the mutation")
  4601. }
  4602. oldValue, err := m.oldValue(ctx)
  4603. if err != nil {
  4604. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4605. }
  4606. return oldValue.Title, nil
  4607. }
  4608. // ClearTitle clears the value of the "title" field.
  4609. func (m *ApiKeyMutation) ClearTitle() {
  4610. m.title = nil
  4611. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4612. }
  4613. // TitleCleared returns if the "title" field was cleared in this mutation.
  4614. func (m *ApiKeyMutation) TitleCleared() bool {
  4615. _, ok := m.clearedFields[apikey.FieldTitle]
  4616. return ok
  4617. }
  4618. // ResetTitle resets all changes to the "title" field.
  4619. func (m *ApiKeyMutation) ResetTitle() {
  4620. m.title = nil
  4621. delete(m.clearedFields, apikey.FieldTitle)
  4622. }
  4623. // SetKey sets the "key" field.
  4624. func (m *ApiKeyMutation) SetKey(s string) {
  4625. m.key = &s
  4626. }
  4627. // Key returns the value of the "key" field in the mutation.
  4628. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4629. v := m.key
  4630. if v == nil {
  4631. return
  4632. }
  4633. return *v, true
  4634. }
  4635. // OldKey returns the old "key" field's value of the ApiKey entity.
  4636. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4638. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4639. if !m.op.Is(OpUpdateOne) {
  4640. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4641. }
  4642. if m.id == nil || m.oldValue == nil {
  4643. return v, errors.New("OldKey requires an ID field in the mutation")
  4644. }
  4645. oldValue, err := m.oldValue(ctx)
  4646. if err != nil {
  4647. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4648. }
  4649. return oldValue.Key, nil
  4650. }
  4651. // ClearKey clears the value of the "key" field.
  4652. func (m *ApiKeyMutation) ClearKey() {
  4653. m.key = nil
  4654. m.clearedFields[apikey.FieldKey] = struct{}{}
  4655. }
  4656. // KeyCleared returns if the "key" field was cleared in this mutation.
  4657. func (m *ApiKeyMutation) KeyCleared() bool {
  4658. _, ok := m.clearedFields[apikey.FieldKey]
  4659. return ok
  4660. }
  4661. // ResetKey resets all changes to the "key" field.
  4662. func (m *ApiKeyMutation) ResetKey() {
  4663. m.key = nil
  4664. delete(m.clearedFields, apikey.FieldKey)
  4665. }
  4666. // SetOrganizationID sets the "organization_id" field.
  4667. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4668. m.organization_id = &u
  4669. m.addorganization_id = nil
  4670. }
  4671. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4672. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4673. v := m.organization_id
  4674. if v == nil {
  4675. return
  4676. }
  4677. return *v, true
  4678. }
  4679. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4680. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4682. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4683. if !m.op.Is(OpUpdateOne) {
  4684. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4685. }
  4686. if m.id == nil || m.oldValue == nil {
  4687. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4688. }
  4689. oldValue, err := m.oldValue(ctx)
  4690. if err != nil {
  4691. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4692. }
  4693. return oldValue.OrganizationID, nil
  4694. }
  4695. // AddOrganizationID adds u to the "organization_id" field.
  4696. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4697. if m.addorganization_id != nil {
  4698. *m.addorganization_id += u
  4699. } else {
  4700. m.addorganization_id = &u
  4701. }
  4702. }
  4703. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4704. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4705. v := m.addorganization_id
  4706. if v == nil {
  4707. return
  4708. }
  4709. return *v, true
  4710. }
  4711. // ResetOrganizationID resets all changes to the "organization_id" field.
  4712. func (m *ApiKeyMutation) ResetOrganizationID() {
  4713. m.organization_id = nil
  4714. m.addorganization_id = nil
  4715. }
  4716. // SetAgentID sets the "agent_id" field.
  4717. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4718. m.agent = &u
  4719. }
  4720. // AgentID returns the value of the "agent_id" field in the mutation.
  4721. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4722. v := m.agent
  4723. if v == nil {
  4724. return
  4725. }
  4726. return *v, true
  4727. }
  4728. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4729. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4731. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4732. if !m.op.Is(OpUpdateOne) {
  4733. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4734. }
  4735. if m.id == nil || m.oldValue == nil {
  4736. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4737. }
  4738. oldValue, err := m.oldValue(ctx)
  4739. if err != nil {
  4740. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4741. }
  4742. return oldValue.AgentID, nil
  4743. }
  4744. // ResetAgentID resets all changes to the "agent_id" field.
  4745. func (m *ApiKeyMutation) ResetAgentID() {
  4746. m.agent = nil
  4747. }
  4748. // SetCustomAgentBase sets the "custom_agent_base" field.
  4749. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4750. m.custom_agent_base = &s
  4751. }
  4752. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4753. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4754. v := m.custom_agent_base
  4755. if v == nil {
  4756. return
  4757. }
  4758. return *v, true
  4759. }
  4760. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4761. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4763. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4764. if !m.op.Is(OpUpdateOne) {
  4765. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4766. }
  4767. if m.id == nil || m.oldValue == nil {
  4768. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4769. }
  4770. oldValue, err := m.oldValue(ctx)
  4771. if err != nil {
  4772. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4773. }
  4774. return oldValue.CustomAgentBase, nil
  4775. }
  4776. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4777. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4778. m.custom_agent_base = nil
  4779. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4780. }
  4781. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4782. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4783. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4784. return ok
  4785. }
  4786. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4787. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4788. m.custom_agent_base = nil
  4789. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4790. }
  4791. // SetCustomAgentKey sets the "custom_agent_key" field.
  4792. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4793. m.custom_agent_key = &s
  4794. }
  4795. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4796. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4797. v := m.custom_agent_key
  4798. if v == nil {
  4799. return
  4800. }
  4801. return *v, true
  4802. }
  4803. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4804. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4806. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4807. if !m.op.Is(OpUpdateOne) {
  4808. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4809. }
  4810. if m.id == nil || m.oldValue == nil {
  4811. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4812. }
  4813. oldValue, err := m.oldValue(ctx)
  4814. if err != nil {
  4815. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4816. }
  4817. return oldValue.CustomAgentKey, nil
  4818. }
  4819. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4820. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4821. m.custom_agent_key = nil
  4822. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4823. }
  4824. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4825. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4826. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4827. return ok
  4828. }
  4829. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4830. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4831. m.custom_agent_key = nil
  4832. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4833. }
  4834. // SetOpenaiBase sets the "openai_base" field.
  4835. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4836. m.openai_base = &s
  4837. }
  4838. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4839. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4840. v := m.openai_base
  4841. if v == nil {
  4842. return
  4843. }
  4844. return *v, true
  4845. }
  4846. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4847. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4849. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4850. if !m.op.Is(OpUpdateOne) {
  4851. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4852. }
  4853. if m.id == nil || m.oldValue == nil {
  4854. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4855. }
  4856. oldValue, err := m.oldValue(ctx)
  4857. if err != nil {
  4858. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4859. }
  4860. return oldValue.OpenaiBase, nil
  4861. }
  4862. // ClearOpenaiBase clears the value of the "openai_base" field.
  4863. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4864. m.openai_base = nil
  4865. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4866. }
  4867. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4868. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4869. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4870. return ok
  4871. }
  4872. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4873. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4874. m.openai_base = nil
  4875. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4876. }
  4877. // SetOpenaiKey sets the "openai_key" field.
  4878. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4879. m.openai_key = &s
  4880. }
  4881. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4882. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4883. v := m.openai_key
  4884. if v == nil {
  4885. return
  4886. }
  4887. return *v, true
  4888. }
  4889. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4890. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4892. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4893. if !m.op.Is(OpUpdateOne) {
  4894. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4895. }
  4896. if m.id == nil || m.oldValue == nil {
  4897. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4898. }
  4899. oldValue, err := m.oldValue(ctx)
  4900. if err != nil {
  4901. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4902. }
  4903. return oldValue.OpenaiKey, nil
  4904. }
  4905. // ClearOpenaiKey clears the value of the "openai_key" field.
  4906. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4907. m.openai_key = nil
  4908. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4909. }
  4910. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4911. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4912. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4913. return ok
  4914. }
  4915. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4916. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4917. m.openai_key = nil
  4918. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4919. }
  4920. // ClearAgent clears the "agent" edge to the Agent entity.
  4921. func (m *ApiKeyMutation) ClearAgent() {
  4922. m.clearedagent = true
  4923. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4924. }
  4925. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4926. func (m *ApiKeyMutation) AgentCleared() bool {
  4927. return m.clearedagent
  4928. }
  4929. // AgentIDs returns the "agent" edge IDs in the mutation.
  4930. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4931. // AgentID instead. It exists only for internal usage by the builders.
  4932. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4933. if id := m.agent; id != nil {
  4934. ids = append(ids, *id)
  4935. }
  4936. return
  4937. }
  4938. // ResetAgent resets all changes to the "agent" edge.
  4939. func (m *ApiKeyMutation) ResetAgent() {
  4940. m.agent = nil
  4941. m.clearedagent = false
  4942. }
  4943. // Where appends a list predicates to the ApiKeyMutation builder.
  4944. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4945. m.predicates = append(m.predicates, ps...)
  4946. }
  4947. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4948. // users can use type-assertion to append predicates that do not depend on any generated package.
  4949. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4950. p := make([]predicate.ApiKey, len(ps))
  4951. for i := range ps {
  4952. p[i] = ps[i]
  4953. }
  4954. m.Where(p...)
  4955. }
  4956. // Op returns the operation name.
  4957. func (m *ApiKeyMutation) Op() Op {
  4958. return m.op
  4959. }
  4960. // SetOp allows setting the mutation operation.
  4961. func (m *ApiKeyMutation) SetOp(op Op) {
  4962. m.op = op
  4963. }
  4964. // Type returns the node type of this mutation (ApiKey).
  4965. func (m *ApiKeyMutation) Type() string {
  4966. return m.typ
  4967. }
  4968. // Fields returns all fields that were changed during this mutation. Note that in
  4969. // order to get all numeric fields that were incremented/decremented, call
  4970. // AddedFields().
  4971. func (m *ApiKeyMutation) Fields() []string {
  4972. fields := make([]string, 0, 11)
  4973. if m.created_at != nil {
  4974. fields = append(fields, apikey.FieldCreatedAt)
  4975. }
  4976. if m.updated_at != nil {
  4977. fields = append(fields, apikey.FieldUpdatedAt)
  4978. }
  4979. if m.deleted_at != nil {
  4980. fields = append(fields, apikey.FieldDeletedAt)
  4981. }
  4982. if m.title != nil {
  4983. fields = append(fields, apikey.FieldTitle)
  4984. }
  4985. if m.key != nil {
  4986. fields = append(fields, apikey.FieldKey)
  4987. }
  4988. if m.organization_id != nil {
  4989. fields = append(fields, apikey.FieldOrganizationID)
  4990. }
  4991. if m.agent != nil {
  4992. fields = append(fields, apikey.FieldAgentID)
  4993. }
  4994. if m.custom_agent_base != nil {
  4995. fields = append(fields, apikey.FieldCustomAgentBase)
  4996. }
  4997. if m.custom_agent_key != nil {
  4998. fields = append(fields, apikey.FieldCustomAgentKey)
  4999. }
  5000. if m.openai_base != nil {
  5001. fields = append(fields, apikey.FieldOpenaiBase)
  5002. }
  5003. if m.openai_key != nil {
  5004. fields = append(fields, apikey.FieldOpenaiKey)
  5005. }
  5006. return fields
  5007. }
  5008. // Field returns the value of a field with the given name. The second boolean
  5009. // return value indicates that this field was not set, or was not defined in the
  5010. // schema.
  5011. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  5012. switch name {
  5013. case apikey.FieldCreatedAt:
  5014. return m.CreatedAt()
  5015. case apikey.FieldUpdatedAt:
  5016. return m.UpdatedAt()
  5017. case apikey.FieldDeletedAt:
  5018. return m.DeletedAt()
  5019. case apikey.FieldTitle:
  5020. return m.Title()
  5021. case apikey.FieldKey:
  5022. return m.Key()
  5023. case apikey.FieldOrganizationID:
  5024. return m.OrganizationID()
  5025. case apikey.FieldAgentID:
  5026. return m.AgentID()
  5027. case apikey.FieldCustomAgentBase:
  5028. return m.CustomAgentBase()
  5029. case apikey.FieldCustomAgentKey:
  5030. return m.CustomAgentKey()
  5031. case apikey.FieldOpenaiBase:
  5032. return m.OpenaiBase()
  5033. case apikey.FieldOpenaiKey:
  5034. return m.OpenaiKey()
  5035. }
  5036. return nil, false
  5037. }
  5038. // OldField returns the old value of the field from the database. An error is
  5039. // returned if the mutation operation is not UpdateOne, or the query to the
  5040. // database failed.
  5041. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5042. switch name {
  5043. case apikey.FieldCreatedAt:
  5044. return m.OldCreatedAt(ctx)
  5045. case apikey.FieldUpdatedAt:
  5046. return m.OldUpdatedAt(ctx)
  5047. case apikey.FieldDeletedAt:
  5048. return m.OldDeletedAt(ctx)
  5049. case apikey.FieldTitle:
  5050. return m.OldTitle(ctx)
  5051. case apikey.FieldKey:
  5052. return m.OldKey(ctx)
  5053. case apikey.FieldOrganizationID:
  5054. return m.OldOrganizationID(ctx)
  5055. case apikey.FieldAgentID:
  5056. return m.OldAgentID(ctx)
  5057. case apikey.FieldCustomAgentBase:
  5058. return m.OldCustomAgentBase(ctx)
  5059. case apikey.FieldCustomAgentKey:
  5060. return m.OldCustomAgentKey(ctx)
  5061. case apikey.FieldOpenaiBase:
  5062. return m.OldOpenaiBase(ctx)
  5063. case apikey.FieldOpenaiKey:
  5064. return m.OldOpenaiKey(ctx)
  5065. }
  5066. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  5067. }
  5068. // SetField sets the value of a field with the given name. It returns an error if
  5069. // the field is not defined in the schema, or if the type mismatched the field
  5070. // type.
  5071. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  5072. switch name {
  5073. case apikey.FieldCreatedAt:
  5074. v, ok := value.(time.Time)
  5075. if !ok {
  5076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5077. }
  5078. m.SetCreatedAt(v)
  5079. return nil
  5080. case apikey.FieldUpdatedAt:
  5081. v, ok := value.(time.Time)
  5082. if !ok {
  5083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5084. }
  5085. m.SetUpdatedAt(v)
  5086. return nil
  5087. case apikey.FieldDeletedAt:
  5088. v, ok := value.(time.Time)
  5089. if !ok {
  5090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5091. }
  5092. m.SetDeletedAt(v)
  5093. return nil
  5094. case apikey.FieldTitle:
  5095. v, ok := value.(string)
  5096. if !ok {
  5097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5098. }
  5099. m.SetTitle(v)
  5100. return nil
  5101. case apikey.FieldKey:
  5102. v, ok := value.(string)
  5103. if !ok {
  5104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5105. }
  5106. m.SetKey(v)
  5107. return nil
  5108. case apikey.FieldOrganizationID:
  5109. v, ok := value.(uint64)
  5110. if !ok {
  5111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5112. }
  5113. m.SetOrganizationID(v)
  5114. return nil
  5115. case apikey.FieldAgentID:
  5116. v, ok := value.(uint64)
  5117. if !ok {
  5118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5119. }
  5120. m.SetAgentID(v)
  5121. return nil
  5122. case apikey.FieldCustomAgentBase:
  5123. v, ok := value.(string)
  5124. if !ok {
  5125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5126. }
  5127. m.SetCustomAgentBase(v)
  5128. return nil
  5129. case apikey.FieldCustomAgentKey:
  5130. v, ok := value.(string)
  5131. if !ok {
  5132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5133. }
  5134. m.SetCustomAgentKey(v)
  5135. return nil
  5136. case apikey.FieldOpenaiBase:
  5137. v, ok := value.(string)
  5138. if !ok {
  5139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5140. }
  5141. m.SetOpenaiBase(v)
  5142. return nil
  5143. case apikey.FieldOpenaiKey:
  5144. v, ok := value.(string)
  5145. if !ok {
  5146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5147. }
  5148. m.SetOpenaiKey(v)
  5149. return nil
  5150. }
  5151. return fmt.Errorf("unknown ApiKey field %s", name)
  5152. }
  5153. // AddedFields returns all numeric fields that were incremented/decremented during
  5154. // this mutation.
  5155. func (m *ApiKeyMutation) AddedFields() []string {
  5156. var fields []string
  5157. if m.addorganization_id != nil {
  5158. fields = append(fields, apikey.FieldOrganizationID)
  5159. }
  5160. return fields
  5161. }
  5162. // AddedField returns the numeric value that was incremented/decremented on a field
  5163. // with the given name. The second boolean return value indicates that this field
  5164. // was not set, or was not defined in the schema.
  5165. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5166. switch name {
  5167. case apikey.FieldOrganizationID:
  5168. return m.AddedOrganizationID()
  5169. }
  5170. return nil, false
  5171. }
  5172. // AddField adds the value to the field with the given name. It returns an error if
  5173. // the field is not defined in the schema, or if the type mismatched the field
  5174. // type.
  5175. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5176. switch name {
  5177. case apikey.FieldOrganizationID:
  5178. v, ok := value.(int64)
  5179. if !ok {
  5180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5181. }
  5182. m.AddOrganizationID(v)
  5183. return nil
  5184. }
  5185. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5186. }
  5187. // ClearedFields returns all nullable fields that were cleared during this
  5188. // mutation.
  5189. func (m *ApiKeyMutation) ClearedFields() []string {
  5190. var fields []string
  5191. if m.FieldCleared(apikey.FieldDeletedAt) {
  5192. fields = append(fields, apikey.FieldDeletedAt)
  5193. }
  5194. if m.FieldCleared(apikey.FieldTitle) {
  5195. fields = append(fields, apikey.FieldTitle)
  5196. }
  5197. if m.FieldCleared(apikey.FieldKey) {
  5198. fields = append(fields, apikey.FieldKey)
  5199. }
  5200. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5201. fields = append(fields, apikey.FieldCustomAgentBase)
  5202. }
  5203. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5204. fields = append(fields, apikey.FieldCustomAgentKey)
  5205. }
  5206. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5207. fields = append(fields, apikey.FieldOpenaiBase)
  5208. }
  5209. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5210. fields = append(fields, apikey.FieldOpenaiKey)
  5211. }
  5212. return fields
  5213. }
  5214. // FieldCleared returns a boolean indicating if a field with the given name was
  5215. // cleared in this mutation.
  5216. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5217. _, ok := m.clearedFields[name]
  5218. return ok
  5219. }
  5220. // ClearField clears the value of the field with the given name. It returns an
  5221. // error if the field is not defined in the schema.
  5222. func (m *ApiKeyMutation) ClearField(name string) error {
  5223. switch name {
  5224. case apikey.FieldDeletedAt:
  5225. m.ClearDeletedAt()
  5226. return nil
  5227. case apikey.FieldTitle:
  5228. m.ClearTitle()
  5229. return nil
  5230. case apikey.FieldKey:
  5231. m.ClearKey()
  5232. return nil
  5233. case apikey.FieldCustomAgentBase:
  5234. m.ClearCustomAgentBase()
  5235. return nil
  5236. case apikey.FieldCustomAgentKey:
  5237. m.ClearCustomAgentKey()
  5238. return nil
  5239. case apikey.FieldOpenaiBase:
  5240. m.ClearOpenaiBase()
  5241. return nil
  5242. case apikey.FieldOpenaiKey:
  5243. m.ClearOpenaiKey()
  5244. return nil
  5245. }
  5246. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5247. }
  5248. // ResetField resets all changes in the mutation for the field with the given name.
  5249. // It returns an error if the field is not defined in the schema.
  5250. func (m *ApiKeyMutation) ResetField(name string) error {
  5251. switch name {
  5252. case apikey.FieldCreatedAt:
  5253. m.ResetCreatedAt()
  5254. return nil
  5255. case apikey.FieldUpdatedAt:
  5256. m.ResetUpdatedAt()
  5257. return nil
  5258. case apikey.FieldDeletedAt:
  5259. m.ResetDeletedAt()
  5260. return nil
  5261. case apikey.FieldTitle:
  5262. m.ResetTitle()
  5263. return nil
  5264. case apikey.FieldKey:
  5265. m.ResetKey()
  5266. return nil
  5267. case apikey.FieldOrganizationID:
  5268. m.ResetOrganizationID()
  5269. return nil
  5270. case apikey.FieldAgentID:
  5271. m.ResetAgentID()
  5272. return nil
  5273. case apikey.FieldCustomAgentBase:
  5274. m.ResetCustomAgentBase()
  5275. return nil
  5276. case apikey.FieldCustomAgentKey:
  5277. m.ResetCustomAgentKey()
  5278. return nil
  5279. case apikey.FieldOpenaiBase:
  5280. m.ResetOpenaiBase()
  5281. return nil
  5282. case apikey.FieldOpenaiKey:
  5283. m.ResetOpenaiKey()
  5284. return nil
  5285. }
  5286. return fmt.Errorf("unknown ApiKey field %s", name)
  5287. }
  5288. // AddedEdges returns all edge names that were set/added in this mutation.
  5289. func (m *ApiKeyMutation) AddedEdges() []string {
  5290. edges := make([]string, 0, 1)
  5291. if m.agent != nil {
  5292. edges = append(edges, apikey.EdgeAgent)
  5293. }
  5294. return edges
  5295. }
  5296. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5297. // name in this mutation.
  5298. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5299. switch name {
  5300. case apikey.EdgeAgent:
  5301. if id := m.agent; id != nil {
  5302. return []ent.Value{*id}
  5303. }
  5304. }
  5305. return nil
  5306. }
  5307. // RemovedEdges returns all edge names that were removed in this mutation.
  5308. func (m *ApiKeyMutation) RemovedEdges() []string {
  5309. edges := make([]string, 0, 1)
  5310. return edges
  5311. }
  5312. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5313. // the given name in this mutation.
  5314. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5315. return nil
  5316. }
  5317. // ClearedEdges returns all edge names that were cleared in this mutation.
  5318. func (m *ApiKeyMutation) ClearedEdges() []string {
  5319. edges := make([]string, 0, 1)
  5320. if m.clearedagent {
  5321. edges = append(edges, apikey.EdgeAgent)
  5322. }
  5323. return edges
  5324. }
  5325. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5326. // was cleared in this mutation.
  5327. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5328. switch name {
  5329. case apikey.EdgeAgent:
  5330. return m.clearedagent
  5331. }
  5332. return false
  5333. }
  5334. // ClearEdge clears the value of the edge with the given name. It returns an error
  5335. // if that edge is not defined in the schema.
  5336. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5337. switch name {
  5338. case apikey.EdgeAgent:
  5339. m.ClearAgent()
  5340. return nil
  5341. }
  5342. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5343. }
  5344. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5345. // It returns an error if the edge is not defined in the schema.
  5346. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5347. switch name {
  5348. case apikey.EdgeAgent:
  5349. m.ResetAgent()
  5350. return nil
  5351. }
  5352. return fmt.Errorf("unknown ApiKey edge %s", name)
  5353. }
  5354. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5355. type BatchMsgMutation struct {
  5356. config
  5357. op Op
  5358. typ string
  5359. id *uint64
  5360. created_at *time.Time
  5361. updated_at *time.Time
  5362. deleted_at *time.Time
  5363. status *uint8
  5364. addstatus *int8
  5365. batch_no *string
  5366. task_name *string
  5367. fromwxid *string
  5368. msg *string
  5369. tag *string
  5370. tagids *string
  5371. total *int32
  5372. addtotal *int32
  5373. success *int32
  5374. addsuccess *int32
  5375. fail *int32
  5376. addfail *int32
  5377. start_time *time.Time
  5378. stop_time *time.Time
  5379. send_time *time.Time
  5380. _type *int32
  5381. add_type *int32
  5382. organization_id *uint64
  5383. addorganization_id *int64
  5384. ctype *uint64
  5385. addctype *int64
  5386. cc *string
  5387. phone *string
  5388. template_name *string
  5389. template_code *string
  5390. lang *string
  5391. clearedFields map[string]struct{}
  5392. done bool
  5393. oldValue func(context.Context) (*BatchMsg, error)
  5394. predicates []predicate.BatchMsg
  5395. }
  5396. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5397. // batchmsgOption allows management of the mutation configuration using functional options.
  5398. type batchmsgOption func(*BatchMsgMutation)
  5399. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5400. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5401. m := &BatchMsgMutation{
  5402. config: c,
  5403. op: op,
  5404. typ: TypeBatchMsg,
  5405. clearedFields: make(map[string]struct{}),
  5406. }
  5407. for _, opt := range opts {
  5408. opt(m)
  5409. }
  5410. return m
  5411. }
  5412. // withBatchMsgID sets the ID field of the mutation.
  5413. func withBatchMsgID(id uint64) batchmsgOption {
  5414. return func(m *BatchMsgMutation) {
  5415. var (
  5416. err error
  5417. once sync.Once
  5418. value *BatchMsg
  5419. )
  5420. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5421. once.Do(func() {
  5422. if m.done {
  5423. err = errors.New("querying old values post mutation is not allowed")
  5424. } else {
  5425. value, err = m.Client().BatchMsg.Get(ctx, id)
  5426. }
  5427. })
  5428. return value, err
  5429. }
  5430. m.id = &id
  5431. }
  5432. }
  5433. // withBatchMsg sets the old BatchMsg of the mutation.
  5434. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5435. return func(m *BatchMsgMutation) {
  5436. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5437. return node, nil
  5438. }
  5439. m.id = &node.ID
  5440. }
  5441. }
  5442. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5443. // executed in a transaction (ent.Tx), a transactional client is returned.
  5444. func (m BatchMsgMutation) Client() *Client {
  5445. client := &Client{config: m.config}
  5446. client.init()
  5447. return client
  5448. }
  5449. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5450. // it returns an error otherwise.
  5451. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5452. if _, ok := m.driver.(*txDriver); !ok {
  5453. return nil, errors.New("ent: mutation is not running in a transaction")
  5454. }
  5455. tx := &Tx{config: m.config}
  5456. tx.init()
  5457. return tx, nil
  5458. }
  5459. // SetID sets the value of the id field. Note that this
  5460. // operation is only accepted on creation of BatchMsg entities.
  5461. func (m *BatchMsgMutation) SetID(id uint64) {
  5462. m.id = &id
  5463. }
  5464. // ID returns the ID value in the mutation. Note that the ID is only available
  5465. // if it was provided to the builder or after it was returned from the database.
  5466. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5467. if m.id == nil {
  5468. return
  5469. }
  5470. return *m.id, true
  5471. }
  5472. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5473. // That means, if the mutation is applied within a transaction with an isolation level such
  5474. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5475. // or updated by the mutation.
  5476. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5477. switch {
  5478. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5479. id, exists := m.ID()
  5480. if exists {
  5481. return []uint64{id}, nil
  5482. }
  5483. fallthrough
  5484. case m.op.Is(OpUpdate | OpDelete):
  5485. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5486. default:
  5487. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5488. }
  5489. }
  5490. // SetCreatedAt sets the "created_at" field.
  5491. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5492. m.created_at = &t
  5493. }
  5494. // CreatedAt returns the value of the "created_at" field in the mutation.
  5495. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5496. v := m.created_at
  5497. if v == nil {
  5498. return
  5499. }
  5500. return *v, true
  5501. }
  5502. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5503. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5505. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5506. if !m.op.Is(OpUpdateOne) {
  5507. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5508. }
  5509. if m.id == nil || m.oldValue == nil {
  5510. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5511. }
  5512. oldValue, err := m.oldValue(ctx)
  5513. if err != nil {
  5514. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5515. }
  5516. return oldValue.CreatedAt, nil
  5517. }
  5518. // ResetCreatedAt resets all changes to the "created_at" field.
  5519. func (m *BatchMsgMutation) ResetCreatedAt() {
  5520. m.created_at = nil
  5521. }
  5522. // SetUpdatedAt sets the "updated_at" field.
  5523. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5524. m.updated_at = &t
  5525. }
  5526. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5527. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5528. v := m.updated_at
  5529. if v == nil {
  5530. return
  5531. }
  5532. return *v, true
  5533. }
  5534. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5535. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5537. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5538. if !m.op.Is(OpUpdateOne) {
  5539. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5540. }
  5541. if m.id == nil || m.oldValue == nil {
  5542. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5543. }
  5544. oldValue, err := m.oldValue(ctx)
  5545. if err != nil {
  5546. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5547. }
  5548. return oldValue.UpdatedAt, nil
  5549. }
  5550. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5551. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5552. m.updated_at = nil
  5553. }
  5554. // SetDeletedAt sets the "deleted_at" field.
  5555. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5556. m.deleted_at = &t
  5557. }
  5558. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5559. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5560. v := m.deleted_at
  5561. if v == nil {
  5562. return
  5563. }
  5564. return *v, true
  5565. }
  5566. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5567. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5569. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5570. if !m.op.Is(OpUpdateOne) {
  5571. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5572. }
  5573. if m.id == nil || m.oldValue == nil {
  5574. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5575. }
  5576. oldValue, err := m.oldValue(ctx)
  5577. if err != nil {
  5578. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5579. }
  5580. return oldValue.DeletedAt, nil
  5581. }
  5582. // ClearDeletedAt clears the value of the "deleted_at" field.
  5583. func (m *BatchMsgMutation) ClearDeletedAt() {
  5584. m.deleted_at = nil
  5585. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5586. }
  5587. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5588. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5589. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5590. return ok
  5591. }
  5592. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5593. func (m *BatchMsgMutation) ResetDeletedAt() {
  5594. m.deleted_at = nil
  5595. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5596. }
  5597. // SetStatus sets the "status" field.
  5598. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5599. m.status = &u
  5600. m.addstatus = nil
  5601. }
  5602. // Status returns the value of the "status" field in the mutation.
  5603. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5604. v := m.status
  5605. if v == nil {
  5606. return
  5607. }
  5608. return *v, true
  5609. }
  5610. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5611. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5613. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5614. if !m.op.Is(OpUpdateOne) {
  5615. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5616. }
  5617. if m.id == nil || m.oldValue == nil {
  5618. return v, errors.New("OldStatus requires an ID field in the mutation")
  5619. }
  5620. oldValue, err := m.oldValue(ctx)
  5621. if err != nil {
  5622. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5623. }
  5624. return oldValue.Status, nil
  5625. }
  5626. // AddStatus adds u to the "status" field.
  5627. func (m *BatchMsgMutation) AddStatus(u int8) {
  5628. if m.addstatus != nil {
  5629. *m.addstatus += u
  5630. } else {
  5631. m.addstatus = &u
  5632. }
  5633. }
  5634. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5635. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5636. v := m.addstatus
  5637. if v == nil {
  5638. return
  5639. }
  5640. return *v, true
  5641. }
  5642. // ClearStatus clears the value of the "status" field.
  5643. func (m *BatchMsgMutation) ClearStatus() {
  5644. m.status = nil
  5645. m.addstatus = nil
  5646. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5647. }
  5648. // StatusCleared returns if the "status" field was cleared in this mutation.
  5649. func (m *BatchMsgMutation) StatusCleared() bool {
  5650. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5651. return ok
  5652. }
  5653. // ResetStatus resets all changes to the "status" field.
  5654. func (m *BatchMsgMutation) ResetStatus() {
  5655. m.status = nil
  5656. m.addstatus = nil
  5657. delete(m.clearedFields, batchmsg.FieldStatus)
  5658. }
  5659. // SetBatchNo sets the "batch_no" field.
  5660. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5661. m.batch_no = &s
  5662. }
  5663. // BatchNo returns the value of the "batch_no" field in the mutation.
  5664. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5665. v := m.batch_no
  5666. if v == nil {
  5667. return
  5668. }
  5669. return *v, true
  5670. }
  5671. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5672. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5674. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5675. if !m.op.Is(OpUpdateOne) {
  5676. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5677. }
  5678. if m.id == nil || m.oldValue == nil {
  5679. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5680. }
  5681. oldValue, err := m.oldValue(ctx)
  5682. if err != nil {
  5683. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5684. }
  5685. return oldValue.BatchNo, nil
  5686. }
  5687. // ClearBatchNo clears the value of the "batch_no" field.
  5688. func (m *BatchMsgMutation) ClearBatchNo() {
  5689. m.batch_no = nil
  5690. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5691. }
  5692. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5693. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5694. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5695. return ok
  5696. }
  5697. // ResetBatchNo resets all changes to the "batch_no" field.
  5698. func (m *BatchMsgMutation) ResetBatchNo() {
  5699. m.batch_no = nil
  5700. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5701. }
  5702. // SetTaskName sets the "task_name" field.
  5703. func (m *BatchMsgMutation) SetTaskName(s string) {
  5704. m.task_name = &s
  5705. }
  5706. // TaskName returns the value of the "task_name" field in the mutation.
  5707. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5708. v := m.task_name
  5709. if v == nil {
  5710. return
  5711. }
  5712. return *v, true
  5713. }
  5714. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5715. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5717. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5718. if !m.op.Is(OpUpdateOne) {
  5719. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5720. }
  5721. if m.id == nil || m.oldValue == nil {
  5722. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5723. }
  5724. oldValue, err := m.oldValue(ctx)
  5725. if err != nil {
  5726. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5727. }
  5728. return oldValue.TaskName, nil
  5729. }
  5730. // ClearTaskName clears the value of the "task_name" field.
  5731. func (m *BatchMsgMutation) ClearTaskName() {
  5732. m.task_name = nil
  5733. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5734. }
  5735. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5736. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5737. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5738. return ok
  5739. }
  5740. // ResetTaskName resets all changes to the "task_name" field.
  5741. func (m *BatchMsgMutation) ResetTaskName() {
  5742. m.task_name = nil
  5743. delete(m.clearedFields, batchmsg.FieldTaskName)
  5744. }
  5745. // SetFromwxid sets the "fromwxid" field.
  5746. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5747. m.fromwxid = &s
  5748. }
  5749. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5750. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5751. v := m.fromwxid
  5752. if v == nil {
  5753. return
  5754. }
  5755. return *v, true
  5756. }
  5757. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5758. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5760. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5761. if !m.op.Is(OpUpdateOne) {
  5762. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5763. }
  5764. if m.id == nil || m.oldValue == nil {
  5765. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5766. }
  5767. oldValue, err := m.oldValue(ctx)
  5768. if err != nil {
  5769. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5770. }
  5771. return oldValue.Fromwxid, nil
  5772. }
  5773. // ClearFromwxid clears the value of the "fromwxid" field.
  5774. func (m *BatchMsgMutation) ClearFromwxid() {
  5775. m.fromwxid = nil
  5776. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5777. }
  5778. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5779. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5780. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5781. return ok
  5782. }
  5783. // ResetFromwxid resets all changes to the "fromwxid" field.
  5784. func (m *BatchMsgMutation) ResetFromwxid() {
  5785. m.fromwxid = nil
  5786. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5787. }
  5788. // SetMsg sets the "msg" field.
  5789. func (m *BatchMsgMutation) SetMsg(s string) {
  5790. m.msg = &s
  5791. }
  5792. // Msg returns the value of the "msg" field in the mutation.
  5793. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5794. v := m.msg
  5795. if v == nil {
  5796. return
  5797. }
  5798. return *v, true
  5799. }
  5800. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5801. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5803. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5804. if !m.op.Is(OpUpdateOne) {
  5805. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5806. }
  5807. if m.id == nil || m.oldValue == nil {
  5808. return v, errors.New("OldMsg requires an ID field in the mutation")
  5809. }
  5810. oldValue, err := m.oldValue(ctx)
  5811. if err != nil {
  5812. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5813. }
  5814. return oldValue.Msg, nil
  5815. }
  5816. // ClearMsg clears the value of the "msg" field.
  5817. func (m *BatchMsgMutation) ClearMsg() {
  5818. m.msg = nil
  5819. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5820. }
  5821. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5822. func (m *BatchMsgMutation) MsgCleared() bool {
  5823. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5824. return ok
  5825. }
  5826. // ResetMsg resets all changes to the "msg" field.
  5827. func (m *BatchMsgMutation) ResetMsg() {
  5828. m.msg = nil
  5829. delete(m.clearedFields, batchmsg.FieldMsg)
  5830. }
  5831. // SetTag sets the "tag" field.
  5832. func (m *BatchMsgMutation) SetTag(s string) {
  5833. m.tag = &s
  5834. }
  5835. // Tag returns the value of the "tag" field in the mutation.
  5836. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5837. v := m.tag
  5838. if v == nil {
  5839. return
  5840. }
  5841. return *v, true
  5842. }
  5843. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5844. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5846. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5847. if !m.op.Is(OpUpdateOne) {
  5848. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5849. }
  5850. if m.id == nil || m.oldValue == nil {
  5851. return v, errors.New("OldTag requires an ID field in the mutation")
  5852. }
  5853. oldValue, err := m.oldValue(ctx)
  5854. if err != nil {
  5855. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5856. }
  5857. return oldValue.Tag, nil
  5858. }
  5859. // ClearTag clears the value of the "tag" field.
  5860. func (m *BatchMsgMutation) ClearTag() {
  5861. m.tag = nil
  5862. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5863. }
  5864. // TagCleared returns if the "tag" field was cleared in this mutation.
  5865. func (m *BatchMsgMutation) TagCleared() bool {
  5866. _, ok := m.clearedFields[batchmsg.FieldTag]
  5867. return ok
  5868. }
  5869. // ResetTag resets all changes to the "tag" field.
  5870. func (m *BatchMsgMutation) ResetTag() {
  5871. m.tag = nil
  5872. delete(m.clearedFields, batchmsg.FieldTag)
  5873. }
  5874. // SetTagids sets the "tagids" field.
  5875. func (m *BatchMsgMutation) SetTagids(s string) {
  5876. m.tagids = &s
  5877. }
  5878. // Tagids returns the value of the "tagids" field in the mutation.
  5879. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5880. v := m.tagids
  5881. if v == nil {
  5882. return
  5883. }
  5884. return *v, true
  5885. }
  5886. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5887. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5889. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5890. if !m.op.Is(OpUpdateOne) {
  5891. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5892. }
  5893. if m.id == nil || m.oldValue == nil {
  5894. return v, errors.New("OldTagids requires an ID field in the mutation")
  5895. }
  5896. oldValue, err := m.oldValue(ctx)
  5897. if err != nil {
  5898. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5899. }
  5900. return oldValue.Tagids, nil
  5901. }
  5902. // ClearTagids clears the value of the "tagids" field.
  5903. func (m *BatchMsgMutation) ClearTagids() {
  5904. m.tagids = nil
  5905. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5906. }
  5907. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5908. func (m *BatchMsgMutation) TagidsCleared() bool {
  5909. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5910. return ok
  5911. }
  5912. // ResetTagids resets all changes to the "tagids" field.
  5913. func (m *BatchMsgMutation) ResetTagids() {
  5914. m.tagids = nil
  5915. delete(m.clearedFields, batchmsg.FieldTagids)
  5916. }
  5917. // SetTotal sets the "total" field.
  5918. func (m *BatchMsgMutation) SetTotal(i int32) {
  5919. m.total = &i
  5920. m.addtotal = nil
  5921. }
  5922. // Total returns the value of the "total" field in the mutation.
  5923. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5924. v := m.total
  5925. if v == nil {
  5926. return
  5927. }
  5928. return *v, true
  5929. }
  5930. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5931. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5933. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5934. if !m.op.Is(OpUpdateOne) {
  5935. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5936. }
  5937. if m.id == nil || m.oldValue == nil {
  5938. return v, errors.New("OldTotal requires an ID field in the mutation")
  5939. }
  5940. oldValue, err := m.oldValue(ctx)
  5941. if err != nil {
  5942. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5943. }
  5944. return oldValue.Total, nil
  5945. }
  5946. // AddTotal adds i to the "total" field.
  5947. func (m *BatchMsgMutation) AddTotal(i int32) {
  5948. if m.addtotal != nil {
  5949. *m.addtotal += i
  5950. } else {
  5951. m.addtotal = &i
  5952. }
  5953. }
  5954. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5955. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5956. v := m.addtotal
  5957. if v == nil {
  5958. return
  5959. }
  5960. return *v, true
  5961. }
  5962. // ClearTotal clears the value of the "total" field.
  5963. func (m *BatchMsgMutation) ClearTotal() {
  5964. m.total = nil
  5965. m.addtotal = nil
  5966. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5967. }
  5968. // TotalCleared returns if the "total" field was cleared in this mutation.
  5969. func (m *BatchMsgMutation) TotalCleared() bool {
  5970. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5971. return ok
  5972. }
  5973. // ResetTotal resets all changes to the "total" field.
  5974. func (m *BatchMsgMutation) ResetTotal() {
  5975. m.total = nil
  5976. m.addtotal = nil
  5977. delete(m.clearedFields, batchmsg.FieldTotal)
  5978. }
  5979. // SetSuccess sets the "success" field.
  5980. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5981. m.success = &i
  5982. m.addsuccess = nil
  5983. }
  5984. // Success returns the value of the "success" field in the mutation.
  5985. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5986. v := m.success
  5987. if v == nil {
  5988. return
  5989. }
  5990. return *v, true
  5991. }
  5992. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5993. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5995. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5996. if !m.op.Is(OpUpdateOne) {
  5997. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5998. }
  5999. if m.id == nil || m.oldValue == nil {
  6000. return v, errors.New("OldSuccess requires an ID field in the mutation")
  6001. }
  6002. oldValue, err := m.oldValue(ctx)
  6003. if err != nil {
  6004. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  6005. }
  6006. return oldValue.Success, nil
  6007. }
  6008. // AddSuccess adds i to the "success" field.
  6009. func (m *BatchMsgMutation) AddSuccess(i int32) {
  6010. if m.addsuccess != nil {
  6011. *m.addsuccess += i
  6012. } else {
  6013. m.addsuccess = &i
  6014. }
  6015. }
  6016. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  6017. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  6018. v := m.addsuccess
  6019. if v == nil {
  6020. return
  6021. }
  6022. return *v, true
  6023. }
  6024. // ClearSuccess clears the value of the "success" field.
  6025. func (m *BatchMsgMutation) ClearSuccess() {
  6026. m.success = nil
  6027. m.addsuccess = nil
  6028. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  6029. }
  6030. // SuccessCleared returns if the "success" field was cleared in this mutation.
  6031. func (m *BatchMsgMutation) SuccessCleared() bool {
  6032. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  6033. return ok
  6034. }
  6035. // ResetSuccess resets all changes to the "success" field.
  6036. func (m *BatchMsgMutation) ResetSuccess() {
  6037. m.success = nil
  6038. m.addsuccess = nil
  6039. delete(m.clearedFields, batchmsg.FieldSuccess)
  6040. }
  6041. // SetFail sets the "fail" field.
  6042. func (m *BatchMsgMutation) SetFail(i int32) {
  6043. m.fail = &i
  6044. m.addfail = nil
  6045. }
  6046. // Fail returns the value of the "fail" field in the mutation.
  6047. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  6048. v := m.fail
  6049. if v == nil {
  6050. return
  6051. }
  6052. return *v, true
  6053. }
  6054. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  6055. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6057. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  6058. if !m.op.Is(OpUpdateOne) {
  6059. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  6060. }
  6061. if m.id == nil || m.oldValue == nil {
  6062. return v, errors.New("OldFail requires an ID field in the mutation")
  6063. }
  6064. oldValue, err := m.oldValue(ctx)
  6065. if err != nil {
  6066. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  6067. }
  6068. return oldValue.Fail, nil
  6069. }
  6070. // AddFail adds i to the "fail" field.
  6071. func (m *BatchMsgMutation) AddFail(i int32) {
  6072. if m.addfail != nil {
  6073. *m.addfail += i
  6074. } else {
  6075. m.addfail = &i
  6076. }
  6077. }
  6078. // AddedFail returns the value that was added to the "fail" field in this mutation.
  6079. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  6080. v := m.addfail
  6081. if v == nil {
  6082. return
  6083. }
  6084. return *v, true
  6085. }
  6086. // ClearFail clears the value of the "fail" field.
  6087. func (m *BatchMsgMutation) ClearFail() {
  6088. m.fail = nil
  6089. m.addfail = nil
  6090. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  6091. }
  6092. // FailCleared returns if the "fail" field was cleared in this mutation.
  6093. func (m *BatchMsgMutation) FailCleared() bool {
  6094. _, ok := m.clearedFields[batchmsg.FieldFail]
  6095. return ok
  6096. }
  6097. // ResetFail resets all changes to the "fail" field.
  6098. func (m *BatchMsgMutation) ResetFail() {
  6099. m.fail = nil
  6100. m.addfail = nil
  6101. delete(m.clearedFields, batchmsg.FieldFail)
  6102. }
  6103. // SetStartTime sets the "start_time" field.
  6104. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  6105. m.start_time = &t
  6106. }
  6107. // StartTime returns the value of the "start_time" field in the mutation.
  6108. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  6109. v := m.start_time
  6110. if v == nil {
  6111. return
  6112. }
  6113. return *v, true
  6114. }
  6115. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  6116. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6118. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  6119. if !m.op.Is(OpUpdateOne) {
  6120. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  6121. }
  6122. if m.id == nil || m.oldValue == nil {
  6123. return v, errors.New("OldStartTime requires an ID field in the mutation")
  6124. }
  6125. oldValue, err := m.oldValue(ctx)
  6126. if err != nil {
  6127. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  6128. }
  6129. return oldValue.StartTime, nil
  6130. }
  6131. // ClearStartTime clears the value of the "start_time" field.
  6132. func (m *BatchMsgMutation) ClearStartTime() {
  6133. m.start_time = nil
  6134. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  6135. }
  6136. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  6137. func (m *BatchMsgMutation) StartTimeCleared() bool {
  6138. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  6139. return ok
  6140. }
  6141. // ResetStartTime resets all changes to the "start_time" field.
  6142. func (m *BatchMsgMutation) ResetStartTime() {
  6143. m.start_time = nil
  6144. delete(m.clearedFields, batchmsg.FieldStartTime)
  6145. }
  6146. // SetStopTime sets the "stop_time" field.
  6147. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  6148. m.stop_time = &t
  6149. }
  6150. // StopTime returns the value of the "stop_time" field in the mutation.
  6151. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  6152. v := m.stop_time
  6153. if v == nil {
  6154. return
  6155. }
  6156. return *v, true
  6157. }
  6158. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  6159. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6161. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  6162. if !m.op.Is(OpUpdateOne) {
  6163. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6164. }
  6165. if m.id == nil || m.oldValue == nil {
  6166. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6167. }
  6168. oldValue, err := m.oldValue(ctx)
  6169. if err != nil {
  6170. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6171. }
  6172. return oldValue.StopTime, nil
  6173. }
  6174. // ClearStopTime clears the value of the "stop_time" field.
  6175. func (m *BatchMsgMutation) ClearStopTime() {
  6176. m.stop_time = nil
  6177. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6178. }
  6179. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6180. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6181. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6182. return ok
  6183. }
  6184. // ResetStopTime resets all changes to the "stop_time" field.
  6185. func (m *BatchMsgMutation) ResetStopTime() {
  6186. m.stop_time = nil
  6187. delete(m.clearedFields, batchmsg.FieldStopTime)
  6188. }
  6189. // SetSendTime sets the "send_time" field.
  6190. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6191. m.send_time = &t
  6192. }
  6193. // SendTime returns the value of the "send_time" field in the mutation.
  6194. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6195. v := m.send_time
  6196. if v == nil {
  6197. return
  6198. }
  6199. return *v, true
  6200. }
  6201. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  6202. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6204. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6205. if !m.op.Is(OpUpdateOne) {
  6206. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6207. }
  6208. if m.id == nil || m.oldValue == nil {
  6209. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6210. }
  6211. oldValue, err := m.oldValue(ctx)
  6212. if err != nil {
  6213. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6214. }
  6215. return oldValue.SendTime, nil
  6216. }
  6217. // ClearSendTime clears the value of the "send_time" field.
  6218. func (m *BatchMsgMutation) ClearSendTime() {
  6219. m.send_time = nil
  6220. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6221. }
  6222. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6223. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6224. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6225. return ok
  6226. }
  6227. // ResetSendTime resets all changes to the "send_time" field.
  6228. func (m *BatchMsgMutation) ResetSendTime() {
  6229. m.send_time = nil
  6230. delete(m.clearedFields, batchmsg.FieldSendTime)
  6231. }
  6232. // SetType sets the "type" field.
  6233. func (m *BatchMsgMutation) SetType(i int32) {
  6234. m._type = &i
  6235. m.add_type = nil
  6236. }
  6237. // GetType returns the value of the "type" field in the mutation.
  6238. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6239. v := m._type
  6240. if v == nil {
  6241. return
  6242. }
  6243. return *v, true
  6244. }
  6245. // OldType returns the old "type" field's value of the BatchMsg entity.
  6246. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6248. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6249. if !m.op.Is(OpUpdateOne) {
  6250. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6251. }
  6252. if m.id == nil || m.oldValue == nil {
  6253. return v, errors.New("OldType requires an ID field in the mutation")
  6254. }
  6255. oldValue, err := m.oldValue(ctx)
  6256. if err != nil {
  6257. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6258. }
  6259. return oldValue.Type, nil
  6260. }
  6261. // AddType adds i to the "type" field.
  6262. func (m *BatchMsgMutation) AddType(i int32) {
  6263. if m.add_type != nil {
  6264. *m.add_type += i
  6265. } else {
  6266. m.add_type = &i
  6267. }
  6268. }
  6269. // AddedType returns the value that was added to the "type" field in this mutation.
  6270. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6271. v := m.add_type
  6272. if v == nil {
  6273. return
  6274. }
  6275. return *v, true
  6276. }
  6277. // ClearType clears the value of the "type" field.
  6278. func (m *BatchMsgMutation) ClearType() {
  6279. m._type = nil
  6280. m.add_type = nil
  6281. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6282. }
  6283. // TypeCleared returns if the "type" field was cleared in this mutation.
  6284. func (m *BatchMsgMutation) TypeCleared() bool {
  6285. _, ok := m.clearedFields[batchmsg.FieldType]
  6286. return ok
  6287. }
  6288. // ResetType resets all changes to the "type" field.
  6289. func (m *BatchMsgMutation) ResetType() {
  6290. m._type = nil
  6291. m.add_type = nil
  6292. delete(m.clearedFields, batchmsg.FieldType)
  6293. }
  6294. // SetOrganizationID sets the "organization_id" field.
  6295. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6296. m.organization_id = &u
  6297. m.addorganization_id = nil
  6298. }
  6299. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6300. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6301. v := m.organization_id
  6302. if v == nil {
  6303. return
  6304. }
  6305. return *v, true
  6306. }
  6307. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6308. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6310. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6311. if !m.op.Is(OpUpdateOne) {
  6312. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6313. }
  6314. if m.id == nil || m.oldValue == nil {
  6315. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6316. }
  6317. oldValue, err := m.oldValue(ctx)
  6318. if err != nil {
  6319. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6320. }
  6321. return oldValue.OrganizationID, nil
  6322. }
  6323. // AddOrganizationID adds u to the "organization_id" field.
  6324. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6325. if m.addorganization_id != nil {
  6326. *m.addorganization_id += u
  6327. } else {
  6328. m.addorganization_id = &u
  6329. }
  6330. }
  6331. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6332. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6333. v := m.addorganization_id
  6334. if v == nil {
  6335. return
  6336. }
  6337. return *v, true
  6338. }
  6339. // ResetOrganizationID resets all changes to the "organization_id" field.
  6340. func (m *BatchMsgMutation) ResetOrganizationID() {
  6341. m.organization_id = nil
  6342. m.addorganization_id = nil
  6343. }
  6344. // SetCtype sets the "ctype" field.
  6345. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6346. m.ctype = &u
  6347. m.addctype = nil
  6348. }
  6349. // Ctype returns the value of the "ctype" field in the mutation.
  6350. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6351. v := m.ctype
  6352. if v == nil {
  6353. return
  6354. }
  6355. return *v, true
  6356. }
  6357. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6358. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6360. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6361. if !m.op.Is(OpUpdateOne) {
  6362. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6363. }
  6364. if m.id == nil || m.oldValue == nil {
  6365. return v, errors.New("OldCtype requires an ID field in the mutation")
  6366. }
  6367. oldValue, err := m.oldValue(ctx)
  6368. if err != nil {
  6369. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6370. }
  6371. return oldValue.Ctype, nil
  6372. }
  6373. // AddCtype adds u to the "ctype" field.
  6374. func (m *BatchMsgMutation) AddCtype(u int64) {
  6375. if m.addctype != nil {
  6376. *m.addctype += u
  6377. } else {
  6378. m.addctype = &u
  6379. }
  6380. }
  6381. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6382. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6383. v := m.addctype
  6384. if v == nil {
  6385. return
  6386. }
  6387. return *v, true
  6388. }
  6389. // ResetCtype resets all changes to the "ctype" field.
  6390. func (m *BatchMsgMutation) ResetCtype() {
  6391. m.ctype = nil
  6392. m.addctype = nil
  6393. }
  6394. // SetCc sets the "cc" field.
  6395. func (m *BatchMsgMutation) SetCc(s string) {
  6396. m.cc = &s
  6397. }
  6398. // Cc returns the value of the "cc" field in the mutation.
  6399. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6400. v := m.cc
  6401. if v == nil {
  6402. return
  6403. }
  6404. return *v, true
  6405. }
  6406. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6407. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6409. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6410. if !m.op.Is(OpUpdateOne) {
  6411. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6412. }
  6413. if m.id == nil || m.oldValue == nil {
  6414. return v, errors.New("OldCc requires an ID field in the mutation")
  6415. }
  6416. oldValue, err := m.oldValue(ctx)
  6417. if err != nil {
  6418. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6419. }
  6420. return oldValue.Cc, nil
  6421. }
  6422. // ClearCc clears the value of the "cc" field.
  6423. func (m *BatchMsgMutation) ClearCc() {
  6424. m.cc = nil
  6425. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6426. }
  6427. // CcCleared returns if the "cc" field was cleared in this mutation.
  6428. func (m *BatchMsgMutation) CcCleared() bool {
  6429. _, ok := m.clearedFields[batchmsg.FieldCc]
  6430. return ok
  6431. }
  6432. // ResetCc resets all changes to the "cc" field.
  6433. func (m *BatchMsgMutation) ResetCc() {
  6434. m.cc = nil
  6435. delete(m.clearedFields, batchmsg.FieldCc)
  6436. }
  6437. // SetPhone sets the "phone" field.
  6438. func (m *BatchMsgMutation) SetPhone(s string) {
  6439. m.phone = &s
  6440. }
  6441. // Phone returns the value of the "phone" field in the mutation.
  6442. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6443. v := m.phone
  6444. if v == nil {
  6445. return
  6446. }
  6447. return *v, true
  6448. }
  6449. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6450. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6452. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6453. if !m.op.Is(OpUpdateOne) {
  6454. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6455. }
  6456. if m.id == nil || m.oldValue == nil {
  6457. return v, errors.New("OldPhone requires an ID field in the mutation")
  6458. }
  6459. oldValue, err := m.oldValue(ctx)
  6460. if err != nil {
  6461. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6462. }
  6463. return oldValue.Phone, nil
  6464. }
  6465. // ClearPhone clears the value of the "phone" field.
  6466. func (m *BatchMsgMutation) ClearPhone() {
  6467. m.phone = nil
  6468. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6469. }
  6470. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6471. func (m *BatchMsgMutation) PhoneCleared() bool {
  6472. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6473. return ok
  6474. }
  6475. // ResetPhone resets all changes to the "phone" field.
  6476. func (m *BatchMsgMutation) ResetPhone() {
  6477. m.phone = nil
  6478. delete(m.clearedFields, batchmsg.FieldPhone)
  6479. }
  6480. // SetTemplateName sets the "template_name" field.
  6481. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6482. m.template_name = &s
  6483. }
  6484. // TemplateName returns the value of the "template_name" field in the mutation.
  6485. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6486. v := m.template_name
  6487. if v == nil {
  6488. return
  6489. }
  6490. return *v, true
  6491. }
  6492. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6493. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6495. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6496. if !m.op.Is(OpUpdateOne) {
  6497. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6498. }
  6499. if m.id == nil || m.oldValue == nil {
  6500. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6501. }
  6502. oldValue, err := m.oldValue(ctx)
  6503. if err != nil {
  6504. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6505. }
  6506. return oldValue.TemplateName, nil
  6507. }
  6508. // ClearTemplateName clears the value of the "template_name" field.
  6509. func (m *BatchMsgMutation) ClearTemplateName() {
  6510. m.template_name = nil
  6511. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6512. }
  6513. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6514. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6515. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6516. return ok
  6517. }
  6518. // ResetTemplateName resets all changes to the "template_name" field.
  6519. func (m *BatchMsgMutation) ResetTemplateName() {
  6520. m.template_name = nil
  6521. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6522. }
  6523. // SetTemplateCode sets the "template_code" field.
  6524. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6525. m.template_code = &s
  6526. }
  6527. // TemplateCode returns the value of the "template_code" field in the mutation.
  6528. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6529. v := m.template_code
  6530. if v == nil {
  6531. return
  6532. }
  6533. return *v, true
  6534. }
  6535. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6536. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6538. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6539. if !m.op.Is(OpUpdateOne) {
  6540. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6541. }
  6542. if m.id == nil || m.oldValue == nil {
  6543. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6544. }
  6545. oldValue, err := m.oldValue(ctx)
  6546. if err != nil {
  6547. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6548. }
  6549. return oldValue.TemplateCode, nil
  6550. }
  6551. // ClearTemplateCode clears the value of the "template_code" field.
  6552. func (m *BatchMsgMutation) ClearTemplateCode() {
  6553. m.template_code = nil
  6554. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6555. }
  6556. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6557. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6558. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6559. return ok
  6560. }
  6561. // ResetTemplateCode resets all changes to the "template_code" field.
  6562. func (m *BatchMsgMutation) ResetTemplateCode() {
  6563. m.template_code = nil
  6564. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6565. }
  6566. // SetLang sets the "lang" field.
  6567. func (m *BatchMsgMutation) SetLang(s string) {
  6568. m.lang = &s
  6569. }
  6570. // Lang returns the value of the "lang" field in the mutation.
  6571. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6572. v := m.lang
  6573. if v == nil {
  6574. return
  6575. }
  6576. return *v, true
  6577. }
  6578. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6579. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6581. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6582. if !m.op.Is(OpUpdateOne) {
  6583. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6584. }
  6585. if m.id == nil || m.oldValue == nil {
  6586. return v, errors.New("OldLang requires an ID field in the mutation")
  6587. }
  6588. oldValue, err := m.oldValue(ctx)
  6589. if err != nil {
  6590. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6591. }
  6592. return oldValue.Lang, nil
  6593. }
  6594. // ClearLang clears the value of the "lang" field.
  6595. func (m *BatchMsgMutation) ClearLang() {
  6596. m.lang = nil
  6597. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6598. }
  6599. // LangCleared returns if the "lang" field was cleared in this mutation.
  6600. func (m *BatchMsgMutation) LangCleared() bool {
  6601. _, ok := m.clearedFields[batchmsg.FieldLang]
  6602. return ok
  6603. }
  6604. // ResetLang resets all changes to the "lang" field.
  6605. func (m *BatchMsgMutation) ResetLang() {
  6606. m.lang = nil
  6607. delete(m.clearedFields, batchmsg.FieldLang)
  6608. }
  6609. // Where appends a list predicates to the BatchMsgMutation builder.
  6610. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6611. m.predicates = append(m.predicates, ps...)
  6612. }
  6613. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6614. // users can use type-assertion to append predicates that do not depend on any generated package.
  6615. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6616. p := make([]predicate.BatchMsg, len(ps))
  6617. for i := range ps {
  6618. p[i] = ps[i]
  6619. }
  6620. m.Where(p...)
  6621. }
  6622. // Op returns the operation name.
  6623. func (m *BatchMsgMutation) Op() Op {
  6624. return m.op
  6625. }
  6626. // SetOp allows setting the mutation operation.
  6627. func (m *BatchMsgMutation) SetOp(op Op) {
  6628. m.op = op
  6629. }
  6630. // Type returns the node type of this mutation (BatchMsg).
  6631. func (m *BatchMsgMutation) Type() string {
  6632. return m.typ
  6633. }
  6634. // Fields returns all fields that were changed during this mutation. Note that in
  6635. // order to get all numeric fields that were incremented/decremented, call
  6636. // AddedFields().
  6637. func (m *BatchMsgMutation) Fields() []string {
  6638. fields := make([]string, 0, 24)
  6639. if m.created_at != nil {
  6640. fields = append(fields, batchmsg.FieldCreatedAt)
  6641. }
  6642. if m.updated_at != nil {
  6643. fields = append(fields, batchmsg.FieldUpdatedAt)
  6644. }
  6645. if m.deleted_at != nil {
  6646. fields = append(fields, batchmsg.FieldDeletedAt)
  6647. }
  6648. if m.status != nil {
  6649. fields = append(fields, batchmsg.FieldStatus)
  6650. }
  6651. if m.batch_no != nil {
  6652. fields = append(fields, batchmsg.FieldBatchNo)
  6653. }
  6654. if m.task_name != nil {
  6655. fields = append(fields, batchmsg.FieldTaskName)
  6656. }
  6657. if m.fromwxid != nil {
  6658. fields = append(fields, batchmsg.FieldFromwxid)
  6659. }
  6660. if m.msg != nil {
  6661. fields = append(fields, batchmsg.FieldMsg)
  6662. }
  6663. if m.tag != nil {
  6664. fields = append(fields, batchmsg.FieldTag)
  6665. }
  6666. if m.tagids != nil {
  6667. fields = append(fields, batchmsg.FieldTagids)
  6668. }
  6669. if m.total != nil {
  6670. fields = append(fields, batchmsg.FieldTotal)
  6671. }
  6672. if m.success != nil {
  6673. fields = append(fields, batchmsg.FieldSuccess)
  6674. }
  6675. if m.fail != nil {
  6676. fields = append(fields, batchmsg.FieldFail)
  6677. }
  6678. if m.start_time != nil {
  6679. fields = append(fields, batchmsg.FieldStartTime)
  6680. }
  6681. if m.stop_time != nil {
  6682. fields = append(fields, batchmsg.FieldStopTime)
  6683. }
  6684. if m.send_time != nil {
  6685. fields = append(fields, batchmsg.FieldSendTime)
  6686. }
  6687. if m._type != nil {
  6688. fields = append(fields, batchmsg.FieldType)
  6689. }
  6690. if m.organization_id != nil {
  6691. fields = append(fields, batchmsg.FieldOrganizationID)
  6692. }
  6693. if m.ctype != nil {
  6694. fields = append(fields, batchmsg.FieldCtype)
  6695. }
  6696. if m.cc != nil {
  6697. fields = append(fields, batchmsg.FieldCc)
  6698. }
  6699. if m.phone != nil {
  6700. fields = append(fields, batchmsg.FieldPhone)
  6701. }
  6702. if m.template_name != nil {
  6703. fields = append(fields, batchmsg.FieldTemplateName)
  6704. }
  6705. if m.template_code != nil {
  6706. fields = append(fields, batchmsg.FieldTemplateCode)
  6707. }
  6708. if m.lang != nil {
  6709. fields = append(fields, batchmsg.FieldLang)
  6710. }
  6711. return fields
  6712. }
  6713. // Field returns the value of a field with the given name. The second boolean
  6714. // return value indicates that this field was not set, or was not defined in the
  6715. // schema.
  6716. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6717. switch name {
  6718. case batchmsg.FieldCreatedAt:
  6719. return m.CreatedAt()
  6720. case batchmsg.FieldUpdatedAt:
  6721. return m.UpdatedAt()
  6722. case batchmsg.FieldDeletedAt:
  6723. return m.DeletedAt()
  6724. case batchmsg.FieldStatus:
  6725. return m.Status()
  6726. case batchmsg.FieldBatchNo:
  6727. return m.BatchNo()
  6728. case batchmsg.FieldTaskName:
  6729. return m.TaskName()
  6730. case batchmsg.FieldFromwxid:
  6731. return m.Fromwxid()
  6732. case batchmsg.FieldMsg:
  6733. return m.Msg()
  6734. case batchmsg.FieldTag:
  6735. return m.Tag()
  6736. case batchmsg.FieldTagids:
  6737. return m.Tagids()
  6738. case batchmsg.FieldTotal:
  6739. return m.Total()
  6740. case batchmsg.FieldSuccess:
  6741. return m.Success()
  6742. case batchmsg.FieldFail:
  6743. return m.Fail()
  6744. case batchmsg.FieldStartTime:
  6745. return m.StartTime()
  6746. case batchmsg.FieldStopTime:
  6747. return m.StopTime()
  6748. case batchmsg.FieldSendTime:
  6749. return m.SendTime()
  6750. case batchmsg.FieldType:
  6751. return m.GetType()
  6752. case batchmsg.FieldOrganizationID:
  6753. return m.OrganizationID()
  6754. case batchmsg.FieldCtype:
  6755. return m.Ctype()
  6756. case batchmsg.FieldCc:
  6757. return m.Cc()
  6758. case batchmsg.FieldPhone:
  6759. return m.Phone()
  6760. case batchmsg.FieldTemplateName:
  6761. return m.TemplateName()
  6762. case batchmsg.FieldTemplateCode:
  6763. return m.TemplateCode()
  6764. case batchmsg.FieldLang:
  6765. return m.Lang()
  6766. }
  6767. return nil, false
  6768. }
  6769. // OldField returns the old value of the field from the database. An error is
  6770. // returned if the mutation operation is not UpdateOne, or the query to the
  6771. // database failed.
  6772. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6773. switch name {
  6774. case batchmsg.FieldCreatedAt:
  6775. return m.OldCreatedAt(ctx)
  6776. case batchmsg.FieldUpdatedAt:
  6777. return m.OldUpdatedAt(ctx)
  6778. case batchmsg.FieldDeletedAt:
  6779. return m.OldDeletedAt(ctx)
  6780. case batchmsg.FieldStatus:
  6781. return m.OldStatus(ctx)
  6782. case batchmsg.FieldBatchNo:
  6783. return m.OldBatchNo(ctx)
  6784. case batchmsg.FieldTaskName:
  6785. return m.OldTaskName(ctx)
  6786. case batchmsg.FieldFromwxid:
  6787. return m.OldFromwxid(ctx)
  6788. case batchmsg.FieldMsg:
  6789. return m.OldMsg(ctx)
  6790. case batchmsg.FieldTag:
  6791. return m.OldTag(ctx)
  6792. case batchmsg.FieldTagids:
  6793. return m.OldTagids(ctx)
  6794. case batchmsg.FieldTotal:
  6795. return m.OldTotal(ctx)
  6796. case batchmsg.FieldSuccess:
  6797. return m.OldSuccess(ctx)
  6798. case batchmsg.FieldFail:
  6799. return m.OldFail(ctx)
  6800. case batchmsg.FieldStartTime:
  6801. return m.OldStartTime(ctx)
  6802. case batchmsg.FieldStopTime:
  6803. return m.OldStopTime(ctx)
  6804. case batchmsg.FieldSendTime:
  6805. return m.OldSendTime(ctx)
  6806. case batchmsg.FieldType:
  6807. return m.OldType(ctx)
  6808. case batchmsg.FieldOrganizationID:
  6809. return m.OldOrganizationID(ctx)
  6810. case batchmsg.FieldCtype:
  6811. return m.OldCtype(ctx)
  6812. case batchmsg.FieldCc:
  6813. return m.OldCc(ctx)
  6814. case batchmsg.FieldPhone:
  6815. return m.OldPhone(ctx)
  6816. case batchmsg.FieldTemplateName:
  6817. return m.OldTemplateName(ctx)
  6818. case batchmsg.FieldTemplateCode:
  6819. return m.OldTemplateCode(ctx)
  6820. case batchmsg.FieldLang:
  6821. return m.OldLang(ctx)
  6822. }
  6823. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6824. }
  6825. // SetField sets the value of a field with the given name. It returns an error if
  6826. // the field is not defined in the schema, or if the type mismatched the field
  6827. // type.
  6828. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6829. switch name {
  6830. case batchmsg.FieldCreatedAt:
  6831. v, ok := value.(time.Time)
  6832. if !ok {
  6833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6834. }
  6835. m.SetCreatedAt(v)
  6836. return nil
  6837. case batchmsg.FieldUpdatedAt:
  6838. v, ok := value.(time.Time)
  6839. if !ok {
  6840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6841. }
  6842. m.SetUpdatedAt(v)
  6843. return nil
  6844. case batchmsg.FieldDeletedAt:
  6845. v, ok := value.(time.Time)
  6846. if !ok {
  6847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6848. }
  6849. m.SetDeletedAt(v)
  6850. return nil
  6851. case batchmsg.FieldStatus:
  6852. v, ok := value.(uint8)
  6853. if !ok {
  6854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6855. }
  6856. m.SetStatus(v)
  6857. return nil
  6858. case batchmsg.FieldBatchNo:
  6859. v, ok := value.(string)
  6860. if !ok {
  6861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6862. }
  6863. m.SetBatchNo(v)
  6864. return nil
  6865. case batchmsg.FieldTaskName:
  6866. v, ok := value.(string)
  6867. if !ok {
  6868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6869. }
  6870. m.SetTaskName(v)
  6871. return nil
  6872. case batchmsg.FieldFromwxid:
  6873. v, ok := value.(string)
  6874. if !ok {
  6875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6876. }
  6877. m.SetFromwxid(v)
  6878. return nil
  6879. case batchmsg.FieldMsg:
  6880. v, ok := value.(string)
  6881. if !ok {
  6882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6883. }
  6884. m.SetMsg(v)
  6885. return nil
  6886. case batchmsg.FieldTag:
  6887. v, ok := value.(string)
  6888. if !ok {
  6889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6890. }
  6891. m.SetTag(v)
  6892. return nil
  6893. case batchmsg.FieldTagids:
  6894. v, ok := value.(string)
  6895. if !ok {
  6896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6897. }
  6898. m.SetTagids(v)
  6899. return nil
  6900. case batchmsg.FieldTotal:
  6901. v, ok := value.(int32)
  6902. if !ok {
  6903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6904. }
  6905. m.SetTotal(v)
  6906. return nil
  6907. case batchmsg.FieldSuccess:
  6908. v, ok := value.(int32)
  6909. if !ok {
  6910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6911. }
  6912. m.SetSuccess(v)
  6913. return nil
  6914. case batchmsg.FieldFail:
  6915. v, ok := value.(int32)
  6916. if !ok {
  6917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6918. }
  6919. m.SetFail(v)
  6920. return nil
  6921. case batchmsg.FieldStartTime:
  6922. v, ok := value.(time.Time)
  6923. if !ok {
  6924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6925. }
  6926. m.SetStartTime(v)
  6927. return nil
  6928. case batchmsg.FieldStopTime:
  6929. v, ok := value.(time.Time)
  6930. if !ok {
  6931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6932. }
  6933. m.SetStopTime(v)
  6934. return nil
  6935. case batchmsg.FieldSendTime:
  6936. v, ok := value.(time.Time)
  6937. if !ok {
  6938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6939. }
  6940. m.SetSendTime(v)
  6941. return nil
  6942. case batchmsg.FieldType:
  6943. v, ok := value.(int32)
  6944. if !ok {
  6945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6946. }
  6947. m.SetType(v)
  6948. return nil
  6949. case batchmsg.FieldOrganizationID:
  6950. v, ok := value.(uint64)
  6951. if !ok {
  6952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6953. }
  6954. m.SetOrganizationID(v)
  6955. return nil
  6956. case batchmsg.FieldCtype:
  6957. v, ok := value.(uint64)
  6958. if !ok {
  6959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6960. }
  6961. m.SetCtype(v)
  6962. return nil
  6963. case batchmsg.FieldCc:
  6964. v, ok := value.(string)
  6965. if !ok {
  6966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6967. }
  6968. m.SetCc(v)
  6969. return nil
  6970. case batchmsg.FieldPhone:
  6971. v, ok := value.(string)
  6972. if !ok {
  6973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6974. }
  6975. m.SetPhone(v)
  6976. return nil
  6977. case batchmsg.FieldTemplateName:
  6978. v, ok := value.(string)
  6979. if !ok {
  6980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6981. }
  6982. m.SetTemplateName(v)
  6983. return nil
  6984. case batchmsg.FieldTemplateCode:
  6985. v, ok := value.(string)
  6986. if !ok {
  6987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6988. }
  6989. m.SetTemplateCode(v)
  6990. return nil
  6991. case batchmsg.FieldLang:
  6992. v, ok := value.(string)
  6993. if !ok {
  6994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6995. }
  6996. m.SetLang(v)
  6997. return nil
  6998. }
  6999. return fmt.Errorf("unknown BatchMsg field %s", name)
  7000. }
  7001. // AddedFields returns all numeric fields that were incremented/decremented during
  7002. // this mutation.
  7003. func (m *BatchMsgMutation) AddedFields() []string {
  7004. var fields []string
  7005. if m.addstatus != nil {
  7006. fields = append(fields, batchmsg.FieldStatus)
  7007. }
  7008. if m.addtotal != nil {
  7009. fields = append(fields, batchmsg.FieldTotal)
  7010. }
  7011. if m.addsuccess != nil {
  7012. fields = append(fields, batchmsg.FieldSuccess)
  7013. }
  7014. if m.addfail != nil {
  7015. fields = append(fields, batchmsg.FieldFail)
  7016. }
  7017. if m.add_type != nil {
  7018. fields = append(fields, batchmsg.FieldType)
  7019. }
  7020. if m.addorganization_id != nil {
  7021. fields = append(fields, batchmsg.FieldOrganizationID)
  7022. }
  7023. if m.addctype != nil {
  7024. fields = append(fields, batchmsg.FieldCtype)
  7025. }
  7026. return fields
  7027. }
  7028. // AddedField returns the numeric value that was incremented/decremented on a field
  7029. // with the given name. The second boolean return value indicates that this field
  7030. // was not set, or was not defined in the schema.
  7031. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  7032. switch name {
  7033. case batchmsg.FieldStatus:
  7034. return m.AddedStatus()
  7035. case batchmsg.FieldTotal:
  7036. return m.AddedTotal()
  7037. case batchmsg.FieldSuccess:
  7038. return m.AddedSuccess()
  7039. case batchmsg.FieldFail:
  7040. return m.AddedFail()
  7041. case batchmsg.FieldType:
  7042. return m.AddedType()
  7043. case batchmsg.FieldOrganizationID:
  7044. return m.AddedOrganizationID()
  7045. case batchmsg.FieldCtype:
  7046. return m.AddedCtype()
  7047. }
  7048. return nil, false
  7049. }
  7050. // AddField adds the value to the field with the given name. It returns an error if
  7051. // the field is not defined in the schema, or if the type mismatched the field
  7052. // type.
  7053. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  7054. switch name {
  7055. case batchmsg.FieldStatus:
  7056. v, ok := value.(int8)
  7057. if !ok {
  7058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7059. }
  7060. m.AddStatus(v)
  7061. return nil
  7062. case batchmsg.FieldTotal:
  7063. v, ok := value.(int32)
  7064. if !ok {
  7065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7066. }
  7067. m.AddTotal(v)
  7068. return nil
  7069. case batchmsg.FieldSuccess:
  7070. v, ok := value.(int32)
  7071. if !ok {
  7072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7073. }
  7074. m.AddSuccess(v)
  7075. return nil
  7076. case batchmsg.FieldFail:
  7077. v, ok := value.(int32)
  7078. if !ok {
  7079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7080. }
  7081. m.AddFail(v)
  7082. return nil
  7083. case batchmsg.FieldType:
  7084. v, ok := value.(int32)
  7085. if !ok {
  7086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7087. }
  7088. m.AddType(v)
  7089. return nil
  7090. case batchmsg.FieldOrganizationID:
  7091. v, ok := value.(int64)
  7092. if !ok {
  7093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7094. }
  7095. m.AddOrganizationID(v)
  7096. return nil
  7097. case batchmsg.FieldCtype:
  7098. v, ok := value.(int64)
  7099. if !ok {
  7100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7101. }
  7102. m.AddCtype(v)
  7103. return nil
  7104. }
  7105. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  7106. }
  7107. // ClearedFields returns all nullable fields that were cleared during this
  7108. // mutation.
  7109. func (m *BatchMsgMutation) ClearedFields() []string {
  7110. var fields []string
  7111. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  7112. fields = append(fields, batchmsg.FieldDeletedAt)
  7113. }
  7114. if m.FieldCleared(batchmsg.FieldStatus) {
  7115. fields = append(fields, batchmsg.FieldStatus)
  7116. }
  7117. if m.FieldCleared(batchmsg.FieldBatchNo) {
  7118. fields = append(fields, batchmsg.FieldBatchNo)
  7119. }
  7120. if m.FieldCleared(batchmsg.FieldTaskName) {
  7121. fields = append(fields, batchmsg.FieldTaskName)
  7122. }
  7123. if m.FieldCleared(batchmsg.FieldFromwxid) {
  7124. fields = append(fields, batchmsg.FieldFromwxid)
  7125. }
  7126. if m.FieldCleared(batchmsg.FieldMsg) {
  7127. fields = append(fields, batchmsg.FieldMsg)
  7128. }
  7129. if m.FieldCleared(batchmsg.FieldTag) {
  7130. fields = append(fields, batchmsg.FieldTag)
  7131. }
  7132. if m.FieldCleared(batchmsg.FieldTagids) {
  7133. fields = append(fields, batchmsg.FieldTagids)
  7134. }
  7135. if m.FieldCleared(batchmsg.FieldTotal) {
  7136. fields = append(fields, batchmsg.FieldTotal)
  7137. }
  7138. if m.FieldCleared(batchmsg.FieldSuccess) {
  7139. fields = append(fields, batchmsg.FieldSuccess)
  7140. }
  7141. if m.FieldCleared(batchmsg.FieldFail) {
  7142. fields = append(fields, batchmsg.FieldFail)
  7143. }
  7144. if m.FieldCleared(batchmsg.FieldStartTime) {
  7145. fields = append(fields, batchmsg.FieldStartTime)
  7146. }
  7147. if m.FieldCleared(batchmsg.FieldStopTime) {
  7148. fields = append(fields, batchmsg.FieldStopTime)
  7149. }
  7150. if m.FieldCleared(batchmsg.FieldSendTime) {
  7151. fields = append(fields, batchmsg.FieldSendTime)
  7152. }
  7153. if m.FieldCleared(batchmsg.FieldType) {
  7154. fields = append(fields, batchmsg.FieldType)
  7155. }
  7156. if m.FieldCleared(batchmsg.FieldCc) {
  7157. fields = append(fields, batchmsg.FieldCc)
  7158. }
  7159. if m.FieldCleared(batchmsg.FieldPhone) {
  7160. fields = append(fields, batchmsg.FieldPhone)
  7161. }
  7162. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7163. fields = append(fields, batchmsg.FieldTemplateName)
  7164. }
  7165. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7166. fields = append(fields, batchmsg.FieldTemplateCode)
  7167. }
  7168. if m.FieldCleared(batchmsg.FieldLang) {
  7169. fields = append(fields, batchmsg.FieldLang)
  7170. }
  7171. return fields
  7172. }
  7173. // FieldCleared returns a boolean indicating if a field with the given name was
  7174. // cleared in this mutation.
  7175. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7176. _, ok := m.clearedFields[name]
  7177. return ok
  7178. }
  7179. // ClearField clears the value of the field with the given name. It returns an
  7180. // error if the field is not defined in the schema.
  7181. func (m *BatchMsgMutation) ClearField(name string) error {
  7182. switch name {
  7183. case batchmsg.FieldDeletedAt:
  7184. m.ClearDeletedAt()
  7185. return nil
  7186. case batchmsg.FieldStatus:
  7187. m.ClearStatus()
  7188. return nil
  7189. case batchmsg.FieldBatchNo:
  7190. m.ClearBatchNo()
  7191. return nil
  7192. case batchmsg.FieldTaskName:
  7193. m.ClearTaskName()
  7194. return nil
  7195. case batchmsg.FieldFromwxid:
  7196. m.ClearFromwxid()
  7197. return nil
  7198. case batchmsg.FieldMsg:
  7199. m.ClearMsg()
  7200. return nil
  7201. case batchmsg.FieldTag:
  7202. m.ClearTag()
  7203. return nil
  7204. case batchmsg.FieldTagids:
  7205. m.ClearTagids()
  7206. return nil
  7207. case batchmsg.FieldTotal:
  7208. m.ClearTotal()
  7209. return nil
  7210. case batchmsg.FieldSuccess:
  7211. m.ClearSuccess()
  7212. return nil
  7213. case batchmsg.FieldFail:
  7214. m.ClearFail()
  7215. return nil
  7216. case batchmsg.FieldStartTime:
  7217. m.ClearStartTime()
  7218. return nil
  7219. case batchmsg.FieldStopTime:
  7220. m.ClearStopTime()
  7221. return nil
  7222. case batchmsg.FieldSendTime:
  7223. m.ClearSendTime()
  7224. return nil
  7225. case batchmsg.FieldType:
  7226. m.ClearType()
  7227. return nil
  7228. case batchmsg.FieldCc:
  7229. m.ClearCc()
  7230. return nil
  7231. case batchmsg.FieldPhone:
  7232. m.ClearPhone()
  7233. return nil
  7234. case batchmsg.FieldTemplateName:
  7235. m.ClearTemplateName()
  7236. return nil
  7237. case batchmsg.FieldTemplateCode:
  7238. m.ClearTemplateCode()
  7239. return nil
  7240. case batchmsg.FieldLang:
  7241. m.ClearLang()
  7242. return nil
  7243. }
  7244. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7245. }
  7246. // ResetField resets all changes in the mutation for the field with the given name.
  7247. // It returns an error if the field is not defined in the schema.
  7248. func (m *BatchMsgMutation) ResetField(name string) error {
  7249. switch name {
  7250. case batchmsg.FieldCreatedAt:
  7251. m.ResetCreatedAt()
  7252. return nil
  7253. case batchmsg.FieldUpdatedAt:
  7254. m.ResetUpdatedAt()
  7255. return nil
  7256. case batchmsg.FieldDeletedAt:
  7257. m.ResetDeletedAt()
  7258. return nil
  7259. case batchmsg.FieldStatus:
  7260. m.ResetStatus()
  7261. return nil
  7262. case batchmsg.FieldBatchNo:
  7263. m.ResetBatchNo()
  7264. return nil
  7265. case batchmsg.FieldTaskName:
  7266. m.ResetTaskName()
  7267. return nil
  7268. case batchmsg.FieldFromwxid:
  7269. m.ResetFromwxid()
  7270. return nil
  7271. case batchmsg.FieldMsg:
  7272. m.ResetMsg()
  7273. return nil
  7274. case batchmsg.FieldTag:
  7275. m.ResetTag()
  7276. return nil
  7277. case batchmsg.FieldTagids:
  7278. m.ResetTagids()
  7279. return nil
  7280. case batchmsg.FieldTotal:
  7281. m.ResetTotal()
  7282. return nil
  7283. case batchmsg.FieldSuccess:
  7284. m.ResetSuccess()
  7285. return nil
  7286. case batchmsg.FieldFail:
  7287. m.ResetFail()
  7288. return nil
  7289. case batchmsg.FieldStartTime:
  7290. m.ResetStartTime()
  7291. return nil
  7292. case batchmsg.FieldStopTime:
  7293. m.ResetStopTime()
  7294. return nil
  7295. case batchmsg.FieldSendTime:
  7296. m.ResetSendTime()
  7297. return nil
  7298. case batchmsg.FieldType:
  7299. m.ResetType()
  7300. return nil
  7301. case batchmsg.FieldOrganizationID:
  7302. m.ResetOrganizationID()
  7303. return nil
  7304. case batchmsg.FieldCtype:
  7305. m.ResetCtype()
  7306. return nil
  7307. case batchmsg.FieldCc:
  7308. m.ResetCc()
  7309. return nil
  7310. case batchmsg.FieldPhone:
  7311. m.ResetPhone()
  7312. return nil
  7313. case batchmsg.FieldTemplateName:
  7314. m.ResetTemplateName()
  7315. return nil
  7316. case batchmsg.FieldTemplateCode:
  7317. m.ResetTemplateCode()
  7318. return nil
  7319. case batchmsg.FieldLang:
  7320. m.ResetLang()
  7321. return nil
  7322. }
  7323. return fmt.Errorf("unknown BatchMsg field %s", name)
  7324. }
  7325. // AddedEdges returns all edge names that were set/added in this mutation.
  7326. func (m *BatchMsgMutation) AddedEdges() []string {
  7327. edges := make([]string, 0, 0)
  7328. return edges
  7329. }
  7330. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7331. // name in this mutation.
  7332. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7333. return nil
  7334. }
  7335. // RemovedEdges returns all edge names that were removed in this mutation.
  7336. func (m *BatchMsgMutation) RemovedEdges() []string {
  7337. edges := make([]string, 0, 0)
  7338. return edges
  7339. }
  7340. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7341. // the given name in this mutation.
  7342. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7343. return nil
  7344. }
  7345. // ClearedEdges returns all edge names that were cleared in this mutation.
  7346. func (m *BatchMsgMutation) ClearedEdges() []string {
  7347. edges := make([]string, 0, 0)
  7348. return edges
  7349. }
  7350. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7351. // was cleared in this mutation.
  7352. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7353. return false
  7354. }
  7355. // ClearEdge clears the value of the edge with the given name. It returns an error
  7356. // if that edge is not defined in the schema.
  7357. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7358. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7359. }
  7360. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7361. // It returns an error if the edge is not defined in the schema.
  7362. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7363. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7364. }
  7365. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7366. type CategoryMutation struct {
  7367. config
  7368. op Op
  7369. typ string
  7370. id *uint64
  7371. created_at *time.Time
  7372. updated_at *time.Time
  7373. deleted_at *time.Time
  7374. name *string
  7375. organization_id *uint64
  7376. addorganization_id *int64
  7377. clearedFields map[string]struct{}
  7378. done bool
  7379. oldValue func(context.Context) (*Category, error)
  7380. predicates []predicate.Category
  7381. }
  7382. var _ ent.Mutation = (*CategoryMutation)(nil)
  7383. // categoryOption allows management of the mutation configuration using functional options.
  7384. type categoryOption func(*CategoryMutation)
  7385. // newCategoryMutation creates new mutation for the Category entity.
  7386. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7387. m := &CategoryMutation{
  7388. config: c,
  7389. op: op,
  7390. typ: TypeCategory,
  7391. clearedFields: make(map[string]struct{}),
  7392. }
  7393. for _, opt := range opts {
  7394. opt(m)
  7395. }
  7396. return m
  7397. }
  7398. // withCategoryID sets the ID field of the mutation.
  7399. func withCategoryID(id uint64) categoryOption {
  7400. return func(m *CategoryMutation) {
  7401. var (
  7402. err error
  7403. once sync.Once
  7404. value *Category
  7405. )
  7406. m.oldValue = func(ctx context.Context) (*Category, error) {
  7407. once.Do(func() {
  7408. if m.done {
  7409. err = errors.New("querying old values post mutation is not allowed")
  7410. } else {
  7411. value, err = m.Client().Category.Get(ctx, id)
  7412. }
  7413. })
  7414. return value, err
  7415. }
  7416. m.id = &id
  7417. }
  7418. }
  7419. // withCategory sets the old Category of the mutation.
  7420. func withCategory(node *Category) categoryOption {
  7421. return func(m *CategoryMutation) {
  7422. m.oldValue = func(context.Context) (*Category, error) {
  7423. return node, nil
  7424. }
  7425. m.id = &node.ID
  7426. }
  7427. }
  7428. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7429. // executed in a transaction (ent.Tx), a transactional client is returned.
  7430. func (m CategoryMutation) Client() *Client {
  7431. client := &Client{config: m.config}
  7432. client.init()
  7433. return client
  7434. }
  7435. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7436. // it returns an error otherwise.
  7437. func (m CategoryMutation) Tx() (*Tx, error) {
  7438. if _, ok := m.driver.(*txDriver); !ok {
  7439. return nil, errors.New("ent: mutation is not running in a transaction")
  7440. }
  7441. tx := &Tx{config: m.config}
  7442. tx.init()
  7443. return tx, nil
  7444. }
  7445. // SetID sets the value of the id field. Note that this
  7446. // operation is only accepted on creation of Category entities.
  7447. func (m *CategoryMutation) SetID(id uint64) {
  7448. m.id = &id
  7449. }
  7450. // ID returns the ID value in the mutation. Note that the ID is only available
  7451. // if it was provided to the builder or after it was returned from the database.
  7452. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7453. if m.id == nil {
  7454. return
  7455. }
  7456. return *m.id, true
  7457. }
  7458. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7459. // That means, if the mutation is applied within a transaction with an isolation level such
  7460. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7461. // or updated by the mutation.
  7462. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7463. switch {
  7464. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7465. id, exists := m.ID()
  7466. if exists {
  7467. return []uint64{id}, nil
  7468. }
  7469. fallthrough
  7470. case m.op.Is(OpUpdate | OpDelete):
  7471. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7472. default:
  7473. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7474. }
  7475. }
  7476. // SetCreatedAt sets the "created_at" field.
  7477. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7478. m.created_at = &t
  7479. }
  7480. // CreatedAt returns the value of the "created_at" field in the mutation.
  7481. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7482. v := m.created_at
  7483. if v == nil {
  7484. return
  7485. }
  7486. return *v, true
  7487. }
  7488. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7489. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7491. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7492. if !m.op.Is(OpUpdateOne) {
  7493. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7494. }
  7495. if m.id == nil || m.oldValue == nil {
  7496. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7497. }
  7498. oldValue, err := m.oldValue(ctx)
  7499. if err != nil {
  7500. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7501. }
  7502. return oldValue.CreatedAt, nil
  7503. }
  7504. // ResetCreatedAt resets all changes to the "created_at" field.
  7505. func (m *CategoryMutation) ResetCreatedAt() {
  7506. m.created_at = nil
  7507. }
  7508. // SetUpdatedAt sets the "updated_at" field.
  7509. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7510. m.updated_at = &t
  7511. }
  7512. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7513. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7514. v := m.updated_at
  7515. if v == nil {
  7516. return
  7517. }
  7518. return *v, true
  7519. }
  7520. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7521. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7523. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7524. if !m.op.Is(OpUpdateOne) {
  7525. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7526. }
  7527. if m.id == nil || m.oldValue == nil {
  7528. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7529. }
  7530. oldValue, err := m.oldValue(ctx)
  7531. if err != nil {
  7532. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7533. }
  7534. return oldValue.UpdatedAt, nil
  7535. }
  7536. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7537. func (m *CategoryMutation) ResetUpdatedAt() {
  7538. m.updated_at = nil
  7539. }
  7540. // SetDeletedAt sets the "deleted_at" field.
  7541. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7542. m.deleted_at = &t
  7543. }
  7544. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7545. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7546. v := m.deleted_at
  7547. if v == nil {
  7548. return
  7549. }
  7550. return *v, true
  7551. }
  7552. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7553. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7555. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7556. if !m.op.Is(OpUpdateOne) {
  7557. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7558. }
  7559. if m.id == nil || m.oldValue == nil {
  7560. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7561. }
  7562. oldValue, err := m.oldValue(ctx)
  7563. if err != nil {
  7564. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7565. }
  7566. return oldValue.DeletedAt, nil
  7567. }
  7568. // ClearDeletedAt clears the value of the "deleted_at" field.
  7569. func (m *CategoryMutation) ClearDeletedAt() {
  7570. m.deleted_at = nil
  7571. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7572. }
  7573. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7574. func (m *CategoryMutation) DeletedAtCleared() bool {
  7575. _, ok := m.clearedFields[category.FieldDeletedAt]
  7576. return ok
  7577. }
  7578. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7579. func (m *CategoryMutation) ResetDeletedAt() {
  7580. m.deleted_at = nil
  7581. delete(m.clearedFields, category.FieldDeletedAt)
  7582. }
  7583. // SetName sets the "name" field.
  7584. func (m *CategoryMutation) SetName(s string) {
  7585. m.name = &s
  7586. }
  7587. // Name returns the value of the "name" field in the mutation.
  7588. func (m *CategoryMutation) Name() (r string, exists bool) {
  7589. v := m.name
  7590. if v == nil {
  7591. return
  7592. }
  7593. return *v, true
  7594. }
  7595. // OldName returns the old "name" field's value of the Category entity.
  7596. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7598. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7599. if !m.op.Is(OpUpdateOne) {
  7600. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7601. }
  7602. if m.id == nil || m.oldValue == nil {
  7603. return v, errors.New("OldName requires an ID field in the mutation")
  7604. }
  7605. oldValue, err := m.oldValue(ctx)
  7606. if err != nil {
  7607. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7608. }
  7609. return oldValue.Name, nil
  7610. }
  7611. // ResetName resets all changes to the "name" field.
  7612. func (m *CategoryMutation) ResetName() {
  7613. m.name = nil
  7614. }
  7615. // SetOrganizationID sets the "organization_id" field.
  7616. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7617. m.organization_id = &u
  7618. m.addorganization_id = nil
  7619. }
  7620. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7621. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7622. v := m.organization_id
  7623. if v == nil {
  7624. return
  7625. }
  7626. return *v, true
  7627. }
  7628. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7629. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7631. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7632. if !m.op.Is(OpUpdateOne) {
  7633. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7634. }
  7635. if m.id == nil || m.oldValue == nil {
  7636. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7637. }
  7638. oldValue, err := m.oldValue(ctx)
  7639. if err != nil {
  7640. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7641. }
  7642. return oldValue.OrganizationID, nil
  7643. }
  7644. // AddOrganizationID adds u to the "organization_id" field.
  7645. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7646. if m.addorganization_id != nil {
  7647. *m.addorganization_id += u
  7648. } else {
  7649. m.addorganization_id = &u
  7650. }
  7651. }
  7652. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7653. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7654. v := m.addorganization_id
  7655. if v == nil {
  7656. return
  7657. }
  7658. return *v, true
  7659. }
  7660. // ResetOrganizationID resets all changes to the "organization_id" field.
  7661. func (m *CategoryMutation) ResetOrganizationID() {
  7662. m.organization_id = nil
  7663. m.addorganization_id = nil
  7664. }
  7665. // Where appends a list predicates to the CategoryMutation builder.
  7666. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7667. m.predicates = append(m.predicates, ps...)
  7668. }
  7669. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7670. // users can use type-assertion to append predicates that do not depend on any generated package.
  7671. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7672. p := make([]predicate.Category, len(ps))
  7673. for i := range ps {
  7674. p[i] = ps[i]
  7675. }
  7676. m.Where(p...)
  7677. }
  7678. // Op returns the operation name.
  7679. func (m *CategoryMutation) Op() Op {
  7680. return m.op
  7681. }
  7682. // SetOp allows setting the mutation operation.
  7683. func (m *CategoryMutation) SetOp(op Op) {
  7684. m.op = op
  7685. }
  7686. // Type returns the node type of this mutation (Category).
  7687. func (m *CategoryMutation) Type() string {
  7688. return m.typ
  7689. }
  7690. // Fields returns all fields that were changed during this mutation. Note that in
  7691. // order to get all numeric fields that were incremented/decremented, call
  7692. // AddedFields().
  7693. func (m *CategoryMutation) Fields() []string {
  7694. fields := make([]string, 0, 5)
  7695. if m.created_at != nil {
  7696. fields = append(fields, category.FieldCreatedAt)
  7697. }
  7698. if m.updated_at != nil {
  7699. fields = append(fields, category.FieldUpdatedAt)
  7700. }
  7701. if m.deleted_at != nil {
  7702. fields = append(fields, category.FieldDeletedAt)
  7703. }
  7704. if m.name != nil {
  7705. fields = append(fields, category.FieldName)
  7706. }
  7707. if m.organization_id != nil {
  7708. fields = append(fields, category.FieldOrganizationID)
  7709. }
  7710. return fields
  7711. }
  7712. // Field returns the value of a field with the given name. The second boolean
  7713. // return value indicates that this field was not set, or was not defined in the
  7714. // schema.
  7715. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7716. switch name {
  7717. case category.FieldCreatedAt:
  7718. return m.CreatedAt()
  7719. case category.FieldUpdatedAt:
  7720. return m.UpdatedAt()
  7721. case category.FieldDeletedAt:
  7722. return m.DeletedAt()
  7723. case category.FieldName:
  7724. return m.Name()
  7725. case category.FieldOrganizationID:
  7726. return m.OrganizationID()
  7727. }
  7728. return nil, false
  7729. }
  7730. // OldField returns the old value of the field from the database. An error is
  7731. // returned if the mutation operation is not UpdateOne, or the query to the
  7732. // database failed.
  7733. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7734. switch name {
  7735. case category.FieldCreatedAt:
  7736. return m.OldCreatedAt(ctx)
  7737. case category.FieldUpdatedAt:
  7738. return m.OldUpdatedAt(ctx)
  7739. case category.FieldDeletedAt:
  7740. return m.OldDeletedAt(ctx)
  7741. case category.FieldName:
  7742. return m.OldName(ctx)
  7743. case category.FieldOrganizationID:
  7744. return m.OldOrganizationID(ctx)
  7745. }
  7746. return nil, fmt.Errorf("unknown Category field %s", name)
  7747. }
  7748. // SetField sets the value of a field with the given name. It returns an error if
  7749. // the field is not defined in the schema, or if the type mismatched the field
  7750. // type.
  7751. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7752. switch name {
  7753. case category.FieldCreatedAt:
  7754. v, ok := value.(time.Time)
  7755. if !ok {
  7756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7757. }
  7758. m.SetCreatedAt(v)
  7759. return nil
  7760. case category.FieldUpdatedAt:
  7761. v, ok := value.(time.Time)
  7762. if !ok {
  7763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7764. }
  7765. m.SetUpdatedAt(v)
  7766. return nil
  7767. case category.FieldDeletedAt:
  7768. v, ok := value.(time.Time)
  7769. if !ok {
  7770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7771. }
  7772. m.SetDeletedAt(v)
  7773. return nil
  7774. case category.FieldName:
  7775. v, ok := value.(string)
  7776. if !ok {
  7777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7778. }
  7779. m.SetName(v)
  7780. return nil
  7781. case category.FieldOrganizationID:
  7782. v, ok := value.(uint64)
  7783. if !ok {
  7784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7785. }
  7786. m.SetOrganizationID(v)
  7787. return nil
  7788. }
  7789. return fmt.Errorf("unknown Category field %s", name)
  7790. }
  7791. // AddedFields returns all numeric fields that were incremented/decremented during
  7792. // this mutation.
  7793. func (m *CategoryMutation) AddedFields() []string {
  7794. var fields []string
  7795. if m.addorganization_id != nil {
  7796. fields = append(fields, category.FieldOrganizationID)
  7797. }
  7798. return fields
  7799. }
  7800. // AddedField returns the numeric value that was incremented/decremented on a field
  7801. // with the given name. The second boolean return value indicates that this field
  7802. // was not set, or was not defined in the schema.
  7803. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7804. switch name {
  7805. case category.FieldOrganizationID:
  7806. return m.AddedOrganizationID()
  7807. }
  7808. return nil, false
  7809. }
  7810. // AddField adds the value to the field with the given name. It returns an error if
  7811. // the field is not defined in the schema, or if the type mismatched the field
  7812. // type.
  7813. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7814. switch name {
  7815. case category.FieldOrganizationID:
  7816. v, ok := value.(int64)
  7817. if !ok {
  7818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7819. }
  7820. m.AddOrganizationID(v)
  7821. return nil
  7822. }
  7823. return fmt.Errorf("unknown Category numeric field %s", name)
  7824. }
  7825. // ClearedFields returns all nullable fields that were cleared during this
  7826. // mutation.
  7827. func (m *CategoryMutation) ClearedFields() []string {
  7828. var fields []string
  7829. if m.FieldCleared(category.FieldDeletedAt) {
  7830. fields = append(fields, category.FieldDeletedAt)
  7831. }
  7832. return fields
  7833. }
  7834. // FieldCleared returns a boolean indicating if a field with the given name was
  7835. // cleared in this mutation.
  7836. func (m *CategoryMutation) FieldCleared(name string) bool {
  7837. _, ok := m.clearedFields[name]
  7838. return ok
  7839. }
  7840. // ClearField clears the value of the field with the given name. It returns an
  7841. // error if the field is not defined in the schema.
  7842. func (m *CategoryMutation) ClearField(name string) error {
  7843. switch name {
  7844. case category.FieldDeletedAt:
  7845. m.ClearDeletedAt()
  7846. return nil
  7847. }
  7848. return fmt.Errorf("unknown Category nullable field %s", name)
  7849. }
  7850. // ResetField resets all changes in the mutation for the field with the given name.
  7851. // It returns an error if the field is not defined in the schema.
  7852. func (m *CategoryMutation) ResetField(name string) error {
  7853. switch name {
  7854. case category.FieldCreatedAt:
  7855. m.ResetCreatedAt()
  7856. return nil
  7857. case category.FieldUpdatedAt:
  7858. m.ResetUpdatedAt()
  7859. return nil
  7860. case category.FieldDeletedAt:
  7861. m.ResetDeletedAt()
  7862. return nil
  7863. case category.FieldName:
  7864. m.ResetName()
  7865. return nil
  7866. case category.FieldOrganizationID:
  7867. m.ResetOrganizationID()
  7868. return nil
  7869. }
  7870. return fmt.Errorf("unknown Category field %s", name)
  7871. }
  7872. // AddedEdges returns all edge names that were set/added in this mutation.
  7873. func (m *CategoryMutation) AddedEdges() []string {
  7874. edges := make([]string, 0, 0)
  7875. return edges
  7876. }
  7877. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7878. // name in this mutation.
  7879. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7880. return nil
  7881. }
  7882. // RemovedEdges returns all edge names that were removed in this mutation.
  7883. func (m *CategoryMutation) RemovedEdges() []string {
  7884. edges := make([]string, 0, 0)
  7885. return edges
  7886. }
  7887. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7888. // the given name in this mutation.
  7889. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7890. return nil
  7891. }
  7892. // ClearedEdges returns all edge names that were cleared in this mutation.
  7893. func (m *CategoryMutation) ClearedEdges() []string {
  7894. edges := make([]string, 0, 0)
  7895. return edges
  7896. }
  7897. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7898. // was cleared in this mutation.
  7899. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7900. return false
  7901. }
  7902. // ClearEdge clears the value of the edge with the given name. It returns an error
  7903. // if that edge is not defined in the schema.
  7904. func (m *CategoryMutation) ClearEdge(name string) error {
  7905. return fmt.Errorf("unknown Category unique edge %s", name)
  7906. }
  7907. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7908. // It returns an error if the edge is not defined in the schema.
  7909. func (m *CategoryMutation) ResetEdge(name string) error {
  7910. return fmt.Errorf("unknown Category edge %s", name)
  7911. }
  7912. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7913. type ChatRecordsMutation struct {
  7914. config
  7915. op Op
  7916. typ string
  7917. id *uint64
  7918. created_at *time.Time
  7919. updated_at *time.Time
  7920. deleted_at *time.Time
  7921. content *string
  7922. content_type *uint8
  7923. addcontent_type *int8
  7924. session_id *uint64
  7925. addsession_id *int64
  7926. user_id *uint64
  7927. adduser_id *int64
  7928. bot_id *uint64
  7929. addbot_id *int64
  7930. bot_type *uint8
  7931. addbot_type *int8
  7932. clearedFields map[string]struct{}
  7933. done bool
  7934. oldValue func(context.Context) (*ChatRecords, error)
  7935. predicates []predicate.ChatRecords
  7936. }
  7937. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7938. // chatrecordsOption allows management of the mutation configuration using functional options.
  7939. type chatrecordsOption func(*ChatRecordsMutation)
  7940. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7941. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7942. m := &ChatRecordsMutation{
  7943. config: c,
  7944. op: op,
  7945. typ: TypeChatRecords,
  7946. clearedFields: make(map[string]struct{}),
  7947. }
  7948. for _, opt := range opts {
  7949. opt(m)
  7950. }
  7951. return m
  7952. }
  7953. // withChatRecordsID sets the ID field of the mutation.
  7954. func withChatRecordsID(id uint64) chatrecordsOption {
  7955. return func(m *ChatRecordsMutation) {
  7956. var (
  7957. err error
  7958. once sync.Once
  7959. value *ChatRecords
  7960. )
  7961. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7962. once.Do(func() {
  7963. if m.done {
  7964. err = errors.New("querying old values post mutation is not allowed")
  7965. } else {
  7966. value, err = m.Client().ChatRecords.Get(ctx, id)
  7967. }
  7968. })
  7969. return value, err
  7970. }
  7971. m.id = &id
  7972. }
  7973. }
  7974. // withChatRecords sets the old ChatRecords of the mutation.
  7975. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7976. return func(m *ChatRecordsMutation) {
  7977. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7978. return node, nil
  7979. }
  7980. m.id = &node.ID
  7981. }
  7982. }
  7983. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7984. // executed in a transaction (ent.Tx), a transactional client is returned.
  7985. func (m ChatRecordsMutation) Client() *Client {
  7986. client := &Client{config: m.config}
  7987. client.init()
  7988. return client
  7989. }
  7990. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7991. // it returns an error otherwise.
  7992. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7993. if _, ok := m.driver.(*txDriver); !ok {
  7994. return nil, errors.New("ent: mutation is not running in a transaction")
  7995. }
  7996. tx := &Tx{config: m.config}
  7997. tx.init()
  7998. return tx, nil
  7999. }
  8000. // SetID sets the value of the id field. Note that this
  8001. // operation is only accepted on creation of ChatRecords entities.
  8002. func (m *ChatRecordsMutation) SetID(id uint64) {
  8003. m.id = &id
  8004. }
  8005. // ID returns the ID value in the mutation. Note that the ID is only available
  8006. // if it was provided to the builder or after it was returned from the database.
  8007. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  8008. if m.id == nil {
  8009. return
  8010. }
  8011. return *m.id, true
  8012. }
  8013. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8014. // That means, if the mutation is applied within a transaction with an isolation level such
  8015. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8016. // or updated by the mutation.
  8017. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8018. switch {
  8019. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8020. id, exists := m.ID()
  8021. if exists {
  8022. return []uint64{id}, nil
  8023. }
  8024. fallthrough
  8025. case m.op.Is(OpUpdate | OpDelete):
  8026. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  8027. default:
  8028. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8029. }
  8030. }
  8031. // SetCreatedAt sets the "created_at" field.
  8032. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  8033. m.created_at = &t
  8034. }
  8035. // CreatedAt returns the value of the "created_at" field in the mutation.
  8036. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8037. v := m.created_at
  8038. if v == nil {
  8039. return
  8040. }
  8041. return *v, true
  8042. }
  8043. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  8044. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8046. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8047. if !m.op.Is(OpUpdateOne) {
  8048. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8049. }
  8050. if m.id == nil || m.oldValue == nil {
  8051. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8052. }
  8053. oldValue, err := m.oldValue(ctx)
  8054. if err != nil {
  8055. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8056. }
  8057. return oldValue.CreatedAt, nil
  8058. }
  8059. // ResetCreatedAt resets all changes to the "created_at" field.
  8060. func (m *ChatRecordsMutation) ResetCreatedAt() {
  8061. m.created_at = nil
  8062. }
  8063. // SetUpdatedAt sets the "updated_at" field.
  8064. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  8065. m.updated_at = &t
  8066. }
  8067. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8068. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8069. v := m.updated_at
  8070. if v == nil {
  8071. return
  8072. }
  8073. return *v, true
  8074. }
  8075. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  8076. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8078. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8079. if !m.op.Is(OpUpdateOne) {
  8080. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8081. }
  8082. if m.id == nil || m.oldValue == nil {
  8083. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8084. }
  8085. oldValue, err := m.oldValue(ctx)
  8086. if err != nil {
  8087. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8088. }
  8089. return oldValue.UpdatedAt, nil
  8090. }
  8091. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8092. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  8093. m.updated_at = nil
  8094. }
  8095. // SetDeletedAt sets the "deleted_at" field.
  8096. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  8097. m.deleted_at = &t
  8098. }
  8099. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8100. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8101. v := m.deleted_at
  8102. if v == nil {
  8103. return
  8104. }
  8105. return *v, true
  8106. }
  8107. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  8108. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8110. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8111. if !m.op.Is(OpUpdateOne) {
  8112. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8113. }
  8114. if m.id == nil || m.oldValue == nil {
  8115. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8116. }
  8117. oldValue, err := m.oldValue(ctx)
  8118. if err != nil {
  8119. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8120. }
  8121. return oldValue.DeletedAt, nil
  8122. }
  8123. // ClearDeletedAt clears the value of the "deleted_at" field.
  8124. func (m *ChatRecordsMutation) ClearDeletedAt() {
  8125. m.deleted_at = nil
  8126. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  8127. }
  8128. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8129. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  8130. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  8131. return ok
  8132. }
  8133. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8134. func (m *ChatRecordsMutation) ResetDeletedAt() {
  8135. m.deleted_at = nil
  8136. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  8137. }
  8138. // SetContent sets the "content" field.
  8139. func (m *ChatRecordsMutation) SetContent(s string) {
  8140. m.content = &s
  8141. }
  8142. // Content returns the value of the "content" field in the mutation.
  8143. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  8144. v := m.content
  8145. if v == nil {
  8146. return
  8147. }
  8148. return *v, true
  8149. }
  8150. // OldContent returns the old "content" field's value of the ChatRecords entity.
  8151. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8153. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8154. if !m.op.Is(OpUpdateOne) {
  8155. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8156. }
  8157. if m.id == nil || m.oldValue == nil {
  8158. return v, errors.New("OldContent requires an ID field in the mutation")
  8159. }
  8160. oldValue, err := m.oldValue(ctx)
  8161. if err != nil {
  8162. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8163. }
  8164. return oldValue.Content, nil
  8165. }
  8166. // ResetContent resets all changes to the "content" field.
  8167. func (m *ChatRecordsMutation) ResetContent() {
  8168. m.content = nil
  8169. }
  8170. // SetContentType sets the "content_type" field.
  8171. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8172. m.content_type = &u
  8173. m.addcontent_type = nil
  8174. }
  8175. // ContentType returns the value of the "content_type" field in the mutation.
  8176. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8177. v := m.content_type
  8178. if v == nil {
  8179. return
  8180. }
  8181. return *v, true
  8182. }
  8183. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8184. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8186. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8187. if !m.op.Is(OpUpdateOne) {
  8188. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8189. }
  8190. if m.id == nil || m.oldValue == nil {
  8191. return v, errors.New("OldContentType requires an ID field in the mutation")
  8192. }
  8193. oldValue, err := m.oldValue(ctx)
  8194. if err != nil {
  8195. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8196. }
  8197. return oldValue.ContentType, nil
  8198. }
  8199. // AddContentType adds u to the "content_type" field.
  8200. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8201. if m.addcontent_type != nil {
  8202. *m.addcontent_type += u
  8203. } else {
  8204. m.addcontent_type = &u
  8205. }
  8206. }
  8207. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8208. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8209. v := m.addcontent_type
  8210. if v == nil {
  8211. return
  8212. }
  8213. return *v, true
  8214. }
  8215. // ResetContentType resets all changes to the "content_type" field.
  8216. func (m *ChatRecordsMutation) ResetContentType() {
  8217. m.content_type = nil
  8218. m.addcontent_type = nil
  8219. }
  8220. // SetSessionID sets the "session_id" field.
  8221. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8222. m.session_id = &u
  8223. m.addsession_id = nil
  8224. }
  8225. // SessionID returns the value of the "session_id" field in the mutation.
  8226. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8227. v := m.session_id
  8228. if v == nil {
  8229. return
  8230. }
  8231. return *v, true
  8232. }
  8233. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8234. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8236. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8237. if !m.op.Is(OpUpdateOne) {
  8238. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8239. }
  8240. if m.id == nil || m.oldValue == nil {
  8241. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8242. }
  8243. oldValue, err := m.oldValue(ctx)
  8244. if err != nil {
  8245. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8246. }
  8247. return oldValue.SessionID, nil
  8248. }
  8249. // AddSessionID adds u to the "session_id" field.
  8250. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8251. if m.addsession_id != nil {
  8252. *m.addsession_id += u
  8253. } else {
  8254. m.addsession_id = &u
  8255. }
  8256. }
  8257. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8258. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8259. v := m.addsession_id
  8260. if v == nil {
  8261. return
  8262. }
  8263. return *v, true
  8264. }
  8265. // ResetSessionID resets all changes to the "session_id" field.
  8266. func (m *ChatRecordsMutation) ResetSessionID() {
  8267. m.session_id = nil
  8268. m.addsession_id = nil
  8269. }
  8270. // SetUserID sets the "user_id" field.
  8271. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8272. m.user_id = &u
  8273. m.adduser_id = nil
  8274. }
  8275. // UserID returns the value of the "user_id" field in the mutation.
  8276. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8277. v := m.user_id
  8278. if v == nil {
  8279. return
  8280. }
  8281. return *v, true
  8282. }
  8283. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8284. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8286. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8287. if !m.op.Is(OpUpdateOne) {
  8288. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8289. }
  8290. if m.id == nil || m.oldValue == nil {
  8291. return v, errors.New("OldUserID requires an ID field in the mutation")
  8292. }
  8293. oldValue, err := m.oldValue(ctx)
  8294. if err != nil {
  8295. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8296. }
  8297. return oldValue.UserID, nil
  8298. }
  8299. // AddUserID adds u to the "user_id" field.
  8300. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8301. if m.adduser_id != nil {
  8302. *m.adduser_id += u
  8303. } else {
  8304. m.adduser_id = &u
  8305. }
  8306. }
  8307. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8308. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8309. v := m.adduser_id
  8310. if v == nil {
  8311. return
  8312. }
  8313. return *v, true
  8314. }
  8315. // ResetUserID resets all changes to the "user_id" field.
  8316. func (m *ChatRecordsMutation) ResetUserID() {
  8317. m.user_id = nil
  8318. m.adduser_id = nil
  8319. }
  8320. // SetBotID sets the "bot_id" field.
  8321. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8322. m.bot_id = &u
  8323. m.addbot_id = nil
  8324. }
  8325. // BotID returns the value of the "bot_id" field in the mutation.
  8326. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8327. v := m.bot_id
  8328. if v == nil {
  8329. return
  8330. }
  8331. return *v, true
  8332. }
  8333. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8334. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8336. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8337. if !m.op.Is(OpUpdateOne) {
  8338. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8339. }
  8340. if m.id == nil || m.oldValue == nil {
  8341. return v, errors.New("OldBotID requires an ID field in the mutation")
  8342. }
  8343. oldValue, err := m.oldValue(ctx)
  8344. if err != nil {
  8345. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8346. }
  8347. return oldValue.BotID, nil
  8348. }
  8349. // AddBotID adds u to the "bot_id" field.
  8350. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8351. if m.addbot_id != nil {
  8352. *m.addbot_id += u
  8353. } else {
  8354. m.addbot_id = &u
  8355. }
  8356. }
  8357. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8358. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8359. v := m.addbot_id
  8360. if v == nil {
  8361. return
  8362. }
  8363. return *v, true
  8364. }
  8365. // ResetBotID resets all changes to the "bot_id" field.
  8366. func (m *ChatRecordsMutation) ResetBotID() {
  8367. m.bot_id = nil
  8368. m.addbot_id = nil
  8369. }
  8370. // SetBotType sets the "bot_type" field.
  8371. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8372. m.bot_type = &u
  8373. m.addbot_type = nil
  8374. }
  8375. // BotType returns the value of the "bot_type" field in the mutation.
  8376. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8377. v := m.bot_type
  8378. if v == nil {
  8379. return
  8380. }
  8381. return *v, true
  8382. }
  8383. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8384. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8386. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8387. if !m.op.Is(OpUpdateOne) {
  8388. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8389. }
  8390. if m.id == nil || m.oldValue == nil {
  8391. return v, errors.New("OldBotType requires an ID field in the mutation")
  8392. }
  8393. oldValue, err := m.oldValue(ctx)
  8394. if err != nil {
  8395. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8396. }
  8397. return oldValue.BotType, nil
  8398. }
  8399. // AddBotType adds u to the "bot_type" field.
  8400. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8401. if m.addbot_type != nil {
  8402. *m.addbot_type += u
  8403. } else {
  8404. m.addbot_type = &u
  8405. }
  8406. }
  8407. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8408. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8409. v := m.addbot_type
  8410. if v == nil {
  8411. return
  8412. }
  8413. return *v, true
  8414. }
  8415. // ResetBotType resets all changes to the "bot_type" field.
  8416. func (m *ChatRecordsMutation) ResetBotType() {
  8417. m.bot_type = nil
  8418. m.addbot_type = nil
  8419. }
  8420. // Where appends a list predicates to the ChatRecordsMutation builder.
  8421. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8422. m.predicates = append(m.predicates, ps...)
  8423. }
  8424. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8425. // users can use type-assertion to append predicates that do not depend on any generated package.
  8426. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8427. p := make([]predicate.ChatRecords, len(ps))
  8428. for i := range ps {
  8429. p[i] = ps[i]
  8430. }
  8431. m.Where(p...)
  8432. }
  8433. // Op returns the operation name.
  8434. func (m *ChatRecordsMutation) Op() Op {
  8435. return m.op
  8436. }
  8437. // SetOp allows setting the mutation operation.
  8438. func (m *ChatRecordsMutation) SetOp(op Op) {
  8439. m.op = op
  8440. }
  8441. // Type returns the node type of this mutation (ChatRecords).
  8442. func (m *ChatRecordsMutation) Type() string {
  8443. return m.typ
  8444. }
  8445. // Fields returns all fields that were changed during this mutation. Note that in
  8446. // order to get all numeric fields that were incremented/decremented, call
  8447. // AddedFields().
  8448. func (m *ChatRecordsMutation) Fields() []string {
  8449. fields := make([]string, 0, 9)
  8450. if m.created_at != nil {
  8451. fields = append(fields, chatrecords.FieldCreatedAt)
  8452. }
  8453. if m.updated_at != nil {
  8454. fields = append(fields, chatrecords.FieldUpdatedAt)
  8455. }
  8456. if m.deleted_at != nil {
  8457. fields = append(fields, chatrecords.FieldDeletedAt)
  8458. }
  8459. if m.content != nil {
  8460. fields = append(fields, chatrecords.FieldContent)
  8461. }
  8462. if m.content_type != nil {
  8463. fields = append(fields, chatrecords.FieldContentType)
  8464. }
  8465. if m.session_id != nil {
  8466. fields = append(fields, chatrecords.FieldSessionID)
  8467. }
  8468. if m.user_id != nil {
  8469. fields = append(fields, chatrecords.FieldUserID)
  8470. }
  8471. if m.bot_id != nil {
  8472. fields = append(fields, chatrecords.FieldBotID)
  8473. }
  8474. if m.bot_type != nil {
  8475. fields = append(fields, chatrecords.FieldBotType)
  8476. }
  8477. return fields
  8478. }
  8479. // Field returns the value of a field with the given name. The second boolean
  8480. // return value indicates that this field was not set, or was not defined in the
  8481. // schema.
  8482. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8483. switch name {
  8484. case chatrecords.FieldCreatedAt:
  8485. return m.CreatedAt()
  8486. case chatrecords.FieldUpdatedAt:
  8487. return m.UpdatedAt()
  8488. case chatrecords.FieldDeletedAt:
  8489. return m.DeletedAt()
  8490. case chatrecords.FieldContent:
  8491. return m.Content()
  8492. case chatrecords.FieldContentType:
  8493. return m.ContentType()
  8494. case chatrecords.FieldSessionID:
  8495. return m.SessionID()
  8496. case chatrecords.FieldUserID:
  8497. return m.UserID()
  8498. case chatrecords.FieldBotID:
  8499. return m.BotID()
  8500. case chatrecords.FieldBotType:
  8501. return m.BotType()
  8502. }
  8503. return nil, false
  8504. }
  8505. // OldField returns the old value of the field from the database. An error is
  8506. // returned if the mutation operation is not UpdateOne, or the query to the
  8507. // database failed.
  8508. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8509. switch name {
  8510. case chatrecords.FieldCreatedAt:
  8511. return m.OldCreatedAt(ctx)
  8512. case chatrecords.FieldUpdatedAt:
  8513. return m.OldUpdatedAt(ctx)
  8514. case chatrecords.FieldDeletedAt:
  8515. return m.OldDeletedAt(ctx)
  8516. case chatrecords.FieldContent:
  8517. return m.OldContent(ctx)
  8518. case chatrecords.FieldContentType:
  8519. return m.OldContentType(ctx)
  8520. case chatrecords.FieldSessionID:
  8521. return m.OldSessionID(ctx)
  8522. case chatrecords.FieldUserID:
  8523. return m.OldUserID(ctx)
  8524. case chatrecords.FieldBotID:
  8525. return m.OldBotID(ctx)
  8526. case chatrecords.FieldBotType:
  8527. return m.OldBotType(ctx)
  8528. }
  8529. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8530. }
  8531. // SetField sets the value of a field with the given name. It returns an error if
  8532. // the field is not defined in the schema, or if the type mismatched the field
  8533. // type.
  8534. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8535. switch name {
  8536. case chatrecords.FieldCreatedAt:
  8537. v, ok := value.(time.Time)
  8538. if !ok {
  8539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8540. }
  8541. m.SetCreatedAt(v)
  8542. return nil
  8543. case chatrecords.FieldUpdatedAt:
  8544. v, ok := value.(time.Time)
  8545. if !ok {
  8546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8547. }
  8548. m.SetUpdatedAt(v)
  8549. return nil
  8550. case chatrecords.FieldDeletedAt:
  8551. v, ok := value.(time.Time)
  8552. if !ok {
  8553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8554. }
  8555. m.SetDeletedAt(v)
  8556. return nil
  8557. case chatrecords.FieldContent:
  8558. v, ok := value.(string)
  8559. if !ok {
  8560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8561. }
  8562. m.SetContent(v)
  8563. return nil
  8564. case chatrecords.FieldContentType:
  8565. v, ok := value.(uint8)
  8566. if !ok {
  8567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8568. }
  8569. m.SetContentType(v)
  8570. return nil
  8571. case chatrecords.FieldSessionID:
  8572. v, ok := value.(uint64)
  8573. if !ok {
  8574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8575. }
  8576. m.SetSessionID(v)
  8577. return nil
  8578. case chatrecords.FieldUserID:
  8579. v, ok := value.(uint64)
  8580. if !ok {
  8581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8582. }
  8583. m.SetUserID(v)
  8584. return nil
  8585. case chatrecords.FieldBotID:
  8586. v, ok := value.(uint64)
  8587. if !ok {
  8588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8589. }
  8590. m.SetBotID(v)
  8591. return nil
  8592. case chatrecords.FieldBotType:
  8593. v, ok := value.(uint8)
  8594. if !ok {
  8595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8596. }
  8597. m.SetBotType(v)
  8598. return nil
  8599. }
  8600. return fmt.Errorf("unknown ChatRecords field %s", name)
  8601. }
  8602. // AddedFields returns all numeric fields that were incremented/decremented during
  8603. // this mutation.
  8604. func (m *ChatRecordsMutation) AddedFields() []string {
  8605. var fields []string
  8606. if m.addcontent_type != nil {
  8607. fields = append(fields, chatrecords.FieldContentType)
  8608. }
  8609. if m.addsession_id != nil {
  8610. fields = append(fields, chatrecords.FieldSessionID)
  8611. }
  8612. if m.adduser_id != nil {
  8613. fields = append(fields, chatrecords.FieldUserID)
  8614. }
  8615. if m.addbot_id != nil {
  8616. fields = append(fields, chatrecords.FieldBotID)
  8617. }
  8618. if m.addbot_type != nil {
  8619. fields = append(fields, chatrecords.FieldBotType)
  8620. }
  8621. return fields
  8622. }
  8623. // AddedField returns the numeric value that was incremented/decremented on a field
  8624. // with the given name. The second boolean return value indicates that this field
  8625. // was not set, or was not defined in the schema.
  8626. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8627. switch name {
  8628. case chatrecords.FieldContentType:
  8629. return m.AddedContentType()
  8630. case chatrecords.FieldSessionID:
  8631. return m.AddedSessionID()
  8632. case chatrecords.FieldUserID:
  8633. return m.AddedUserID()
  8634. case chatrecords.FieldBotID:
  8635. return m.AddedBotID()
  8636. case chatrecords.FieldBotType:
  8637. return m.AddedBotType()
  8638. }
  8639. return nil, false
  8640. }
  8641. // AddField adds the value to the field with the given name. It returns an error if
  8642. // the field is not defined in the schema, or if the type mismatched the field
  8643. // type.
  8644. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8645. switch name {
  8646. case chatrecords.FieldContentType:
  8647. v, ok := value.(int8)
  8648. if !ok {
  8649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8650. }
  8651. m.AddContentType(v)
  8652. return nil
  8653. case chatrecords.FieldSessionID:
  8654. v, ok := value.(int64)
  8655. if !ok {
  8656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8657. }
  8658. m.AddSessionID(v)
  8659. return nil
  8660. case chatrecords.FieldUserID:
  8661. v, ok := value.(int64)
  8662. if !ok {
  8663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8664. }
  8665. m.AddUserID(v)
  8666. return nil
  8667. case chatrecords.FieldBotID:
  8668. v, ok := value.(int64)
  8669. if !ok {
  8670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8671. }
  8672. m.AddBotID(v)
  8673. return nil
  8674. case chatrecords.FieldBotType:
  8675. v, ok := value.(int8)
  8676. if !ok {
  8677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8678. }
  8679. m.AddBotType(v)
  8680. return nil
  8681. }
  8682. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8683. }
  8684. // ClearedFields returns all nullable fields that were cleared during this
  8685. // mutation.
  8686. func (m *ChatRecordsMutation) ClearedFields() []string {
  8687. var fields []string
  8688. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8689. fields = append(fields, chatrecords.FieldDeletedAt)
  8690. }
  8691. return fields
  8692. }
  8693. // FieldCleared returns a boolean indicating if a field with the given name was
  8694. // cleared in this mutation.
  8695. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8696. _, ok := m.clearedFields[name]
  8697. return ok
  8698. }
  8699. // ClearField clears the value of the field with the given name. It returns an
  8700. // error if the field is not defined in the schema.
  8701. func (m *ChatRecordsMutation) ClearField(name string) error {
  8702. switch name {
  8703. case chatrecords.FieldDeletedAt:
  8704. m.ClearDeletedAt()
  8705. return nil
  8706. }
  8707. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8708. }
  8709. // ResetField resets all changes in the mutation for the field with the given name.
  8710. // It returns an error if the field is not defined in the schema.
  8711. func (m *ChatRecordsMutation) ResetField(name string) error {
  8712. switch name {
  8713. case chatrecords.FieldCreatedAt:
  8714. m.ResetCreatedAt()
  8715. return nil
  8716. case chatrecords.FieldUpdatedAt:
  8717. m.ResetUpdatedAt()
  8718. return nil
  8719. case chatrecords.FieldDeletedAt:
  8720. m.ResetDeletedAt()
  8721. return nil
  8722. case chatrecords.FieldContent:
  8723. m.ResetContent()
  8724. return nil
  8725. case chatrecords.FieldContentType:
  8726. m.ResetContentType()
  8727. return nil
  8728. case chatrecords.FieldSessionID:
  8729. m.ResetSessionID()
  8730. return nil
  8731. case chatrecords.FieldUserID:
  8732. m.ResetUserID()
  8733. return nil
  8734. case chatrecords.FieldBotID:
  8735. m.ResetBotID()
  8736. return nil
  8737. case chatrecords.FieldBotType:
  8738. m.ResetBotType()
  8739. return nil
  8740. }
  8741. return fmt.Errorf("unknown ChatRecords field %s", name)
  8742. }
  8743. // AddedEdges returns all edge names that were set/added in this mutation.
  8744. func (m *ChatRecordsMutation) AddedEdges() []string {
  8745. edges := make([]string, 0, 0)
  8746. return edges
  8747. }
  8748. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8749. // name in this mutation.
  8750. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8751. return nil
  8752. }
  8753. // RemovedEdges returns all edge names that were removed in this mutation.
  8754. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8755. edges := make([]string, 0, 0)
  8756. return edges
  8757. }
  8758. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8759. // the given name in this mutation.
  8760. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8761. return nil
  8762. }
  8763. // ClearedEdges returns all edge names that were cleared in this mutation.
  8764. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8765. edges := make([]string, 0, 0)
  8766. return edges
  8767. }
  8768. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8769. // was cleared in this mutation.
  8770. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8771. return false
  8772. }
  8773. // ClearEdge clears the value of the edge with the given name. It returns an error
  8774. // if that edge is not defined in the schema.
  8775. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8776. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8777. }
  8778. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8779. // It returns an error if the edge is not defined in the schema.
  8780. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8781. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8782. }
  8783. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8784. type ChatSessionMutation struct {
  8785. config
  8786. op Op
  8787. typ string
  8788. id *uint64
  8789. created_at *time.Time
  8790. updated_at *time.Time
  8791. deleted_at *time.Time
  8792. name *string
  8793. user_id *uint64
  8794. adduser_id *int64
  8795. bot_id *uint64
  8796. addbot_id *int64
  8797. bot_type *uint8
  8798. addbot_type *int8
  8799. clearedFields map[string]struct{}
  8800. done bool
  8801. oldValue func(context.Context) (*ChatSession, error)
  8802. predicates []predicate.ChatSession
  8803. }
  8804. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8805. // chatsessionOption allows management of the mutation configuration using functional options.
  8806. type chatsessionOption func(*ChatSessionMutation)
  8807. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8808. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8809. m := &ChatSessionMutation{
  8810. config: c,
  8811. op: op,
  8812. typ: TypeChatSession,
  8813. clearedFields: make(map[string]struct{}),
  8814. }
  8815. for _, opt := range opts {
  8816. opt(m)
  8817. }
  8818. return m
  8819. }
  8820. // withChatSessionID sets the ID field of the mutation.
  8821. func withChatSessionID(id uint64) chatsessionOption {
  8822. return func(m *ChatSessionMutation) {
  8823. var (
  8824. err error
  8825. once sync.Once
  8826. value *ChatSession
  8827. )
  8828. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8829. once.Do(func() {
  8830. if m.done {
  8831. err = errors.New("querying old values post mutation is not allowed")
  8832. } else {
  8833. value, err = m.Client().ChatSession.Get(ctx, id)
  8834. }
  8835. })
  8836. return value, err
  8837. }
  8838. m.id = &id
  8839. }
  8840. }
  8841. // withChatSession sets the old ChatSession of the mutation.
  8842. func withChatSession(node *ChatSession) chatsessionOption {
  8843. return func(m *ChatSessionMutation) {
  8844. m.oldValue = func(context.Context) (*ChatSession, error) {
  8845. return node, nil
  8846. }
  8847. m.id = &node.ID
  8848. }
  8849. }
  8850. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8851. // executed in a transaction (ent.Tx), a transactional client is returned.
  8852. func (m ChatSessionMutation) Client() *Client {
  8853. client := &Client{config: m.config}
  8854. client.init()
  8855. return client
  8856. }
  8857. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8858. // it returns an error otherwise.
  8859. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8860. if _, ok := m.driver.(*txDriver); !ok {
  8861. return nil, errors.New("ent: mutation is not running in a transaction")
  8862. }
  8863. tx := &Tx{config: m.config}
  8864. tx.init()
  8865. return tx, nil
  8866. }
  8867. // SetID sets the value of the id field. Note that this
  8868. // operation is only accepted on creation of ChatSession entities.
  8869. func (m *ChatSessionMutation) SetID(id uint64) {
  8870. m.id = &id
  8871. }
  8872. // ID returns the ID value in the mutation. Note that the ID is only available
  8873. // if it was provided to the builder or after it was returned from the database.
  8874. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8875. if m.id == nil {
  8876. return
  8877. }
  8878. return *m.id, true
  8879. }
  8880. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8881. // That means, if the mutation is applied within a transaction with an isolation level such
  8882. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8883. // or updated by the mutation.
  8884. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8885. switch {
  8886. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8887. id, exists := m.ID()
  8888. if exists {
  8889. return []uint64{id}, nil
  8890. }
  8891. fallthrough
  8892. case m.op.Is(OpUpdate | OpDelete):
  8893. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8894. default:
  8895. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8896. }
  8897. }
  8898. // SetCreatedAt sets the "created_at" field.
  8899. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8900. m.created_at = &t
  8901. }
  8902. // CreatedAt returns the value of the "created_at" field in the mutation.
  8903. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8904. v := m.created_at
  8905. if v == nil {
  8906. return
  8907. }
  8908. return *v, true
  8909. }
  8910. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8911. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8913. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8914. if !m.op.Is(OpUpdateOne) {
  8915. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8916. }
  8917. if m.id == nil || m.oldValue == nil {
  8918. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8919. }
  8920. oldValue, err := m.oldValue(ctx)
  8921. if err != nil {
  8922. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8923. }
  8924. return oldValue.CreatedAt, nil
  8925. }
  8926. // ResetCreatedAt resets all changes to the "created_at" field.
  8927. func (m *ChatSessionMutation) ResetCreatedAt() {
  8928. m.created_at = nil
  8929. }
  8930. // SetUpdatedAt sets the "updated_at" field.
  8931. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8932. m.updated_at = &t
  8933. }
  8934. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8935. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8936. v := m.updated_at
  8937. if v == nil {
  8938. return
  8939. }
  8940. return *v, true
  8941. }
  8942. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8943. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8945. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8946. if !m.op.Is(OpUpdateOne) {
  8947. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8948. }
  8949. if m.id == nil || m.oldValue == nil {
  8950. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8951. }
  8952. oldValue, err := m.oldValue(ctx)
  8953. if err != nil {
  8954. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8955. }
  8956. return oldValue.UpdatedAt, nil
  8957. }
  8958. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8959. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8960. m.updated_at = nil
  8961. }
  8962. // SetDeletedAt sets the "deleted_at" field.
  8963. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8964. m.deleted_at = &t
  8965. }
  8966. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8967. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8968. v := m.deleted_at
  8969. if v == nil {
  8970. return
  8971. }
  8972. return *v, true
  8973. }
  8974. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8975. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8977. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8978. if !m.op.Is(OpUpdateOne) {
  8979. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8980. }
  8981. if m.id == nil || m.oldValue == nil {
  8982. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8983. }
  8984. oldValue, err := m.oldValue(ctx)
  8985. if err != nil {
  8986. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8987. }
  8988. return oldValue.DeletedAt, nil
  8989. }
  8990. // ClearDeletedAt clears the value of the "deleted_at" field.
  8991. func (m *ChatSessionMutation) ClearDeletedAt() {
  8992. m.deleted_at = nil
  8993. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8994. }
  8995. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8996. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8997. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8998. return ok
  8999. }
  9000. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9001. func (m *ChatSessionMutation) ResetDeletedAt() {
  9002. m.deleted_at = nil
  9003. delete(m.clearedFields, chatsession.FieldDeletedAt)
  9004. }
  9005. // SetName sets the "name" field.
  9006. func (m *ChatSessionMutation) SetName(s string) {
  9007. m.name = &s
  9008. }
  9009. // Name returns the value of the "name" field in the mutation.
  9010. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  9011. v := m.name
  9012. if v == nil {
  9013. return
  9014. }
  9015. return *v, true
  9016. }
  9017. // OldName returns the old "name" field's value of the ChatSession entity.
  9018. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9020. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  9021. if !m.op.Is(OpUpdateOne) {
  9022. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9023. }
  9024. if m.id == nil || m.oldValue == nil {
  9025. return v, errors.New("OldName requires an ID field in the mutation")
  9026. }
  9027. oldValue, err := m.oldValue(ctx)
  9028. if err != nil {
  9029. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9030. }
  9031. return oldValue.Name, nil
  9032. }
  9033. // ResetName resets all changes to the "name" field.
  9034. func (m *ChatSessionMutation) ResetName() {
  9035. m.name = nil
  9036. }
  9037. // SetUserID sets the "user_id" field.
  9038. func (m *ChatSessionMutation) SetUserID(u uint64) {
  9039. m.user_id = &u
  9040. m.adduser_id = nil
  9041. }
  9042. // UserID returns the value of the "user_id" field in the mutation.
  9043. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  9044. v := m.user_id
  9045. if v == nil {
  9046. return
  9047. }
  9048. return *v, true
  9049. }
  9050. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  9051. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9053. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9054. if !m.op.Is(OpUpdateOne) {
  9055. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9056. }
  9057. if m.id == nil || m.oldValue == nil {
  9058. return v, errors.New("OldUserID requires an ID field in the mutation")
  9059. }
  9060. oldValue, err := m.oldValue(ctx)
  9061. if err != nil {
  9062. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9063. }
  9064. return oldValue.UserID, nil
  9065. }
  9066. // AddUserID adds u to the "user_id" field.
  9067. func (m *ChatSessionMutation) AddUserID(u int64) {
  9068. if m.adduser_id != nil {
  9069. *m.adduser_id += u
  9070. } else {
  9071. m.adduser_id = &u
  9072. }
  9073. }
  9074. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9075. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  9076. v := m.adduser_id
  9077. if v == nil {
  9078. return
  9079. }
  9080. return *v, true
  9081. }
  9082. // ResetUserID resets all changes to the "user_id" field.
  9083. func (m *ChatSessionMutation) ResetUserID() {
  9084. m.user_id = nil
  9085. m.adduser_id = nil
  9086. }
  9087. // SetBotID sets the "bot_id" field.
  9088. func (m *ChatSessionMutation) SetBotID(u uint64) {
  9089. m.bot_id = &u
  9090. m.addbot_id = nil
  9091. }
  9092. // BotID returns the value of the "bot_id" field in the mutation.
  9093. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  9094. v := m.bot_id
  9095. if v == nil {
  9096. return
  9097. }
  9098. return *v, true
  9099. }
  9100. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  9101. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9103. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9104. if !m.op.Is(OpUpdateOne) {
  9105. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9106. }
  9107. if m.id == nil || m.oldValue == nil {
  9108. return v, errors.New("OldBotID requires an ID field in the mutation")
  9109. }
  9110. oldValue, err := m.oldValue(ctx)
  9111. if err != nil {
  9112. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9113. }
  9114. return oldValue.BotID, nil
  9115. }
  9116. // AddBotID adds u to the "bot_id" field.
  9117. func (m *ChatSessionMutation) AddBotID(u int64) {
  9118. if m.addbot_id != nil {
  9119. *m.addbot_id += u
  9120. } else {
  9121. m.addbot_id = &u
  9122. }
  9123. }
  9124. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9125. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  9126. v := m.addbot_id
  9127. if v == nil {
  9128. return
  9129. }
  9130. return *v, true
  9131. }
  9132. // ResetBotID resets all changes to the "bot_id" field.
  9133. func (m *ChatSessionMutation) ResetBotID() {
  9134. m.bot_id = nil
  9135. m.addbot_id = nil
  9136. }
  9137. // SetBotType sets the "bot_type" field.
  9138. func (m *ChatSessionMutation) SetBotType(u uint8) {
  9139. m.bot_type = &u
  9140. m.addbot_type = nil
  9141. }
  9142. // BotType returns the value of the "bot_type" field in the mutation.
  9143. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  9144. v := m.bot_type
  9145. if v == nil {
  9146. return
  9147. }
  9148. return *v, true
  9149. }
  9150. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  9151. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9153. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9154. if !m.op.Is(OpUpdateOne) {
  9155. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9156. }
  9157. if m.id == nil || m.oldValue == nil {
  9158. return v, errors.New("OldBotType requires an ID field in the mutation")
  9159. }
  9160. oldValue, err := m.oldValue(ctx)
  9161. if err != nil {
  9162. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9163. }
  9164. return oldValue.BotType, nil
  9165. }
  9166. // AddBotType adds u to the "bot_type" field.
  9167. func (m *ChatSessionMutation) AddBotType(u int8) {
  9168. if m.addbot_type != nil {
  9169. *m.addbot_type += u
  9170. } else {
  9171. m.addbot_type = &u
  9172. }
  9173. }
  9174. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9175. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9176. v := m.addbot_type
  9177. if v == nil {
  9178. return
  9179. }
  9180. return *v, true
  9181. }
  9182. // ResetBotType resets all changes to the "bot_type" field.
  9183. func (m *ChatSessionMutation) ResetBotType() {
  9184. m.bot_type = nil
  9185. m.addbot_type = nil
  9186. }
  9187. // Where appends a list predicates to the ChatSessionMutation builder.
  9188. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9189. m.predicates = append(m.predicates, ps...)
  9190. }
  9191. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9192. // users can use type-assertion to append predicates that do not depend on any generated package.
  9193. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9194. p := make([]predicate.ChatSession, len(ps))
  9195. for i := range ps {
  9196. p[i] = ps[i]
  9197. }
  9198. m.Where(p...)
  9199. }
  9200. // Op returns the operation name.
  9201. func (m *ChatSessionMutation) Op() Op {
  9202. return m.op
  9203. }
  9204. // SetOp allows setting the mutation operation.
  9205. func (m *ChatSessionMutation) SetOp(op Op) {
  9206. m.op = op
  9207. }
  9208. // Type returns the node type of this mutation (ChatSession).
  9209. func (m *ChatSessionMutation) Type() string {
  9210. return m.typ
  9211. }
  9212. // Fields returns all fields that were changed during this mutation. Note that in
  9213. // order to get all numeric fields that were incremented/decremented, call
  9214. // AddedFields().
  9215. func (m *ChatSessionMutation) Fields() []string {
  9216. fields := make([]string, 0, 7)
  9217. if m.created_at != nil {
  9218. fields = append(fields, chatsession.FieldCreatedAt)
  9219. }
  9220. if m.updated_at != nil {
  9221. fields = append(fields, chatsession.FieldUpdatedAt)
  9222. }
  9223. if m.deleted_at != nil {
  9224. fields = append(fields, chatsession.FieldDeletedAt)
  9225. }
  9226. if m.name != nil {
  9227. fields = append(fields, chatsession.FieldName)
  9228. }
  9229. if m.user_id != nil {
  9230. fields = append(fields, chatsession.FieldUserID)
  9231. }
  9232. if m.bot_id != nil {
  9233. fields = append(fields, chatsession.FieldBotID)
  9234. }
  9235. if m.bot_type != nil {
  9236. fields = append(fields, chatsession.FieldBotType)
  9237. }
  9238. return fields
  9239. }
  9240. // Field returns the value of a field with the given name. The second boolean
  9241. // return value indicates that this field was not set, or was not defined in the
  9242. // schema.
  9243. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9244. switch name {
  9245. case chatsession.FieldCreatedAt:
  9246. return m.CreatedAt()
  9247. case chatsession.FieldUpdatedAt:
  9248. return m.UpdatedAt()
  9249. case chatsession.FieldDeletedAt:
  9250. return m.DeletedAt()
  9251. case chatsession.FieldName:
  9252. return m.Name()
  9253. case chatsession.FieldUserID:
  9254. return m.UserID()
  9255. case chatsession.FieldBotID:
  9256. return m.BotID()
  9257. case chatsession.FieldBotType:
  9258. return m.BotType()
  9259. }
  9260. return nil, false
  9261. }
  9262. // OldField returns the old value of the field from the database. An error is
  9263. // returned if the mutation operation is not UpdateOne, or the query to the
  9264. // database failed.
  9265. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9266. switch name {
  9267. case chatsession.FieldCreatedAt:
  9268. return m.OldCreatedAt(ctx)
  9269. case chatsession.FieldUpdatedAt:
  9270. return m.OldUpdatedAt(ctx)
  9271. case chatsession.FieldDeletedAt:
  9272. return m.OldDeletedAt(ctx)
  9273. case chatsession.FieldName:
  9274. return m.OldName(ctx)
  9275. case chatsession.FieldUserID:
  9276. return m.OldUserID(ctx)
  9277. case chatsession.FieldBotID:
  9278. return m.OldBotID(ctx)
  9279. case chatsession.FieldBotType:
  9280. return m.OldBotType(ctx)
  9281. }
  9282. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9283. }
  9284. // SetField sets the value of a field with the given name. It returns an error if
  9285. // the field is not defined in the schema, or if the type mismatched the field
  9286. // type.
  9287. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9288. switch name {
  9289. case chatsession.FieldCreatedAt:
  9290. v, ok := value.(time.Time)
  9291. if !ok {
  9292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9293. }
  9294. m.SetCreatedAt(v)
  9295. return nil
  9296. case chatsession.FieldUpdatedAt:
  9297. v, ok := value.(time.Time)
  9298. if !ok {
  9299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9300. }
  9301. m.SetUpdatedAt(v)
  9302. return nil
  9303. case chatsession.FieldDeletedAt:
  9304. v, ok := value.(time.Time)
  9305. if !ok {
  9306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9307. }
  9308. m.SetDeletedAt(v)
  9309. return nil
  9310. case chatsession.FieldName:
  9311. v, ok := value.(string)
  9312. if !ok {
  9313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9314. }
  9315. m.SetName(v)
  9316. return nil
  9317. case chatsession.FieldUserID:
  9318. v, ok := value.(uint64)
  9319. if !ok {
  9320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9321. }
  9322. m.SetUserID(v)
  9323. return nil
  9324. case chatsession.FieldBotID:
  9325. v, ok := value.(uint64)
  9326. if !ok {
  9327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9328. }
  9329. m.SetBotID(v)
  9330. return nil
  9331. case chatsession.FieldBotType:
  9332. v, ok := value.(uint8)
  9333. if !ok {
  9334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9335. }
  9336. m.SetBotType(v)
  9337. return nil
  9338. }
  9339. return fmt.Errorf("unknown ChatSession field %s", name)
  9340. }
  9341. // AddedFields returns all numeric fields that were incremented/decremented during
  9342. // this mutation.
  9343. func (m *ChatSessionMutation) AddedFields() []string {
  9344. var fields []string
  9345. if m.adduser_id != nil {
  9346. fields = append(fields, chatsession.FieldUserID)
  9347. }
  9348. if m.addbot_id != nil {
  9349. fields = append(fields, chatsession.FieldBotID)
  9350. }
  9351. if m.addbot_type != nil {
  9352. fields = append(fields, chatsession.FieldBotType)
  9353. }
  9354. return fields
  9355. }
  9356. // AddedField returns the numeric value that was incremented/decremented on a field
  9357. // with the given name. The second boolean return value indicates that this field
  9358. // was not set, or was not defined in the schema.
  9359. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9360. switch name {
  9361. case chatsession.FieldUserID:
  9362. return m.AddedUserID()
  9363. case chatsession.FieldBotID:
  9364. return m.AddedBotID()
  9365. case chatsession.FieldBotType:
  9366. return m.AddedBotType()
  9367. }
  9368. return nil, false
  9369. }
  9370. // AddField adds the value to the field with the given name. It returns an error if
  9371. // the field is not defined in the schema, or if the type mismatched the field
  9372. // type.
  9373. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9374. switch name {
  9375. case chatsession.FieldUserID:
  9376. v, ok := value.(int64)
  9377. if !ok {
  9378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9379. }
  9380. m.AddUserID(v)
  9381. return nil
  9382. case chatsession.FieldBotID:
  9383. v, ok := value.(int64)
  9384. if !ok {
  9385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9386. }
  9387. m.AddBotID(v)
  9388. return nil
  9389. case chatsession.FieldBotType:
  9390. v, ok := value.(int8)
  9391. if !ok {
  9392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9393. }
  9394. m.AddBotType(v)
  9395. return nil
  9396. }
  9397. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9398. }
  9399. // ClearedFields returns all nullable fields that were cleared during this
  9400. // mutation.
  9401. func (m *ChatSessionMutation) ClearedFields() []string {
  9402. var fields []string
  9403. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9404. fields = append(fields, chatsession.FieldDeletedAt)
  9405. }
  9406. return fields
  9407. }
  9408. // FieldCleared returns a boolean indicating if a field with the given name was
  9409. // cleared in this mutation.
  9410. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9411. _, ok := m.clearedFields[name]
  9412. return ok
  9413. }
  9414. // ClearField clears the value of the field with the given name. It returns an
  9415. // error if the field is not defined in the schema.
  9416. func (m *ChatSessionMutation) ClearField(name string) error {
  9417. switch name {
  9418. case chatsession.FieldDeletedAt:
  9419. m.ClearDeletedAt()
  9420. return nil
  9421. }
  9422. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9423. }
  9424. // ResetField resets all changes in the mutation for the field with the given name.
  9425. // It returns an error if the field is not defined in the schema.
  9426. func (m *ChatSessionMutation) ResetField(name string) error {
  9427. switch name {
  9428. case chatsession.FieldCreatedAt:
  9429. m.ResetCreatedAt()
  9430. return nil
  9431. case chatsession.FieldUpdatedAt:
  9432. m.ResetUpdatedAt()
  9433. return nil
  9434. case chatsession.FieldDeletedAt:
  9435. m.ResetDeletedAt()
  9436. return nil
  9437. case chatsession.FieldName:
  9438. m.ResetName()
  9439. return nil
  9440. case chatsession.FieldUserID:
  9441. m.ResetUserID()
  9442. return nil
  9443. case chatsession.FieldBotID:
  9444. m.ResetBotID()
  9445. return nil
  9446. case chatsession.FieldBotType:
  9447. m.ResetBotType()
  9448. return nil
  9449. }
  9450. return fmt.Errorf("unknown ChatSession field %s", name)
  9451. }
  9452. // AddedEdges returns all edge names that were set/added in this mutation.
  9453. func (m *ChatSessionMutation) AddedEdges() []string {
  9454. edges := make([]string, 0, 0)
  9455. return edges
  9456. }
  9457. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9458. // name in this mutation.
  9459. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9460. return nil
  9461. }
  9462. // RemovedEdges returns all edge names that were removed in this mutation.
  9463. func (m *ChatSessionMutation) RemovedEdges() []string {
  9464. edges := make([]string, 0, 0)
  9465. return edges
  9466. }
  9467. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9468. // the given name in this mutation.
  9469. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9470. return nil
  9471. }
  9472. // ClearedEdges returns all edge names that were cleared in this mutation.
  9473. func (m *ChatSessionMutation) ClearedEdges() []string {
  9474. edges := make([]string, 0, 0)
  9475. return edges
  9476. }
  9477. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9478. // was cleared in this mutation.
  9479. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9480. return false
  9481. }
  9482. // ClearEdge clears the value of the edge with the given name. It returns an error
  9483. // if that edge is not defined in the schema.
  9484. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9485. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9486. }
  9487. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9488. // It returns an error if the edge is not defined in the schema.
  9489. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9490. return fmt.Errorf("unknown ChatSession edge %s", name)
  9491. }
  9492. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  9493. type CompapiAsynctaskMutation struct {
  9494. config
  9495. op Op
  9496. typ string
  9497. id *uint64
  9498. created_at *time.Time
  9499. updated_at *time.Time
  9500. auth_token *string
  9501. event_type *string
  9502. chat_id *string
  9503. response_chat_item_id *string
  9504. organization_id *uint64
  9505. addorganization_id *int64
  9506. openai_base *string
  9507. openai_key *string
  9508. request_raw *string
  9509. response_raw *string
  9510. callback_url *string
  9511. callback_response_raw *string
  9512. model *string
  9513. task_status *int8
  9514. addtask_status *int8
  9515. retry_count *int8
  9516. addretry_count *int8
  9517. last_error *string
  9518. clearedFields map[string]struct{}
  9519. done bool
  9520. oldValue func(context.Context) (*CompapiAsynctask, error)
  9521. predicates []predicate.CompapiAsynctask
  9522. }
  9523. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  9524. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  9525. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  9526. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  9527. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  9528. m := &CompapiAsynctaskMutation{
  9529. config: c,
  9530. op: op,
  9531. typ: TypeCompapiAsynctask,
  9532. clearedFields: make(map[string]struct{}),
  9533. }
  9534. for _, opt := range opts {
  9535. opt(m)
  9536. }
  9537. return m
  9538. }
  9539. // withCompapiAsynctaskID sets the ID field of the mutation.
  9540. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  9541. return func(m *CompapiAsynctaskMutation) {
  9542. var (
  9543. err error
  9544. once sync.Once
  9545. value *CompapiAsynctask
  9546. )
  9547. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  9548. once.Do(func() {
  9549. if m.done {
  9550. err = errors.New("querying old values post mutation is not allowed")
  9551. } else {
  9552. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  9553. }
  9554. })
  9555. return value, err
  9556. }
  9557. m.id = &id
  9558. }
  9559. }
  9560. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  9561. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  9562. return func(m *CompapiAsynctaskMutation) {
  9563. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  9564. return node, nil
  9565. }
  9566. m.id = &node.ID
  9567. }
  9568. }
  9569. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9570. // executed in a transaction (ent.Tx), a transactional client is returned.
  9571. func (m CompapiAsynctaskMutation) Client() *Client {
  9572. client := &Client{config: m.config}
  9573. client.init()
  9574. return client
  9575. }
  9576. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9577. // it returns an error otherwise.
  9578. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  9579. if _, ok := m.driver.(*txDriver); !ok {
  9580. return nil, errors.New("ent: mutation is not running in a transaction")
  9581. }
  9582. tx := &Tx{config: m.config}
  9583. tx.init()
  9584. return tx, nil
  9585. }
  9586. // SetID sets the value of the id field. Note that this
  9587. // operation is only accepted on creation of CompapiAsynctask entities.
  9588. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  9589. m.id = &id
  9590. }
  9591. // ID returns the ID value in the mutation. Note that the ID is only available
  9592. // if it was provided to the builder or after it was returned from the database.
  9593. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  9594. if m.id == nil {
  9595. return
  9596. }
  9597. return *m.id, true
  9598. }
  9599. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9600. // That means, if the mutation is applied within a transaction with an isolation level such
  9601. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9602. // or updated by the mutation.
  9603. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  9604. switch {
  9605. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9606. id, exists := m.ID()
  9607. if exists {
  9608. return []uint64{id}, nil
  9609. }
  9610. fallthrough
  9611. case m.op.Is(OpUpdate | OpDelete):
  9612. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  9613. default:
  9614. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9615. }
  9616. }
  9617. // SetCreatedAt sets the "created_at" field.
  9618. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  9619. m.created_at = &t
  9620. }
  9621. // CreatedAt returns the value of the "created_at" field in the mutation.
  9622. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  9623. v := m.created_at
  9624. if v == nil {
  9625. return
  9626. }
  9627. return *v, true
  9628. }
  9629. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  9630. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9632. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9633. if !m.op.Is(OpUpdateOne) {
  9634. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9635. }
  9636. if m.id == nil || m.oldValue == nil {
  9637. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9638. }
  9639. oldValue, err := m.oldValue(ctx)
  9640. if err != nil {
  9641. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9642. }
  9643. return oldValue.CreatedAt, nil
  9644. }
  9645. // ResetCreatedAt resets all changes to the "created_at" field.
  9646. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  9647. m.created_at = nil
  9648. }
  9649. // SetUpdatedAt sets the "updated_at" field.
  9650. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  9651. m.updated_at = &t
  9652. }
  9653. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9654. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  9655. v := m.updated_at
  9656. if v == nil {
  9657. return
  9658. }
  9659. return *v, true
  9660. }
  9661. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  9662. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9664. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9665. if !m.op.Is(OpUpdateOne) {
  9666. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9667. }
  9668. if m.id == nil || m.oldValue == nil {
  9669. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9670. }
  9671. oldValue, err := m.oldValue(ctx)
  9672. if err != nil {
  9673. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9674. }
  9675. return oldValue.UpdatedAt, nil
  9676. }
  9677. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9678. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  9679. m.updated_at = nil
  9680. }
  9681. // SetAuthToken sets the "auth_token" field.
  9682. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  9683. m.auth_token = &s
  9684. }
  9685. // AuthToken returns the value of the "auth_token" field in the mutation.
  9686. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  9687. v := m.auth_token
  9688. if v == nil {
  9689. return
  9690. }
  9691. return *v, true
  9692. }
  9693. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  9694. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9696. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  9697. if !m.op.Is(OpUpdateOne) {
  9698. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  9699. }
  9700. if m.id == nil || m.oldValue == nil {
  9701. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  9702. }
  9703. oldValue, err := m.oldValue(ctx)
  9704. if err != nil {
  9705. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  9706. }
  9707. return oldValue.AuthToken, nil
  9708. }
  9709. // ResetAuthToken resets all changes to the "auth_token" field.
  9710. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  9711. m.auth_token = nil
  9712. }
  9713. // SetEventType sets the "event_type" field.
  9714. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  9715. m.event_type = &s
  9716. }
  9717. // EventType returns the value of the "event_type" field in the mutation.
  9718. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  9719. v := m.event_type
  9720. if v == nil {
  9721. return
  9722. }
  9723. return *v, true
  9724. }
  9725. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  9726. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9728. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  9729. if !m.op.Is(OpUpdateOne) {
  9730. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  9731. }
  9732. if m.id == nil || m.oldValue == nil {
  9733. return v, errors.New("OldEventType requires an ID field in the mutation")
  9734. }
  9735. oldValue, err := m.oldValue(ctx)
  9736. if err != nil {
  9737. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  9738. }
  9739. return oldValue.EventType, nil
  9740. }
  9741. // ResetEventType resets all changes to the "event_type" field.
  9742. func (m *CompapiAsynctaskMutation) ResetEventType() {
  9743. m.event_type = nil
  9744. }
  9745. // SetChatID sets the "chat_id" field.
  9746. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  9747. m.chat_id = &s
  9748. }
  9749. // ChatID returns the value of the "chat_id" field in the mutation.
  9750. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  9751. v := m.chat_id
  9752. if v == nil {
  9753. return
  9754. }
  9755. return *v, true
  9756. }
  9757. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  9758. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9760. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  9761. if !m.op.Is(OpUpdateOne) {
  9762. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  9763. }
  9764. if m.id == nil || m.oldValue == nil {
  9765. return v, errors.New("OldChatID requires an ID field in the mutation")
  9766. }
  9767. oldValue, err := m.oldValue(ctx)
  9768. if err != nil {
  9769. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  9770. }
  9771. return oldValue.ChatID, nil
  9772. }
  9773. // ClearChatID clears the value of the "chat_id" field.
  9774. func (m *CompapiAsynctaskMutation) ClearChatID() {
  9775. m.chat_id = nil
  9776. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  9777. }
  9778. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  9779. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  9780. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  9781. return ok
  9782. }
  9783. // ResetChatID resets all changes to the "chat_id" field.
  9784. func (m *CompapiAsynctaskMutation) ResetChatID() {
  9785. m.chat_id = nil
  9786. delete(m.clearedFields, compapiasynctask.FieldChatID)
  9787. }
  9788. // SetResponseChatItemID sets the "response_chat_item_id" field.
  9789. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  9790. m.response_chat_item_id = &s
  9791. }
  9792. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  9793. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  9794. v := m.response_chat_item_id
  9795. if v == nil {
  9796. return
  9797. }
  9798. return *v, true
  9799. }
  9800. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  9801. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9803. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  9804. if !m.op.Is(OpUpdateOne) {
  9805. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  9806. }
  9807. if m.id == nil || m.oldValue == nil {
  9808. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  9809. }
  9810. oldValue, err := m.oldValue(ctx)
  9811. if err != nil {
  9812. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  9813. }
  9814. return oldValue.ResponseChatItemID, nil
  9815. }
  9816. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  9817. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  9818. m.response_chat_item_id = nil
  9819. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  9820. }
  9821. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  9822. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  9823. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  9824. return ok
  9825. }
  9826. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  9827. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  9828. m.response_chat_item_id = nil
  9829. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  9830. }
  9831. // SetOrganizationID sets the "organization_id" field.
  9832. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  9833. m.organization_id = &u
  9834. m.addorganization_id = nil
  9835. }
  9836. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9837. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  9838. v := m.organization_id
  9839. if v == nil {
  9840. return
  9841. }
  9842. return *v, true
  9843. }
  9844. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  9845. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9847. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9848. if !m.op.Is(OpUpdateOne) {
  9849. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9850. }
  9851. if m.id == nil || m.oldValue == nil {
  9852. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9853. }
  9854. oldValue, err := m.oldValue(ctx)
  9855. if err != nil {
  9856. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9857. }
  9858. return oldValue.OrganizationID, nil
  9859. }
  9860. // AddOrganizationID adds u to the "organization_id" field.
  9861. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  9862. if m.addorganization_id != nil {
  9863. *m.addorganization_id += u
  9864. } else {
  9865. m.addorganization_id = &u
  9866. }
  9867. }
  9868. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9869. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  9870. v := m.addorganization_id
  9871. if v == nil {
  9872. return
  9873. }
  9874. return *v, true
  9875. }
  9876. // ResetOrganizationID resets all changes to the "organization_id" field.
  9877. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  9878. m.organization_id = nil
  9879. m.addorganization_id = nil
  9880. }
  9881. // SetOpenaiBase sets the "openai_base" field.
  9882. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  9883. m.openai_base = &s
  9884. }
  9885. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  9886. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  9887. v := m.openai_base
  9888. if v == nil {
  9889. return
  9890. }
  9891. return *v, true
  9892. }
  9893. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  9894. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9896. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  9897. if !m.op.Is(OpUpdateOne) {
  9898. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  9899. }
  9900. if m.id == nil || m.oldValue == nil {
  9901. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  9902. }
  9903. oldValue, err := m.oldValue(ctx)
  9904. if err != nil {
  9905. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  9906. }
  9907. return oldValue.OpenaiBase, nil
  9908. }
  9909. // ResetOpenaiBase resets all changes to the "openai_base" field.
  9910. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  9911. m.openai_base = nil
  9912. }
  9913. // SetOpenaiKey sets the "openai_key" field.
  9914. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  9915. m.openai_key = &s
  9916. }
  9917. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  9918. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  9919. v := m.openai_key
  9920. if v == nil {
  9921. return
  9922. }
  9923. return *v, true
  9924. }
  9925. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  9926. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9928. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  9929. if !m.op.Is(OpUpdateOne) {
  9930. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  9931. }
  9932. if m.id == nil || m.oldValue == nil {
  9933. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  9934. }
  9935. oldValue, err := m.oldValue(ctx)
  9936. if err != nil {
  9937. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  9938. }
  9939. return oldValue.OpenaiKey, nil
  9940. }
  9941. // ResetOpenaiKey resets all changes to the "openai_key" field.
  9942. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  9943. m.openai_key = nil
  9944. }
  9945. // SetRequestRaw sets the "request_raw" field.
  9946. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  9947. m.request_raw = &s
  9948. }
  9949. // RequestRaw returns the value of the "request_raw" field in the mutation.
  9950. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  9951. v := m.request_raw
  9952. if v == nil {
  9953. return
  9954. }
  9955. return *v, true
  9956. }
  9957. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  9958. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9960. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  9961. if !m.op.Is(OpUpdateOne) {
  9962. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  9963. }
  9964. if m.id == nil || m.oldValue == nil {
  9965. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  9966. }
  9967. oldValue, err := m.oldValue(ctx)
  9968. if err != nil {
  9969. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  9970. }
  9971. return oldValue.RequestRaw, nil
  9972. }
  9973. // ResetRequestRaw resets all changes to the "request_raw" field.
  9974. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  9975. m.request_raw = nil
  9976. }
  9977. // SetResponseRaw sets the "response_raw" field.
  9978. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  9979. m.response_raw = &s
  9980. }
  9981. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  9982. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  9983. v := m.response_raw
  9984. if v == nil {
  9985. return
  9986. }
  9987. return *v, true
  9988. }
  9989. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  9990. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9992. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  9993. if !m.op.Is(OpUpdateOne) {
  9994. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  9995. }
  9996. if m.id == nil || m.oldValue == nil {
  9997. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  9998. }
  9999. oldValue, err := m.oldValue(ctx)
  10000. if err != nil {
  10001. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  10002. }
  10003. return oldValue.ResponseRaw, nil
  10004. }
  10005. // ClearResponseRaw clears the value of the "response_raw" field.
  10006. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  10007. m.response_raw = nil
  10008. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  10009. }
  10010. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  10011. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  10012. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  10013. return ok
  10014. }
  10015. // ResetResponseRaw resets all changes to the "response_raw" field.
  10016. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  10017. m.response_raw = nil
  10018. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  10019. }
  10020. // SetCallbackURL sets the "callback_url" field.
  10021. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  10022. m.callback_url = &s
  10023. }
  10024. // CallbackURL returns the value of the "callback_url" field in the mutation.
  10025. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  10026. v := m.callback_url
  10027. if v == nil {
  10028. return
  10029. }
  10030. return *v, true
  10031. }
  10032. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  10033. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10035. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  10036. if !m.op.Is(OpUpdateOne) {
  10037. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  10038. }
  10039. if m.id == nil || m.oldValue == nil {
  10040. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  10041. }
  10042. oldValue, err := m.oldValue(ctx)
  10043. if err != nil {
  10044. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  10045. }
  10046. return oldValue.CallbackURL, nil
  10047. }
  10048. // ResetCallbackURL resets all changes to the "callback_url" field.
  10049. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  10050. m.callback_url = nil
  10051. }
  10052. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  10053. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  10054. m.callback_response_raw = &s
  10055. }
  10056. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  10057. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  10058. v := m.callback_response_raw
  10059. if v == nil {
  10060. return
  10061. }
  10062. return *v, true
  10063. }
  10064. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  10065. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10067. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  10068. if !m.op.Is(OpUpdateOne) {
  10069. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  10070. }
  10071. if m.id == nil || m.oldValue == nil {
  10072. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  10073. }
  10074. oldValue, err := m.oldValue(ctx)
  10075. if err != nil {
  10076. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  10077. }
  10078. return oldValue.CallbackResponseRaw, nil
  10079. }
  10080. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  10081. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  10082. m.callback_response_raw = nil
  10083. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  10084. }
  10085. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  10086. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  10087. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  10088. return ok
  10089. }
  10090. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  10091. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  10092. m.callback_response_raw = nil
  10093. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  10094. }
  10095. // SetModel sets the "model" field.
  10096. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  10097. m.model = &s
  10098. }
  10099. // Model returns the value of the "model" field in the mutation.
  10100. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  10101. v := m.model
  10102. if v == nil {
  10103. return
  10104. }
  10105. return *v, true
  10106. }
  10107. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  10108. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10110. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  10111. if !m.op.Is(OpUpdateOne) {
  10112. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  10113. }
  10114. if m.id == nil || m.oldValue == nil {
  10115. return v, errors.New("OldModel requires an ID field in the mutation")
  10116. }
  10117. oldValue, err := m.oldValue(ctx)
  10118. if err != nil {
  10119. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  10120. }
  10121. return oldValue.Model, nil
  10122. }
  10123. // ClearModel clears the value of the "model" field.
  10124. func (m *CompapiAsynctaskMutation) ClearModel() {
  10125. m.model = nil
  10126. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  10127. }
  10128. // ModelCleared returns if the "model" field was cleared in this mutation.
  10129. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  10130. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  10131. return ok
  10132. }
  10133. // ResetModel resets all changes to the "model" field.
  10134. func (m *CompapiAsynctaskMutation) ResetModel() {
  10135. m.model = nil
  10136. delete(m.clearedFields, compapiasynctask.FieldModel)
  10137. }
  10138. // SetTaskStatus sets the "task_status" field.
  10139. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  10140. m.task_status = &i
  10141. m.addtask_status = nil
  10142. }
  10143. // TaskStatus returns the value of the "task_status" field in the mutation.
  10144. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  10145. v := m.task_status
  10146. if v == nil {
  10147. return
  10148. }
  10149. return *v, true
  10150. }
  10151. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  10152. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10154. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  10155. if !m.op.Is(OpUpdateOne) {
  10156. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  10157. }
  10158. if m.id == nil || m.oldValue == nil {
  10159. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  10160. }
  10161. oldValue, err := m.oldValue(ctx)
  10162. if err != nil {
  10163. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  10164. }
  10165. return oldValue.TaskStatus, nil
  10166. }
  10167. // AddTaskStatus adds i to the "task_status" field.
  10168. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  10169. if m.addtask_status != nil {
  10170. *m.addtask_status += i
  10171. } else {
  10172. m.addtask_status = &i
  10173. }
  10174. }
  10175. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  10176. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  10177. v := m.addtask_status
  10178. if v == nil {
  10179. return
  10180. }
  10181. return *v, true
  10182. }
  10183. // ClearTaskStatus clears the value of the "task_status" field.
  10184. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  10185. m.task_status = nil
  10186. m.addtask_status = nil
  10187. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  10188. }
  10189. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  10190. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  10191. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  10192. return ok
  10193. }
  10194. // ResetTaskStatus resets all changes to the "task_status" field.
  10195. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  10196. m.task_status = nil
  10197. m.addtask_status = nil
  10198. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  10199. }
  10200. // SetRetryCount sets the "retry_count" field.
  10201. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  10202. m.retry_count = &i
  10203. m.addretry_count = nil
  10204. }
  10205. // RetryCount returns the value of the "retry_count" field in the mutation.
  10206. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  10207. v := m.retry_count
  10208. if v == nil {
  10209. return
  10210. }
  10211. return *v, true
  10212. }
  10213. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  10214. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10216. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  10217. if !m.op.Is(OpUpdateOne) {
  10218. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  10219. }
  10220. if m.id == nil || m.oldValue == nil {
  10221. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  10222. }
  10223. oldValue, err := m.oldValue(ctx)
  10224. if err != nil {
  10225. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  10226. }
  10227. return oldValue.RetryCount, nil
  10228. }
  10229. // AddRetryCount adds i to the "retry_count" field.
  10230. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  10231. if m.addretry_count != nil {
  10232. *m.addretry_count += i
  10233. } else {
  10234. m.addretry_count = &i
  10235. }
  10236. }
  10237. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  10238. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  10239. v := m.addretry_count
  10240. if v == nil {
  10241. return
  10242. }
  10243. return *v, true
  10244. }
  10245. // ClearRetryCount clears the value of the "retry_count" field.
  10246. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  10247. m.retry_count = nil
  10248. m.addretry_count = nil
  10249. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  10250. }
  10251. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  10252. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  10253. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  10254. return ok
  10255. }
  10256. // ResetRetryCount resets all changes to the "retry_count" field.
  10257. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  10258. m.retry_count = nil
  10259. m.addretry_count = nil
  10260. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  10261. }
  10262. // SetLastError sets the "last_error" field.
  10263. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  10264. m.last_error = &s
  10265. }
  10266. // LastError returns the value of the "last_error" field in the mutation.
  10267. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  10268. v := m.last_error
  10269. if v == nil {
  10270. return
  10271. }
  10272. return *v, true
  10273. }
  10274. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  10275. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10277. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  10278. if !m.op.Is(OpUpdateOne) {
  10279. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  10280. }
  10281. if m.id == nil || m.oldValue == nil {
  10282. return v, errors.New("OldLastError requires an ID field in the mutation")
  10283. }
  10284. oldValue, err := m.oldValue(ctx)
  10285. if err != nil {
  10286. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  10287. }
  10288. return oldValue.LastError, nil
  10289. }
  10290. // ClearLastError clears the value of the "last_error" field.
  10291. func (m *CompapiAsynctaskMutation) ClearLastError() {
  10292. m.last_error = nil
  10293. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  10294. }
  10295. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  10296. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  10297. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  10298. return ok
  10299. }
  10300. // ResetLastError resets all changes to the "last_error" field.
  10301. func (m *CompapiAsynctaskMutation) ResetLastError() {
  10302. m.last_error = nil
  10303. delete(m.clearedFields, compapiasynctask.FieldLastError)
  10304. }
  10305. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  10306. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  10307. m.predicates = append(m.predicates, ps...)
  10308. }
  10309. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  10310. // users can use type-assertion to append predicates that do not depend on any generated package.
  10311. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  10312. p := make([]predicate.CompapiAsynctask, len(ps))
  10313. for i := range ps {
  10314. p[i] = ps[i]
  10315. }
  10316. m.Where(p...)
  10317. }
  10318. // Op returns the operation name.
  10319. func (m *CompapiAsynctaskMutation) Op() Op {
  10320. return m.op
  10321. }
  10322. // SetOp allows setting the mutation operation.
  10323. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  10324. m.op = op
  10325. }
  10326. // Type returns the node type of this mutation (CompapiAsynctask).
  10327. func (m *CompapiAsynctaskMutation) Type() string {
  10328. return m.typ
  10329. }
  10330. // Fields returns all fields that were changed during this mutation. Note that in
  10331. // order to get all numeric fields that were incremented/decremented, call
  10332. // AddedFields().
  10333. func (m *CompapiAsynctaskMutation) Fields() []string {
  10334. fields := make([]string, 0, 17)
  10335. if m.created_at != nil {
  10336. fields = append(fields, compapiasynctask.FieldCreatedAt)
  10337. }
  10338. if m.updated_at != nil {
  10339. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  10340. }
  10341. if m.auth_token != nil {
  10342. fields = append(fields, compapiasynctask.FieldAuthToken)
  10343. }
  10344. if m.event_type != nil {
  10345. fields = append(fields, compapiasynctask.FieldEventType)
  10346. }
  10347. if m.chat_id != nil {
  10348. fields = append(fields, compapiasynctask.FieldChatID)
  10349. }
  10350. if m.response_chat_item_id != nil {
  10351. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10352. }
  10353. if m.organization_id != nil {
  10354. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10355. }
  10356. if m.openai_base != nil {
  10357. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  10358. }
  10359. if m.openai_key != nil {
  10360. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  10361. }
  10362. if m.request_raw != nil {
  10363. fields = append(fields, compapiasynctask.FieldRequestRaw)
  10364. }
  10365. if m.response_raw != nil {
  10366. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10367. }
  10368. if m.callback_url != nil {
  10369. fields = append(fields, compapiasynctask.FieldCallbackURL)
  10370. }
  10371. if m.callback_response_raw != nil {
  10372. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10373. }
  10374. if m.model != nil {
  10375. fields = append(fields, compapiasynctask.FieldModel)
  10376. }
  10377. if m.task_status != nil {
  10378. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10379. }
  10380. if m.retry_count != nil {
  10381. fields = append(fields, compapiasynctask.FieldRetryCount)
  10382. }
  10383. if m.last_error != nil {
  10384. fields = append(fields, compapiasynctask.FieldLastError)
  10385. }
  10386. return fields
  10387. }
  10388. // Field returns the value of a field with the given name. The second boolean
  10389. // return value indicates that this field was not set, or was not defined in the
  10390. // schema.
  10391. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  10392. switch name {
  10393. case compapiasynctask.FieldCreatedAt:
  10394. return m.CreatedAt()
  10395. case compapiasynctask.FieldUpdatedAt:
  10396. return m.UpdatedAt()
  10397. case compapiasynctask.FieldAuthToken:
  10398. return m.AuthToken()
  10399. case compapiasynctask.FieldEventType:
  10400. return m.EventType()
  10401. case compapiasynctask.FieldChatID:
  10402. return m.ChatID()
  10403. case compapiasynctask.FieldResponseChatItemID:
  10404. return m.ResponseChatItemID()
  10405. case compapiasynctask.FieldOrganizationID:
  10406. return m.OrganizationID()
  10407. case compapiasynctask.FieldOpenaiBase:
  10408. return m.OpenaiBase()
  10409. case compapiasynctask.FieldOpenaiKey:
  10410. return m.OpenaiKey()
  10411. case compapiasynctask.FieldRequestRaw:
  10412. return m.RequestRaw()
  10413. case compapiasynctask.FieldResponseRaw:
  10414. return m.ResponseRaw()
  10415. case compapiasynctask.FieldCallbackURL:
  10416. return m.CallbackURL()
  10417. case compapiasynctask.FieldCallbackResponseRaw:
  10418. return m.CallbackResponseRaw()
  10419. case compapiasynctask.FieldModel:
  10420. return m.Model()
  10421. case compapiasynctask.FieldTaskStatus:
  10422. return m.TaskStatus()
  10423. case compapiasynctask.FieldRetryCount:
  10424. return m.RetryCount()
  10425. case compapiasynctask.FieldLastError:
  10426. return m.LastError()
  10427. }
  10428. return nil, false
  10429. }
  10430. // OldField returns the old value of the field from the database. An error is
  10431. // returned if the mutation operation is not UpdateOne, or the query to the
  10432. // database failed.
  10433. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10434. switch name {
  10435. case compapiasynctask.FieldCreatedAt:
  10436. return m.OldCreatedAt(ctx)
  10437. case compapiasynctask.FieldUpdatedAt:
  10438. return m.OldUpdatedAt(ctx)
  10439. case compapiasynctask.FieldAuthToken:
  10440. return m.OldAuthToken(ctx)
  10441. case compapiasynctask.FieldEventType:
  10442. return m.OldEventType(ctx)
  10443. case compapiasynctask.FieldChatID:
  10444. return m.OldChatID(ctx)
  10445. case compapiasynctask.FieldResponseChatItemID:
  10446. return m.OldResponseChatItemID(ctx)
  10447. case compapiasynctask.FieldOrganizationID:
  10448. return m.OldOrganizationID(ctx)
  10449. case compapiasynctask.FieldOpenaiBase:
  10450. return m.OldOpenaiBase(ctx)
  10451. case compapiasynctask.FieldOpenaiKey:
  10452. return m.OldOpenaiKey(ctx)
  10453. case compapiasynctask.FieldRequestRaw:
  10454. return m.OldRequestRaw(ctx)
  10455. case compapiasynctask.FieldResponseRaw:
  10456. return m.OldResponseRaw(ctx)
  10457. case compapiasynctask.FieldCallbackURL:
  10458. return m.OldCallbackURL(ctx)
  10459. case compapiasynctask.FieldCallbackResponseRaw:
  10460. return m.OldCallbackResponseRaw(ctx)
  10461. case compapiasynctask.FieldModel:
  10462. return m.OldModel(ctx)
  10463. case compapiasynctask.FieldTaskStatus:
  10464. return m.OldTaskStatus(ctx)
  10465. case compapiasynctask.FieldRetryCount:
  10466. return m.OldRetryCount(ctx)
  10467. case compapiasynctask.FieldLastError:
  10468. return m.OldLastError(ctx)
  10469. }
  10470. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10471. }
  10472. // SetField sets the value of a field with the given name. It returns an error if
  10473. // the field is not defined in the schema, or if the type mismatched the field
  10474. // type.
  10475. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  10476. switch name {
  10477. case compapiasynctask.FieldCreatedAt:
  10478. v, ok := value.(time.Time)
  10479. if !ok {
  10480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10481. }
  10482. m.SetCreatedAt(v)
  10483. return nil
  10484. case compapiasynctask.FieldUpdatedAt:
  10485. v, ok := value.(time.Time)
  10486. if !ok {
  10487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10488. }
  10489. m.SetUpdatedAt(v)
  10490. return nil
  10491. case compapiasynctask.FieldAuthToken:
  10492. v, ok := value.(string)
  10493. if !ok {
  10494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10495. }
  10496. m.SetAuthToken(v)
  10497. return nil
  10498. case compapiasynctask.FieldEventType:
  10499. v, ok := value.(string)
  10500. if !ok {
  10501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10502. }
  10503. m.SetEventType(v)
  10504. return nil
  10505. case compapiasynctask.FieldChatID:
  10506. v, ok := value.(string)
  10507. if !ok {
  10508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10509. }
  10510. m.SetChatID(v)
  10511. return nil
  10512. case compapiasynctask.FieldResponseChatItemID:
  10513. v, ok := value.(string)
  10514. if !ok {
  10515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10516. }
  10517. m.SetResponseChatItemID(v)
  10518. return nil
  10519. case compapiasynctask.FieldOrganizationID:
  10520. v, ok := value.(uint64)
  10521. if !ok {
  10522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10523. }
  10524. m.SetOrganizationID(v)
  10525. return nil
  10526. case compapiasynctask.FieldOpenaiBase:
  10527. v, ok := value.(string)
  10528. if !ok {
  10529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10530. }
  10531. m.SetOpenaiBase(v)
  10532. return nil
  10533. case compapiasynctask.FieldOpenaiKey:
  10534. v, ok := value.(string)
  10535. if !ok {
  10536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10537. }
  10538. m.SetOpenaiKey(v)
  10539. return nil
  10540. case compapiasynctask.FieldRequestRaw:
  10541. v, ok := value.(string)
  10542. if !ok {
  10543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10544. }
  10545. m.SetRequestRaw(v)
  10546. return nil
  10547. case compapiasynctask.FieldResponseRaw:
  10548. v, ok := value.(string)
  10549. if !ok {
  10550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10551. }
  10552. m.SetResponseRaw(v)
  10553. return nil
  10554. case compapiasynctask.FieldCallbackURL:
  10555. v, ok := value.(string)
  10556. if !ok {
  10557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10558. }
  10559. m.SetCallbackURL(v)
  10560. return nil
  10561. case compapiasynctask.FieldCallbackResponseRaw:
  10562. v, ok := value.(string)
  10563. if !ok {
  10564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10565. }
  10566. m.SetCallbackResponseRaw(v)
  10567. return nil
  10568. case compapiasynctask.FieldModel:
  10569. v, ok := value.(string)
  10570. if !ok {
  10571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10572. }
  10573. m.SetModel(v)
  10574. return nil
  10575. case compapiasynctask.FieldTaskStatus:
  10576. v, ok := value.(int8)
  10577. if !ok {
  10578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10579. }
  10580. m.SetTaskStatus(v)
  10581. return nil
  10582. case compapiasynctask.FieldRetryCount:
  10583. v, ok := value.(int8)
  10584. if !ok {
  10585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10586. }
  10587. m.SetRetryCount(v)
  10588. return nil
  10589. case compapiasynctask.FieldLastError:
  10590. v, ok := value.(string)
  10591. if !ok {
  10592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10593. }
  10594. m.SetLastError(v)
  10595. return nil
  10596. }
  10597. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10598. }
  10599. // AddedFields returns all numeric fields that were incremented/decremented during
  10600. // this mutation.
  10601. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  10602. var fields []string
  10603. if m.addorganization_id != nil {
  10604. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10605. }
  10606. if m.addtask_status != nil {
  10607. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10608. }
  10609. if m.addretry_count != nil {
  10610. fields = append(fields, compapiasynctask.FieldRetryCount)
  10611. }
  10612. return fields
  10613. }
  10614. // AddedField returns the numeric value that was incremented/decremented on a field
  10615. // with the given name. The second boolean return value indicates that this field
  10616. // was not set, or was not defined in the schema.
  10617. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  10618. switch name {
  10619. case compapiasynctask.FieldOrganizationID:
  10620. return m.AddedOrganizationID()
  10621. case compapiasynctask.FieldTaskStatus:
  10622. return m.AddedTaskStatus()
  10623. case compapiasynctask.FieldRetryCount:
  10624. return m.AddedRetryCount()
  10625. }
  10626. return nil, false
  10627. }
  10628. // AddField adds the value to the field with the given name. It returns an error if
  10629. // the field is not defined in the schema, or if the type mismatched the field
  10630. // type.
  10631. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  10632. switch name {
  10633. case compapiasynctask.FieldOrganizationID:
  10634. v, ok := value.(int64)
  10635. if !ok {
  10636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10637. }
  10638. m.AddOrganizationID(v)
  10639. return nil
  10640. case compapiasynctask.FieldTaskStatus:
  10641. v, ok := value.(int8)
  10642. if !ok {
  10643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10644. }
  10645. m.AddTaskStatus(v)
  10646. return nil
  10647. case compapiasynctask.FieldRetryCount:
  10648. v, ok := value.(int8)
  10649. if !ok {
  10650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10651. }
  10652. m.AddRetryCount(v)
  10653. return nil
  10654. }
  10655. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  10656. }
  10657. // ClearedFields returns all nullable fields that were cleared during this
  10658. // mutation.
  10659. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  10660. var fields []string
  10661. if m.FieldCleared(compapiasynctask.FieldChatID) {
  10662. fields = append(fields, compapiasynctask.FieldChatID)
  10663. }
  10664. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  10665. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10666. }
  10667. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  10668. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10669. }
  10670. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  10671. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10672. }
  10673. if m.FieldCleared(compapiasynctask.FieldModel) {
  10674. fields = append(fields, compapiasynctask.FieldModel)
  10675. }
  10676. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  10677. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10678. }
  10679. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  10680. fields = append(fields, compapiasynctask.FieldRetryCount)
  10681. }
  10682. if m.FieldCleared(compapiasynctask.FieldLastError) {
  10683. fields = append(fields, compapiasynctask.FieldLastError)
  10684. }
  10685. return fields
  10686. }
  10687. // FieldCleared returns a boolean indicating if a field with the given name was
  10688. // cleared in this mutation.
  10689. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  10690. _, ok := m.clearedFields[name]
  10691. return ok
  10692. }
  10693. // ClearField clears the value of the field with the given name. It returns an
  10694. // error if the field is not defined in the schema.
  10695. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  10696. switch name {
  10697. case compapiasynctask.FieldChatID:
  10698. m.ClearChatID()
  10699. return nil
  10700. case compapiasynctask.FieldResponseChatItemID:
  10701. m.ClearResponseChatItemID()
  10702. return nil
  10703. case compapiasynctask.FieldResponseRaw:
  10704. m.ClearResponseRaw()
  10705. return nil
  10706. case compapiasynctask.FieldCallbackResponseRaw:
  10707. m.ClearCallbackResponseRaw()
  10708. return nil
  10709. case compapiasynctask.FieldModel:
  10710. m.ClearModel()
  10711. return nil
  10712. case compapiasynctask.FieldTaskStatus:
  10713. m.ClearTaskStatus()
  10714. return nil
  10715. case compapiasynctask.FieldRetryCount:
  10716. m.ClearRetryCount()
  10717. return nil
  10718. case compapiasynctask.FieldLastError:
  10719. m.ClearLastError()
  10720. return nil
  10721. }
  10722. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  10723. }
  10724. // ResetField resets all changes in the mutation for the field with the given name.
  10725. // It returns an error if the field is not defined in the schema.
  10726. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  10727. switch name {
  10728. case compapiasynctask.FieldCreatedAt:
  10729. m.ResetCreatedAt()
  10730. return nil
  10731. case compapiasynctask.FieldUpdatedAt:
  10732. m.ResetUpdatedAt()
  10733. return nil
  10734. case compapiasynctask.FieldAuthToken:
  10735. m.ResetAuthToken()
  10736. return nil
  10737. case compapiasynctask.FieldEventType:
  10738. m.ResetEventType()
  10739. return nil
  10740. case compapiasynctask.FieldChatID:
  10741. m.ResetChatID()
  10742. return nil
  10743. case compapiasynctask.FieldResponseChatItemID:
  10744. m.ResetResponseChatItemID()
  10745. return nil
  10746. case compapiasynctask.FieldOrganizationID:
  10747. m.ResetOrganizationID()
  10748. return nil
  10749. case compapiasynctask.FieldOpenaiBase:
  10750. m.ResetOpenaiBase()
  10751. return nil
  10752. case compapiasynctask.FieldOpenaiKey:
  10753. m.ResetOpenaiKey()
  10754. return nil
  10755. case compapiasynctask.FieldRequestRaw:
  10756. m.ResetRequestRaw()
  10757. return nil
  10758. case compapiasynctask.FieldResponseRaw:
  10759. m.ResetResponseRaw()
  10760. return nil
  10761. case compapiasynctask.FieldCallbackURL:
  10762. m.ResetCallbackURL()
  10763. return nil
  10764. case compapiasynctask.FieldCallbackResponseRaw:
  10765. m.ResetCallbackResponseRaw()
  10766. return nil
  10767. case compapiasynctask.FieldModel:
  10768. m.ResetModel()
  10769. return nil
  10770. case compapiasynctask.FieldTaskStatus:
  10771. m.ResetTaskStatus()
  10772. return nil
  10773. case compapiasynctask.FieldRetryCount:
  10774. m.ResetRetryCount()
  10775. return nil
  10776. case compapiasynctask.FieldLastError:
  10777. m.ResetLastError()
  10778. return nil
  10779. }
  10780. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10781. }
  10782. // AddedEdges returns all edge names that were set/added in this mutation.
  10783. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  10784. edges := make([]string, 0, 0)
  10785. return edges
  10786. }
  10787. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10788. // name in this mutation.
  10789. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  10790. return nil
  10791. }
  10792. // RemovedEdges returns all edge names that were removed in this mutation.
  10793. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  10794. edges := make([]string, 0, 0)
  10795. return edges
  10796. }
  10797. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10798. // the given name in this mutation.
  10799. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  10800. return nil
  10801. }
  10802. // ClearedEdges returns all edge names that were cleared in this mutation.
  10803. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  10804. edges := make([]string, 0, 0)
  10805. return edges
  10806. }
  10807. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10808. // was cleared in this mutation.
  10809. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  10810. return false
  10811. }
  10812. // ClearEdge clears the value of the edge with the given name. It returns an error
  10813. // if that edge is not defined in the schema.
  10814. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  10815. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  10816. }
  10817. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10818. // It returns an error if the edge is not defined in the schema.
  10819. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  10820. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  10821. }
  10822. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  10823. type ContactMutation struct {
  10824. config
  10825. op Op
  10826. typ string
  10827. id *uint64
  10828. created_at *time.Time
  10829. updated_at *time.Time
  10830. status *uint8
  10831. addstatus *int8
  10832. deleted_at *time.Time
  10833. wx_wxid *string
  10834. _type *int
  10835. add_type *int
  10836. wxid *string
  10837. account *string
  10838. nickname *string
  10839. markname *string
  10840. headimg *string
  10841. sex *int
  10842. addsex *int
  10843. starrole *string
  10844. dontseeit *int
  10845. adddontseeit *int
  10846. dontseeme *int
  10847. adddontseeme *int
  10848. lag *string
  10849. gid *string
  10850. gname *string
  10851. v3 *string
  10852. organization_id *uint64
  10853. addorganization_id *int64
  10854. ctype *uint64
  10855. addctype *int64
  10856. cage *int
  10857. addcage *int
  10858. cname *string
  10859. carea *string
  10860. cbirthday *string
  10861. cbirtharea *string
  10862. cidcard_no *string
  10863. ctitle *string
  10864. cc *string
  10865. phone *string
  10866. clearedFields map[string]struct{}
  10867. contact_relationships map[uint64]struct{}
  10868. removedcontact_relationships map[uint64]struct{}
  10869. clearedcontact_relationships bool
  10870. contact_messages map[uint64]struct{}
  10871. removedcontact_messages map[uint64]struct{}
  10872. clearedcontact_messages bool
  10873. done bool
  10874. oldValue func(context.Context) (*Contact, error)
  10875. predicates []predicate.Contact
  10876. }
  10877. var _ ent.Mutation = (*ContactMutation)(nil)
  10878. // contactOption allows management of the mutation configuration using functional options.
  10879. type contactOption func(*ContactMutation)
  10880. // newContactMutation creates new mutation for the Contact entity.
  10881. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  10882. m := &ContactMutation{
  10883. config: c,
  10884. op: op,
  10885. typ: TypeContact,
  10886. clearedFields: make(map[string]struct{}),
  10887. }
  10888. for _, opt := range opts {
  10889. opt(m)
  10890. }
  10891. return m
  10892. }
  10893. // withContactID sets the ID field of the mutation.
  10894. func withContactID(id uint64) contactOption {
  10895. return func(m *ContactMutation) {
  10896. var (
  10897. err error
  10898. once sync.Once
  10899. value *Contact
  10900. )
  10901. m.oldValue = func(ctx context.Context) (*Contact, error) {
  10902. once.Do(func() {
  10903. if m.done {
  10904. err = errors.New("querying old values post mutation is not allowed")
  10905. } else {
  10906. value, err = m.Client().Contact.Get(ctx, id)
  10907. }
  10908. })
  10909. return value, err
  10910. }
  10911. m.id = &id
  10912. }
  10913. }
  10914. // withContact sets the old Contact of the mutation.
  10915. func withContact(node *Contact) contactOption {
  10916. return func(m *ContactMutation) {
  10917. m.oldValue = func(context.Context) (*Contact, error) {
  10918. return node, nil
  10919. }
  10920. m.id = &node.ID
  10921. }
  10922. }
  10923. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10924. // executed in a transaction (ent.Tx), a transactional client is returned.
  10925. func (m ContactMutation) Client() *Client {
  10926. client := &Client{config: m.config}
  10927. client.init()
  10928. return client
  10929. }
  10930. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10931. // it returns an error otherwise.
  10932. func (m ContactMutation) Tx() (*Tx, error) {
  10933. if _, ok := m.driver.(*txDriver); !ok {
  10934. return nil, errors.New("ent: mutation is not running in a transaction")
  10935. }
  10936. tx := &Tx{config: m.config}
  10937. tx.init()
  10938. return tx, nil
  10939. }
  10940. // SetID sets the value of the id field. Note that this
  10941. // operation is only accepted on creation of Contact entities.
  10942. func (m *ContactMutation) SetID(id uint64) {
  10943. m.id = &id
  10944. }
  10945. // ID returns the ID value in the mutation. Note that the ID is only available
  10946. // if it was provided to the builder or after it was returned from the database.
  10947. func (m *ContactMutation) ID() (id uint64, exists bool) {
  10948. if m.id == nil {
  10949. return
  10950. }
  10951. return *m.id, true
  10952. }
  10953. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10954. // That means, if the mutation is applied within a transaction with an isolation level such
  10955. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10956. // or updated by the mutation.
  10957. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  10958. switch {
  10959. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10960. id, exists := m.ID()
  10961. if exists {
  10962. return []uint64{id}, nil
  10963. }
  10964. fallthrough
  10965. case m.op.Is(OpUpdate | OpDelete):
  10966. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  10967. default:
  10968. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10969. }
  10970. }
  10971. // SetCreatedAt sets the "created_at" field.
  10972. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  10973. m.created_at = &t
  10974. }
  10975. // CreatedAt returns the value of the "created_at" field in the mutation.
  10976. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  10977. v := m.created_at
  10978. if v == nil {
  10979. return
  10980. }
  10981. return *v, true
  10982. }
  10983. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  10984. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10986. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10987. if !m.op.Is(OpUpdateOne) {
  10988. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10989. }
  10990. if m.id == nil || m.oldValue == nil {
  10991. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10992. }
  10993. oldValue, err := m.oldValue(ctx)
  10994. if err != nil {
  10995. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10996. }
  10997. return oldValue.CreatedAt, nil
  10998. }
  10999. // ResetCreatedAt resets all changes to the "created_at" field.
  11000. func (m *ContactMutation) ResetCreatedAt() {
  11001. m.created_at = nil
  11002. }
  11003. // SetUpdatedAt sets the "updated_at" field.
  11004. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  11005. m.updated_at = &t
  11006. }
  11007. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11008. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  11009. v := m.updated_at
  11010. if v == nil {
  11011. return
  11012. }
  11013. return *v, true
  11014. }
  11015. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  11016. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11018. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11019. if !m.op.Is(OpUpdateOne) {
  11020. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11021. }
  11022. if m.id == nil || m.oldValue == nil {
  11023. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11024. }
  11025. oldValue, err := m.oldValue(ctx)
  11026. if err != nil {
  11027. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11028. }
  11029. return oldValue.UpdatedAt, nil
  11030. }
  11031. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11032. func (m *ContactMutation) ResetUpdatedAt() {
  11033. m.updated_at = nil
  11034. }
  11035. // SetStatus sets the "status" field.
  11036. func (m *ContactMutation) SetStatus(u uint8) {
  11037. m.status = &u
  11038. m.addstatus = nil
  11039. }
  11040. // Status returns the value of the "status" field in the mutation.
  11041. func (m *ContactMutation) Status() (r uint8, exists bool) {
  11042. v := m.status
  11043. if v == nil {
  11044. return
  11045. }
  11046. return *v, true
  11047. }
  11048. // OldStatus returns the old "status" field's value of the Contact entity.
  11049. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11051. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11052. if !m.op.Is(OpUpdateOne) {
  11053. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11054. }
  11055. if m.id == nil || m.oldValue == nil {
  11056. return v, errors.New("OldStatus requires an ID field in the mutation")
  11057. }
  11058. oldValue, err := m.oldValue(ctx)
  11059. if err != nil {
  11060. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11061. }
  11062. return oldValue.Status, nil
  11063. }
  11064. // AddStatus adds u to the "status" field.
  11065. func (m *ContactMutation) AddStatus(u int8) {
  11066. if m.addstatus != nil {
  11067. *m.addstatus += u
  11068. } else {
  11069. m.addstatus = &u
  11070. }
  11071. }
  11072. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11073. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  11074. v := m.addstatus
  11075. if v == nil {
  11076. return
  11077. }
  11078. return *v, true
  11079. }
  11080. // ClearStatus clears the value of the "status" field.
  11081. func (m *ContactMutation) ClearStatus() {
  11082. m.status = nil
  11083. m.addstatus = nil
  11084. m.clearedFields[contact.FieldStatus] = struct{}{}
  11085. }
  11086. // StatusCleared returns if the "status" field was cleared in this mutation.
  11087. func (m *ContactMutation) StatusCleared() bool {
  11088. _, ok := m.clearedFields[contact.FieldStatus]
  11089. return ok
  11090. }
  11091. // ResetStatus resets all changes to the "status" field.
  11092. func (m *ContactMutation) ResetStatus() {
  11093. m.status = nil
  11094. m.addstatus = nil
  11095. delete(m.clearedFields, contact.FieldStatus)
  11096. }
  11097. // SetDeletedAt sets the "deleted_at" field.
  11098. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  11099. m.deleted_at = &t
  11100. }
  11101. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11102. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  11103. v := m.deleted_at
  11104. if v == nil {
  11105. return
  11106. }
  11107. return *v, true
  11108. }
  11109. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  11110. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11112. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11113. if !m.op.Is(OpUpdateOne) {
  11114. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11115. }
  11116. if m.id == nil || m.oldValue == nil {
  11117. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11118. }
  11119. oldValue, err := m.oldValue(ctx)
  11120. if err != nil {
  11121. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11122. }
  11123. return oldValue.DeletedAt, nil
  11124. }
  11125. // ClearDeletedAt clears the value of the "deleted_at" field.
  11126. func (m *ContactMutation) ClearDeletedAt() {
  11127. m.deleted_at = nil
  11128. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  11129. }
  11130. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11131. func (m *ContactMutation) DeletedAtCleared() bool {
  11132. _, ok := m.clearedFields[contact.FieldDeletedAt]
  11133. return ok
  11134. }
  11135. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11136. func (m *ContactMutation) ResetDeletedAt() {
  11137. m.deleted_at = nil
  11138. delete(m.clearedFields, contact.FieldDeletedAt)
  11139. }
  11140. // SetWxWxid sets the "wx_wxid" field.
  11141. func (m *ContactMutation) SetWxWxid(s string) {
  11142. m.wx_wxid = &s
  11143. }
  11144. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  11145. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  11146. v := m.wx_wxid
  11147. if v == nil {
  11148. return
  11149. }
  11150. return *v, true
  11151. }
  11152. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  11153. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11155. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  11156. if !m.op.Is(OpUpdateOne) {
  11157. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  11158. }
  11159. if m.id == nil || m.oldValue == nil {
  11160. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  11161. }
  11162. oldValue, err := m.oldValue(ctx)
  11163. if err != nil {
  11164. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  11165. }
  11166. return oldValue.WxWxid, nil
  11167. }
  11168. // ResetWxWxid resets all changes to the "wx_wxid" field.
  11169. func (m *ContactMutation) ResetWxWxid() {
  11170. m.wx_wxid = nil
  11171. }
  11172. // SetType sets the "type" field.
  11173. func (m *ContactMutation) SetType(i int) {
  11174. m._type = &i
  11175. m.add_type = nil
  11176. }
  11177. // GetType returns the value of the "type" field in the mutation.
  11178. func (m *ContactMutation) GetType() (r int, exists bool) {
  11179. v := m._type
  11180. if v == nil {
  11181. return
  11182. }
  11183. return *v, true
  11184. }
  11185. // OldType returns the old "type" field's value of the Contact entity.
  11186. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11188. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  11189. if !m.op.Is(OpUpdateOne) {
  11190. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11191. }
  11192. if m.id == nil || m.oldValue == nil {
  11193. return v, errors.New("OldType requires an ID field in the mutation")
  11194. }
  11195. oldValue, err := m.oldValue(ctx)
  11196. if err != nil {
  11197. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11198. }
  11199. return oldValue.Type, nil
  11200. }
  11201. // AddType adds i to the "type" field.
  11202. func (m *ContactMutation) AddType(i int) {
  11203. if m.add_type != nil {
  11204. *m.add_type += i
  11205. } else {
  11206. m.add_type = &i
  11207. }
  11208. }
  11209. // AddedType returns the value that was added to the "type" field in this mutation.
  11210. func (m *ContactMutation) AddedType() (r int, exists bool) {
  11211. v := m.add_type
  11212. if v == nil {
  11213. return
  11214. }
  11215. return *v, true
  11216. }
  11217. // ClearType clears the value of the "type" field.
  11218. func (m *ContactMutation) ClearType() {
  11219. m._type = nil
  11220. m.add_type = nil
  11221. m.clearedFields[contact.FieldType] = struct{}{}
  11222. }
  11223. // TypeCleared returns if the "type" field was cleared in this mutation.
  11224. func (m *ContactMutation) TypeCleared() bool {
  11225. _, ok := m.clearedFields[contact.FieldType]
  11226. return ok
  11227. }
  11228. // ResetType resets all changes to the "type" field.
  11229. func (m *ContactMutation) ResetType() {
  11230. m._type = nil
  11231. m.add_type = nil
  11232. delete(m.clearedFields, contact.FieldType)
  11233. }
  11234. // SetWxid sets the "wxid" field.
  11235. func (m *ContactMutation) SetWxid(s string) {
  11236. m.wxid = &s
  11237. }
  11238. // Wxid returns the value of the "wxid" field in the mutation.
  11239. func (m *ContactMutation) Wxid() (r string, exists bool) {
  11240. v := m.wxid
  11241. if v == nil {
  11242. return
  11243. }
  11244. return *v, true
  11245. }
  11246. // OldWxid returns the old "wxid" field's value of the Contact entity.
  11247. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11249. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  11250. if !m.op.Is(OpUpdateOne) {
  11251. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11252. }
  11253. if m.id == nil || m.oldValue == nil {
  11254. return v, errors.New("OldWxid requires an ID field in the mutation")
  11255. }
  11256. oldValue, err := m.oldValue(ctx)
  11257. if err != nil {
  11258. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11259. }
  11260. return oldValue.Wxid, nil
  11261. }
  11262. // ResetWxid resets all changes to the "wxid" field.
  11263. func (m *ContactMutation) ResetWxid() {
  11264. m.wxid = nil
  11265. }
  11266. // SetAccount sets the "account" field.
  11267. func (m *ContactMutation) SetAccount(s string) {
  11268. m.account = &s
  11269. }
  11270. // Account returns the value of the "account" field in the mutation.
  11271. func (m *ContactMutation) Account() (r string, exists bool) {
  11272. v := m.account
  11273. if v == nil {
  11274. return
  11275. }
  11276. return *v, true
  11277. }
  11278. // OldAccount returns the old "account" field's value of the Contact entity.
  11279. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11281. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  11282. if !m.op.Is(OpUpdateOne) {
  11283. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  11284. }
  11285. if m.id == nil || m.oldValue == nil {
  11286. return v, errors.New("OldAccount requires an ID field in the mutation")
  11287. }
  11288. oldValue, err := m.oldValue(ctx)
  11289. if err != nil {
  11290. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  11291. }
  11292. return oldValue.Account, nil
  11293. }
  11294. // ResetAccount resets all changes to the "account" field.
  11295. func (m *ContactMutation) ResetAccount() {
  11296. m.account = nil
  11297. }
  11298. // SetNickname sets the "nickname" field.
  11299. func (m *ContactMutation) SetNickname(s string) {
  11300. m.nickname = &s
  11301. }
  11302. // Nickname returns the value of the "nickname" field in the mutation.
  11303. func (m *ContactMutation) Nickname() (r string, exists bool) {
  11304. v := m.nickname
  11305. if v == nil {
  11306. return
  11307. }
  11308. return *v, true
  11309. }
  11310. // OldNickname returns the old "nickname" field's value of the Contact entity.
  11311. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11313. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  11314. if !m.op.Is(OpUpdateOne) {
  11315. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  11316. }
  11317. if m.id == nil || m.oldValue == nil {
  11318. return v, errors.New("OldNickname requires an ID field in the mutation")
  11319. }
  11320. oldValue, err := m.oldValue(ctx)
  11321. if err != nil {
  11322. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  11323. }
  11324. return oldValue.Nickname, nil
  11325. }
  11326. // ResetNickname resets all changes to the "nickname" field.
  11327. func (m *ContactMutation) ResetNickname() {
  11328. m.nickname = nil
  11329. }
  11330. // SetMarkname sets the "markname" field.
  11331. func (m *ContactMutation) SetMarkname(s string) {
  11332. m.markname = &s
  11333. }
  11334. // Markname returns the value of the "markname" field in the mutation.
  11335. func (m *ContactMutation) Markname() (r string, exists bool) {
  11336. v := m.markname
  11337. if v == nil {
  11338. return
  11339. }
  11340. return *v, true
  11341. }
  11342. // OldMarkname returns the old "markname" field's value of the Contact entity.
  11343. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11345. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  11346. if !m.op.Is(OpUpdateOne) {
  11347. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  11348. }
  11349. if m.id == nil || m.oldValue == nil {
  11350. return v, errors.New("OldMarkname requires an ID field in the mutation")
  11351. }
  11352. oldValue, err := m.oldValue(ctx)
  11353. if err != nil {
  11354. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  11355. }
  11356. return oldValue.Markname, nil
  11357. }
  11358. // ResetMarkname resets all changes to the "markname" field.
  11359. func (m *ContactMutation) ResetMarkname() {
  11360. m.markname = nil
  11361. }
  11362. // SetHeadimg sets the "headimg" field.
  11363. func (m *ContactMutation) SetHeadimg(s string) {
  11364. m.headimg = &s
  11365. }
  11366. // Headimg returns the value of the "headimg" field in the mutation.
  11367. func (m *ContactMutation) Headimg() (r string, exists bool) {
  11368. v := m.headimg
  11369. if v == nil {
  11370. return
  11371. }
  11372. return *v, true
  11373. }
  11374. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  11375. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11377. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  11378. if !m.op.Is(OpUpdateOne) {
  11379. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  11380. }
  11381. if m.id == nil || m.oldValue == nil {
  11382. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  11383. }
  11384. oldValue, err := m.oldValue(ctx)
  11385. if err != nil {
  11386. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  11387. }
  11388. return oldValue.Headimg, nil
  11389. }
  11390. // ResetHeadimg resets all changes to the "headimg" field.
  11391. func (m *ContactMutation) ResetHeadimg() {
  11392. m.headimg = nil
  11393. }
  11394. // SetSex sets the "sex" field.
  11395. func (m *ContactMutation) SetSex(i int) {
  11396. m.sex = &i
  11397. m.addsex = nil
  11398. }
  11399. // Sex returns the value of the "sex" field in the mutation.
  11400. func (m *ContactMutation) Sex() (r int, exists bool) {
  11401. v := m.sex
  11402. if v == nil {
  11403. return
  11404. }
  11405. return *v, true
  11406. }
  11407. // OldSex returns the old "sex" field's value of the Contact entity.
  11408. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11410. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  11411. if !m.op.Is(OpUpdateOne) {
  11412. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  11413. }
  11414. if m.id == nil || m.oldValue == nil {
  11415. return v, errors.New("OldSex requires an ID field in the mutation")
  11416. }
  11417. oldValue, err := m.oldValue(ctx)
  11418. if err != nil {
  11419. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  11420. }
  11421. return oldValue.Sex, nil
  11422. }
  11423. // AddSex adds i to the "sex" field.
  11424. func (m *ContactMutation) AddSex(i int) {
  11425. if m.addsex != nil {
  11426. *m.addsex += i
  11427. } else {
  11428. m.addsex = &i
  11429. }
  11430. }
  11431. // AddedSex returns the value that was added to the "sex" field in this mutation.
  11432. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  11433. v := m.addsex
  11434. if v == nil {
  11435. return
  11436. }
  11437. return *v, true
  11438. }
  11439. // ResetSex resets all changes to the "sex" field.
  11440. func (m *ContactMutation) ResetSex() {
  11441. m.sex = nil
  11442. m.addsex = nil
  11443. }
  11444. // SetStarrole sets the "starrole" field.
  11445. func (m *ContactMutation) SetStarrole(s string) {
  11446. m.starrole = &s
  11447. }
  11448. // Starrole returns the value of the "starrole" field in the mutation.
  11449. func (m *ContactMutation) Starrole() (r string, exists bool) {
  11450. v := m.starrole
  11451. if v == nil {
  11452. return
  11453. }
  11454. return *v, true
  11455. }
  11456. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  11457. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11459. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  11460. if !m.op.Is(OpUpdateOne) {
  11461. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  11462. }
  11463. if m.id == nil || m.oldValue == nil {
  11464. return v, errors.New("OldStarrole requires an ID field in the mutation")
  11465. }
  11466. oldValue, err := m.oldValue(ctx)
  11467. if err != nil {
  11468. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  11469. }
  11470. return oldValue.Starrole, nil
  11471. }
  11472. // ResetStarrole resets all changes to the "starrole" field.
  11473. func (m *ContactMutation) ResetStarrole() {
  11474. m.starrole = nil
  11475. }
  11476. // SetDontseeit sets the "dontseeit" field.
  11477. func (m *ContactMutation) SetDontseeit(i int) {
  11478. m.dontseeit = &i
  11479. m.adddontseeit = nil
  11480. }
  11481. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  11482. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  11483. v := m.dontseeit
  11484. if v == nil {
  11485. return
  11486. }
  11487. return *v, true
  11488. }
  11489. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  11490. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11492. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  11493. if !m.op.Is(OpUpdateOne) {
  11494. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  11495. }
  11496. if m.id == nil || m.oldValue == nil {
  11497. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  11498. }
  11499. oldValue, err := m.oldValue(ctx)
  11500. if err != nil {
  11501. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  11502. }
  11503. return oldValue.Dontseeit, nil
  11504. }
  11505. // AddDontseeit adds i to the "dontseeit" field.
  11506. func (m *ContactMutation) AddDontseeit(i int) {
  11507. if m.adddontseeit != nil {
  11508. *m.adddontseeit += i
  11509. } else {
  11510. m.adddontseeit = &i
  11511. }
  11512. }
  11513. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  11514. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  11515. v := m.adddontseeit
  11516. if v == nil {
  11517. return
  11518. }
  11519. return *v, true
  11520. }
  11521. // ResetDontseeit resets all changes to the "dontseeit" field.
  11522. func (m *ContactMutation) ResetDontseeit() {
  11523. m.dontseeit = nil
  11524. m.adddontseeit = nil
  11525. }
  11526. // SetDontseeme sets the "dontseeme" field.
  11527. func (m *ContactMutation) SetDontseeme(i int) {
  11528. m.dontseeme = &i
  11529. m.adddontseeme = nil
  11530. }
  11531. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  11532. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  11533. v := m.dontseeme
  11534. if v == nil {
  11535. return
  11536. }
  11537. return *v, true
  11538. }
  11539. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  11540. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11542. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  11543. if !m.op.Is(OpUpdateOne) {
  11544. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  11545. }
  11546. if m.id == nil || m.oldValue == nil {
  11547. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  11548. }
  11549. oldValue, err := m.oldValue(ctx)
  11550. if err != nil {
  11551. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  11552. }
  11553. return oldValue.Dontseeme, nil
  11554. }
  11555. // AddDontseeme adds i to the "dontseeme" field.
  11556. func (m *ContactMutation) AddDontseeme(i int) {
  11557. if m.adddontseeme != nil {
  11558. *m.adddontseeme += i
  11559. } else {
  11560. m.adddontseeme = &i
  11561. }
  11562. }
  11563. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  11564. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  11565. v := m.adddontseeme
  11566. if v == nil {
  11567. return
  11568. }
  11569. return *v, true
  11570. }
  11571. // ResetDontseeme resets all changes to the "dontseeme" field.
  11572. func (m *ContactMutation) ResetDontseeme() {
  11573. m.dontseeme = nil
  11574. m.adddontseeme = nil
  11575. }
  11576. // SetLag sets the "lag" field.
  11577. func (m *ContactMutation) SetLag(s string) {
  11578. m.lag = &s
  11579. }
  11580. // Lag returns the value of the "lag" field in the mutation.
  11581. func (m *ContactMutation) Lag() (r string, exists bool) {
  11582. v := m.lag
  11583. if v == nil {
  11584. return
  11585. }
  11586. return *v, true
  11587. }
  11588. // OldLag returns the old "lag" field's value of the Contact entity.
  11589. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11591. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  11592. if !m.op.Is(OpUpdateOne) {
  11593. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  11594. }
  11595. if m.id == nil || m.oldValue == nil {
  11596. return v, errors.New("OldLag requires an ID field in the mutation")
  11597. }
  11598. oldValue, err := m.oldValue(ctx)
  11599. if err != nil {
  11600. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  11601. }
  11602. return oldValue.Lag, nil
  11603. }
  11604. // ResetLag resets all changes to the "lag" field.
  11605. func (m *ContactMutation) ResetLag() {
  11606. m.lag = nil
  11607. }
  11608. // SetGid sets the "gid" field.
  11609. func (m *ContactMutation) SetGid(s string) {
  11610. m.gid = &s
  11611. }
  11612. // Gid returns the value of the "gid" field in the mutation.
  11613. func (m *ContactMutation) Gid() (r string, exists bool) {
  11614. v := m.gid
  11615. if v == nil {
  11616. return
  11617. }
  11618. return *v, true
  11619. }
  11620. // OldGid returns the old "gid" field's value of the Contact entity.
  11621. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11623. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  11624. if !m.op.Is(OpUpdateOne) {
  11625. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  11626. }
  11627. if m.id == nil || m.oldValue == nil {
  11628. return v, errors.New("OldGid requires an ID field in the mutation")
  11629. }
  11630. oldValue, err := m.oldValue(ctx)
  11631. if err != nil {
  11632. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  11633. }
  11634. return oldValue.Gid, nil
  11635. }
  11636. // ResetGid resets all changes to the "gid" field.
  11637. func (m *ContactMutation) ResetGid() {
  11638. m.gid = nil
  11639. }
  11640. // SetGname sets the "gname" field.
  11641. func (m *ContactMutation) SetGname(s string) {
  11642. m.gname = &s
  11643. }
  11644. // Gname returns the value of the "gname" field in the mutation.
  11645. func (m *ContactMutation) Gname() (r string, exists bool) {
  11646. v := m.gname
  11647. if v == nil {
  11648. return
  11649. }
  11650. return *v, true
  11651. }
  11652. // OldGname returns the old "gname" field's value of the Contact entity.
  11653. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11655. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  11656. if !m.op.Is(OpUpdateOne) {
  11657. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  11658. }
  11659. if m.id == nil || m.oldValue == nil {
  11660. return v, errors.New("OldGname requires an ID field in the mutation")
  11661. }
  11662. oldValue, err := m.oldValue(ctx)
  11663. if err != nil {
  11664. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  11665. }
  11666. return oldValue.Gname, nil
  11667. }
  11668. // ResetGname resets all changes to the "gname" field.
  11669. func (m *ContactMutation) ResetGname() {
  11670. m.gname = nil
  11671. }
  11672. // SetV3 sets the "v3" field.
  11673. func (m *ContactMutation) SetV3(s string) {
  11674. m.v3 = &s
  11675. }
  11676. // V3 returns the value of the "v3" field in the mutation.
  11677. func (m *ContactMutation) V3() (r string, exists bool) {
  11678. v := m.v3
  11679. if v == nil {
  11680. return
  11681. }
  11682. return *v, true
  11683. }
  11684. // OldV3 returns the old "v3" field's value of the Contact entity.
  11685. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11687. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  11688. if !m.op.Is(OpUpdateOne) {
  11689. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  11690. }
  11691. if m.id == nil || m.oldValue == nil {
  11692. return v, errors.New("OldV3 requires an ID field in the mutation")
  11693. }
  11694. oldValue, err := m.oldValue(ctx)
  11695. if err != nil {
  11696. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  11697. }
  11698. return oldValue.V3, nil
  11699. }
  11700. // ResetV3 resets all changes to the "v3" field.
  11701. func (m *ContactMutation) ResetV3() {
  11702. m.v3 = nil
  11703. }
  11704. // SetOrganizationID sets the "organization_id" field.
  11705. func (m *ContactMutation) SetOrganizationID(u uint64) {
  11706. m.organization_id = &u
  11707. m.addorganization_id = nil
  11708. }
  11709. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11710. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  11711. v := m.organization_id
  11712. if v == nil {
  11713. return
  11714. }
  11715. return *v, true
  11716. }
  11717. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  11718. // If the Contact 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 *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11721. if !m.op.Is(OpUpdateOne) {
  11722. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11723. }
  11724. if m.id == nil || m.oldValue == nil {
  11725. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  11730. }
  11731. return oldValue.OrganizationID, nil
  11732. }
  11733. // AddOrganizationID adds u to the "organization_id" field.
  11734. func (m *ContactMutation) AddOrganizationID(u int64) {
  11735. if m.addorganization_id != nil {
  11736. *m.addorganization_id += u
  11737. } else {
  11738. m.addorganization_id = &u
  11739. }
  11740. }
  11741. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11742. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  11743. v := m.addorganization_id
  11744. if v == nil {
  11745. return
  11746. }
  11747. return *v, true
  11748. }
  11749. // ClearOrganizationID clears the value of the "organization_id" field.
  11750. func (m *ContactMutation) ClearOrganizationID() {
  11751. m.organization_id = nil
  11752. m.addorganization_id = nil
  11753. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  11754. }
  11755. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11756. func (m *ContactMutation) OrganizationIDCleared() bool {
  11757. _, ok := m.clearedFields[contact.FieldOrganizationID]
  11758. return ok
  11759. }
  11760. // ResetOrganizationID resets all changes to the "organization_id" field.
  11761. func (m *ContactMutation) ResetOrganizationID() {
  11762. m.organization_id = nil
  11763. m.addorganization_id = nil
  11764. delete(m.clearedFields, contact.FieldOrganizationID)
  11765. }
  11766. // SetCtype sets the "ctype" field.
  11767. func (m *ContactMutation) SetCtype(u uint64) {
  11768. m.ctype = &u
  11769. m.addctype = nil
  11770. }
  11771. // Ctype returns the value of the "ctype" field in the mutation.
  11772. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  11773. v := m.ctype
  11774. if v == nil {
  11775. return
  11776. }
  11777. return *v, true
  11778. }
  11779. // OldCtype returns the old "ctype" field's value of the Contact entity.
  11780. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11782. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  11783. if !m.op.Is(OpUpdateOne) {
  11784. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  11785. }
  11786. if m.id == nil || m.oldValue == nil {
  11787. return v, errors.New("OldCtype requires an ID field in the mutation")
  11788. }
  11789. oldValue, err := m.oldValue(ctx)
  11790. if err != nil {
  11791. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  11792. }
  11793. return oldValue.Ctype, nil
  11794. }
  11795. // AddCtype adds u to the "ctype" field.
  11796. func (m *ContactMutation) AddCtype(u int64) {
  11797. if m.addctype != nil {
  11798. *m.addctype += u
  11799. } else {
  11800. m.addctype = &u
  11801. }
  11802. }
  11803. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  11804. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  11805. v := m.addctype
  11806. if v == nil {
  11807. return
  11808. }
  11809. return *v, true
  11810. }
  11811. // ResetCtype resets all changes to the "ctype" field.
  11812. func (m *ContactMutation) ResetCtype() {
  11813. m.ctype = nil
  11814. m.addctype = nil
  11815. }
  11816. // SetCage sets the "cage" field.
  11817. func (m *ContactMutation) SetCage(i int) {
  11818. m.cage = &i
  11819. m.addcage = nil
  11820. }
  11821. // Cage returns the value of the "cage" field in the mutation.
  11822. func (m *ContactMutation) Cage() (r int, exists bool) {
  11823. v := m.cage
  11824. if v == nil {
  11825. return
  11826. }
  11827. return *v, true
  11828. }
  11829. // OldCage returns the old "cage" field's value of the Contact entity.
  11830. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11832. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  11833. if !m.op.Is(OpUpdateOne) {
  11834. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  11835. }
  11836. if m.id == nil || m.oldValue == nil {
  11837. return v, errors.New("OldCage requires an ID field in the mutation")
  11838. }
  11839. oldValue, err := m.oldValue(ctx)
  11840. if err != nil {
  11841. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  11842. }
  11843. return oldValue.Cage, nil
  11844. }
  11845. // AddCage adds i to the "cage" field.
  11846. func (m *ContactMutation) AddCage(i int) {
  11847. if m.addcage != nil {
  11848. *m.addcage += i
  11849. } else {
  11850. m.addcage = &i
  11851. }
  11852. }
  11853. // AddedCage returns the value that was added to the "cage" field in this mutation.
  11854. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  11855. v := m.addcage
  11856. if v == nil {
  11857. return
  11858. }
  11859. return *v, true
  11860. }
  11861. // ResetCage resets all changes to the "cage" field.
  11862. func (m *ContactMutation) ResetCage() {
  11863. m.cage = nil
  11864. m.addcage = nil
  11865. }
  11866. // SetCname sets the "cname" field.
  11867. func (m *ContactMutation) SetCname(s string) {
  11868. m.cname = &s
  11869. }
  11870. // Cname returns the value of the "cname" field in the mutation.
  11871. func (m *ContactMutation) Cname() (r string, exists bool) {
  11872. v := m.cname
  11873. if v == nil {
  11874. return
  11875. }
  11876. return *v, true
  11877. }
  11878. // OldCname returns the old "cname" field's value of the Contact entity.
  11879. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11881. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  11882. if !m.op.Is(OpUpdateOne) {
  11883. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  11884. }
  11885. if m.id == nil || m.oldValue == nil {
  11886. return v, errors.New("OldCname requires an ID field in the mutation")
  11887. }
  11888. oldValue, err := m.oldValue(ctx)
  11889. if err != nil {
  11890. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  11891. }
  11892. return oldValue.Cname, nil
  11893. }
  11894. // ResetCname resets all changes to the "cname" field.
  11895. func (m *ContactMutation) ResetCname() {
  11896. m.cname = nil
  11897. }
  11898. // SetCarea sets the "carea" field.
  11899. func (m *ContactMutation) SetCarea(s string) {
  11900. m.carea = &s
  11901. }
  11902. // Carea returns the value of the "carea" field in the mutation.
  11903. func (m *ContactMutation) Carea() (r string, exists bool) {
  11904. v := m.carea
  11905. if v == nil {
  11906. return
  11907. }
  11908. return *v, true
  11909. }
  11910. // OldCarea returns the old "carea" field's value of the Contact entity.
  11911. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11913. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  11914. if !m.op.Is(OpUpdateOne) {
  11915. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  11916. }
  11917. if m.id == nil || m.oldValue == nil {
  11918. return v, errors.New("OldCarea requires an ID field in the mutation")
  11919. }
  11920. oldValue, err := m.oldValue(ctx)
  11921. if err != nil {
  11922. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  11923. }
  11924. return oldValue.Carea, nil
  11925. }
  11926. // ResetCarea resets all changes to the "carea" field.
  11927. func (m *ContactMutation) ResetCarea() {
  11928. m.carea = nil
  11929. }
  11930. // SetCbirthday sets the "cbirthday" field.
  11931. func (m *ContactMutation) SetCbirthday(s string) {
  11932. m.cbirthday = &s
  11933. }
  11934. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  11935. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  11936. v := m.cbirthday
  11937. if v == nil {
  11938. return
  11939. }
  11940. return *v, true
  11941. }
  11942. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  11943. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11945. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  11946. if !m.op.Is(OpUpdateOne) {
  11947. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  11948. }
  11949. if m.id == nil || m.oldValue == nil {
  11950. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  11951. }
  11952. oldValue, err := m.oldValue(ctx)
  11953. if err != nil {
  11954. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  11955. }
  11956. return oldValue.Cbirthday, nil
  11957. }
  11958. // ResetCbirthday resets all changes to the "cbirthday" field.
  11959. func (m *ContactMutation) ResetCbirthday() {
  11960. m.cbirthday = nil
  11961. }
  11962. // SetCbirtharea sets the "cbirtharea" field.
  11963. func (m *ContactMutation) SetCbirtharea(s string) {
  11964. m.cbirtharea = &s
  11965. }
  11966. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  11967. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  11968. v := m.cbirtharea
  11969. if v == nil {
  11970. return
  11971. }
  11972. return *v, true
  11973. }
  11974. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  11975. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11977. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  11978. if !m.op.Is(OpUpdateOne) {
  11979. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  11980. }
  11981. if m.id == nil || m.oldValue == nil {
  11982. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  11983. }
  11984. oldValue, err := m.oldValue(ctx)
  11985. if err != nil {
  11986. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  11987. }
  11988. return oldValue.Cbirtharea, nil
  11989. }
  11990. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  11991. func (m *ContactMutation) ResetCbirtharea() {
  11992. m.cbirtharea = nil
  11993. }
  11994. // SetCidcardNo sets the "cidcard_no" field.
  11995. func (m *ContactMutation) SetCidcardNo(s string) {
  11996. m.cidcard_no = &s
  11997. }
  11998. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  11999. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  12000. v := m.cidcard_no
  12001. if v == nil {
  12002. return
  12003. }
  12004. return *v, true
  12005. }
  12006. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  12007. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12009. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  12010. if !m.op.Is(OpUpdateOne) {
  12011. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  12012. }
  12013. if m.id == nil || m.oldValue == nil {
  12014. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  12015. }
  12016. oldValue, err := m.oldValue(ctx)
  12017. if err != nil {
  12018. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  12019. }
  12020. return oldValue.CidcardNo, nil
  12021. }
  12022. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  12023. func (m *ContactMutation) ResetCidcardNo() {
  12024. m.cidcard_no = nil
  12025. }
  12026. // SetCtitle sets the "ctitle" field.
  12027. func (m *ContactMutation) SetCtitle(s string) {
  12028. m.ctitle = &s
  12029. }
  12030. // Ctitle returns the value of the "ctitle" field in the mutation.
  12031. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  12032. v := m.ctitle
  12033. if v == nil {
  12034. return
  12035. }
  12036. return *v, true
  12037. }
  12038. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  12039. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12041. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  12042. if !m.op.Is(OpUpdateOne) {
  12043. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  12044. }
  12045. if m.id == nil || m.oldValue == nil {
  12046. return v, errors.New("OldCtitle requires an ID field in the mutation")
  12047. }
  12048. oldValue, err := m.oldValue(ctx)
  12049. if err != nil {
  12050. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  12051. }
  12052. return oldValue.Ctitle, nil
  12053. }
  12054. // ResetCtitle resets all changes to the "ctitle" field.
  12055. func (m *ContactMutation) ResetCtitle() {
  12056. m.ctitle = nil
  12057. }
  12058. // SetCc sets the "cc" field.
  12059. func (m *ContactMutation) SetCc(s string) {
  12060. m.cc = &s
  12061. }
  12062. // Cc returns the value of the "cc" field in the mutation.
  12063. func (m *ContactMutation) Cc() (r string, exists bool) {
  12064. v := m.cc
  12065. if v == nil {
  12066. return
  12067. }
  12068. return *v, true
  12069. }
  12070. // OldCc returns the old "cc" field's value of the Contact entity.
  12071. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12073. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  12074. if !m.op.Is(OpUpdateOne) {
  12075. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  12076. }
  12077. if m.id == nil || m.oldValue == nil {
  12078. return v, errors.New("OldCc requires an ID field in the mutation")
  12079. }
  12080. oldValue, err := m.oldValue(ctx)
  12081. if err != nil {
  12082. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  12083. }
  12084. return oldValue.Cc, nil
  12085. }
  12086. // ResetCc resets all changes to the "cc" field.
  12087. func (m *ContactMutation) ResetCc() {
  12088. m.cc = nil
  12089. }
  12090. // SetPhone sets the "phone" field.
  12091. func (m *ContactMutation) SetPhone(s string) {
  12092. m.phone = &s
  12093. }
  12094. // Phone returns the value of the "phone" field in the mutation.
  12095. func (m *ContactMutation) Phone() (r string, exists bool) {
  12096. v := m.phone
  12097. if v == nil {
  12098. return
  12099. }
  12100. return *v, true
  12101. }
  12102. // OldPhone returns the old "phone" field's value of the Contact entity.
  12103. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12105. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  12106. if !m.op.Is(OpUpdateOne) {
  12107. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  12108. }
  12109. if m.id == nil || m.oldValue == nil {
  12110. return v, errors.New("OldPhone requires an ID field in the mutation")
  12111. }
  12112. oldValue, err := m.oldValue(ctx)
  12113. if err != nil {
  12114. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  12115. }
  12116. return oldValue.Phone, nil
  12117. }
  12118. // ResetPhone resets all changes to the "phone" field.
  12119. func (m *ContactMutation) ResetPhone() {
  12120. m.phone = nil
  12121. }
  12122. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  12123. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  12124. if m.contact_relationships == nil {
  12125. m.contact_relationships = make(map[uint64]struct{})
  12126. }
  12127. for i := range ids {
  12128. m.contact_relationships[ids[i]] = struct{}{}
  12129. }
  12130. }
  12131. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  12132. func (m *ContactMutation) ClearContactRelationships() {
  12133. m.clearedcontact_relationships = true
  12134. }
  12135. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  12136. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  12137. return m.clearedcontact_relationships
  12138. }
  12139. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  12140. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  12141. if m.removedcontact_relationships == nil {
  12142. m.removedcontact_relationships = make(map[uint64]struct{})
  12143. }
  12144. for i := range ids {
  12145. delete(m.contact_relationships, ids[i])
  12146. m.removedcontact_relationships[ids[i]] = struct{}{}
  12147. }
  12148. }
  12149. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  12150. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  12151. for id := range m.removedcontact_relationships {
  12152. ids = append(ids, id)
  12153. }
  12154. return
  12155. }
  12156. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  12157. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  12158. for id := range m.contact_relationships {
  12159. ids = append(ids, id)
  12160. }
  12161. return
  12162. }
  12163. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  12164. func (m *ContactMutation) ResetContactRelationships() {
  12165. m.contact_relationships = nil
  12166. m.clearedcontact_relationships = false
  12167. m.removedcontact_relationships = nil
  12168. }
  12169. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  12170. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  12171. if m.contact_messages == nil {
  12172. m.contact_messages = make(map[uint64]struct{})
  12173. }
  12174. for i := range ids {
  12175. m.contact_messages[ids[i]] = struct{}{}
  12176. }
  12177. }
  12178. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  12179. func (m *ContactMutation) ClearContactMessages() {
  12180. m.clearedcontact_messages = true
  12181. }
  12182. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  12183. func (m *ContactMutation) ContactMessagesCleared() bool {
  12184. return m.clearedcontact_messages
  12185. }
  12186. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  12187. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  12188. if m.removedcontact_messages == nil {
  12189. m.removedcontact_messages = make(map[uint64]struct{})
  12190. }
  12191. for i := range ids {
  12192. delete(m.contact_messages, ids[i])
  12193. m.removedcontact_messages[ids[i]] = struct{}{}
  12194. }
  12195. }
  12196. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  12197. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  12198. for id := range m.removedcontact_messages {
  12199. ids = append(ids, id)
  12200. }
  12201. return
  12202. }
  12203. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  12204. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  12205. for id := range m.contact_messages {
  12206. ids = append(ids, id)
  12207. }
  12208. return
  12209. }
  12210. // ResetContactMessages resets all changes to the "contact_messages" edge.
  12211. func (m *ContactMutation) ResetContactMessages() {
  12212. m.contact_messages = nil
  12213. m.clearedcontact_messages = false
  12214. m.removedcontact_messages = nil
  12215. }
  12216. // Where appends a list predicates to the ContactMutation builder.
  12217. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  12218. m.predicates = append(m.predicates, ps...)
  12219. }
  12220. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  12221. // users can use type-assertion to append predicates that do not depend on any generated package.
  12222. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  12223. p := make([]predicate.Contact, len(ps))
  12224. for i := range ps {
  12225. p[i] = ps[i]
  12226. }
  12227. m.Where(p...)
  12228. }
  12229. // Op returns the operation name.
  12230. func (m *ContactMutation) Op() Op {
  12231. return m.op
  12232. }
  12233. // SetOp allows setting the mutation operation.
  12234. func (m *ContactMutation) SetOp(op Op) {
  12235. m.op = op
  12236. }
  12237. // Type returns the node type of this mutation (Contact).
  12238. func (m *ContactMutation) Type() string {
  12239. return m.typ
  12240. }
  12241. // Fields returns all fields that were changed during this mutation. Note that in
  12242. // order to get all numeric fields that were incremented/decremented, call
  12243. // AddedFields().
  12244. func (m *ContactMutation) Fields() []string {
  12245. fields := make([]string, 0, 30)
  12246. if m.created_at != nil {
  12247. fields = append(fields, contact.FieldCreatedAt)
  12248. }
  12249. if m.updated_at != nil {
  12250. fields = append(fields, contact.FieldUpdatedAt)
  12251. }
  12252. if m.status != nil {
  12253. fields = append(fields, contact.FieldStatus)
  12254. }
  12255. if m.deleted_at != nil {
  12256. fields = append(fields, contact.FieldDeletedAt)
  12257. }
  12258. if m.wx_wxid != nil {
  12259. fields = append(fields, contact.FieldWxWxid)
  12260. }
  12261. if m._type != nil {
  12262. fields = append(fields, contact.FieldType)
  12263. }
  12264. if m.wxid != nil {
  12265. fields = append(fields, contact.FieldWxid)
  12266. }
  12267. if m.account != nil {
  12268. fields = append(fields, contact.FieldAccount)
  12269. }
  12270. if m.nickname != nil {
  12271. fields = append(fields, contact.FieldNickname)
  12272. }
  12273. if m.markname != nil {
  12274. fields = append(fields, contact.FieldMarkname)
  12275. }
  12276. if m.headimg != nil {
  12277. fields = append(fields, contact.FieldHeadimg)
  12278. }
  12279. if m.sex != nil {
  12280. fields = append(fields, contact.FieldSex)
  12281. }
  12282. if m.starrole != nil {
  12283. fields = append(fields, contact.FieldStarrole)
  12284. }
  12285. if m.dontseeit != nil {
  12286. fields = append(fields, contact.FieldDontseeit)
  12287. }
  12288. if m.dontseeme != nil {
  12289. fields = append(fields, contact.FieldDontseeme)
  12290. }
  12291. if m.lag != nil {
  12292. fields = append(fields, contact.FieldLag)
  12293. }
  12294. if m.gid != nil {
  12295. fields = append(fields, contact.FieldGid)
  12296. }
  12297. if m.gname != nil {
  12298. fields = append(fields, contact.FieldGname)
  12299. }
  12300. if m.v3 != nil {
  12301. fields = append(fields, contact.FieldV3)
  12302. }
  12303. if m.organization_id != nil {
  12304. fields = append(fields, contact.FieldOrganizationID)
  12305. }
  12306. if m.ctype != nil {
  12307. fields = append(fields, contact.FieldCtype)
  12308. }
  12309. if m.cage != nil {
  12310. fields = append(fields, contact.FieldCage)
  12311. }
  12312. if m.cname != nil {
  12313. fields = append(fields, contact.FieldCname)
  12314. }
  12315. if m.carea != nil {
  12316. fields = append(fields, contact.FieldCarea)
  12317. }
  12318. if m.cbirthday != nil {
  12319. fields = append(fields, contact.FieldCbirthday)
  12320. }
  12321. if m.cbirtharea != nil {
  12322. fields = append(fields, contact.FieldCbirtharea)
  12323. }
  12324. if m.cidcard_no != nil {
  12325. fields = append(fields, contact.FieldCidcardNo)
  12326. }
  12327. if m.ctitle != nil {
  12328. fields = append(fields, contact.FieldCtitle)
  12329. }
  12330. if m.cc != nil {
  12331. fields = append(fields, contact.FieldCc)
  12332. }
  12333. if m.phone != nil {
  12334. fields = append(fields, contact.FieldPhone)
  12335. }
  12336. return fields
  12337. }
  12338. // Field returns the value of a field with the given name. The second boolean
  12339. // return value indicates that this field was not set, or was not defined in the
  12340. // schema.
  12341. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  12342. switch name {
  12343. case contact.FieldCreatedAt:
  12344. return m.CreatedAt()
  12345. case contact.FieldUpdatedAt:
  12346. return m.UpdatedAt()
  12347. case contact.FieldStatus:
  12348. return m.Status()
  12349. case contact.FieldDeletedAt:
  12350. return m.DeletedAt()
  12351. case contact.FieldWxWxid:
  12352. return m.WxWxid()
  12353. case contact.FieldType:
  12354. return m.GetType()
  12355. case contact.FieldWxid:
  12356. return m.Wxid()
  12357. case contact.FieldAccount:
  12358. return m.Account()
  12359. case contact.FieldNickname:
  12360. return m.Nickname()
  12361. case contact.FieldMarkname:
  12362. return m.Markname()
  12363. case contact.FieldHeadimg:
  12364. return m.Headimg()
  12365. case contact.FieldSex:
  12366. return m.Sex()
  12367. case contact.FieldStarrole:
  12368. return m.Starrole()
  12369. case contact.FieldDontseeit:
  12370. return m.Dontseeit()
  12371. case contact.FieldDontseeme:
  12372. return m.Dontseeme()
  12373. case contact.FieldLag:
  12374. return m.Lag()
  12375. case contact.FieldGid:
  12376. return m.Gid()
  12377. case contact.FieldGname:
  12378. return m.Gname()
  12379. case contact.FieldV3:
  12380. return m.V3()
  12381. case contact.FieldOrganizationID:
  12382. return m.OrganizationID()
  12383. case contact.FieldCtype:
  12384. return m.Ctype()
  12385. case contact.FieldCage:
  12386. return m.Cage()
  12387. case contact.FieldCname:
  12388. return m.Cname()
  12389. case contact.FieldCarea:
  12390. return m.Carea()
  12391. case contact.FieldCbirthday:
  12392. return m.Cbirthday()
  12393. case contact.FieldCbirtharea:
  12394. return m.Cbirtharea()
  12395. case contact.FieldCidcardNo:
  12396. return m.CidcardNo()
  12397. case contact.FieldCtitle:
  12398. return m.Ctitle()
  12399. case contact.FieldCc:
  12400. return m.Cc()
  12401. case contact.FieldPhone:
  12402. return m.Phone()
  12403. }
  12404. return nil, false
  12405. }
  12406. // OldField returns the old value of the field from the database. An error is
  12407. // returned if the mutation operation is not UpdateOne, or the query to the
  12408. // database failed.
  12409. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12410. switch name {
  12411. case contact.FieldCreatedAt:
  12412. return m.OldCreatedAt(ctx)
  12413. case contact.FieldUpdatedAt:
  12414. return m.OldUpdatedAt(ctx)
  12415. case contact.FieldStatus:
  12416. return m.OldStatus(ctx)
  12417. case contact.FieldDeletedAt:
  12418. return m.OldDeletedAt(ctx)
  12419. case contact.FieldWxWxid:
  12420. return m.OldWxWxid(ctx)
  12421. case contact.FieldType:
  12422. return m.OldType(ctx)
  12423. case contact.FieldWxid:
  12424. return m.OldWxid(ctx)
  12425. case contact.FieldAccount:
  12426. return m.OldAccount(ctx)
  12427. case contact.FieldNickname:
  12428. return m.OldNickname(ctx)
  12429. case contact.FieldMarkname:
  12430. return m.OldMarkname(ctx)
  12431. case contact.FieldHeadimg:
  12432. return m.OldHeadimg(ctx)
  12433. case contact.FieldSex:
  12434. return m.OldSex(ctx)
  12435. case contact.FieldStarrole:
  12436. return m.OldStarrole(ctx)
  12437. case contact.FieldDontseeit:
  12438. return m.OldDontseeit(ctx)
  12439. case contact.FieldDontseeme:
  12440. return m.OldDontseeme(ctx)
  12441. case contact.FieldLag:
  12442. return m.OldLag(ctx)
  12443. case contact.FieldGid:
  12444. return m.OldGid(ctx)
  12445. case contact.FieldGname:
  12446. return m.OldGname(ctx)
  12447. case contact.FieldV3:
  12448. return m.OldV3(ctx)
  12449. case contact.FieldOrganizationID:
  12450. return m.OldOrganizationID(ctx)
  12451. case contact.FieldCtype:
  12452. return m.OldCtype(ctx)
  12453. case contact.FieldCage:
  12454. return m.OldCage(ctx)
  12455. case contact.FieldCname:
  12456. return m.OldCname(ctx)
  12457. case contact.FieldCarea:
  12458. return m.OldCarea(ctx)
  12459. case contact.FieldCbirthday:
  12460. return m.OldCbirthday(ctx)
  12461. case contact.FieldCbirtharea:
  12462. return m.OldCbirtharea(ctx)
  12463. case contact.FieldCidcardNo:
  12464. return m.OldCidcardNo(ctx)
  12465. case contact.FieldCtitle:
  12466. return m.OldCtitle(ctx)
  12467. case contact.FieldCc:
  12468. return m.OldCc(ctx)
  12469. case contact.FieldPhone:
  12470. return m.OldPhone(ctx)
  12471. }
  12472. return nil, fmt.Errorf("unknown Contact field %s", name)
  12473. }
  12474. // SetField sets the value of a field with the given name. It returns an error if
  12475. // the field is not defined in the schema, or if the type mismatched the field
  12476. // type.
  12477. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  12478. switch name {
  12479. case contact.FieldCreatedAt:
  12480. v, ok := value.(time.Time)
  12481. if !ok {
  12482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12483. }
  12484. m.SetCreatedAt(v)
  12485. return nil
  12486. case contact.FieldUpdatedAt:
  12487. v, ok := value.(time.Time)
  12488. if !ok {
  12489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12490. }
  12491. m.SetUpdatedAt(v)
  12492. return nil
  12493. case contact.FieldStatus:
  12494. v, ok := value.(uint8)
  12495. if !ok {
  12496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12497. }
  12498. m.SetStatus(v)
  12499. return nil
  12500. case contact.FieldDeletedAt:
  12501. v, ok := value.(time.Time)
  12502. if !ok {
  12503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12504. }
  12505. m.SetDeletedAt(v)
  12506. return nil
  12507. case contact.FieldWxWxid:
  12508. v, ok := value.(string)
  12509. if !ok {
  12510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12511. }
  12512. m.SetWxWxid(v)
  12513. return nil
  12514. case contact.FieldType:
  12515. v, ok := value.(int)
  12516. if !ok {
  12517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12518. }
  12519. m.SetType(v)
  12520. return nil
  12521. case contact.FieldWxid:
  12522. v, ok := value.(string)
  12523. if !ok {
  12524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12525. }
  12526. m.SetWxid(v)
  12527. return nil
  12528. case contact.FieldAccount:
  12529. v, ok := value.(string)
  12530. if !ok {
  12531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12532. }
  12533. m.SetAccount(v)
  12534. return nil
  12535. case contact.FieldNickname:
  12536. v, ok := value.(string)
  12537. if !ok {
  12538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12539. }
  12540. m.SetNickname(v)
  12541. return nil
  12542. case contact.FieldMarkname:
  12543. v, ok := value.(string)
  12544. if !ok {
  12545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12546. }
  12547. m.SetMarkname(v)
  12548. return nil
  12549. case contact.FieldHeadimg:
  12550. v, ok := value.(string)
  12551. if !ok {
  12552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12553. }
  12554. m.SetHeadimg(v)
  12555. return nil
  12556. case contact.FieldSex:
  12557. v, ok := value.(int)
  12558. if !ok {
  12559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12560. }
  12561. m.SetSex(v)
  12562. return nil
  12563. case contact.FieldStarrole:
  12564. v, ok := value.(string)
  12565. if !ok {
  12566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12567. }
  12568. m.SetStarrole(v)
  12569. return nil
  12570. case contact.FieldDontseeit:
  12571. v, ok := value.(int)
  12572. if !ok {
  12573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12574. }
  12575. m.SetDontseeit(v)
  12576. return nil
  12577. case contact.FieldDontseeme:
  12578. v, ok := value.(int)
  12579. if !ok {
  12580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12581. }
  12582. m.SetDontseeme(v)
  12583. return nil
  12584. case contact.FieldLag:
  12585. v, ok := value.(string)
  12586. if !ok {
  12587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12588. }
  12589. m.SetLag(v)
  12590. return nil
  12591. case contact.FieldGid:
  12592. v, ok := value.(string)
  12593. if !ok {
  12594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12595. }
  12596. m.SetGid(v)
  12597. return nil
  12598. case contact.FieldGname:
  12599. v, ok := value.(string)
  12600. if !ok {
  12601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12602. }
  12603. m.SetGname(v)
  12604. return nil
  12605. case contact.FieldV3:
  12606. v, ok := value.(string)
  12607. if !ok {
  12608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12609. }
  12610. m.SetV3(v)
  12611. return nil
  12612. case contact.FieldOrganizationID:
  12613. v, ok := value.(uint64)
  12614. if !ok {
  12615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12616. }
  12617. m.SetOrganizationID(v)
  12618. return nil
  12619. case contact.FieldCtype:
  12620. v, ok := value.(uint64)
  12621. if !ok {
  12622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12623. }
  12624. m.SetCtype(v)
  12625. return nil
  12626. case contact.FieldCage:
  12627. v, ok := value.(int)
  12628. if !ok {
  12629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12630. }
  12631. m.SetCage(v)
  12632. return nil
  12633. case contact.FieldCname:
  12634. v, ok := value.(string)
  12635. if !ok {
  12636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12637. }
  12638. m.SetCname(v)
  12639. return nil
  12640. case contact.FieldCarea:
  12641. v, ok := value.(string)
  12642. if !ok {
  12643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12644. }
  12645. m.SetCarea(v)
  12646. return nil
  12647. case contact.FieldCbirthday:
  12648. v, ok := value.(string)
  12649. if !ok {
  12650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12651. }
  12652. m.SetCbirthday(v)
  12653. return nil
  12654. case contact.FieldCbirtharea:
  12655. v, ok := value.(string)
  12656. if !ok {
  12657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12658. }
  12659. m.SetCbirtharea(v)
  12660. return nil
  12661. case contact.FieldCidcardNo:
  12662. v, ok := value.(string)
  12663. if !ok {
  12664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12665. }
  12666. m.SetCidcardNo(v)
  12667. return nil
  12668. case contact.FieldCtitle:
  12669. v, ok := value.(string)
  12670. if !ok {
  12671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12672. }
  12673. m.SetCtitle(v)
  12674. return nil
  12675. case contact.FieldCc:
  12676. v, ok := value.(string)
  12677. if !ok {
  12678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12679. }
  12680. m.SetCc(v)
  12681. return nil
  12682. case contact.FieldPhone:
  12683. v, ok := value.(string)
  12684. if !ok {
  12685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12686. }
  12687. m.SetPhone(v)
  12688. return nil
  12689. }
  12690. return fmt.Errorf("unknown Contact field %s", name)
  12691. }
  12692. // AddedFields returns all numeric fields that were incremented/decremented during
  12693. // this mutation.
  12694. func (m *ContactMutation) AddedFields() []string {
  12695. var fields []string
  12696. if m.addstatus != nil {
  12697. fields = append(fields, contact.FieldStatus)
  12698. }
  12699. if m.add_type != nil {
  12700. fields = append(fields, contact.FieldType)
  12701. }
  12702. if m.addsex != nil {
  12703. fields = append(fields, contact.FieldSex)
  12704. }
  12705. if m.adddontseeit != nil {
  12706. fields = append(fields, contact.FieldDontseeit)
  12707. }
  12708. if m.adddontseeme != nil {
  12709. fields = append(fields, contact.FieldDontseeme)
  12710. }
  12711. if m.addorganization_id != nil {
  12712. fields = append(fields, contact.FieldOrganizationID)
  12713. }
  12714. if m.addctype != nil {
  12715. fields = append(fields, contact.FieldCtype)
  12716. }
  12717. if m.addcage != nil {
  12718. fields = append(fields, contact.FieldCage)
  12719. }
  12720. return fields
  12721. }
  12722. // AddedField returns the numeric value that was incremented/decremented on a field
  12723. // with the given name. The second boolean return value indicates that this field
  12724. // was not set, or was not defined in the schema.
  12725. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  12726. switch name {
  12727. case contact.FieldStatus:
  12728. return m.AddedStatus()
  12729. case contact.FieldType:
  12730. return m.AddedType()
  12731. case contact.FieldSex:
  12732. return m.AddedSex()
  12733. case contact.FieldDontseeit:
  12734. return m.AddedDontseeit()
  12735. case contact.FieldDontseeme:
  12736. return m.AddedDontseeme()
  12737. case contact.FieldOrganizationID:
  12738. return m.AddedOrganizationID()
  12739. case contact.FieldCtype:
  12740. return m.AddedCtype()
  12741. case contact.FieldCage:
  12742. return m.AddedCage()
  12743. }
  12744. return nil, false
  12745. }
  12746. // AddField adds the value to the field with the given name. It returns an error if
  12747. // the field is not defined in the schema, or if the type mismatched the field
  12748. // type.
  12749. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  12750. switch name {
  12751. case contact.FieldStatus:
  12752. v, ok := value.(int8)
  12753. if !ok {
  12754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12755. }
  12756. m.AddStatus(v)
  12757. return nil
  12758. case contact.FieldType:
  12759. v, ok := value.(int)
  12760. if !ok {
  12761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12762. }
  12763. m.AddType(v)
  12764. return nil
  12765. case contact.FieldSex:
  12766. v, ok := value.(int)
  12767. if !ok {
  12768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12769. }
  12770. m.AddSex(v)
  12771. return nil
  12772. case contact.FieldDontseeit:
  12773. v, ok := value.(int)
  12774. if !ok {
  12775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12776. }
  12777. m.AddDontseeit(v)
  12778. return nil
  12779. case contact.FieldDontseeme:
  12780. v, ok := value.(int)
  12781. if !ok {
  12782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12783. }
  12784. m.AddDontseeme(v)
  12785. return nil
  12786. case contact.FieldOrganizationID:
  12787. v, ok := value.(int64)
  12788. if !ok {
  12789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12790. }
  12791. m.AddOrganizationID(v)
  12792. return nil
  12793. case contact.FieldCtype:
  12794. v, ok := value.(int64)
  12795. if !ok {
  12796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12797. }
  12798. m.AddCtype(v)
  12799. return nil
  12800. case contact.FieldCage:
  12801. v, ok := value.(int)
  12802. if !ok {
  12803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12804. }
  12805. m.AddCage(v)
  12806. return nil
  12807. }
  12808. return fmt.Errorf("unknown Contact numeric field %s", name)
  12809. }
  12810. // ClearedFields returns all nullable fields that were cleared during this
  12811. // mutation.
  12812. func (m *ContactMutation) ClearedFields() []string {
  12813. var fields []string
  12814. if m.FieldCleared(contact.FieldStatus) {
  12815. fields = append(fields, contact.FieldStatus)
  12816. }
  12817. if m.FieldCleared(contact.FieldDeletedAt) {
  12818. fields = append(fields, contact.FieldDeletedAt)
  12819. }
  12820. if m.FieldCleared(contact.FieldType) {
  12821. fields = append(fields, contact.FieldType)
  12822. }
  12823. if m.FieldCleared(contact.FieldOrganizationID) {
  12824. fields = append(fields, contact.FieldOrganizationID)
  12825. }
  12826. return fields
  12827. }
  12828. // FieldCleared returns a boolean indicating if a field with the given name was
  12829. // cleared in this mutation.
  12830. func (m *ContactMutation) FieldCleared(name string) bool {
  12831. _, ok := m.clearedFields[name]
  12832. return ok
  12833. }
  12834. // ClearField clears the value of the field with the given name. It returns an
  12835. // error if the field is not defined in the schema.
  12836. func (m *ContactMutation) ClearField(name string) error {
  12837. switch name {
  12838. case contact.FieldStatus:
  12839. m.ClearStatus()
  12840. return nil
  12841. case contact.FieldDeletedAt:
  12842. m.ClearDeletedAt()
  12843. return nil
  12844. case contact.FieldType:
  12845. m.ClearType()
  12846. return nil
  12847. case contact.FieldOrganizationID:
  12848. m.ClearOrganizationID()
  12849. return nil
  12850. }
  12851. return fmt.Errorf("unknown Contact nullable field %s", name)
  12852. }
  12853. // ResetField resets all changes in the mutation for the field with the given name.
  12854. // It returns an error if the field is not defined in the schema.
  12855. func (m *ContactMutation) ResetField(name string) error {
  12856. switch name {
  12857. case contact.FieldCreatedAt:
  12858. m.ResetCreatedAt()
  12859. return nil
  12860. case contact.FieldUpdatedAt:
  12861. m.ResetUpdatedAt()
  12862. return nil
  12863. case contact.FieldStatus:
  12864. m.ResetStatus()
  12865. return nil
  12866. case contact.FieldDeletedAt:
  12867. m.ResetDeletedAt()
  12868. return nil
  12869. case contact.FieldWxWxid:
  12870. m.ResetWxWxid()
  12871. return nil
  12872. case contact.FieldType:
  12873. m.ResetType()
  12874. return nil
  12875. case contact.FieldWxid:
  12876. m.ResetWxid()
  12877. return nil
  12878. case contact.FieldAccount:
  12879. m.ResetAccount()
  12880. return nil
  12881. case contact.FieldNickname:
  12882. m.ResetNickname()
  12883. return nil
  12884. case contact.FieldMarkname:
  12885. m.ResetMarkname()
  12886. return nil
  12887. case contact.FieldHeadimg:
  12888. m.ResetHeadimg()
  12889. return nil
  12890. case contact.FieldSex:
  12891. m.ResetSex()
  12892. return nil
  12893. case contact.FieldStarrole:
  12894. m.ResetStarrole()
  12895. return nil
  12896. case contact.FieldDontseeit:
  12897. m.ResetDontseeit()
  12898. return nil
  12899. case contact.FieldDontseeme:
  12900. m.ResetDontseeme()
  12901. return nil
  12902. case contact.FieldLag:
  12903. m.ResetLag()
  12904. return nil
  12905. case contact.FieldGid:
  12906. m.ResetGid()
  12907. return nil
  12908. case contact.FieldGname:
  12909. m.ResetGname()
  12910. return nil
  12911. case contact.FieldV3:
  12912. m.ResetV3()
  12913. return nil
  12914. case contact.FieldOrganizationID:
  12915. m.ResetOrganizationID()
  12916. return nil
  12917. case contact.FieldCtype:
  12918. m.ResetCtype()
  12919. return nil
  12920. case contact.FieldCage:
  12921. m.ResetCage()
  12922. return nil
  12923. case contact.FieldCname:
  12924. m.ResetCname()
  12925. return nil
  12926. case contact.FieldCarea:
  12927. m.ResetCarea()
  12928. return nil
  12929. case contact.FieldCbirthday:
  12930. m.ResetCbirthday()
  12931. return nil
  12932. case contact.FieldCbirtharea:
  12933. m.ResetCbirtharea()
  12934. return nil
  12935. case contact.FieldCidcardNo:
  12936. m.ResetCidcardNo()
  12937. return nil
  12938. case contact.FieldCtitle:
  12939. m.ResetCtitle()
  12940. return nil
  12941. case contact.FieldCc:
  12942. m.ResetCc()
  12943. return nil
  12944. case contact.FieldPhone:
  12945. m.ResetPhone()
  12946. return nil
  12947. }
  12948. return fmt.Errorf("unknown Contact field %s", name)
  12949. }
  12950. // AddedEdges returns all edge names that were set/added in this mutation.
  12951. func (m *ContactMutation) AddedEdges() []string {
  12952. edges := make([]string, 0, 2)
  12953. if m.contact_relationships != nil {
  12954. edges = append(edges, contact.EdgeContactRelationships)
  12955. }
  12956. if m.contact_messages != nil {
  12957. edges = append(edges, contact.EdgeContactMessages)
  12958. }
  12959. return edges
  12960. }
  12961. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12962. // name in this mutation.
  12963. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  12964. switch name {
  12965. case contact.EdgeContactRelationships:
  12966. ids := make([]ent.Value, 0, len(m.contact_relationships))
  12967. for id := range m.contact_relationships {
  12968. ids = append(ids, id)
  12969. }
  12970. return ids
  12971. case contact.EdgeContactMessages:
  12972. ids := make([]ent.Value, 0, len(m.contact_messages))
  12973. for id := range m.contact_messages {
  12974. ids = append(ids, id)
  12975. }
  12976. return ids
  12977. }
  12978. return nil
  12979. }
  12980. // RemovedEdges returns all edge names that were removed in this mutation.
  12981. func (m *ContactMutation) RemovedEdges() []string {
  12982. edges := make([]string, 0, 2)
  12983. if m.removedcontact_relationships != nil {
  12984. edges = append(edges, contact.EdgeContactRelationships)
  12985. }
  12986. if m.removedcontact_messages != nil {
  12987. edges = append(edges, contact.EdgeContactMessages)
  12988. }
  12989. return edges
  12990. }
  12991. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12992. // the given name in this mutation.
  12993. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  12994. switch name {
  12995. case contact.EdgeContactRelationships:
  12996. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  12997. for id := range m.removedcontact_relationships {
  12998. ids = append(ids, id)
  12999. }
  13000. return ids
  13001. case contact.EdgeContactMessages:
  13002. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  13003. for id := range m.removedcontact_messages {
  13004. ids = append(ids, id)
  13005. }
  13006. return ids
  13007. }
  13008. return nil
  13009. }
  13010. // ClearedEdges returns all edge names that were cleared in this mutation.
  13011. func (m *ContactMutation) ClearedEdges() []string {
  13012. edges := make([]string, 0, 2)
  13013. if m.clearedcontact_relationships {
  13014. edges = append(edges, contact.EdgeContactRelationships)
  13015. }
  13016. if m.clearedcontact_messages {
  13017. edges = append(edges, contact.EdgeContactMessages)
  13018. }
  13019. return edges
  13020. }
  13021. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13022. // was cleared in this mutation.
  13023. func (m *ContactMutation) EdgeCleared(name string) bool {
  13024. switch name {
  13025. case contact.EdgeContactRelationships:
  13026. return m.clearedcontact_relationships
  13027. case contact.EdgeContactMessages:
  13028. return m.clearedcontact_messages
  13029. }
  13030. return false
  13031. }
  13032. // ClearEdge clears the value of the edge with the given name. It returns an error
  13033. // if that edge is not defined in the schema.
  13034. func (m *ContactMutation) ClearEdge(name string) error {
  13035. switch name {
  13036. }
  13037. return fmt.Errorf("unknown Contact unique edge %s", name)
  13038. }
  13039. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13040. // It returns an error if the edge is not defined in the schema.
  13041. func (m *ContactMutation) ResetEdge(name string) error {
  13042. switch name {
  13043. case contact.EdgeContactRelationships:
  13044. m.ResetContactRelationships()
  13045. return nil
  13046. case contact.EdgeContactMessages:
  13047. m.ResetContactMessages()
  13048. return nil
  13049. }
  13050. return fmt.Errorf("unknown Contact edge %s", name)
  13051. }
  13052. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  13053. type CreditBalanceMutation struct {
  13054. config
  13055. op Op
  13056. typ string
  13057. id *uint64
  13058. created_at *time.Time
  13059. updated_at *time.Time
  13060. deleted_at *time.Time
  13061. user_id *string
  13062. balance *float32
  13063. addbalance *float32
  13064. status *int
  13065. addstatus *int
  13066. organization_id *uint64
  13067. addorganization_id *int64
  13068. clearedFields map[string]struct{}
  13069. done bool
  13070. oldValue func(context.Context) (*CreditBalance, error)
  13071. predicates []predicate.CreditBalance
  13072. }
  13073. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  13074. // creditbalanceOption allows management of the mutation configuration using functional options.
  13075. type creditbalanceOption func(*CreditBalanceMutation)
  13076. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  13077. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  13078. m := &CreditBalanceMutation{
  13079. config: c,
  13080. op: op,
  13081. typ: TypeCreditBalance,
  13082. clearedFields: make(map[string]struct{}),
  13083. }
  13084. for _, opt := range opts {
  13085. opt(m)
  13086. }
  13087. return m
  13088. }
  13089. // withCreditBalanceID sets the ID field of the mutation.
  13090. func withCreditBalanceID(id uint64) creditbalanceOption {
  13091. return func(m *CreditBalanceMutation) {
  13092. var (
  13093. err error
  13094. once sync.Once
  13095. value *CreditBalance
  13096. )
  13097. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  13098. once.Do(func() {
  13099. if m.done {
  13100. err = errors.New("querying old values post mutation is not allowed")
  13101. } else {
  13102. value, err = m.Client().CreditBalance.Get(ctx, id)
  13103. }
  13104. })
  13105. return value, err
  13106. }
  13107. m.id = &id
  13108. }
  13109. }
  13110. // withCreditBalance sets the old CreditBalance of the mutation.
  13111. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  13112. return func(m *CreditBalanceMutation) {
  13113. m.oldValue = func(context.Context) (*CreditBalance, error) {
  13114. return node, nil
  13115. }
  13116. m.id = &node.ID
  13117. }
  13118. }
  13119. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13120. // executed in a transaction (ent.Tx), a transactional client is returned.
  13121. func (m CreditBalanceMutation) Client() *Client {
  13122. client := &Client{config: m.config}
  13123. client.init()
  13124. return client
  13125. }
  13126. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13127. // it returns an error otherwise.
  13128. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  13129. if _, ok := m.driver.(*txDriver); !ok {
  13130. return nil, errors.New("ent: mutation is not running in a transaction")
  13131. }
  13132. tx := &Tx{config: m.config}
  13133. tx.init()
  13134. return tx, nil
  13135. }
  13136. // SetID sets the value of the id field. Note that this
  13137. // operation is only accepted on creation of CreditBalance entities.
  13138. func (m *CreditBalanceMutation) SetID(id uint64) {
  13139. m.id = &id
  13140. }
  13141. // ID returns the ID value in the mutation. Note that the ID is only available
  13142. // if it was provided to the builder or after it was returned from the database.
  13143. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  13144. if m.id == nil {
  13145. return
  13146. }
  13147. return *m.id, true
  13148. }
  13149. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13150. // That means, if the mutation is applied within a transaction with an isolation level such
  13151. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13152. // or updated by the mutation.
  13153. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  13154. switch {
  13155. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13156. id, exists := m.ID()
  13157. if exists {
  13158. return []uint64{id}, nil
  13159. }
  13160. fallthrough
  13161. case m.op.Is(OpUpdate | OpDelete):
  13162. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  13163. default:
  13164. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13165. }
  13166. }
  13167. // SetCreatedAt sets the "created_at" field.
  13168. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  13169. m.created_at = &t
  13170. }
  13171. // CreatedAt returns the value of the "created_at" field in the mutation.
  13172. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  13173. v := m.created_at
  13174. if v == nil {
  13175. return
  13176. }
  13177. return *v, true
  13178. }
  13179. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  13180. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13182. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13183. if !m.op.Is(OpUpdateOne) {
  13184. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13185. }
  13186. if m.id == nil || m.oldValue == nil {
  13187. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13188. }
  13189. oldValue, err := m.oldValue(ctx)
  13190. if err != nil {
  13191. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13192. }
  13193. return oldValue.CreatedAt, nil
  13194. }
  13195. // ResetCreatedAt resets all changes to the "created_at" field.
  13196. func (m *CreditBalanceMutation) ResetCreatedAt() {
  13197. m.created_at = nil
  13198. }
  13199. // SetUpdatedAt sets the "updated_at" field.
  13200. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  13201. m.updated_at = &t
  13202. }
  13203. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13204. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  13205. v := m.updated_at
  13206. if v == nil {
  13207. return
  13208. }
  13209. return *v, true
  13210. }
  13211. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  13212. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13214. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13215. if !m.op.Is(OpUpdateOne) {
  13216. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13217. }
  13218. if m.id == nil || m.oldValue == nil {
  13219. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13220. }
  13221. oldValue, err := m.oldValue(ctx)
  13222. if err != nil {
  13223. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13224. }
  13225. return oldValue.UpdatedAt, nil
  13226. }
  13227. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13228. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  13229. m.updated_at = nil
  13230. }
  13231. // SetDeletedAt sets the "deleted_at" field.
  13232. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  13233. m.deleted_at = &t
  13234. }
  13235. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13236. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  13237. v := m.deleted_at
  13238. if v == nil {
  13239. return
  13240. }
  13241. return *v, true
  13242. }
  13243. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  13244. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13246. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13247. if !m.op.Is(OpUpdateOne) {
  13248. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13249. }
  13250. if m.id == nil || m.oldValue == nil {
  13251. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13252. }
  13253. oldValue, err := m.oldValue(ctx)
  13254. if err != nil {
  13255. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13256. }
  13257. return oldValue.DeletedAt, nil
  13258. }
  13259. // ClearDeletedAt clears the value of the "deleted_at" field.
  13260. func (m *CreditBalanceMutation) ClearDeletedAt() {
  13261. m.deleted_at = nil
  13262. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  13263. }
  13264. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13265. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  13266. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  13267. return ok
  13268. }
  13269. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13270. func (m *CreditBalanceMutation) ResetDeletedAt() {
  13271. m.deleted_at = nil
  13272. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  13273. }
  13274. // SetUserID sets the "user_id" field.
  13275. func (m *CreditBalanceMutation) SetUserID(s string) {
  13276. m.user_id = &s
  13277. }
  13278. // UserID returns the value of the "user_id" field in the mutation.
  13279. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  13280. v := m.user_id
  13281. if v == nil {
  13282. return
  13283. }
  13284. return *v, true
  13285. }
  13286. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  13287. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13289. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  13290. if !m.op.Is(OpUpdateOne) {
  13291. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  13292. }
  13293. if m.id == nil || m.oldValue == nil {
  13294. return v, errors.New("OldUserID requires an ID field in the mutation")
  13295. }
  13296. oldValue, err := m.oldValue(ctx)
  13297. if err != nil {
  13298. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  13299. }
  13300. return oldValue.UserID, nil
  13301. }
  13302. // ClearUserID clears the value of the "user_id" field.
  13303. func (m *CreditBalanceMutation) ClearUserID() {
  13304. m.user_id = nil
  13305. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  13306. }
  13307. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  13308. func (m *CreditBalanceMutation) UserIDCleared() bool {
  13309. _, ok := m.clearedFields[creditbalance.FieldUserID]
  13310. return ok
  13311. }
  13312. // ResetUserID resets all changes to the "user_id" field.
  13313. func (m *CreditBalanceMutation) ResetUserID() {
  13314. m.user_id = nil
  13315. delete(m.clearedFields, creditbalance.FieldUserID)
  13316. }
  13317. // SetBalance sets the "balance" field.
  13318. func (m *CreditBalanceMutation) SetBalance(f float32) {
  13319. m.balance = &f
  13320. m.addbalance = nil
  13321. }
  13322. // Balance returns the value of the "balance" field in the mutation.
  13323. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  13324. v := m.balance
  13325. if v == nil {
  13326. return
  13327. }
  13328. return *v, true
  13329. }
  13330. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  13331. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13333. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  13334. if !m.op.Is(OpUpdateOne) {
  13335. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  13336. }
  13337. if m.id == nil || m.oldValue == nil {
  13338. return v, errors.New("OldBalance requires an ID field in the mutation")
  13339. }
  13340. oldValue, err := m.oldValue(ctx)
  13341. if err != nil {
  13342. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  13343. }
  13344. return oldValue.Balance, nil
  13345. }
  13346. // AddBalance adds f to the "balance" field.
  13347. func (m *CreditBalanceMutation) AddBalance(f float32) {
  13348. if m.addbalance != nil {
  13349. *m.addbalance += f
  13350. } else {
  13351. m.addbalance = &f
  13352. }
  13353. }
  13354. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  13355. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  13356. v := m.addbalance
  13357. if v == nil {
  13358. return
  13359. }
  13360. return *v, true
  13361. }
  13362. // ResetBalance resets all changes to the "balance" field.
  13363. func (m *CreditBalanceMutation) ResetBalance() {
  13364. m.balance = nil
  13365. m.addbalance = nil
  13366. }
  13367. // SetStatus sets the "status" field.
  13368. func (m *CreditBalanceMutation) SetStatus(i int) {
  13369. m.status = &i
  13370. m.addstatus = nil
  13371. }
  13372. // Status returns the value of the "status" field in the mutation.
  13373. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  13374. v := m.status
  13375. if v == nil {
  13376. return
  13377. }
  13378. return *v, true
  13379. }
  13380. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  13381. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13383. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  13384. if !m.op.Is(OpUpdateOne) {
  13385. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13386. }
  13387. if m.id == nil || m.oldValue == nil {
  13388. return v, errors.New("OldStatus requires an ID field in the mutation")
  13389. }
  13390. oldValue, err := m.oldValue(ctx)
  13391. if err != nil {
  13392. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13393. }
  13394. return oldValue.Status, nil
  13395. }
  13396. // AddStatus adds i to the "status" field.
  13397. func (m *CreditBalanceMutation) AddStatus(i int) {
  13398. if m.addstatus != nil {
  13399. *m.addstatus += i
  13400. } else {
  13401. m.addstatus = &i
  13402. }
  13403. }
  13404. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13405. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  13406. v := m.addstatus
  13407. if v == nil {
  13408. return
  13409. }
  13410. return *v, true
  13411. }
  13412. // ClearStatus clears the value of the "status" field.
  13413. func (m *CreditBalanceMutation) ClearStatus() {
  13414. m.status = nil
  13415. m.addstatus = nil
  13416. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  13417. }
  13418. // StatusCleared returns if the "status" field was cleared in this mutation.
  13419. func (m *CreditBalanceMutation) StatusCleared() bool {
  13420. _, ok := m.clearedFields[creditbalance.FieldStatus]
  13421. return ok
  13422. }
  13423. // ResetStatus resets all changes to the "status" field.
  13424. func (m *CreditBalanceMutation) ResetStatus() {
  13425. m.status = nil
  13426. m.addstatus = nil
  13427. delete(m.clearedFields, creditbalance.FieldStatus)
  13428. }
  13429. // SetOrganizationID sets the "organization_id" field.
  13430. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  13431. m.organization_id = &u
  13432. m.addorganization_id = nil
  13433. }
  13434. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13435. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  13436. v := m.organization_id
  13437. if v == nil {
  13438. return
  13439. }
  13440. return *v, true
  13441. }
  13442. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  13443. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13445. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13446. if !m.op.Is(OpUpdateOne) {
  13447. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13448. }
  13449. if m.id == nil || m.oldValue == nil {
  13450. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13451. }
  13452. oldValue, err := m.oldValue(ctx)
  13453. if err != nil {
  13454. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13455. }
  13456. return oldValue.OrganizationID, nil
  13457. }
  13458. // AddOrganizationID adds u to the "organization_id" field.
  13459. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  13460. if m.addorganization_id != nil {
  13461. *m.addorganization_id += u
  13462. } else {
  13463. m.addorganization_id = &u
  13464. }
  13465. }
  13466. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13467. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  13468. v := m.addorganization_id
  13469. if v == nil {
  13470. return
  13471. }
  13472. return *v, true
  13473. }
  13474. // ClearOrganizationID clears the value of the "organization_id" field.
  13475. func (m *CreditBalanceMutation) ClearOrganizationID() {
  13476. m.organization_id = nil
  13477. m.addorganization_id = nil
  13478. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  13479. }
  13480. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13481. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  13482. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  13483. return ok
  13484. }
  13485. // ResetOrganizationID resets all changes to the "organization_id" field.
  13486. func (m *CreditBalanceMutation) ResetOrganizationID() {
  13487. m.organization_id = nil
  13488. m.addorganization_id = nil
  13489. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  13490. }
  13491. // Where appends a list predicates to the CreditBalanceMutation builder.
  13492. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  13493. m.predicates = append(m.predicates, ps...)
  13494. }
  13495. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  13496. // users can use type-assertion to append predicates that do not depend on any generated package.
  13497. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  13498. p := make([]predicate.CreditBalance, len(ps))
  13499. for i := range ps {
  13500. p[i] = ps[i]
  13501. }
  13502. m.Where(p...)
  13503. }
  13504. // Op returns the operation name.
  13505. func (m *CreditBalanceMutation) Op() Op {
  13506. return m.op
  13507. }
  13508. // SetOp allows setting the mutation operation.
  13509. func (m *CreditBalanceMutation) SetOp(op Op) {
  13510. m.op = op
  13511. }
  13512. // Type returns the node type of this mutation (CreditBalance).
  13513. func (m *CreditBalanceMutation) Type() string {
  13514. return m.typ
  13515. }
  13516. // Fields returns all fields that were changed during this mutation. Note that in
  13517. // order to get all numeric fields that were incremented/decremented, call
  13518. // AddedFields().
  13519. func (m *CreditBalanceMutation) Fields() []string {
  13520. fields := make([]string, 0, 7)
  13521. if m.created_at != nil {
  13522. fields = append(fields, creditbalance.FieldCreatedAt)
  13523. }
  13524. if m.updated_at != nil {
  13525. fields = append(fields, creditbalance.FieldUpdatedAt)
  13526. }
  13527. if m.deleted_at != nil {
  13528. fields = append(fields, creditbalance.FieldDeletedAt)
  13529. }
  13530. if m.user_id != nil {
  13531. fields = append(fields, creditbalance.FieldUserID)
  13532. }
  13533. if m.balance != nil {
  13534. fields = append(fields, creditbalance.FieldBalance)
  13535. }
  13536. if m.status != nil {
  13537. fields = append(fields, creditbalance.FieldStatus)
  13538. }
  13539. if m.organization_id != nil {
  13540. fields = append(fields, creditbalance.FieldOrganizationID)
  13541. }
  13542. return fields
  13543. }
  13544. // Field returns the value of a field with the given name. The second boolean
  13545. // return value indicates that this field was not set, or was not defined in the
  13546. // schema.
  13547. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  13548. switch name {
  13549. case creditbalance.FieldCreatedAt:
  13550. return m.CreatedAt()
  13551. case creditbalance.FieldUpdatedAt:
  13552. return m.UpdatedAt()
  13553. case creditbalance.FieldDeletedAt:
  13554. return m.DeletedAt()
  13555. case creditbalance.FieldUserID:
  13556. return m.UserID()
  13557. case creditbalance.FieldBalance:
  13558. return m.Balance()
  13559. case creditbalance.FieldStatus:
  13560. return m.Status()
  13561. case creditbalance.FieldOrganizationID:
  13562. return m.OrganizationID()
  13563. }
  13564. return nil, false
  13565. }
  13566. // OldField returns the old value of the field from the database. An error is
  13567. // returned if the mutation operation is not UpdateOne, or the query to the
  13568. // database failed.
  13569. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13570. switch name {
  13571. case creditbalance.FieldCreatedAt:
  13572. return m.OldCreatedAt(ctx)
  13573. case creditbalance.FieldUpdatedAt:
  13574. return m.OldUpdatedAt(ctx)
  13575. case creditbalance.FieldDeletedAt:
  13576. return m.OldDeletedAt(ctx)
  13577. case creditbalance.FieldUserID:
  13578. return m.OldUserID(ctx)
  13579. case creditbalance.FieldBalance:
  13580. return m.OldBalance(ctx)
  13581. case creditbalance.FieldStatus:
  13582. return m.OldStatus(ctx)
  13583. case creditbalance.FieldOrganizationID:
  13584. return m.OldOrganizationID(ctx)
  13585. }
  13586. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  13587. }
  13588. // SetField sets the value of a field with the given name. It returns an error if
  13589. // the field is not defined in the schema, or if the type mismatched the field
  13590. // type.
  13591. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  13592. switch name {
  13593. case creditbalance.FieldCreatedAt:
  13594. v, ok := value.(time.Time)
  13595. if !ok {
  13596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13597. }
  13598. m.SetCreatedAt(v)
  13599. return nil
  13600. case creditbalance.FieldUpdatedAt:
  13601. v, ok := value.(time.Time)
  13602. if !ok {
  13603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13604. }
  13605. m.SetUpdatedAt(v)
  13606. return nil
  13607. case creditbalance.FieldDeletedAt:
  13608. v, ok := value.(time.Time)
  13609. if !ok {
  13610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13611. }
  13612. m.SetDeletedAt(v)
  13613. return nil
  13614. case creditbalance.FieldUserID:
  13615. v, ok := value.(string)
  13616. if !ok {
  13617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13618. }
  13619. m.SetUserID(v)
  13620. return nil
  13621. case creditbalance.FieldBalance:
  13622. v, ok := value.(float32)
  13623. if !ok {
  13624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13625. }
  13626. m.SetBalance(v)
  13627. return nil
  13628. case creditbalance.FieldStatus:
  13629. v, ok := value.(int)
  13630. if !ok {
  13631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13632. }
  13633. m.SetStatus(v)
  13634. return nil
  13635. case creditbalance.FieldOrganizationID:
  13636. v, ok := value.(uint64)
  13637. if !ok {
  13638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13639. }
  13640. m.SetOrganizationID(v)
  13641. return nil
  13642. }
  13643. return fmt.Errorf("unknown CreditBalance field %s", name)
  13644. }
  13645. // AddedFields returns all numeric fields that were incremented/decremented during
  13646. // this mutation.
  13647. func (m *CreditBalanceMutation) AddedFields() []string {
  13648. var fields []string
  13649. if m.addbalance != nil {
  13650. fields = append(fields, creditbalance.FieldBalance)
  13651. }
  13652. if m.addstatus != nil {
  13653. fields = append(fields, creditbalance.FieldStatus)
  13654. }
  13655. if m.addorganization_id != nil {
  13656. fields = append(fields, creditbalance.FieldOrganizationID)
  13657. }
  13658. return fields
  13659. }
  13660. // AddedField returns the numeric value that was incremented/decremented on a field
  13661. // with the given name. The second boolean return value indicates that this field
  13662. // was not set, or was not defined in the schema.
  13663. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  13664. switch name {
  13665. case creditbalance.FieldBalance:
  13666. return m.AddedBalance()
  13667. case creditbalance.FieldStatus:
  13668. return m.AddedStatus()
  13669. case creditbalance.FieldOrganizationID:
  13670. return m.AddedOrganizationID()
  13671. }
  13672. return nil, false
  13673. }
  13674. // AddField adds the value to the field with the given name. It returns an error if
  13675. // the field is not defined in the schema, or if the type mismatched the field
  13676. // type.
  13677. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  13678. switch name {
  13679. case creditbalance.FieldBalance:
  13680. v, ok := value.(float32)
  13681. if !ok {
  13682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13683. }
  13684. m.AddBalance(v)
  13685. return nil
  13686. case creditbalance.FieldStatus:
  13687. v, ok := value.(int)
  13688. if !ok {
  13689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13690. }
  13691. m.AddStatus(v)
  13692. return nil
  13693. case creditbalance.FieldOrganizationID:
  13694. v, ok := value.(int64)
  13695. if !ok {
  13696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13697. }
  13698. m.AddOrganizationID(v)
  13699. return nil
  13700. }
  13701. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  13702. }
  13703. // ClearedFields returns all nullable fields that were cleared during this
  13704. // mutation.
  13705. func (m *CreditBalanceMutation) ClearedFields() []string {
  13706. var fields []string
  13707. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  13708. fields = append(fields, creditbalance.FieldDeletedAt)
  13709. }
  13710. if m.FieldCleared(creditbalance.FieldUserID) {
  13711. fields = append(fields, creditbalance.FieldUserID)
  13712. }
  13713. if m.FieldCleared(creditbalance.FieldStatus) {
  13714. fields = append(fields, creditbalance.FieldStatus)
  13715. }
  13716. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  13717. fields = append(fields, creditbalance.FieldOrganizationID)
  13718. }
  13719. return fields
  13720. }
  13721. // FieldCleared returns a boolean indicating if a field with the given name was
  13722. // cleared in this mutation.
  13723. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  13724. _, ok := m.clearedFields[name]
  13725. return ok
  13726. }
  13727. // ClearField clears the value of the field with the given name. It returns an
  13728. // error if the field is not defined in the schema.
  13729. func (m *CreditBalanceMutation) ClearField(name string) error {
  13730. switch name {
  13731. case creditbalance.FieldDeletedAt:
  13732. m.ClearDeletedAt()
  13733. return nil
  13734. case creditbalance.FieldUserID:
  13735. m.ClearUserID()
  13736. return nil
  13737. case creditbalance.FieldStatus:
  13738. m.ClearStatus()
  13739. return nil
  13740. case creditbalance.FieldOrganizationID:
  13741. m.ClearOrganizationID()
  13742. return nil
  13743. }
  13744. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  13745. }
  13746. // ResetField resets all changes in the mutation for the field with the given name.
  13747. // It returns an error if the field is not defined in the schema.
  13748. func (m *CreditBalanceMutation) ResetField(name string) error {
  13749. switch name {
  13750. case creditbalance.FieldCreatedAt:
  13751. m.ResetCreatedAt()
  13752. return nil
  13753. case creditbalance.FieldUpdatedAt:
  13754. m.ResetUpdatedAt()
  13755. return nil
  13756. case creditbalance.FieldDeletedAt:
  13757. m.ResetDeletedAt()
  13758. return nil
  13759. case creditbalance.FieldUserID:
  13760. m.ResetUserID()
  13761. return nil
  13762. case creditbalance.FieldBalance:
  13763. m.ResetBalance()
  13764. return nil
  13765. case creditbalance.FieldStatus:
  13766. m.ResetStatus()
  13767. return nil
  13768. case creditbalance.FieldOrganizationID:
  13769. m.ResetOrganizationID()
  13770. return nil
  13771. }
  13772. return fmt.Errorf("unknown CreditBalance field %s", name)
  13773. }
  13774. // AddedEdges returns all edge names that were set/added in this mutation.
  13775. func (m *CreditBalanceMutation) AddedEdges() []string {
  13776. edges := make([]string, 0, 0)
  13777. return edges
  13778. }
  13779. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13780. // name in this mutation.
  13781. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  13782. return nil
  13783. }
  13784. // RemovedEdges returns all edge names that were removed in this mutation.
  13785. func (m *CreditBalanceMutation) RemovedEdges() []string {
  13786. edges := make([]string, 0, 0)
  13787. return edges
  13788. }
  13789. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13790. // the given name in this mutation.
  13791. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  13792. return nil
  13793. }
  13794. // ClearedEdges returns all edge names that were cleared in this mutation.
  13795. func (m *CreditBalanceMutation) ClearedEdges() []string {
  13796. edges := make([]string, 0, 0)
  13797. return edges
  13798. }
  13799. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13800. // was cleared in this mutation.
  13801. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  13802. return false
  13803. }
  13804. // ClearEdge clears the value of the edge with the given name. It returns an error
  13805. // if that edge is not defined in the schema.
  13806. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  13807. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  13808. }
  13809. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13810. // It returns an error if the edge is not defined in the schema.
  13811. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  13812. return fmt.Errorf("unknown CreditBalance edge %s", name)
  13813. }
  13814. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  13815. type CreditUsageMutation struct {
  13816. config
  13817. op Op
  13818. typ string
  13819. id *uint64
  13820. created_at *time.Time
  13821. updated_at *time.Time
  13822. deleted_at *time.Time
  13823. user_id *string
  13824. number *float32
  13825. addnumber *float32
  13826. status *int
  13827. addstatus *int
  13828. ntype *int
  13829. addntype *int
  13830. table *string
  13831. organization_id *uint64
  13832. addorganization_id *int64
  13833. nid *uint64
  13834. addnid *int64
  13835. reason *string
  13836. operator *string
  13837. clearedFields map[string]struct{}
  13838. done bool
  13839. oldValue func(context.Context) (*CreditUsage, error)
  13840. predicates []predicate.CreditUsage
  13841. }
  13842. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  13843. // creditusageOption allows management of the mutation configuration using functional options.
  13844. type creditusageOption func(*CreditUsageMutation)
  13845. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  13846. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  13847. m := &CreditUsageMutation{
  13848. config: c,
  13849. op: op,
  13850. typ: TypeCreditUsage,
  13851. clearedFields: make(map[string]struct{}),
  13852. }
  13853. for _, opt := range opts {
  13854. opt(m)
  13855. }
  13856. return m
  13857. }
  13858. // withCreditUsageID sets the ID field of the mutation.
  13859. func withCreditUsageID(id uint64) creditusageOption {
  13860. return func(m *CreditUsageMutation) {
  13861. var (
  13862. err error
  13863. once sync.Once
  13864. value *CreditUsage
  13865. )
  13866. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  13867. once.Do(func() {
  13868. if m.done {
  13869. err = errors.New("querying old values post mutation is not allowed")
  13870. } else {
  13871. value, err = m.Client().CreditUsage.Get(ctx, id)
  13872. }
  13873. })
  13874. return value, err
  13875. }
  13876. m.id = &id
  13877. }
  13878. }
  13879. // withCreditUsage sets the old CreditUsage of the mutation.
  13880. func withCreditUsage(node *CreditUsage) creditusageOption {
  13881. return func(m *CreditUsageMutation) {
  13882. m.oldValue = func(context.Context) (*CreditUsage, error) {
  13883. return node, nil
  13884. }
  13885. m.id = &node.ID
  13886. }
  13887. }
  13888. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13889. // executed in a transaction (ent.Tx), a transactional client is returned.
  13890. func (m CreditUsageMutation) Client() *Client {
  13891. client := &Client{config: m.config}
  13892. client.init()
  13893. return client
  13894. }
  13895. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13896. // it returns an error otherwise.
  13897. func (m CreditUsageMutation) Tx() (*Tx, error) {
  13898. if _, ok := m.driver.(*txDriver); !ok {
  13899. return nil, errors.New("ent: mutation is not running in a transaction")
  13900. }
  13901. tx := &Tx{config: m.config}
  13902. tx.init()
  13903. return tx, nil
  13904. }
  13905. // SetID sets the value of the id field. Note that this
  13906. // operation is only accepted on creation of CreditUsage entities.
  13907. func (m *CreditUsageMutation) SetID(id uint64) {
  13908. m.id = &id
  13909. }
  13910. // ID returns the ID value in the mutation. Note that the ID is only available
  13911. // if it was provided to the builder or after it was returned from the database.
  13912. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  13913. if m.id == nil {
  13914. return
  13915. }
  13916. return *m.id, true
  13917. }
  13918. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13919. // That means, if the mutation is applied within a transaction with an isolation level such
  13920. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13921. // or updated by the mutation.
  13922. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13923. switch {
  13924. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13925. id, exists := m.ID()
  13926. if exists {
  13927. return []uint64{id}, nil
  13928. }
  13929. fallthrough
  13930. case m.op.Is(OpUpdate | OpDelete):
  13931. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  13932. default:
  13933. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13934. }
  13935. }
  13936. // SetCreatedAt sets the "created_at" field.
  13937. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  13938. m.created_at = &t
  13939. }
  13940. // CreatedAt returns the value of the "created_at" field in the mutation.
  13941. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  13942. v := m.created_at
  13943. if v == nil {
  13944. return
  13945. }
  13946. return *v, true
  13947. }
  13948. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  13949. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13951. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13952. if !m.op.Is(OpUpdateOne) {
  13953. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13954. }
  13955. if m.id == nil || m.oldValue == nil {
  13956. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13957. }
  13958. oldValue, err := m.oldValue(ctx)
  13959. if err != nil {
  13960. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13961. }
  13962. return oldValue.CreatedAt, nil
  13963. }
  13964. // ResetCreatedAt resets all changes to the "created_at" field.
  13965. func (m *CreditUsageMutation) ResetCreatedAt() {
  13966. m.created_at = nil
  13967. }
  13968. // SetUpdatedAt sets the "updated_at" field.
  13969. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  13970. m.updated_at = &t
  13971. }
  13972. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13973. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  13974. v := m.updated_at
  13975. if v == nil {
  13976. return
  13977. }
  13978. return *v, true
  13979. }
  13980. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  13981. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13983. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13984. if !m.op.Is(OpUpdateOne) {
  13985. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13986. }
  13987. if m.id == nil || m.oldValue == nil {
  13988. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13989. }
  13990. oldValue, err := m.oldValue(ctx)
  13991. if err != nil {
  13992. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13993. }
  13994. return oldValue.UpdatedAt, nil
  13995. }
  13996. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13997. func (m *CreditUsageMutation) ResetUpdatedAt() {
  13998. m.updated_at = nil
  13999. }
  14000. // SetDeletedAt sets the "deleted_at" field.
  14001. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  14002. m.deleted_at = &t
  14003. }
  14004. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14005. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  14006. v := m.deleted_at
  14007. if v == nil {
  14008. return
  14009. }
  14010. return *v, true
  14011. }
  14012. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  14013. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14015. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14016. if !m.op.Is(OpUpdateOne) {
  14017. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14018. }
  14019. if m.id == nil || m.oldValue == nil {
  14020. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14021. }
  14022. oldValue, err := m.oldValue(ctx)
  14023. if err != nil {
  14024. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14025. }
  14026. return oldValue.DeletedAt, nil
  14027. }
  14028. // ClearDeletedAt clears the value of the "deleted_at" field.
  14029. func (m *CreditUsageMutation) ClearDeletedAt() {
  14030. m.deleted_at = nil
  14031. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  14032. }
  14033. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14034. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  14035. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  14036. return ok
  14037. }
  14038. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14039. func (m *CreditUsageMutation) ResetDeletedAt() {
  14040. m.deleted_at = nil
  14041. delete(m.clearedFields, creditusage.FieldDeletedAt)
  14042. }
  14043. // SetUserID sets the "user_id" field.
  14044. func (m *CreditUsageMutation) SetUserID(s string) {
  14045. m.user_id = &s
  14046. }
  14047. // UserID returns the value of the "user_id" field in the mutation.
  14048. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  14049. v := m.user_id
  14050. if v == nil {
  14051. return
  14052. }
  14053. return *v, true
  14054. }
  14055. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  14056. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14058. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  14059. if !m.op.Is(OpUpdateOne) {
  14060. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  14061. }
  14062. if m.id == nil || m.oldValue == nil {
  14063. return v, errors.New("OldUserID requires an ID field in the mutation")
  14064. }
  14065. oldValue, err := m.oldValue(ctx)
  14066. if err != nil {
  14067. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  14068. }
  14069. return oldValue.UserID, nil
  14070. }
  14071. // ClearUserID clears the value of the "user_id" field.
  14072. func (m *CreditUsageMutation) ClearUserID() {
  14073. m.user_id = nil
  14074. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  14075. }
  14076. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  14077. func (m *CreditUsageMutation) UserIDCleared() bool {
  14078. _, ok := m.clearedFields[creditusage.FieldUserID]
  14079. return ok
  14080. }
  14081. // ResetUserID resets all changes to the "user_id" field.
  14082. func (m *CreditUsageMutation) ResetUserID() {
  14083. m.user_id = nil
  14084. delete(m.clearedFields, creditusage.FieldUserID)
  14085. }
  14086. // SetNumber sets the "number" field.
  14087. func (m *CreditUsageMutation) SetNumber(f float32) {
  14088. m.number = &f
  14089. m.addnumber = nil
  14090. }
  14091. // Number returns the value of the "number" field in the mutation.
  14092. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  14093. v := m.number
  14094. if v == nil {
  14095. return
  14096. }
  14097. return *v, true
  14098. }
  14099. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  14100. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14102. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  14103. if !m.op.Is(OpUpdateOne) {
  14104. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  14105. }
  14106. if m.id == nil || m.oldValue == nil {
  14107. return v, errors.New("OldNumber requires an ID field in the mutation")
  14108. }
  14109. oldValue, err := m.oldValue(ctx)
  14110. if err != nil {
  14111. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  14112. }
  14113. return oldValue.Number, nil
  14114. }
  14115. // AddNumber adds f to the "number" field.
  14116. func (m *CreditUsageMutation) AddNumber(f float32) {
  14117. if m.addnumber != nil {
  14118. *m.addnumber += f
  14119. } else {
  14120. m.addnumber = &f
  14121. }
  14122. }
  14123. // AddedNumber returns the value that was added to the "number" field in this mutation.
  14124. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  14125. v := m.addnumber
  14126. if v == nil {
  14127. return
  14128. }
  14129. return *v, true
  14130. }
  14131. // ResetNumber resets all changes to the "number" field.
  14132. func (m *CreditUsageMutation) ResetNumber() {
  14133. m.number = nil
  14134. m.addnumber = nil
  14135. }
  14136. // SetStatus sets the "status" field.
  14137. func (m *CreditUsageMutation) SetStatus(i int) {
  14138. m.status = &i
  14139. m.addstatus = nil
  14140. }
  14141. // Status returns the value of the "status" field in the mutation.
  14142. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  14143. v := m.status
  14144. if v == nil {
  14145. return
  14146. }
  14147. return *v, true
  14148. }
  14149. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  14150. // If the CreditUsage 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 *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  14153. if !m.op.Is(OpUpdateOne) {
  14154. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14155. }
  14156. if m.id == nil || m.oldValue == nil {
  14157. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  14162. }
  14163. return oldValue.Status, nil
  14164. }
  14165. // AddStatus adds i to the "status" field.
  14166. func (m *CreditUsageMutation) AddStatus(i int) {
  14167. if m.addstatus != nil {
  14168. *m.addstatus += i
  14169. } else {
  14170. m.addstatus = &i
  14171. }
  14172. }
  14173. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14174. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  14175. v := m.addstatus
  14176. if v == nil {
  14177. return
  14178. }
  14179. return *v, true
  14180. }
  14181. // ClearStatus clears the value of the "status" field.
  14182. func (m *CreditUsageMutation) ClearStatus() {
  14183. m.status = nil
  14184. m.addstatus = nil
  14185. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  14186. }
  14187. // StatusCleared returns if the "status" field was cleared in this mutation.
  14188. func (m *CreditUsageMutation) StatusCleared() bool {
  14189. _, ok := m.clearedFields[creditusage.FieldStatus]
  14190. return ok
  14191. }
  14192. // ResetStatus resets all changes to the "status" field.
  14193. func (m *CreditUsageMutation) ResetStatus() {
  14194. m.status = nil
  14195. m.addstatus = nil
  14196. delete(m.clearedFields, creditusage.FieldStatus)
  14197. }
  14198. // SetNtype sets the "ntype" field.
  14199. func (m *CreditUsageMutation) SetNtype(i int) {
  14200. m.ntype = &i
  14201. m.addntype = nil
  14202. }
  14203. // Ntype returns the value of the "ntype" field in the mutation.
  14204. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  14205. v := m.ntype
  14206. if v == nil {
  14207. return
  14208. }
  14209. return *v, true
  14210. }
  14211. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  14212. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14214. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  14215. if !m.op.Is(OpUpdateOne) {
  14216. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  14217. }
  14218. if m.id == nil || m.oldValue == nil {
  14219. return v, errors.New("OldNtype requires an ID field in the mutation")
  14220. }
  14221. oldValue, err := m.oldValue(ctx)
  14222. if err != nil {
  14223. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  14224. }
  14225. return oldValue.Ntype, nil
  14226. }
  14227. // AddNtype adds i to the "ntype" field.
  14228. func (m *CreditUsageMutation) AddNtype(i int) {
  14229. if m.addntype != nil {
  14230. *m.addntype += i
  14231. } else {
  14232. m.addntype = &i
  14233. }
  14234. }
  14235. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  14236. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  14237. v := m.addntype
  14238. if v == nil {
  14239. return
  14240. }
  14241. return *v, true
  14242. }
  14243. // ResetNtype resets all changes to the "ntype" field.
  14244. func (m *CreditUsageMutation) ResetNtype() {
  14245. m.ntype = nil
  14246. m.addntype = nil
  14247. }
  14248. // SetTable sets the "table" field.
  14249. func (m *CreditUsageMutation) SetTable(s string) {
  14250. m.table = &s
  14251. }
  14252. // Table returns the value of the "table" field in the mutation.
  14253. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  14254. v := m.table
  14255. if v == nil {
  14256. return
  14257. }
  14258. return *v, true
  14259. }
  14260. // OldTable returns the old "table" field's value of the CreditUsage entity.
  14261. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14263. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  14264. if !m.op.Is(OpUpdateOne) {
  14265. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  14266. }
  14267. if m.id == nil || m.oldValue == nil {
  14268. return v, errors.New("OldTable requires an ID field in the mutation")
  14269. }
  14270. oldValue, err := m.oldValue(ctx)
  14271. if err != nil {
  14272. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  14273. }
  14274. return oldValue.Table, nil
  14275. }
  14276. // ResetTable resets all changes to the "table" field.
  14277. func (m *CreditUsageMutation) ResetTable() {
  14278. m.table = nil
  14279. }
  14280. // SetOrganizationID sets the "organization_id" field.
  14281. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  14282. m.organization_id = &u
  14283. m.addorganization_id = nil
  14284. }
  14285. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14286. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  14287. v := m.organization_id
  14288. if v == nil {
  14289. return
  14290. }
  14291. return *v, true
  14292. }
  14293. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  14294. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14296. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14297. if !m.op.Is(OpUpdateOne) {
  14298. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14299. }
  14300. if m.id == nil || m.oldValue == nil {
  14301. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14302. }
  14303. oldValue, err := m.oldValue(ctx)
  14304. if err != nil {
  14305. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14306. }
  14307. return oldValue.OrganizationID, nil
  14308. }
  14309. // AddOrganizationID adds u to the "organization_id" field.
  14310. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  14311. if m.addorganization_id != nil {
  14312. *m.addorganization_id += u
  14313. } else {
  14314. m.addorganization_id = &u
  14315. }
  14316. }
  14317. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14318. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  14319. v := m.addorganization_id
  14320. if v == nil {
  14321. return
  14322. }
  14323. return *v, true
  14324. }
  14325. // ClearOrganizationID clears the value of the "organization_id" field.
  14326. func (m *CreditUsageMutation) ClearOrganizationID() {
  14327. m.organization_id = nil
  14328. m.addorganization_id = nil
  14329. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  14330. }
  14331. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14332. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  14333. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  14334. return ok
  14335. }
  14336. // ResetOrganizationID resets all changes to the "organization_id" field.
  14337. func (m *CreditUsageMutation) ResetOrganizationID() {
  14338. m.organization_id = nil
  14339. m.addorganization_id = nil
  14340. delete(m.clearedFields, creditusage.FieldOrganizationID)
  14341. }
  14342. // SetNid sets the "nid" field.
  14343. func (m *CreditUsageMutation) SetNid(u uint64) {
  14344. m.nid = &u
  14345. m.addnid = nil
  14346. }
  14347. // Nid returns the value of the "nid" field in the mutation.
  14348. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  14349. v := m.nid
  14350. if v == nil {
  14351. return
  14352. }
  14353. return *v, true
  14354. }
  14355. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  14356. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14358. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  14359. if !m.op.Is(OpUpdateOne) {
  14360. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  14361. }
  14362. if m.id == nil || m.oldValue == nil {
  14363. return v, errors.New("OldNid requires an ID field in the mutation")
  14364. }
  14365. oldValue, err := m.oldValue(ctx)
  14366. if err != nil {
  14367. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  14368. }
  14369. return oldValue.Nid, nil
  14370. }
  14371. // AddNid adds u to the "nid" field.
  14372. func (m *CreditUsageMutation) AddNid(u int64) {
  14373. if m.addnid != nil {
  14374. *m.addnid += u
  14375. } else {
  14376. m.addnid = &u
  14377. }
  14378. }
  14379. // AddedNid returns the value that was added to the "nid" field in this mutation.
  14380. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  14381. v := m.addnid
  14382. if v == nil {
  14383. return
  14384. }
  14385. return *v, true
  14386. }
  14387. // ResetNid resets all changes to the "nid" field.
  14388. func (m *CreditUsageMutation) ResetNid() {
  14389. m.nid = nil
  14390. m.addnid = nil
  14391. }
  14392. // SetReason sets the "reason" field.
  14393. func (m *CreditUsageMutation) SetReason(s string) {
  14394. m.reason = &s
  14395. }
  14396. // Reason returns the value of the "reason" field in the mutation.
  14397. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  14398. v := m.reason
  14399. if v == nil {
  14400. return
  14401. }
  14402. return *v, true
  14403. }
  14404. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  14405. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14407. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  14408. if !m.op.Is(OpUpdateOne) {
  14409. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  14410. }
  14411. if m.id == nil || m.oldValue == nil {
  14412. return v, errors.New("OldReason requires an ID field in the mutation")
  14413. }
  14414. oldValue, err := m.oldValue(ctx)
  14415. if err != nil {
  14416. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  14417. }
  14418. return oldValue.Reason, nil
  14419. }
  14420. // ResetReason resets all changes to the "reason" field.
  14421. func (m *CreditUsageMutation) ResetReason() {
  14422. m.reason = nil
  14423. }
  14424. // SetOperator sets the "operator" field.
  14425. func (m *CreditUsageMutation) SetOperator(s string) {
  14426. m.operator = &s
  14427. }
  14428. // Operator returns the value of the "operator" field in the mutation.
  14429. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  14430. v := m.operator
  14431. if v == nil {
  14432. return
  14433. }
  14434. return *v, true
  14435. }
  14436. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  14437. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14439. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  14440. if !m.op.Is(OpUpdateOne) {
  14441. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  14442. }
  14443. if m.id == nil || m.oldValue == nil {
  14444. return v, errors.New("OldOperator requires an ID field in the mutation")
  14445. }
  14446. oldValue, err := m.oldValue(ctx)
  14447. if err != nil {
  14448. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  14449. }
  14450. return oldValue.Operator, nil
  14451. }
  14452. // ResetOperator resets all changes to the "operator" field.
  14453. func (m *CreditUsageMutation) ResetOperator() {
  14454. m.operator = nil
  14455. }
  14456. // Where appends a list predicates to the CreditUsageMutation builder.
  14457. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  14458. m.predicates = append(m.predicates, ps...)
  14459. }
  14460. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  14461. // users can use type-assertion to append predicates that do not depend on any generated package.
  14462. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  14463. p := make([]predicate.CreditUsage, len(ps))
  14464. for i := range ps {
  14465. p[i] = ps[i]
  14466. }
  14467. m.Where(p...)
  14468. }
  14469. // Op returns the operation name.
  14470. func (m *CreditUsageMutation) Op() Op {
  14471. return m.op
  14472. }
  14473. // SetOp allows setting the mutation operation.
  14474. func (m *CreditUsageMutation) SetOp(op Op) {
  14475. m.op = op
  14476. }
  14477. // Type returns the node type of this mutation (CreditUsage).
  14478. func (m *CreditUsageMutation) Type() string {
  14479. return m.typ
  14480. }
  14481. // Fields returns all fields that were changed during this mutation. Note that in
  14482. // order to get all numeric fields that were incremented/decremented, call
  14483. // AddedFields().
  14484. func (m *CreditUsageMutation) Fields() []string {
  14485. fields := make([]string, 0, 12)
  14486. if m.created_at != nil {
  14487. fields = append(fields, creditusage.FieldCreatedAt)
  14488. }
  14489. if m.updated_at != nil {
  14490. fields = append(fields, creditusage.FieldUpdatedAt)
  14491. }
  14492. if m.deleted_at != nil {
  14493. fields = append(fields, creditusage.FieldDeletedAt)
  14494. }
  14495. if m.user_id != nil {
  14496. fields = append(fields, creditusage.FieldUserID)
  14497. }
  14498. if m.number != nil {
  14499. fields = append(fields, creditusage.FieldNumber)
  14500. }
  14501. if m.status != nil {
  14502. fields = append(fields, creditusage.FieldStatus)
  14503. }
  14504. if m.ntype != nil {
  14505. fields = append(fields, creditusage.FieldNtype)
  14506. }
  14507. if m.table != nil {
  14508. fields = append(fields, creditusage.FieldTable)
  14509. }
  14510. if m.organization_id != nil {
  14511. fields = append(fields, creditusage.FieldOrganizationID)
  14512. }
  14513. if m.nid != nil {
  14514. fields = append(fields, creditusage.FieldNid)
  14515. }
  14516. if m.reason != nil {
  14517. fields = append(fields, creditusage.FieldReason)
  14518. }
  14519. if m.operator != nil {
  14520. fields = append(fields, creditusage.FieldOperator)
  14521. }
  14522. return fields
  14523. }
  14524. // Field returns the value of a field with the given name. The second boolean
  14525. // return value indicates that this field was not set, or was not defined in the
  14526. // schema.
  14527. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  14528. switch name {
  14529. case creditusage.FieldCreatedAt:
  14530. return m.CreatedAt()
  14531. case creditusage.FieldUpdatedAt:
  14532. return m.UpdatedAt()
  14533. case creditusage.FieldDeletedAt:
  14534. return m.DeletedAt()
  14535. case creditusage.FieldUserID:
  14536. return m.UserID()
  14537. case creditusage.FieldNumber:
  14538. return m.Number()
  14539. case creditusage.FieldStatus:
  14540. return m.Status()
  14541. case creditusage.FieldNtype:
  14542. return m.Ntype()
  14543. case creditusage.FieldTable:
  14544. return m.Table()
  14545. case creditusage.FieldOrganizationID:
  14546. return m.OrganizationID()
  14547. case creditusage.FieldNid:
  14548. return m.Nid()
  14549. case creditusage.FieldReason:
  14550. return m.Reason()
  14551. case creditusage.FieldOperator:
  14552. return m.Operator()
  14553. }
  14554. return nil, false
  14555. }
  14556. // OldField returns the old value of the field from the database. An error is
  14557. // returned if the mutation operation is not UpdateOne, or the query to the
  14558. // database failed.
  14559. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14560. switch name {
  14561. case creditusage.FieldCreatedAt:
  14562. return m.OldCreatedAt(ctx)
  14563. case creditusage.FieldUpdatedAt:
  14564. return m.OldUpdatedAt(ctx)
  14565. case creditusage.FieldDeletedAt:
  14566. return m.OldDeletedAt(ctx)
  14567. case creditusage.FieldUserID:
  14568. return m.OldUserID(ctx)
  14569. case creditusage.FieldNumber:
  14570. return m.OldNumber(ctx)
  14571. case creditusage.FieldStatus:
  14572. return m.OldStatus(ctx)
  14573. case creditusage.FieldNtype:
  14574. return m.OldNtype(ctx)
  14575. case creditusage.FieldTable:
  14576. return m.OldTable(ctx)
  14577. case creditusage.FieldOrganizationID:
  14578. return m.OldOrganizationID(ctx)
  14579. case creditusage.FieldNid:
  14580. return m.OldNid(ctx)
  14581. case creditusage.FieldReason:
  14582. return m.OldReason(ctx)
  14583. case creditusage.FieldOperator:
  14584. return m.OldOperator(ctx)
  14585. }
  14586. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  14587. }
  14588. // SetField sets the value of a field with the given name. It returns an error if
  14589. // the field is not defined in the schema, or if the type mismatched the field
  14590. // type.
  14591. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  14592. switch name {
  14593. case creditusage.FieldCreatedAt:
  14594. v, ok := value.(time.Time)
  14595. if !ok {
  14596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14597. }
  14598. m.SetCreatedAt(v)
  14599. return nil
  14600. case creditusage.FieldUpdatedAt:
  14601. v, ok := value.(time.Time)
  14602. if !ok {
  14603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14604. }
  14605. m.SetUpdatedAt(v)
  14606. return nil
  14607. case creditusage.FieldDeletedAt:
  14608. v, ok := value.(time.Time)
  14609. if !ok {
  14610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14611. }
  14612. m.SetDeletedAt(v)
  14613. return nil
  14614. case creditusage.FieldUserID:
  14615. v, ok := value.(string)
  14616. if !ok {
  14617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14618. }
  14619. m.SetUserID(v)
  14620. return nil
  14621. case creditusage.FieldNumber:
  14622. v, ok := value.(float32)
  14623. if !ok {
  14624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14625. }
  14626. m.SetNumber(v)
  14627. return nil
  14628. case creditusage.FieldStatus:
  14629. v, ok := value.(int)
  14630. if !ok {
  14631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14632. }
  14633. m.SetStatus(v)
  14634. return nil
  14635. case creditusage.FieldNtype:
  14636. v, ok := value.(int)
  14637. if !ok {
  14638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14639. }
  14640. m.SetNtype(v)
  14641. return nil
  14642. case creditusage.FieldTable:
  14643. v, ok := value.(string)
  14644. if !ok {
  14645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14646. }
  14647. m.SetTable(v)
  14648. return nil
  14649. case creditusage.FieldOrganizationID:
  14650. v, ok := value.(uint64)
  14651. if !ok {
  14652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14653. }
  14654. m.SetOrganizationID(v)
  14655. return nil
  14656. case creditusage.FieldNid:
  14657. v, ok := value.(uint64)
  14658. if !ok {
  14659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14660. }
  14661. m.SetNid(v)
  14662. return nil
  14663. case creditusage.FieldReason:
  14664. v, ok := value.(string)
  14665. if !ok {
  14666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14667. }
  14668. m.SetReason(v)
  14669. return nil
  14670. case creditusage.FieldOperator:
  14671. v, ok := value.(string)
  14672. if !ok {
  14673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14674. }
  14675. m.SetOperator(v)
  14676. return nil
  14677. }
  14678. return fmt.Errorf("unknown CreditUsage field %s", name)
  14679. }
  14680. // AddedFields returns all numeric fields that were incremented/decremented during
  14681. // this mutation.
  14682. func (m *CreditUsageMutation) AddedFields() []string {
  14683. var fields []string
  14684. if m.addnumber != nil {
  14685. fields = append(fields, creditusage.FieldNumber)
  14686. }
  14687. if m.addstatus != nil {
  14688. fields = append(fields, creditusage.FieldStatus)
  14689. }
  14690. if m.addntype != nil {
  14691. fields = append(fields, creditusage.FieldNtype)
  14692. }
  14693. if m.addorganization_id != nil {
  14694. fields = append(fields, creditusage.FieldOrganizationID)
  14695. }
  14696. if m.addnid != nil {
  14697. fields = append(fields, creditusage.FieldNid)
  14698. }
  14699. return fields
  14700. }
  14701. // AddedField returns the numeric value that was incremented/decremented on a field
  14702. // with the given name. The second boolean return value indicates that this field
  14703. // was not set, or was not defined in the schema.
  14704. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  14705. switch name {
  14706. case creditusage.FieldNumber:
  14707. return m.AddedNumber()
  14708. case creditusage.FieldStatus:
  14709. return m.AddedStatus()
  14710. case creditusage.FieldNtype:
  14711. return m.AddedNtype()
  14712. case creditusage.FieldOrganizationID:
  14713. return m.AddedOrganizationID()
  14714. case creditusage.FieldNid:
  14715. return m.AddedNid()
  14716. }
  14717. return nil, false
  14718. }
  14719. // AddField adds the value to the field with the given name. It returns an error if
  14720. // the field is not defined in the schema, or if the type mismatched the field
  14721. // type.
  14722. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  14723. switch name {
  14724. case creditusage.FieldNumber:
  14725. v, ok := value.(float32)
  14726. if !ok {
  14727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14728. }
  14729. m.AddNumber(v)
  14730. return nil
  14731. case creditusage.FieldStatus:
  14732. v, ok := value.(int)
  14733. if !ok {
  14734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14735. }
  14736. m.AddStatus(v)
  14737. return nil
  14738. case creditusage.FieldNtype:
  14739. v, ok := value.(int)
  14740. if !ok {
  14741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14742. }
  14743. m.AddNtype(v)
  14744. return nil
  14745. case creditusage.FieldOrganizationID:
  14746. v, ok := value.(int64)
  14747. if !ok {
  14748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14749. }
  14750. m.AddOrganizationID(v)
  14751. return nil
  14752. case creditusage.FieldNid:
  14753. v, ok := value.(int64)
  14754. if !ok {
  14755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14756. }
  14757. m.AddNid(v)
  14758. return nil
  14759. }
  14760. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  14761. }
  14762. // ClearedFields returns all nullable fields that were cleared during this
  14763. // mutation.
  14764. func (m *CreditUsageMutation) ClearedFields() []string {
  14765. var fields []string
  14766. if m.FieldCleared(creditusage.FieldDeletedAt) {
  14767. fields = append(fields, creditusage.FieldDeletedAt)
  14768. }
  14769. if m.FieldCleared(creditusage.FieldUserID) {
  14770. fields = append(fields, creditusage.FieldUserID)
  14771. }
  14772. if m.FieldCleared(creditusage.FieldStatus) {
  14773. fields = append(fields, creditusage.FieldStatus)
  14774. }
  14775. if m.FieldCleared(creditusage.FieldOrganizationID) {
  14776. fields = append(fields, creditusage.FieldOrganizationID)
  14777. }
  14778. return fields
  14779. }
  14780. // FieldCleared returns a boolean indicating if a field with the given name was
  14781. // cleared in this mutation.
  14782. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  14783. _, ok := m.clearedFields[name]
  14784. return ok
  14785. }
  14786. // ClearField clears the value of the field with the given name. It returns an
  14787. // error if the field is not defined in the schema.
  14788. func (m *CreditUsageMutation) ClearField(name string) error {
  14789. switch name {
  14790. case creditusage.FieldDeletedAt:
  14791. m.ClearDeletedAt()
  14792. return nil
  14793. case creditusage.FieldUserID:
  14794. m.ClearUserID()
  14795. return nil
  14796. case creditusage.FieldStatus:
  14797. m.ClearStatus()
  14798. return nil
  14799. case creditusage.FieldOrganizationID:
  14800. m.ClearOrganizationID()
  14801. return nil
  14802. }
  14803. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  14804. }
  14805. // ResetField resets all changes in the mutation for the field with the given name.
  14806. // It returns an error if the field is not defined in the schema.
  14807. func (m *CreditUsageMutation) ResetField(name string) error {
  14808. switch name {
  14809. case creditusage.FieldCreatedAt:
  14810. m.ResetCreatedAt()
  14811. return nil
  14812. case creditusage.FieldUpdatedAt:
  14813. m.ResetUpdatedAt()
  14814. return nil
  14815. case creditusage.FieldDeletedAt:
  14816. m.ResetDeletedAt()
  14817. return nil
  14818. case creditusage.FieldUserID:
  14819. m.ResetUserID()
  14820. return nil
  14821. case creditusage.FieldNumber:
  14822. m.ResetNumber()
  14823. return nil
  14824. case creditusage.FieldStatus:
  14825. m.ResetStatus()
  14826. return nil
  14827. case creditusage.FieldNtype:
  14828. m.ResetNtype()
  14829. return nil
  14830. case creditusage.FieldTable:
  14831. m.ResetTable()
  14832. return nil
  14833. case creditusage.FieldOrganizationID:
  14834. m.ResetOrganizationID()
  14835. return nil
  14836. case creditusage.FieldNid:
  14837. m.ResetNid()
  14838. return nil
  14839. case creditusage.FieldReason:
  14840. m.ResetReason()
  14841. return nil
  14842. case creditusage.FieldOperator:
  14843. m.ResetOperator()
  14844. return nil
  14845. }
  14846. return fmt.Errorf("unknown CreditUsage field %s", name)
  14847. }
  14848. // AddedEdges returns all edge names that were set/added in this mutation.
  14849. func (m *CreditUsageMutation) AddedEdges() []string {
  14850. edges := make([]string, 0, 0)
  14851. return edges
  14852. }
  14853. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14854. // name in this mutation.
  14855. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  14856. return nil
  14857. }
  14858. // RemovedEdges returns all edge names that were removed in this mutation.
  14859. func (m *CreditUsageMutation) RemovedEdges() []string {
  14860. edges := make([]string, 0, 0)
  14861. return edges
  14862. }
  14863. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14864. // the given name in this mutation.
  14865. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  14866. return nil
  14867. }
  14868. // ClearedEdges returns all edge names that were cleared in this mutation.
  14869. func (m *CreditUsageMutation) ClearedEdges() []string {
  14870. edges := make([]string, 0, 0)
  14871. return edges
  14872. }
  14873. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14874. // was cleared in this mutation.
  14875. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  14876. return false
  14877. }
  14878. // ClearEdge clears the value of the edge with the given name. It returns an error
  14879. // if that edge is not defined in the schema.
  14880. func (m *CreditUsageMutation) ClearEdge(name string) error {
  14881. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  14882. }
  14883. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14884. // It returns an error if the edge is not defined in the schema.
  14885. func (m *CreditUsageMutation) ResetEdge(name string) error {
  14886. return fmt.Errorf("unknown CreditUsage edge %s", name)
  14887. }
  14888. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  14889. type EmployeeMutation struct {
  14890. config
  14891. op Op
  14892. typ string
  14893. id *uint64
  14894. created_at *time.Time
  14895. updated_at *time.Time
  14896. deleted_at *time.Time
  14897. title *string
  14898. avatar *string
  14899. tags *string
  14900. hire_count *int
  14901. addhire_count *int
  14902. service_count *int
  14903. addservice_count *int
  14904. achievement_count *int
  14905. addachievement_count *int
  14906. intro *string
  14907. estimate *string
  14908. skill *string
  14909. ability_type *string
  14910. scene *string
  14911. switch_in *string
  14912. video_url *string
  14913. organization_id *uint64
  14914. addorganization_id *int64
  14915. category_id *uint64
  14916. addcategory_id *int64
  14917. api_base *string
  14918. api_key *string
  14919. ai_info *string
  14920. is_vip *int
  14921. addis_vip *int
  14922. chat_url *string
  14923. clearedFields map[string]struct{}
  14924. em_work_experiences map[uint64]struct{}
  14925. removedem_work_experiences map[uint64]struct{}
  14926. clearedem_work_experiences bool
  14927. em_tutorial map[uint64]struct{}
  14928. removedem_tutorial map[uint64]struct{}
  14929. clearedem_tutorial bool
  14930. done bool
  14931. oldValue func(context.Context) (*Employee, error)
  14932. predicates []predicate.Employee
  14933. }
  14934. var _ ent.Mutation = (*EmployeeMutation)(nil)
  14935. // employeeOption allows management of the mutation configuration using functional options.
  14936. type employeeOption func(*EmployeeMutation)
  14937. // newEmployeeMutation creates new mutation for the Employee entity.
  14938. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  14939. m := &EmployeeMutation{
  14940. config: c,
  14941. op: op,
  14942. typ: TypeEmployee,
  14943. clearedFields: make(map[string]struct{}),
  14944. }
  14945. for _, opt := range opts {
  14946. opt(m)
  14947. }
  14948. return m
  14949. }
  14950. // withEmployeeID sets the ID field of the mutation.
  14951. func withEmployeeID(id uint64) employeeOption {
  14952. return func(m *EmployeeMutation) {
  14953. var (
  14954. err error
  14955. once sync.Once
  14956. value *Employee
  14957. )
  14958. m.oldValue = func(ctx context.Context) (*Employee, error) {
  14959. once.Do(func() {
  14960. if m.done {
  14961. err = errors.New("querying old values post mutation is not allowed")
  14962. } else {
  14963. value, err = m.Client().Employee.Get(ctx, id)
  14964. }
  14965. })
  14966. return value, err
  14967. }
  14968. m.id = &id
  14969. }
  14970. }
  14971. // withEmployee sets the old Employee of the mutation.
  14972. func withEmployee(node *Employee) employeeOption {
  14973. return func(m *EmployeeMutation) {
  14974. m.oldValue = func(context.Context) (*Employee, error) {
  14975. return node, nil
  14976. }
  14977. m.id = &node.ID
  14978. }
  14979. }
  14980. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14981. // executed in a transaction (ent.Tx), a transactional client is returned.
  14982. func (m EmployeeMutation) Client() *Client {
  14983. client := &Client{config: m.config}
  14984. client.init()
  14985. return client
  14986. }
  14987. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14988. // it returns an error otherwise.
  14989. func (m EmployeeMutation) Tx() (*Tx, error) {
  14990. if _, ok := m.driver.(*txDriver); !ok {
  14991. return nil, errors.New("ent: mutation is not running in a transaction")
  14992. }
  14993. tx := &Tx{config: m.config}
  14994. tx.init()
  14995. return tx, nil
  14996. }
  14997. // SetID sets the value of the id field. Note that this
  14998. // operation is only accepted on creation of Employee entities.
  14999. func (m *EmployeeMutation) SetID(id uint64) {
  15000. m.id = &id
  15001. }
  15002. // ID returns the ID value in the mutation. Note that the ID is only available
  15003. // if it was provided to the builder or after it was returned from the database.
  15004. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  15005. if m.id == nil {
  15006. return
  15007. }
  15008. return *m.id, true
  15009. }
  15010. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15011. // That means, if the mutation is applied within a transaction with an isolation level such
  15012. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15013. // or updated by the mutation.
  15014. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  15015. switch {
  15016. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15017. id, exists := m.ID()
  15018. if exists {
  15019. return []uint64{id}, nil
  15020. }
  15021. fallthrough
  15022. case m.op.Is(OpUpdate | OpDelete):
  15023. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  15024. default:
  15025. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15026. }
  15027. }
  15028. // SetCreatedAt sets the "created_at" field.
  15029. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  15030. m.created_at = &t
  15031. }
  15032. // CreatedAt returns the value of the "created_at" field in the mutation.
  15033. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  15034. v := m.created_at
  15035. if v == nil {
  15036. return
  15037. }
  15038. return *v, true
  15039. }
  15040. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  15041. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15043. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15044. if !m.op.Is(OpUpdateOne) {
  15045. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15046. }
  15047. if m.id == nil || m.oldValue == nil {
  15048. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15049. }
  15050. oldValue, err := m.oldValue(ctx)
  15051. if err != nil {
  15052. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15053. }
  15054. return oldValue.CreatedAt, nil
  15055. }
  15056. // ResetCreatedAt resets all changes to the "created_at" field.
  15057. func (m *EmployeeMutation) ResetCreatedAt() {
  15058. m.created_at = nil
  15059. }
  15060. // SetUpdatedAt sets the "updated_at" field.
  15061. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  15062. m.updated_at = &t
  15063. }
  15064. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15065. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  15066. v := m.updated_at
  15067. if v == nil {
  15068. return
  15069. }
  15070. return *v, true
  15071. }
  15072. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  15073. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15075. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15076. if !m.op.Is(OpUpdateOne) {
  15077. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15078. }
  15079. if m.id == nil || m.oldValue == nil {
  15080. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15081. }
  15082. oldValue, err := m.oldValue(ctx)
  15083. if err != nil {
  15084. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15085. }
  15086. return oldValue.UpdatedAt, nil
  15087. }
  15088. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15089. func (m *EmployeeMutation) ResetUpdatedAt() {
  15090. m.updated_at = nil
  15091. }
  15092. // SetDeletedAt sets the "deleted_at" field.
  15093. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  15094. m.deleted_at = &t
  15095. }
  15096. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15097. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  15098. v := m.deleted_at
  15099. if v == nil {
  15100. return
  15101. }
  15102. return *v, true
  15103. }
  15104. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  15105. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15107. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15108. if !m.op.Is(OpUpdateOne) {
  15109. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15110. }
  15111. if m.id == nil || m.oldValue == nil {
  15112. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15113. }
  15114. oldValue, err := m.oldValue(ctx)
  15115. if err != nil {
  15116. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15117. }
  15118. return oldValue.DeletedAt, nil
  15119. }
  15120. // ClearDeletedAt clears the value of the "deleted_at" field.
  15121. func (m *EmployeeMutation) ClearDeletedAt() {
  15122. m.deleted_at = nil
  15123. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  15124. }
  15125. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15126. func (m *EmployeeMutation) DeletedAtCleared() bool {
  15127. _, ok := m.clearedFields[employee.FieldDeletedAt]
  15128. return ok
  15129. }
  15130. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15131. func (m *EmployeeMutation) ResetDeletedAt() {
  15132. m.deleted_at = nil
  15133. delete(m.clearedFields, employee.FieldDeletedAt)
  15134. }
  15135. // SetTitle sets the "title" field.
  15136. func (m *EmployeeMutation) SetTitle(s string) {
  15137. m.title = &s
  15138. }
  15139. // Title returns the value of the "title" field in the mutation.
  15140. func (m *EmployeeMutation) Title() (r string, exists bool) {
  15141. v := m.title
  15142. if v == nil {
  15143. return
  15144. }
  15145. return *v, true
  15146. }
  15147. // OldTitle returns the old "title" field's value of the Employee entity.
  15148. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15150. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  15151. if !m.op.Is(OpUpdateOne) {
  15152. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15153. }
  15154. if m.id == nil || m.oldValue == nil {
  15155. return v, errors.New("OldTitle requires an ID field in the mutation")
  15156. }
  15157. oldValue, err := m.oldValue(ctx)
  15158. if err != nil {
  15159. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15160. }
  15161. return oldValue.Title, nil
  15162. }
  15163. // ResetTitle resets all changes to the "title" field.
  15164. func (m *EmployeeMutation) ResetTitle() {
  15165. m.title = nil
  15166. }
  15167. // SetAvatar sets the "avatar" field.
  15168. func (m *EmployeeMutation) SetAvatar(s string) {
  15169. m.avatar = &s
  15170. }
  15171. // Avatar returns the value of the "avatar" field in the mutation.
  15172. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  15173. v := m.avatar
  15174. if v == nil {
  15175. return
  15176. }
  15177. return *v, true
  15178. }
  15179. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  15180. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15182. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  15183. if !m.op.Is(OpUpdateOne) {
  15184. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  15185. }
  15186. if m.id == nil || m.oldValue == nil {
  15187. return v, errors.New("OldAvatar requires an ID field in the mutation")
  15188. }
  15189. oldValue, err := m.oldValue(ctx)
  15190. if err != nil {
  15191. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  15192. }
  15193. return oldValue.Avatar, nil
  15194. }
  15195. // ResetAvatar resets all changes to the "avatar" field.
  15196. func (m *EmployeeMutation) ResetAvatar() {
  15197. m.avatar = nil
  15198. }
  15199. // SetTags sets the "tags" field.
  15200. func (m *EmployeeMutation) SetTags(s string) {
  15201. m.tags = &s
  15202. }
  15203. // Tags returns the value of the "tags" field in the mutation.
  15204. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  15205. v := m.tags
  15206. if v == nil {
  15207. return
  15208. }
  15209. return *v, true
  15210. }
  15211. // OldTags returns the old "tags" field's value of the Employee entity.
  15212. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15214. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  15215. if !m.op.Is(OpUpdateOne) {
  15216. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  15217. }
  15218. if m.id == nil || m.oldValue == nil {
  15219. return v, errors.New("OldTags requires an ID field in the mutation")
  15220. }
  15221. oldValue, err := m.oldValue(ctx)
  15222. if err != nil {
  15223. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  15224. }
  15225. return oldValue.Tags, nil
  15226. }
  15227. // ResetTags resets all changes to the "tags" field.
  15228. func (m *EmployeeMutation) ResetTags() {
  15229. m.tags = nil
  15230. }
  15231. // SetHireCount sets the "hire_count" field.
  15232. func (m *EmployeeMutation) SetHireCount(i int) {
  15233. m.hire_count = &i
  15234. m.addhire_count = nil
  15235. }
  15236. // HireCount returns the value of the "hire_count" field in the mutation.
  15237. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  15238. v := m.hire_count
  15239. if v == nil {
  15240. return
  15241. }
  15242. return *v, true
  15243. }
  15244. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  15245. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15247. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  15248. if !m.op.Is(OpUpdateOne) {
  15249. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  15250. }
  15251. if m.id == nil || m.oldValue == nil {
  15252. return v, errors.New("OldHireCount requires an ID field in the mutation")
  15253. }
  15254. oldValue, err := m.oldValue(ctx)
  15255. if err != nil {
  15256. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  15257. }
  15258. return oldValue.HireCount, nil
  15259. }
  15260. // AddHireCount adds i to the "hire_count" field.
  15261. func (m *EmployeeMutation) AddHireCount(i int) {
  15262. if m.addhire_count != nil {
  15263. *m.addhire_count += i
  15264. } else {
  15265. m.addhire_count = &i
  15266. }
  15267. }
  15268. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  15269. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  15270. v := m.addhire_count
  15271. if v == nil {
  15272. return
  15273. }
  15274. return *v, true
  15275. }
  15276. // ResetHireCount resets all changes to the "hire_count" field.
  15277. func (m *EmployeeMutation) ResetHireCount() {
  15278. m.hire_count = nil
  15279. m.addhire_count = nil
  15280. }
  15281. // SetServiceCount sets the "service_count" field.
  15282. func (m *EmployeeMutation) SetServiceCount(i int) {
  15283. m.service_count = &i
  15284. m.addservice_count = nil
  15285. }
  15286. // ServiceCount returns the value of the "service_count" field in the mutation.
  15287. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  15288. v := m.service_count
  15289. if v == nil {
  15290. return
  15291. }
  15292. return *v, true
  15293. }
  15294. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  15295. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15297. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  15298. if !m.op.Is(OpUpdateOne) {
  15299. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  15300. }
  15301. if m.id == nil || m.oldValue == nil {
  15302. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  15303. }
  15304. oldValue, err := m.oldValue(ctx)
  15305. if err != nil {
  15306. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  15307. }
  15308. return oldValue.ServiceCount, nil
  15309. }
  15310. // AddServiceCount adds i to the "service_count" field.
  15311. func (m *EmployeeMutation) AddServiceCount(i int) {
  15312. if m.addservice_count != nil {
  15313. *m.addservice_count += i
  15314. } else {
  15315. m.addservice_count = &i
  15316. }
  15317. }
  15318. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  15319. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  15320. v := m.addservice_count
  15321. if v == nil {
  15322. return
  15323. }
  15324. return *v, true
  15325. }
  15326. // ResetServiceCount resets all changes to the "service_count" field.
  15327. func (m *EmployeeMutation) ResetServiceCount() {
  15328. m.service_count = nil
  15329. m.addservice_count = nil
  15330. }
  15331. // SetAchievementCount sets the "achievement_count" field.
  15332. func (m *EmployeeMutation) SetAchievementCount(i int) {
  15333. m.achievement_count = &i
  15334. m.addachievement_count = nil
  15335. }
  15336. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  15337. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  15338. v := m.achievement_count
  15339. if v == nil {
  15340. return
  15341. }
  15342. return *v, true
  15343. }
  15344. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  15345. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15347. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  15348. if !m.op.Is(OpUpdateOne) {
  15349. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  15350. }
  15351. if m.id == nil || m.oldValue == nil {
  15352. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  15353. }
  15354. oldValue, err := m.oldValue(ctx)
  15355. if err != nil {
  15356. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  15357. }
  15358. return oldValue.AchievementCount, nil
  15359. }
  15360. // AddAchievementCount adds i to the "achievement_count" field.
  15361. func (m *EmployeeMutation) AddAchievementCount(i int) {
  15362. if m.addachievement_count != nil {
  15363. *m.addachievement_count += i
  15364. } else {
  15365. m.addachievement_count = &i
  15366. }
  15367. }
  15368. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  15369. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  15370. v := m.addachievement_count
  15371. if v == nil {
  15372. return
  15373. }
  15374. return *v, true
  15375. }
  15376. // ResetAchievementCount resets all changes to the "achievement_count" field.
  15377. func (m *EmployeeMutation) ResetAchievementCount() {
  15378. m.achievement_count = nil
  15379. m.addachievement_count = nil
  15380. }
  15381. // SetIntro sets the "intro" field.
  15382. func (m *EmployeeMutation) SetIntro(s string) {
  15383. m.intro = &s
  15384. }
  15385. // Intro returns the value of the "intro" field in the mutation.
  15386. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  15387. v := m.intro
  15388. if v == nil {
  15389. return
  15390. }
  15391. return *v, true
  15392. }
  15393. // OldIntro returns the old "intro" field's value of the Employee entity.
  15394. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15396. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  15397. if !m.op.Is(OpUpdateOne) {
  15398. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  15399. }
  15400. if m.id == nil || m.oldValue == nil {
  15401. return v, errors.New("OldIntro requires an ID field in the mutation")
  15402. }
  15403. oldValue, err := m.oldValue(ctx)
  15404. if err != nil {
  15405. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  15406. }
  15407. return oldValue.Intro, nil
  15408. }
  15409. // ResetIntro resets all changes to the "intro" field.
  15410. func (m *EmployeeMutation) ResetIntro() {
  15411. m.intro = nil
  15412. }
  15413. // SetEstimate sets the "estimate" field.
  15414. func (m *EmployeeMutation) SetEstimate(s string) {
  15415. m.estimate = &s
  15416. }
  15417. // Estimate returns the value of the "estimate" field in the mutation.
  15418. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  15419. v := m.estimate
  15420. if v == nil {
  15421. return
  15422. }
  15423. return *v, true
  15424. }
  15425. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  15426. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15428. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  15429. if !m.op.Is(OpUpdateOne) {
  15430. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  15431. }
  15432. if m.id == nil || m.oldValue == nil {
  15433. return v, errors.New("OldEstimate requires an ID field in the mutation")
  15434. }
  15435. oldValue, err := m.oldValue(ctx)
  15436. if err != nil {
  15437. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  15438. }
  15439. return oldValue.Estimate, nil
  15440. }
  15441. // ResetEstimate resets all changes to the "estimate" field.
  15442. func (m *EmployeeMutation) ResetEstimate() {
  15443. m.estimate = nil
  15444. }
  15445. // SetSkill sets the "skill" field.
  15446. func (m *EmployeeMutation) SetSkill(s string) {
  15447. m.skill = &s
  15448. }
  15449. // Skill returns the value of the "skill" field in the mutation.
  15450. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  15451. v := m.skill
  15452. if v == nil {
  15453. return
  15454. }
  15455. return *v, true
  15456. }
  15457. // OldSkill returns the old "skill" field's value of the Employee entity.
  15458. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15460. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  15461. if !m.op.Is(OpUpdateOne) {
  15462. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  15463. }
  15464. if m.id == nil || m.oldValue == nil {
  15465. return v, errors.New("OldSkill requires an ID field in the mutation")
  15466. }
  15467. oldValue, err := m.oldValue(ctx)
  15468. if err != nil {
  15469. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  15470. }
  15471. return oldValue.Skill, nil
  15472. }
  15473. // ResetSkill resets all changes to the "skill" field.
  15474. func (m *EmployeeMutation) ResetSkill() {
  15475. m.skill = nil
  15476. }
  15477. // SetAbilityType sets the "ability_type" field.
  15478. func (m *EmployeeMutation) SetAbilityType(s string) {
  15479. m.ability_type = &s
  15480. }
  15481. // AbilityType returns the value of the "ability_type" field in the mutation.
  15482. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  15483. v := m.ability_type
  15484. if v == nil {
  15485. return
  15486. }
  15487. return *v, true
  15488. }
  15489. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  15490. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15492. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  15493. if !m.op.Is(OpUpdateOne) {
  15494. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  15495. }
  15496. if m.id == nil || m.oldValue == nil {
  15497. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  15498. }
  15499. oldValue, err := m.oldValue(ctx)
  15500. if err != nil {
  15501. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  15502. }
  15503. return oldValue.AbilityType, nil
  15504. }
  15505. // ResetAbilityType resets all changes to the "ability_type" field.
  15506. func (m *EmployeeMutation) ResetAbilityType() {
  15507. m.ability_type = nil
  15508. }
  15509. // SetScene sets the "scene" field.
  15510. func (m *EmployeeMutation) SetScene(s string) {
  15511. m.scene = &s
  15512. }
  15513. // Scene returns the value of the "scene" field in the mutation.
  15514. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  15515. v := m.scene
  15516. if v == nil {
  15517. return
  15518. }
  15519. return *v, true
  15520. }
  15521. // OldScene returns the old "scene" field's value of the Employee entity.
  15522. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15524. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  15525. if !m.op.Is(OpUpdateOne) {
  15526. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  15527. }
  15528. if m.id == nil || m.oldValue == nil {
  15529. return v, errors.New("OldScene requires an ID field in the mutation")
  15530. }
  15531. oldValue, err := m.oldValue(ctx)
  15532. if err != nil {
  15533. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  15534. }
  15535. return oldValue.Scene, nil
  15536. }
  15537. // ResetScene resets all changes to the "scene" field.
  15538. func (m *EmployeeMutation) ResetScene() {
  15539. m.scene = nil
  15540. }
  15541. // SetSwitchIn sets the "switch_in" field.
  15542. func (m *EmployeeMutation) SetSwitchIn(s string) {
  15543. m.switch_in = &s
  15544. }
  15545. // SwitchIn returns the value of the "switch_in" field in the mutation.
  15546. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  15547. v := m.switch_in
  15548. if v == nil {
  15549. return
  15550. }
  15551. return *v, true
  15552. }
  15553. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  15554. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15556. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  15557. if !m.op.Is(OpUpdateOne) {
  15558. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  15559. }
  15560. if m.id == nil || m.oldValue == nil {
  15561. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  15562. }
  15563. oldValue, err := m.oldValue(ctx)
  15564. if err != nil {
  15565. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  15566. }
  15567. return oldValue.SwitchIn, nil
  15568. }
  15569. // ResetSwitchIn resets all changes to the "switch_in" field.
  15570. func (m *EmployeeMutation) ResetSwitchIn() {
  15571. m.switch_in = nil
  15572. }
  15573. // SetVideoURL sets the "video_url" field.
  15574. func (m *EmployeeMutation) SetVideoURL(s string) {
  15575. m.video_url = &s
  15576. }
  15577. // VideoURL returns the value of the "video_url" field in the mutation.
  15578. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  15579. v := m.video_url
  15580. if v == nil {
  15581. return
  15582. }
  15583. return *v, true
  15584. }
  15585. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  15586. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15588. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  15589. if !m.op.Is(OpUpdateOne) {
  15590. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  15591. }
  15592. if m.id == nil || m.oldValue == nil {
  15593. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  15594. }
  15595. oldValue, err := m.oldValue(ctx)
  15596. if err != nil {
  15597. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  15598. }
  15599. return oldValue.VideoURL, nil
  15600. }
  15601. // ResetVideoURL resets all changes to the "video_url" field.
  15602. func (m *EmployeeMutation) ResetVideoURL() {
  15603. m.video_url = nil
  15604. }
  15605. // SetOrganizationID sets the "organization_id" field.
  15606. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  15607. m.organization_id = &u
  15608. m.addorganization_id = nil
  15609. }
  15610. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15611. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  15612. v := m.organization_id
  15613. if v == nil {
  15614. return
  15615. }
  15616. return *v, true
  15617. }
  15618. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  15619. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15621. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15622. if !m.op.Is(OpUpdateOne) {
  15623. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15624. }
  15625. if m.id == nil || m.oldValue == nil {
  15626. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15627. }
  15628. oldValue, err := m.oldValue(ctx)
  15629. if err != nil {
  15630. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15631. }
  15632. return oldValue.OrganizationID, nil
  15633. }
  15634. // AddOrganizationID adds u to the "organization_id" field.
  15635. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  15636. if m.addorganization_id != nil {
  15637. *m.addorganization_id += u
  15638. } else {
  15639. m.addorganization_id = &u
  15640. }
  15641. }
  15642. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15643. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  15644. v := m.addorganization_id
  15645. if v == nil {
  15646. return
  15647. }
  15648. return *v, true
  15649. }
  15650. // ResetOrganizationID resets all changes to the "organization_id" field.
  15651. func (m *EmployeeMutation) ResetOrganizationID() {
  15652. m.organization_id = nil
  15653. m.addorganization_id = nil
  15654. }
  15655. // SetCategoryID sets the "category_id" field.
  15656. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  15657. m.category_id = &u
  15658. m.addcategory_id = nil
  15659. }
  15660. // CategoryID returns the value of the "category_id" field in the mutation.
  15661. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  15662. v := m.category_id
  15663. if v == nil {
  15664. return
  15665. }
  15666. return *v, true
  15667. }
  15668. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  15669. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15671. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  15672. if !m.op.Is(OpUpdateOne) {
  15673. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  15674. }
  15675. if m.id == nil || m.oldValue == nil {
  15676. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  15677. }
  15678. oldValue, err := m.oldValue(ctx)
  15679. if err != nil {
  15680. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  15681. }
  15682. return oldValue.CategoryID, nil
  15683. }
  15684. // AddCategoryID adds u to the "category_id" field.
  15685. func (m *EmployeeMutation) AddCategoryID(u int64) {
  15686. if m.addcategory_id != nil {
  15687. *m.addcategory_id += u
  15688. } else {
  15689. m.addcategory_id = &u
  15690. }
  15691. }
  15692. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  15693. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  15694. v := m.addcategory_id
  15695. if v == nil {
  15696. return
  15697. }
  15698. return *v, true
  15699. }
  15700. // ResetCategoryID resets all changes to the "category_id" field.
  15701. func (m *EmployeeMutation) ResetCategoryID() {
  15702. m.category_id = nil
  15703. m.addcategory_id = nil
  15704. }
  15705. // SetAPIBase sets the "api_base" field.
  15706. func (m *EmployeeMutation) SetAPIBase(s string) {
  15707. m.api_base = &s
  15708. }
  15709. // APIBase returns the value of the "api_base" field in the mutation.
  15710. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  15711. v := m.api_base
  15712. if v == nil {
  15713. return
  15714. }
  15715. return *v, true
  15716. }
  15717. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  15718. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15720. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  15721. if !m.op.Is(OpUpdateOne) {
  15722. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  15723. }
  15724. if m.id == nil || m.oldValue == nil {
  15725. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  15726. }
  15727. oldValue, err := m.oldValue(ctx)
  15728. if err != nil {
  15729. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  15730. }
  15731. return oldValue.APIBase, nil
  15732. }
  15733. // ResetAPIBase resets all changes to the "api_base" field.
  15734. func (m *EmployeeMutation) ResetAPIBase() {
  15735. m.api_base = nil
  15736. }
  15737. // SetAPIKey sets the "api_key" field.
  15738. func (m *EmployeeMutation) SetAPIKey(s string) {
  15739. m.api_key = &s
  15740. }
  15741. // APIKey returns the value of the "api_key" field in the mutation.
  15742. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  15743. v := m.api_key
  15744. if v == nil {
  15745. return
  15746. }
  15747. return *v, true
  15748. }
  15749. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  15750. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15752. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  15753. if !m.op.Is(OpUpdateOne) {
  15754. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  15755. }
  15756. if m.id == nil || m.oldValue == nil {
  15757. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  15758. }
  15759. oldValue, err := m.oldValue(ctx)
  15760. if err != nil {
  15761. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  15762. }
  15763. return oldValue.APIKey, nil
  15764. }
  15765. // ResetAPIKey resets all changes to the "api_key" field.
  15766. func (m *EmployeeMutation) ResetAPIKey() {
  15767. m.api_key = nil
  15768. }
  15769. // SetAiInfo sets the "ai_info" field.
  15770. func (m *EmployeeMutation) SetAiInfo(s string) {
  15771. m.ai_info = &s
  15772. }
  15773. // AiInfo returns the value of the "ai_info" field in the mutation.
  15774. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  15775. v := m.ai_info
  15776. if v == nil {
  15777. return
  15778. }
  15779. return *v, true
  15780. }
  15781. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  15782. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15784. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  15785. if !m.op.Is(OpUpdateOne) {
  15786. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  15787. }
  15788. if m.id == nil || m.oldValue == nil {
  15789. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  15790. }
  15791. oldValue, err := m.oldValue(ctx)
  15792. if err != nil {
  15793. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  15794. }
  15795. return oldValue.AiInfo, nil
  15796. }
  15797. // ClearAiInfo clears the value of the "ai_info" field.
  15798. func (m *EmployeeMutation) ClearAiInfo() {
  15799. m.ai_info = nil
  15800. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  15801. }
  15802. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  15803. func (m *EmployeeMutation) AiInfoCleared() bool {
  15804. _, ok := m.clearedFields[employee.FieldAiInfo]
  15805. return ok
  15806. }
  15807. // ResetAiInfo resets all changes to the "ai_info" field.
  15808. func (m *EmployeeMutation) ResetAiInfo() {
  15809. m.ai_info = nil
  15810. delete(m.clearedFields, employee.FieldAiInfo)
  15811. }
  15812. // SetIsVip sets the "is_vip" field.
  15813. func (m *EmployeeMutation) SetIsVip(i int) {
  15814. m.is_vip = &i
  15815. m.addis_vip = nil
  15816. }
  15817. // IsVip returns the value of the "is_vip" field in the mutation.
  15818. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  15819. v := m.is_vip
  15820. if v == nil {
  15821. return
  15822. }
  15823. return *v, true
  15824. }
  15825. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  15826. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15828. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  15829. if !m.op.Is(OpUpdateOne) {
  15830. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  15831. }
  15832. if m.id == nil || m.oldValue == nil {
  15833. return v, errors.New("OldIsVip requires an ID field in the mutation")
  15834. }
  15835. oldValue, err := m.oldValue(ctx)
  15836. if err != nil {
  15837. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  15838. }
  15839. return oldValue.IsVip, nil
  15840. }
  15841. // AddIsVip adds i to the "is_vip" field.
  15842. func (m *EmployeeMutation) AddIsVip(i int) {
  15843. if m.addis_vip != nil {
  15844. *m.addis_vip += i
  15845. } else {
  15846. m.addis_vip = &i
  15847. }
  15848. }
  15849. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  15850. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  15851. v := m.addis_vip
  15852. if v == nil {
  15853. return
  15854. }
  15855. return *v, true
  15856. }
  15857. // ResetIsVip resets all changes to the "is_vip" field.
  15858. func (m *EmployeeMutation) ResetIsVip() {
  15859. m.is_vip = nil
  15860. m.addis_vip = nil
  15861. }
  15862. // SetChatURL sets the "chat_url" field.
  15863. func (m *EmployeeMutation) SetChatURL(s string) {
  15864. m.chat_url = &s
  15865. }
  15866. // ChatURL returns the value of the "chat_url" field in the mutation.
  15867. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  15868. v := m.chat_url
  15869. if v == nil {
  15870. return
  15871. }
  15872. return *v, true
  15873. }
  15874. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  15875. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15877. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  15878. if !m.op.Is(OpUpdateOne) {
  15879. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  15880. }
  15881. if m.id == nil || m.oldValue == nil {
  15882. return v, errors.New("OldChatURL requires an ID field in the mutation")
  15883. }
  15884. oldValue, err := m.oldValue(ctx)
  15885. if err != nil {
  15886. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  15887. }
  15888. return oldValue.ChatURL, nil
  15889. }
  15890. // ResetChatURL resets all changes to the "chat_url" field.
  15891. func (m *EmployeeMutation) ResetChatURL() {
  15892. m.chat_url = nil
  15893. }
  15894. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  15895. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  15896. if m.em_work_experiences == nil {
  15897. m.em_work_experiences = make(map[uint64]struct{})
  15898. }
  15899. for i := range ids {
  15900. m.em_work_experiences[ids[i]] = struct{}{}
  15901. }
  15902. }
  15903. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  15904. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  15905. m.clearedem_work_experiences = true
  15906. }
  15907. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  15908. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  15909. return m.clearedem_work_experiences
  15910. }
  15911. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  15912. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  15913. if m.removedem_work_experiences == nil {
  15914. m.removedem_work_experiences = make(map[uint64]struct{})
  15915. }
  15916. for i := range ids {
  15917. delete(m.em_work_experiences, ids[i])
  15918. m.removedem_work_experiences[ids[i]] = struct{}{}
  15919. }
  15920. }
  15921. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  15922. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  15923. for id := range m.removedem_work_experiences {
  15924. ids = append(ids, id)
  15925. }
  15926. return
  15927. }
  15928. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  15929. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  15930. for id := range m.em_work_experiences {
  15931. ids = append(ids, id)
  15932. }
  15933. return
  15934. }
  15935. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  15936. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  15937. m.em_work_experiences = nil
  15938. m.clearedem_work_experiences = false
  15939. m.removedem_work_experiences = nil
  15940. }
  15941. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  15942. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  15943. if m.em_tutorial == nil {
  15944. m.em_tutorial = make(map[uint64]struct{})
  15945. }
  15946. for i := range ids {
  15947. m.em_tutorial[ids[i]] = struct{}{}
  15948. }
  15949. }
  15950. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  15951. func (m *EmployeeMutation) ClearEmTutorial() {
  15952. m.clearedem_tutorial = true
  15953. }
  15954. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  15955. func (m *EmployeeMutation) EmTutorialCleared() bool {
  15956. return m.clearedem_tutorial
  15957. }
  15958. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  15959. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  15960. if m.removedem_tutorial == nil {
  15961. m.removedem_tutorial = make(map[uint64]struct{})
  15962. }
  15963. for i := range ids {
  15964. delete(m.em_tutorial, ids[i])
  15965. m.removedem_tutorial[ids[i]] = struct{}{}
  15966. }
  15967. }
  15968. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  15969. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  15970. for id := range m.removedem_tutorial {
  15971. ids = append(ids, id)
  15972. }
  15973. return
  15974. }
  15975. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  15976. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  15977. for id := range m.em_tutorial {
  15978. ids = append(ids, id)
  15979. }
  15980. return
  15981. }
  15982. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  15983. func (m *EmployeeMutation) ResetEmTutorial() {
  15984. m.em_tutorial = nil
  15985. m.clearedem_tutorial = false
  15986. m.removedem_tutorial = nil
  15987. }
  15988. // Where appends a list predicates to the EmployeeMutation builder.
  15989. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  15990. m.predicates = append(m.predicates, ps...)
  15991. }
  15992. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  15993. // users can use type-assertion to append predicates that do not depend on any generated package.
  15994. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  15995. p := make([]predicate.Employee, len(ps))
  15996. for i := range ps {
  15997. p[i] = ps[i]
  15998. }
  15999. m.Where(p...)
  16000. }
  16001. // Op returns the operation name.
  16002. func (m *EmployeeMutation) Op() Op {
  16003. return m.op
  16004. }
  16005. // SetOp allows setting the mutation operation.
  16006. func (m *EmployeeMutation) SetOp(op Op) {
  16007. m.op = op
  16008. }
  16009. // Type returns the node type of this mutation (Employee).
  16010. func (m *EmployeeMutation) Type() string {
  16011. return m.typ
  16012. }
  16013. // Fields returns all fields that were changed during this mutation. Note that in
  16014. // order to get all numeric fields that were incremented/decremented, call
  16015. // AddedFields().
  16016. func (m *EmployeeMutation) Fields() []string {
  16017. fields := make([]string, 0, 23)
  16018. if m.created_at != nil {
  16019. fields = append(fields, employee.FieldCreatedAt)
  16020. }
  16021. if m.updated_at != nil {
  16022. fields = append(fields, employee.FieldUpdatedAt)
  16023. }
  16024. if m.deleted_at != nil {
  16025. fields = append(fields, employee.FieldDeletedAt)
  16026. }
  16027. if m.title != nil {
  16028. fields = append(fields, employee.FieldTitle)
  16029. }
  16030. if m.avatar != nil {
  16031. fields = append(fields, employee.FieldAvatar)
  16032. }
  16033. if m.tags != nil {
  16034. fields = append(fields, employee.FieldTags)
  16035. }
  16036. if m.hire_count != nil {
  16037. fields = append(fields, employee.FieldHireCount)
  16038. }
  16039. if m.service_count != nil {
  16040. fields = append(fields, employee.FieldServiceCount)
  16041. }
  16042. if m.achievement_count != nil {
  16043. fields = append(fields, employee.FieldAchievementCount)
  16044. }
  16045. if m.intro != nil {
  16046. fields = append(fields, employee.FieldIntro)
  16047. }
  16048. if m.estimate != nil {
  16049. fields = append(fields, employee.FieldEstimate)
  16050. }
  16051. if m.skill != nil {
  16052. fields = append(fields, employee.FieldSkill)
  16053. }
  16054. if m.ability_type != nil {
  16055. fields = append(fields, employee.FieldAbilityType)
  16056. }
  16057. if m.scene != nil {
  16058. fields = append(fields, employee.FieldScene)
  16059. }
  16060. if m.switch_in != nil {
  16061. fields = append(fields, employee.FieldSwitchIn)
  16062. }
  16063. if m.video_url != nil {
  16064. fields = append(fields, employee.FieldVideoURL)
  16065. }
  16066. if m.organization_id != nil {
  16067. fields = append(fields, employee.FieldOrganizationID)
  16068. }
  16069. if m.category_id != nil {
  16070. fields = append(fields, employee.FieldCategoryID)
  16071. }
  16072. if m.api_base != nil {
  16073. fields = append(fields, employee.FieldAPIBase)
  16074. }
  16075. if m.api_key != nil {
  16076. fields = append(fields, employee.FieldAPIKey)
  16077. }
  16078. if m.ai_info != nil {
  16079. fields = append(fields, employee.FieldAiInfo)
  16080. }
  16081. if m.is_vip != nil {
  16082. fields = append(fields, employee.FieldIsVip)
  16083. }
  16084. if m.chat_url != nil {
  16085. fields = append(fields, employee.FieldChatURL)
  16086. }
  16087. return fields
  16088. }
  16089. // Field returns the value of a field with the given name. The second boolean
  16090. // return value indicates that this field was not set, or was not defined in the
  16091. // schema.
  16092. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  16093. switch name {
  16094. case employee.FieldCreatedAt:
  16095. return m.CreatedAt()
  16096. case employee.FieldUpdatedAt:
  16097. return m.UpdatedAt()
  16098. case employee.FieldDeletedAt:
  16099. return m.DeletedAt()
  16100. case employee.FieldTitle:
  16101. return m.Title()
  16102. case employee.FieldAvatar:
  16103. return m.Avatar()
  16104. case employee.FieldTags:
  16105. return m.Tags()
  16106. case employee.FieldHireCount:
  16107. return m.HireCount()
  16108. case employee.FieldServiceCount:
  16109. return m.ServiceCount()
  16110. case employee.FieldAchievementCount:
  16111. return m.AchievementCount()
  16112. case employee.FieldIntro:
  16113. return m.Intro()
  16114. case employee.FieldEstimate:
  16115. return m.Estimate()
  16116. case employee.FieldSkill:
  16117. return m.Skill()
  16118. case employee.FieldAbilityType:
  16119. return m.AbilityType()
  16120. case employee.FieldScene:
  16121. return m.Scene()
  16122. case employee.FieldSwitchIn:
  16123. return m.SwitchIn()
  16124. case employee.FieldVideoURL:
  16125. return m.VideoURL()
  16126. case employee.FieldOrganizationID:
  16127. return m.OrganizationID()
  16128. case employee.FieldCategoryID:
  16129. return m.CategoryID()
  16130. case employee.FieldAPIBase:
  16131. return m.APIBase()
  16132. case employee.FieldAPIKey:
  16133. return m.APIKey()
  16134. case employee.FieldAiInfo:
  16135. return m.AiInfo()
  16136. case employee.FieldIsVip:
  16137. return m.IsVip()
  16138. case employee.FieldChatURL:
  16139. return m.ChatURL()
  16140. }
  16141. return nil, false
  16142. }
  16143. // OldField returns the old value of the field from the database. An error is
  16144. // returned if the mutation operation is not UpdateOne, or the query to the
  16145. // database failed.
  16146. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16147. switch name {
  16148. case employee.FieldCreatedAt:
  16149. return m.OldCreatedAt(ctx)
  16150. case employee.FieldUpdatedAt:
  16151. return m.OldUpdatedAt(ctx)
  16152. case employee.FieldDeletedAt:
  16153. return m.OldDeletedAt(ctx)
  16154. case employee.FieldTitle:
  16155. return m.OldTitle(ctx)
  16156. case employee.FieldAvatar:
  16157. return m.OldAvatar(ctx)
  16158. case employee.FieldTags:
  16159. return m.OldTags(ctx)
  16160. case employee.FieldHireCount:
  16161. return m.OldHireCount(ctx)
  16162. case employee.FieldServiceCount:
  16163. return m.OldServiceCount(ctx)
  16164. case employee.FieldAchievementCount:
  16165. return m.OldAchievementCount(ctx)
  16166. case employee.FieldIntro:
  16167. return m.OldIntro(ctx)
  16168. case employee.FieldEstimate:
  16169. return m.OldEstimate(ctx)
  16170. case employee.FieldSkill:
  16171. return m.OldSkill(ctx)
  16172. case employee.FieldAbilityType:
  16173. return m.OldAbilityType(ctx)
  16174. case employee.FieldScene:
  16175. return m.OldScene(ctx)
  16176. case employee.FieldSwitchIn:
  16177. return m.OldSwitchIn(ctx)
  16178. case employee.FieldVideoURL:
  16179. return m.OldVideoURL(ctx)
  16180. case employee.FieldOrganizationID:
  16181. return m.OldOrganizationID(ctx)
  16182. case employee.FieldCategoryID:
  16183. return m.OldCategoryID(ctx)
  16184. case employee.FieldAPIBase:
  16185. return m.OldAPIBase(ctx)
  16186. case employee.FieldAPIKey:
  16187. return m.OldAPIKey(ctx)
  16188. case employee.FieldAiInfo:
  16189. return m.OldAiInfo(ctx)
  16190. case employee.FieldIsVip:
  16191. return m.OldIsVip(ctx)
  16192. case employee.FieldChatURL:
  16193. return m.OldChatURL(ctx)
  16194. }
  16195. return nil, fmt.Errorf("unknown Employee field %s", name)
  16196. }
  16197. // SetField sets the value of a field with the given name. It returns an error if
  16198. // the field is not defined in the schema, or if the type mismatched the field
  16199. // type.
  16200. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  16201. switch name {
  16202. case employee.FieldCreatedAt:
  16203. v, ok := value.(time.Time)
  16204. if !ok {
  16205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16206. }
  16207. m.SetCreatedAt(v)
  16208. return nil
  16209. case employee.FieldUpdatedAt:
  16210. v, ok := value.(time.Time)
  16211. if !ok {
  16212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16213. }
  16214. m.SetUpdatedAt(v)
  16215. return nil
  16216. case employee.FieldDeletedAt:
  16217. v, ok := value.(time.Time)
  16218. if !ok {
  16219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16220. }
  16221. m.SetDeletedAt(v)
  16222. return nil
  16223. case employee.FieldTitle:
  16224. v, ok := value.(string)
  16225. if !ok {
  16226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16227. }
  16228. m.SetTitle(v)
  16229. return nil
  16230. case employee.FieldAvatar:
  16231. v, ok := value.(string)
  16232. if !ok {
  16233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16234. }
  16235. m.SetAvatar(v)
  16236. return nil
  16237. case employee.FieldTags:
  16238. v, ok := value.(string)
  16239. if !ok {
  16240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16241. }
  16242. m.SetTags(v)
  16243. return nil
  16244. case employee.FieldHireCount:
  16245. v, ok := value.(int)
  16246. if !ok {
  16247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16248. }
  16249. m.SetHireCount(v)
  16250. return nil
  16251. case employee.FieldServiceCount:
  16252. v, ok := value.(int)
  16253. if !ok {
  16254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16255. }
  16256. m.SetServiceCount(v)
  16257. return nil
  16258. case employee.FieldAchievementCount:
  16259. v, ok := value.(int)
  16260. if !ok {
  16261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16262. }
  16263. m.SetAchievementCount(v)
  16264. return nil
  16265. case employee.FieldIntro:
  16266. v, ok := value.(string)
  16267. if !ok {
  16268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16269. }
  16270. m.SetIntro(v)
  16271. return nil
  16272. case employee.FieldEstimate:
  16273. v, ok := value.(string)
  16274. if !ok {
  16275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16276. }
  16277. m.SetEstimate(v)
  16278. return nil
  16279. case employee.FieldSkill:
  16280. v, ok := value.(string)
  16281. if !ok {
  16282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16283. }
  16284. m.SetSkill(v)
  16285. return nil
  16286. case employee.FieldAbilityType:
  16287. v, ok := value.(string)
  16288. if !ok {
  16289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16290. }
  16291. m.SetAbilityType(v)
  16292. return nil
  16293. case employee.FieldScene:
  16294. v, ok := value.(string)
  16295. if !ok {
  16296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16297. }
  16298. m.SetScene(v)
  16299. return nil
  16300. case employee.FieldSwitchIn:
  16301. v, ok := value.(string)
  16302. if !ok {
  16303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16304. }
  16305. m.SetSwitchIn(v)
  16306. return nil
  16307. case employee.FieldVideoURL:
  16308. v, ok := value.(string)
  16309. if !ok {
  16310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16311. }
  16312. m.SetVideoURL(v)
  16313. return nil
  16314. case employee.FieldOrganizationID:
  16315. v, ok := value.(uint64)
  16316. if !ok {
  16317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16318. }
  16319. m.SetOrganizationID(v)
  16320. return nil
  16321. case employee.FieldCategoryID:
  16322. v, ok := value.(uint64)
  16323. if !ok {
  16324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16325. }
  16326. m.SetCategoryID(v)
  16327. return nil
  16328. case employee.FieldAPIBase:
  16329. v, ok := value.(string)
  16330. if !ok {
  16331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16332. }
  16333. m.SetAPIBase(v)
  16334. return nil
  16335. case employee.FieldAPIKey:
  16336. v, ok := value.(string)
  16337. if !ok {
  16338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16339. }
  16340. m.SetAPIKey(v)
  16341. return nil
  16342. case employee.FieldAiInfo:
  16343. v, ok := value.(string)
  16344. if !ok {
  16345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16346. }
  16347. m.SetAiInfo(v)
  16348. return nil
  16349. case employee.FieldIsVip:
  16350. v, ok := value.(int)
  16351. if !ok {
  16352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16353. }
  16354. m.SetIsVip(v)
  16355. return nil
  16356. case employee.FieldChatURL:
  16357. v, ok := value.(string)
  16358. if !ok {
  16359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16360. }
  16361. m.SetChatURL(v)
  16362. return nil
  16363. }
  16364. return fmt.Errorf("unknown Employee field %s", name)
  16365. }
  16366. // AddedFields returns all numeric fields that were incremented/decremented during
  16367. // this mutation.
  16368. func (m *EmployeeMutation) AddedFields() []string {
  16369. var fields []string
  16370. if m.addhire_count != nil {
  16371. fields = append(fields, employee.FieldHireCount)
  16372. }
  16373. if m.addservice_count != nil {
  16374. fields = append(fields, employee.FieldServiceCount)
  16375. }
  16376. if m.addachievement_count != nil {
  16377. fields = append(fields, employee.FieldAchievementCount)
  16378. }
  16379. if m.addorganization_id != nil {
  16380. fields = append(fields, employee.FieldOrganizationID)
  16381. }
  16382. if m.addcategory_id != nil {
  16383. fields = append(fields, employee.FieldCategoryID)
  16384. }
  16385. if m.addis_vip != nil {
  16386. fields = append(fields, employee.FieldIsVip)
  16387. }
  16388. return fields
  16389. }
  16390. // AddedField returns the numeric value that was incremented/decremented on a field
  16391. // with the given name. The second boolean return value indicates that this field
  16392. // was not set, or was not defined in the schema.
  16393. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  16394. switch name {
  16395. case employee.FieldHireCount:
  16396. return m.AddedHireCount()
  16397. case employee.FieldServiceCount:
  16398. return m.AddedServiceCount()
  16399. case employee.FieldAchievementCount:
  16400. return m.AddedAchievementCount()
  16401. case employee.FieldOrganizationID:
  16402. return m.AddedOrganizationID()
  16403. case employee.FieldCategoryID:
  16404. return m.AddedCategoryID()
  16405. case employee.FieldIsVip:
  16406. return m.AddedIsVip()
  16407. }
  16408. return nil, false
  16409. }
  16410. // AddField adds the value to the field with the given name. It returns an error if
  16411. // the field is not defined in the schema, or if the type mismatched the field
  16412. // type.
  16413. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  16414. switch name {
  16415. case employee.FieldHireCount:
  16416. v, ok := value.(int)
  16417. if !ok {
  16418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16419. }
  16420. m.AddHireCount(v)
  16421. return nil
  16422. case employee.FieldServiceCount:
  16423. v, ok := value.(int)
  16424. if !ok {
  16425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16426. }
  16427. m.AddServiceCount(v)
  16428. return nil
  16429. case employee.FieldAchievementCount:
  16430. v, ok := value.(int)
  16431. if !ok {
  16432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16433. }
  16434. m.AddAchievementCount(v)
  16435. return nil
  16436. case employee.FieldOrganizationID:
  16437. v, ok := value.(int64)
  16438. if !ok {
  16439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16440. }
  16441. m.AddOrganizationID(v)
  16442. return nil
  16443. case employee.FieldCategoryID:
  16444. v, ok := value.(int64)
  16445. if !ok {
  16446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16447. }
  16448. m.AddCategoryID(v)
  16449. return nil
  16450. case employee.FieldIsVip:
  16451. v, ok := value.(int)
  16452. if !ok {
  16453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16454. }
  16455. m.AddIsVip(v)
  16456. return nil
  16457. }
  16458. return fmt.Errorf("unknown Employee numeric field %s", name)
  16459. }
  16460. // ClearedFields returns all nullable fields that were cleared during this
  16461. // mutation.
  16462. func (m *EmployeeMutation) ClearedFields() []string {
  16463. var fields []string
  16464. if m.FieldCleared(employee.FieldDeletedAt) {
  16465. fields = append(fields, employee.FieldDeletedAt)
  16466. }
  16467. if m.FieldCleared(employee.FieldAiInfo) {
  16468. fields = append(fields, employee.FieldAiInfo)
  16469. }
  16470. return fields
  16471. }
  16472. // FieldCleared returns a boolean indicating if a field with the given name was
  16473. // cleared in this mutation.
  16474. func (m *EmployeeMutation) FieldCleared(name string) bool {
  16475. _, ok := m.clearedFields[name]
  16476. return ok
  16477. }
  16478. // ClearField clears the value of the field with the given name. It returns an
  16479. // error if the field is not defined in the schema.
  16480. func (m *EmployeeMutation) ClearField(name string) error {
  16481. switch name {
  16482. case employee.FieldDeletedAt:
  16483. m.ClearDeletedAt()
  16484. return nil
  16485. case employee.FieldAiInfo:
  16486. m.ClearAiInfo()
  16487. return nil
  16488. }
  16489. return fmt.Errorf("unknown Employee nullable field %s", name)
  16490. }
  16491. // ResetField resets all changes in the mutation for the field with the given name.
  16492. // It returns an error if the field is not defined in the schema.
  16493. func (m *EmployeeMutation) ResetField(name string) error {
  16494. switch name {
  16495. case employee.FieldCreatedAt:
  16496. m.ResetCreatedAt()
  16497. return nil
  16498. case employee.FieldUpdatedAt:
  16499. m.ResetUpdatedAt()
  16500. return nil
  16501. case employee.FieldDeletedAt:
  16502. m.ResetDeletedAt()
  16503. return nil
  16504. case employee.FieldTitle:
  16505. m.ResetTitle()
  16506. return nil
  16507. case employee.FieldAvatar:
  16508. m.ResetAvatar()
  16509. return nil
  16510. case employee.FieldTags:
  16511. m.ResetTags()
  16512. return nil
  16513. case employee.FieldHireCount:
  16514. m.ResetHireCount()
  16515. return nil
  16516. case employee.FieldServiceCount:
  16517. m.ResetServiceCount()
  16518. return nil
  16519. case employee.FieldAchievementCount:
  16520. m.ResetAchievementCount()
  16521. return nil
  16522. case employee.FieldIntro:
  16523. m.ResetIntro()
  16524. return nil
  16525. case employee.FieldEstimate:
  16526. m.ResetEstimate()
  16527. return nil
  16528. case employee.FieldSkill:
  16529. m.ResetSkill()
  16530. return nil
  16531. case employee.FieldAbilityType:
  16532. m.ResetAbilityType()
  16533. return nil
  16534. case employee.FieldScene:
  16535. m.ResetScene()
  16536. return nil
  16537. case employee.FieldSwitchIn:
  16538. m.ResetSwitchIn()
  16539. return nil
  16540. case employee.FieldVideoURL:
  16541. m.ResetVideoURL()
  16542. return nil
  16543. case employee.FieldOrganizationID:
  16544. m.ResetOrganizationID()
  16545. return nil
  16546. case employee.FieldCategoryID:
  16547. m.ResetCategoryID()
  16548. return nil
  16549. case employee.FieldAPIBase:
  16550. m.ResetAPIBase()
  16551. return nil
  16552. case employee.FieldAPIKey:
  16553. m.ResetAPIKey()
  16554. return nil
  16555. case employee.FieldAiInfo:
  16556. m.ResetAiInfo()
  16557. return nil
  16558. case employee.FieldIsVip:
  16559. m.ResetIsVip()
  16560. return nil
  16561. case employee.FieldChatURL:
  16562. m.ResetChatURL()
  16563. return nil
  16564. }
  16565. return fmt.Errorf("unknown Employee field %s", name)
  16566. }
  16567. // AddedEdges returns all edge names that were set/added in this mutation.
  16568. func (m *EmployeeMutation) AddedEdges() []string {
  16569. edges := make([]string, 0, 2)
  16570. if m.em_work_experiences != nil {
  16571. edges = append(edges, employee.EdgeEmWorkExperiences)
  16572. }
  16573. if m.em_tutorial != nil {
  16574. edges = append(edges, employee.EdgeEmTutorial)
  16575. }
  16576. return edges
  16577. }
  16578. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16579. // name in this mutation.
  16580. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  16581. switch name {
  16582. case employee.EdgeEmWorkExperiences:
  16583. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  16584. for id := range m.em_work_experiences {
  16585. ids = append(ids, id)
  16586. }
  16587. return ids
  16588. case employee.EdgeEmTutorial:
  16589. ids := make([]ent.Value, 0, len(m.em_tutorial))
  16590. for id := range m.em_tutorial {
  16591. ids = append(ids, id)
  16592. }
  16593. return ids
  16594. }
  16595. return nil
  16596. }
  16597. // RemovedEdges returns all edge names that were removed in this mutation.
  16598. func (m *EmployeeMutation) RemovedEdges() []string {
  16599. edges := make([]string, 0, 2)
  16600. if m.removedem_work_experiences != nil {
  16601. edges = append(edges, employee.EdgeEmWorkExperiences)
  16602. }
  16603. if m.removedem_tutorial != nil {
  16604. edges = append(edges, employee.EdgeEmTutorial)
  16605. }
  16606. return edges
  16607. }
  16608. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16609. // the given name in this mutation.
  16610. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  16611. switch name {
  16612. case employee.EdgeEmWorkExperiences:
  16613. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  16614. for id := range m.removedem_work_experiences {
  16615. ids = append(ids, id)
  16616. }
  16617. return ids
  16618. case employee.EdgeEmTutorial:
  16619. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  16620. for id := range m.removedem_tutorial {
  16621. ids = append(ids, id)
  16622. }
  16623. return ids
  16624. }
  16625. return nil
  16626. }
  16627. // ClearedEdges returns all edge names that were cleared in this mutation.
  16628. func (m *EmployeeMutation) ClearedEdges() []string {
  16629. edges := make([]string, 0, 2)
  16630. if m.clearedem_work_experiences {
  16631. edges = append(edges, employee.EdgeEmWorkExperiences)
  16632. }
  16633. if m.clearedem_tutorial {
  16634. edges = append(edges, employee.EdgeEmTutorial)
  16635. }
  16636. return edges
  16637. }
  16638. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16639. // was cleared in this mutation.
  16640. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  16641. switch name {
  16642. case employee.EdgeEmWorkExperiences:
  16643. return m.clearedem_work_experiences
  16644. case employee.EdgeEmTutorial:
  16645. return m.clearedem_tutorial
  16646. }
  16647. return false
  16648. }
  16649. // ClearEdge clears the value of the edge with the given name. It returns an error
  16650. // if that edge is not defined in the schema.
  16651. func (m *EmployeeMutation) ClearEdge(name string) error {
  16652. switch name {
  16653. }
  16654. return fmt.Errorf("unknown Employee unique edge %s", name)
  16655. }
  16656. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16657. // It returns an error if the edge is not defined in the schema.
  16658. func (m *EmployeeMutation) ResetEdge(name string) error {
  16659. switch name {
  16660. case employee.EdgeEmWorkExperiences:
  16661. m.ResetEmWorkExperiences()
  16662. return nil
  16663. case employee.EdgeEmTutorial:
  16664. m.ResetEmTutorial()
  16665. return nil
  16666. }
  16667. return fmt.Errorf("unknown Employee edge %s", name)
  16668. }
  16669. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  16670. type EmployeeConfigMutation struct {
  16671. config
  16672. op Op
  16673. typ string
  16674. id *uint64
  16675. created_at *time.Time
  16676. updated_at *time.Time
  16677. deleted_at *time.Time
  16678. stype *string
  16679. title *string
  16680. photo *string
  16681. organization_id *uint64
  16682. addorganization_id *int64
  16683. clearedFields map[string]struct{}
  16684. done bool
  16685. oldValue func(context.Context) (*EmployeeConfig, error)
  16686. predicates []predicate.EmployeeConfig
  16687. }
  16688. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  16689. // employeeconfigOption allows management of the mutation configuration using functional options.
  16690. type employeeconfigOption func(*EmployeeConfigMutation)
  16691. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  16692. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  16693. m := &EmployeeConfigMutation{
  16694. config: c,
  16695. op: op,
  16696. typ: TypeEmployeeConfig,
  16697. clearedFields: make(map[string]struct{}),
  16698. }
  16699. for _, opt := range opts {
  16700. opt(m)
  16701. }
  16702. return m
  16703. }
  16704. // withEmployeeConfigID sets the ID field of the mutation.
  16705. func withEmployeeConfigID(id uint64) employeeconfigOption {
  16706. return func(m *EmployeeConfigMutation) {
  16707. var (
  16708. err error
  16709. once sync.Once
  16710. value *EmployeeConfig
  16711. )
  16712. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  16713. once.Do(func() {
  16714. if m.done {
  16715. err = errors.New("querying old values post mutation is not allowed")
  16716. } else {
  16717. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  16718. }
  16719. })
  16720. return value, err
  16721. }
  16722. m.id = &id
  16723. }
  16724. }
  16725. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  16726. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  16727. return func(m *EmployeeConfigMutation) {
  16728. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  16729. return node, nil
  16730. }
  16731. m.id = &node.ID
  16732. }
  16733. }
  16734. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16735. // executed in a transaction (ent.Tx), a transactional client is returned.
  16736. func (m EmployeeConfigMutation) Client() *Client {
  16737. client := &Client{config: m.config}
  16738. client.init()
  16739. return client
  16740. }
  16741. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16742. // it returns an error otherwise.
  16743. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  16744. if _, ok := m.driver.(*txDriver); !ok {
  16745. return nil, errors.New("ent: mutation is not running in a transaction")
  16746. }
  16747. tx := &Tx{config: m.config}
  16748. tx.init()
  16749. return tx, nil
  16750. }
  16751. // SetID sets the value of the id field. Note that this
  16752. // operation is only accepted on creation of EmployeeConfig entities.
  16753. func (m *EmployeeConfigMutation) SetID(id uint64) {
  16754. m.id = &id
  16755. }
  16756. // ID returns the ID value in the mutation. Note that the ID is only available
  16757. // if it was provided to the builder or after it was returned from the database.
  16758. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  16759. if m.id == nil {
  16760. return
  16761. }
  16762. return *m.id, true
  16763. }
  16764. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16765. // That means, if the mutation is applied within a transaction with an isolation level such
  16766. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16767. // or updated by the mutation.
  16768. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  16769. switch {
  16770. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16771. id, exists := m.ID()
  16772. if exists {
  16773. return []uint64{id}, nil
  16774. }
  16775. fallthrough
  16776. case m.op.Is(OpUpdate | OpDelete):
  16777. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  16778. default:
  16779. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16780. }
  16781. }
  16782. // SetCreatedAt sets the "created_at" field.
  16783. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  16784. m.created_at = &t
  16785. }
  16786. // CreatedAt returns the value of the "created_at" field in the mutation.
  16787. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  16788. v := m.created_at
  16789. if v == nil {
  16790. return
  16791. }
  16792. return *v, true
  16793. }
  16794. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  16795. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16797. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16798. if !m.op.Is(OpUpdateOne) {
  16799. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16800. }
  16801. if m.id == nil || m.oldValue == nil {
  16802. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16803. }
  16804. oldValue, err := m.oldValue(ctx)
  16805. if err != nil {
  16806. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16807. }
  16808. return oldValue.CreatedAt, nil
  16809. }
  16810. // ResetCreatedAt resets all changes to the "created_at" field.
  16811. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  16812. m.created_at = nil
  16813. }
  16814. // SetUpdatedAt sets the "updated_at" field.
  16815. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  16816. m.updated_at = &t
  16817. }
  16818. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16819. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  16820. v := m.updated_at
  16821. if v == nil {
  16822. return
  16823. }
  16824. return *v, true
  16825. }
  16826. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  16827. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16829. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16830. if !m.op.Is(OpUpdateOne) {
  16831. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16832. }
  16833. if m.id == nil || m.oldValue == nil {
  16834. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16835. }
  16836. oldValue, err := m.oldValue(ctx)
  16837. if err != nil {
  16838. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16839. }
  16840. return oldValue.UpdatedAt, nil
  16841. }
  16842. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16843. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  16844. m.updated_at = nil
  16845. }
  16846. // SetDeletedAt sets the "deleted_at" field.
  16847. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  16848. m.deleted_at = &t
  16849. }
  16850. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16851. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  16852. v := m.deleted_at
  16853. if v == nil {
  16854. return
  16855. }
  16856. return *v, true
  16857. }
  16858. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  16859. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16861. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16862. if !m.op.Is(OpUpdateOne) {
  16863. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16864. }
  16865. if m.id == nil || m.oldValue == nil {
  16866. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16867. }
  16868. oldValue, err := m.oldValue(ctx)
  16869. if err != nil {
  16870. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16871. }
  16872. return oldValue.DeletedAt, nil
  16873. }
  16874. // ClearDeletedAt clears the value of the "deleted_at" field.
  16875. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  16876. m.deleted_at = nil
  16877. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  16878. }
  16879. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16880. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  16881. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  16882. return ok
  16883. }
  16884. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16885. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  16886. m.deleted_at = nil
  16887. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  16888. }
  16889. // SetStype sets the "stype" field.
  16890. func (m *EmployeeConfigMutation) SetStype(s string) {
  16891. m.stype = &s
  16892. }
  16893. // Stype returns the value of the "stype" field in the mutation.
  16894. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  16895. v := m.stype
  16896. if v == nil {
  16897. return
  16898. }
  16899. return *v, true
  16900. }
  16901. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  16902. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16904. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  16905. if !m.op.Is(OpUpdateOne) {
  16906. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  16907. }
  16908. if m.id == nil || m.oldValue == nil {
  16909. return v, errors.New("OldStype requires an ID field in the mutation")
  16910. }
  16911. oldValue, err := m.oldValue(ctx)
  16912. if err != nil {
  16913. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  16914. }
  16915. return oldValue.Stype, nil
  16916. }
  16917. // ResetStype resets all changes to the "stype" field.
  16918. func (m *EmployeeConfigMutation) ResetStype() {
  16919. m.stype = nil
  16920. }
  16921. // SetTitle sets the "title" field.
  16922. func (m *EmployeeConfigMutation) SetTitle(s string) {
  16923. m.title = &s
  16924. }
  16925. // Title returns the value of the "title" field in the mutation.
  16926. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  16927. v := m.title
  16928. if v == nil {
  16929. return
  16930. }
  16931. return *v, true
  16932. }
  16933. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  16934. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16936. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  16937. if !m.op.Is(OpUpdateOne) {
  16938. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16939. }
  16940. if m.id == nil || m.oldValue == nil {
  16941. return v, errors.New("OldTitle requires an ID field in the mutation")
  16942. }
  16943. oldValue, err := m.oldValue(ctx)
  16944. if err != nil {
  16945. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16946. }
  16947. return oldValue.Title, nil
  16948. }
  16949. // ResetTitle resets all changes to the "title" field.
  16950. func (m *EmployeeConfigMutation) ResetTitle() {
  16951. m.title = nil
  16952. }
  16953. // SetPhoto sets the "photo" field.
  16954. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  16955. m.photo = &s
  16956. }
  16957. // Photo returns the value of the "photo" field in the mutation.
  16958. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  16959. v := m.photo
  16960. if v == nil {
  16961. return
  16962. }
  16963. return *v, true
  16964. }
  16965. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  16966. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16968. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  16969. if !m.op.Is(OpUpdateOne) {
  16970. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  16971. }
  16972. if m.id == nil || m.oldValue == nil {
  16973. return v, errors.New("OldPhoto requires an ID field in the mutation")
  16974. }
  16975. oldValue, err := m.oldValue(ctx)
  16976. if err != nil {
  16977. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  16978. }
  16979. return oldValue.Photo, nil
  16980. }
  16981. // ResetPhoto resets all changes to the "photo" field.
  16982. func (m *EmployeeConfigMutation) ResetPhoto() {
  16983. m.photo = nil
  16984. }
  16985. // SetOrganizationID sets the "organization_id" field.
  16986. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  16987. m.organization_id = &u
  16988. m.addorganization_id = nil
  16989. }
  16990. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16991. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  16992. v := m.organization_id
  16993. if v == nil {
  16994. return
  16995. }
  16996. return *v, true
  16997. }
  16998. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  16999. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17001. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17002. if !m.op.Is(OpUpdateOne) {
  17003. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17004. }
  17005. if m.id == nil || m.oldValue == nil {
  17006. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17007. }
  17008. oldValue, err := m.oldValue(ctx)
  17009. if err != nil {
  17010. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17011. }
  17012. return oldValue.OrganizationID, nil
  17013. }
  17014. // AddOrganizationID adds u to the "organization_id" field.
  17015. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  17016. if m.addorganization_id != nil {
  17017. *m.addorganization_id += u
  17018. } else {
  17019. m.addorganization_id = &u
  17020. }
  17021. }
  17022. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17023. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  17024. v := m.addorganization_id
  17025. if v == nil {
  17026. return
  17027. }
  17028. return *v, true
  17029. }
  17030. // ClearOrganizationID clears the value of the "organization_id" field.
  17031. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  17032. m.organization_id = nil
  17033. m.addorganization_id = nil
  17034. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  17035. }
  17036. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17037. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  17038. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  17039. return ok
  17040. }
  17041. // ResetOrganizationID resets all changes to the "organization_id" field.
  17042. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  17043. m.organization_id = nil
  17044. m.addorganization_id = nil
  17045. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  17046. }
  17047. // Where appends a list predicates to the EmployeeConfigMutation builder.
  17048. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  17049. m.predicates = append(m.predicates, ps...)
  17050. }
  17051. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  17052. // users can use type-assertion to append predicates that do not depend on any generated package.
  17053. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  17054. p := make([]predicate.EmployeeConfig, len(ps))
  17055. for i := range ps {
  17056. p[i] = ps[i]
  17057. }
  17058. m.Where(p...)
  17059. }
  17060. // Op returns the operation name.
  17061. func (m *EmployeeConfigMutation) Op() Op {
  17062. return m.op
  17063. }
  17064. // SetOp allows setting the mutation operation.
  17065. func (m *EmployeeConfigMutation) SetOp(op Op) {
  17066. m.op = op
  17067. }
  17068. // Type returns the node type of this mutation (EmployeeConfig).
  17069. func (m *EmployeeConfigMutation) Type() string {
  17070. return m.typ
  17071. }
  17072. // Fields returns all fields that were changed during this mutation. Note that in
  17073. // order to get all numeric fields that were incremented/decremented, call
  17074. // AddedFields().
  17075. func (m *EmployeeConfigMutation) Fields() []string {
  17076. fields := make([]string, 0, 7)
  17077. if m.created_at != nil {
  17078. fields = append(fields, employeeconfig.FieldCreatedAt)
  17079. }
  17080. if m.updated_at != nil {
  17081. fields = append(fields, employeeconfig.FieldUpdatedAt)
  17082. }
  17083. if m.deleted_at != nil {
  17084. fields = append(fields, employeeconfig.FieldDeletedAt)
  17085. }
  17086. if m.stype != nil {
  17087. fields = append(fields, employeeconfig.FieldStype)
  17088. }
  17089. if m.title != nil {
  17090. fields = append(fields, employeeconfig.FieldTitle)
  17091. }
  17092. if m.photo != nil {
  17093. fields = append(fields, employeeconfig.FieldPhoto)
  17094. }
  17095. if m.organization_id != nil {
  17096. fields = append(fields, employeeconfig.FieldOrganizationID)
  17097. }
  17098. return fields
  17099. }
  17100. // Field returns the value of a field with the given name. The second boolean
  17101. // return value indicates that this field was not set, or was not defined in the
  17102. // schema.
  17103. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  17104. switch name {
  17105. case employeeconfig.FieldCreatedAt:
  17106. return m.CreatedAt()
  17107. case employeeconfig.FieldUpdatedAt:
  17108. return m.UpdatedAt()
  17109. case employeeconfig.FieldDeletedAt:
  17110. return m.DeletedAt()
  17111. case employeeconfig.FieldStype:
  17112. return m.Stype()
  17113. case employeeconfig.FieldTitle:
  17114. return m.Title()
  17115. case employeeconfig.FieldPhoto:
  17116. return m.Photo()
  17117. case employeeconfig.FieldOrganizationID:
  17118. return m.OrganizationID()
  17119. }
  17120. return nil, false
  17121. }
  17122. // OldField returns the old value of the field from the database. An error is
  17123. // returned if the mutation operation is not UpdateOne, or the query to the
  17124. // database failed.
  17125. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17126. switch name {
  17127. case employeeconfig.FieldCreatedAt:
  17128. return m.OldCreatedAt(ctx)
  17129. case employeeconfig.FieldUpdatedAt:
  17130. return m.OldUpdatedAt(ctx)
  17131. case employeeconfig.FieldDeletedAt:
  17132. return m.OldDeletedAt(ctx)
  17133. case employeeconfig.FieldStype:
  17134. return m.OldStype(ctx)
  17135. case employeeconfig.FieldTitle:
  17136. return m.OldTitle(ctx)
  17137. case employeeconfig.FieldPhoto:
  17138. return m.OldPhoto(ctx)
  17139. case employeeconfig.FieldOrganizationID:
  17140. return m.OldOrganizationID(ctx)
  17141. }
  17142. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  17143. }
  17144. // SetField sets the value of a field with the given name. It returns an error if
  17145. // the field is not defined in the schema, or if the type mismatched the field
  17146. // type.
  17147. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  17148. switch name {
  17149. case employeeconfig.FieldCreatedAt:
  17150. v, ok := value.(time.Time)
  17151. if !ok {
  17152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17153. }
  17154. m.SetCreatedAt(v)
  17155. return nil
  17156. case employeeconfig.FieldUpdatedAt:
  17157. v, ok := value.(time.Time)
  17158. if !ok {
  17159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17160. }
  17161. m.SetUpdatedAt(v)
  17162. return nil
  17163. case employeeconfig.FieldDeletedAt:
  17164. v, ok := value.(time.Time)
  17165. if !ok {
  17166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17167. }
  17168. m.SetDeletedAt(v)
  17169. return nil
  17170. case employeeconfig.FieldStype:
  17171. v, ok := value.(string)
  17172. if !ok {
  17173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17174. }
  17175. m.SetStype(v)
  17176. return nil
  17177. case employeeconfig.FieldTitle:
  17178. v, ok := value.(string)
  17179. if !ok {
  17180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17181. }
  17182. m.SetTitle(v)
  17183. return nil
  17184. case employeeconfig.FieldPhoto:
  17185. v, ok := value.(string)
  17186. if !ok {
  17187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17188. }
  17189. m.SetPhoto(v)
  17190. return nil
  17191. case employeeconfig.FieldOrganizationID:
  17192. v, ok := value.(uint64)
  17193. if !ok {
  17194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17195. }
  17196. m.SetOrganizationID(v)
  17197. return nil
  17198. }
  17199. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17200. }
  17201. // AddedFields returns all numeric fields that were incremented/decremented during
  17202. // this mutation.
  17203. func (m *EmployeeConfigMutation) AddedFields() []string {
  17204. var fields []string
  17205. if m.addorganization_id != nil {
  17206. fields = append(fields, employeeconfig.FieldOrganizationID)
  17207. }
  17208. return fields
  17209. }
  17210. // AddedField returns the numeric value that was incremented/decremented on a field
  17211. // with the given name. The second boolean return value indicates that this field
  17212. // was not set, or was not defined in the schema.
  17213. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  17214. switch name {
  17215. case employeeconfig.FieldOrganizationID:
  17216. return m.AddedOrganizationID()
  17217. }
  17218. return nil, false
  17219. }
  17220. // AddField adds the value to the field with the given name. It returns an error if
  17221. // the field is not defined in the schema, or if the type mismatched the field
  17222. // type.
  17223. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  17224. switch name {
  17225. case employeeconfig.FieldOrganizationID:
  17226. v, ok := value.(int64)
  17227. if !ok {
  17228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17229. }
  17230. m.AddOrganizationID(v)
  17231. return nil
  17232. }
  17233. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  17234. }
  17235. // ClearedFields returns all nullable fields that were cleared during this
  17236. // mutation.
  17237. func (m *EmployeeConfigMutation) ClearedFields() []string {
  17238. var fields []string
  17239. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  17240. fields = append(fields, employeeconfig.FieldDeletedAt)
  17241. }
  17242. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  17243. fields = append(fields, employeeconfig.FieldOrganizationID)
  17244. }
  17245. return fields
  17246. }
  17247. // FieldCleared returns a boolean indicating if a field with the given name was
  17248. // cleared in this mutation.
  17249. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  17250. _, ok := m.clearedFields[name]
  17251. return ok
  17252. }
  17253. // ClearField clears the value of the field with the given name. It returns an
  17254. // error if the field is not defined in the schema.
  17255. func (m *EmployeeConfigMutation) ClearField(name string) error {
  17256. switch name {
  17257. case employeeconfig.FieldDeletedAt:
  17258. m.ClearDeletedAt()
  17259. return nil
  17260. case employeeconfig.FieldOrganizationID:
  17261. m.ClearOrganizationID()
  17262. return nil
  17263. }
  17264. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  17265. }
  17266. // ResetField resets all changes in the mutation for the field with the given name.
  17267. // It returns an error if the field is not defined in the schema.
  17268. func (m *EmployeeConfigMutation) ResetField(name string) error {
  17269. switch name {
  17270. case employeeconfig.FieldCreatedAt:
  17271. m.ResetCreatedAt()
  17272. return nil
  17273. case employeeconfig.FieldUpdatedAt:
  17274. m.ResetUpdatedAt()
  17275. return nil
  17276. case employeeconfig.FieldDeletedAt:
  17277. m.ResetDeletedAt()
  17278. return nil
  17279. case employeeconfig.FieldStype:
  17280. m.ResetStype()
  17281. return nil
  17282. case employeeconfig.FieldTitle:
  17283. m.ResetTitle()
  17284. return nil
  17285. case employeeconfig.FieldPhoto:
  17286. m.ResetPhoto()
  17287. return nil
  17288. case employeeconfig.FieldOrganizationID:
  17289. m.ResetOrganizationID()
  17290. return nil
  17291. }
  17292. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17293. }
  17294. // AddedEdges returns all edge names that were set/added in this mutation.
  17295. func (m *EmployeeConfigMutation) AddedEdges() []string {
  17296. edges := make([]string, 0, 0)
  17297. return edges
  17298. }
  17299. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17300. // name in this mutation.
  17301. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  17302. return nil
  17303. }
  17304. // RemovedEdges returns all edge names that were removed in this mutation.
  17305. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  17306. edges := make([]string, 0, 0)
  17307. return edges
  17308. }
  17309. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17310. // the given name in this mutation.
  17311. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  17312. return nil
  17313. }
  17314. // ClearedEdges returns all edge names that were cleared in this mutation.
  17315. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  17316. edges := make([]string, 0, 0)
  17317. return edges
  17318. }
  17319. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17320. // was cleared in this mutation.
  17321. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  17322. return false
  17323. }
  17324. // ClearEdge clears the value of the edge with the given name. It returns an error
  17325. // if that edge is not defined in the schema.
  17326. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  17327. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  17328. }
  17329. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17330. // It returns an error if the edge is not defined in the schema.
  17331. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  17332. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  17333. }
  17334. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  17335. type LabelMutation struct {
  17336. config
  17337. op Op
  17338. typ string
  17339. id *uint64
  17340. created_at *time.Time
  17341. updated_at *time.Time
  17342. status *uint8
  17343. addstatus *int8
  17344. _type *int
  17345. add_type *int
  17346. name *string
  17347. from *int
  17348. addfrom *int
  17349. mode *int
  17350. addmode *int
  17351. conditions *string
  17352. organization_id *uint64
  17353. addorganization_id *int64
  17354. clearedFields map[string]struct{}
  17355. label_relationships map[uint64]struct{}
  17356. removedlabel_relationships map[uint64]struct{}
  17357. clearedlabel_relationships bool
  17358. done bool
  17359. oldValue func(context.Context) (*Label, error)
  17360. predicates []predicate.Label
  17361. }
  17362. var _ ent.Mutation = (*LabelMutation)(nil)
  17363. // labelOption allows management of the mutation configuration using functional options.
  17364. type labelOption func(*LabelMutation)
  17365. // newLabelMutation creates new mutation for the Label entity.
  17366. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  17367. m := &LabelMutation{
  17368. config: c,
  17369. op: op,
  17370. typ: TypeLabel,
  17371. clearedFields: make(map[string]struct{}),
  17372. }
  17373. for _, opt := range opts {
  17374. opt(m)
  17375. }
  17376. return m
  17377. }
  17378. // withLabelID sets the ID field of the mutation.
  17379. func withLabelID(id uint64) labelOption {
  17380. return func(m *LabelMutation) {
  17381. var (
  17382. err error
  17383. once sync.Once
  17384. value *Label
  17385. )
  17386. m.oldValue = func(ctx context.Context) (*Label, error) {
  17387. once.Do(func() {
  17388. if m.done {
  17389. err = errors.New("querying old values post mutation is not allowed")
  17390. } else {
  17391. value, err = m.Client().Label.Get(ctx, id)
  17392. }
  17393. })
  17394. return value, err
  17395. }
  17396. m.id = &id
  17397. }
  17398. }
  17399. // withLabel sets the old Label of the mutation.
  17400. func withLabel(node *Label) labelOption {
  17401. return func(m *LabelMutation) {
  17402. m.oldValue = func(context.Context) (*Label, error) {
  17403. return node, nil
  17404. }
  17405. m.id = &node.ID
  17406. }
  17407. }
  17408. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17409. // executed in a transaction (ent.Tx), a transactional client is returned.
  17410. func (m LabelMutation) Client() *Client {
  17411. client := &Client{config: m.config}
  17412. client.init()
  17413. return client
  17414. }
  17415. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17416. // it returns an error otherwise.
  17417. func (m LabelMutation) Tx() (*Tx, error) {
  17418. if _, ok := m.driver.(*txDriver); !ok {
  17419. return nil, errors.New("ent: mutation is not running in a transaction")
  17420. }
  17421. tx := &Tx{config: m.config}
  17422. tx.init()
  17423. return tx, nil
  17424. }
  17425. // SetID sets the value of the id field. Note that this
  17426. // operation is only accepted on creation of Label entities.
  17427. func (m *LabelMutation) SetID(id uint64) {
  17428. m.id = &id
  17429. }
  17430. // ID returns the ID value in the mutation. Note that the ID is only available
  17431. // if it was provided to the builder or after it was returned from the database.
  17432. func (m *LabelMutation) ID() (id uint64, exists bool) {
  17433. if m.id == nil {
  17434. return
  17435. }
  17436. return *m.id, true
  17437. }
  17438. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17439. // That means, if the mutation is applied within a transaction with an isolation level such
  17440. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17441. // or updated by the mutation.
  17442. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  17443. switch {
  17444. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17445. id, exists := m.ID()
  17446. if exists {
  17447. return []uint64{id}, nil
  17448. }
  17449. fallthrough
  17450. case m.op.Is(OpUpdate | OpDelete):
  17451. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  17452. default:
  17453. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17454. }
  17455. }
  17456. // SetCreatedAt sets the "created_at" field.
  17457. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  17458. m.created_at = &t
  17459. }
  17460. // CreatedAt returns the value of the "created_at" field in the mutation.
  17461. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  17462. v := m.created_at
  17463. if v == nil {
  17464. return
  17465. }
  17466. return *v, true
  17467. }
  17468. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  17469. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17471. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17472. if !m.op.Is(OpUpdateOne) {
  17473. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17474. }
  17475. if m.id == nil || m.oldValue == nil {
  17476. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17477. }
  17478. oldValue, err := m.oldValue(ctx)
  17479. if err != nil {
  17480. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17481. }
  17482. return oldValue.CreatedAt, nil
  17483. }
  17484. // ResetCreatedAt resets all changes to the "created_at" field.
  17485. func (m *LabelMutation) ResetCreatedAt() {
  17486. m.created_at = nil
  17487. }
  17488. // SetUpdatedAt sets the "updated_at" field.
  17489. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  17490. m.updated_at = &t
  17491. }
  17492. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17493. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  17494. v := m.updated_at
  17495. if v == nil {
  17496. return
  17497. }
  17498. return *v, true
  17499. }
  17500. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  17501. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17503. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17504. if !m.op.Is(OpUpdateOne) {
  17505. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17506. }
  17507. if m.id == nil || m.oldValue == nil {
  17508. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17509. }
  17510. oldValue, err := m.oldValue(ctx)
  17511. if err != nil {
  17512. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17513. }
  17514. return oldValue.UpdatedAt, nil
  17515. }
  17516. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17517. func (m *LabelMutation) ResetUpdatedAt() {
  17518. m.updated_at = nil
  17519. }
  17520. // SetStatus sets the "status" field.
  17521. func (m *LabelMutation) SetStatus(u uint8) {
  17522. m.status = &u
  17523. m.addstatus = nil
  17524. }
  17525. // Status returns the value of the "status" field in the mutation.
  17526. func (m *LabelMutation) Status() (r uint8, exists bool) {
  17527. v := m.status
  17528. if v == nil {
  17529. return
  17530. }
  17531. return *v, true
  17532. }
  17533. // OldStatus returns the old "status" field's value of the Label entity.
  17534. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17536. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17537. if !m.op.Is(OpUpdateOne) {
  17538. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17539. }
  17540. if m.id == nil || m.oldValue == nil {
  17541. return v, errors.New("OldStatus requires an ID field in the mutation")
  17542. }
  17543. oldValue, err := m.oldValue(ctx)
  17544. if err != nil {
  17545. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17546. }
  17547. return oldValue.Status, nil
  17548. }
  17549. // AddStatus adds u to the "status" field.
  17550. func (m *LabelMutation) AddStatus(u int8) {
  17551. if m.addstatus != nil {
  17552. *m.addstatus += u
  17553. } else {
  17554. m.addstatus = &u
  17555. }
  17556. }
  17557. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17558. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  17559. v := m.addstatus
  17560. if v == nil {
  17561. return
  17562. }
  17563. return *v, true
  17564. }
  17565. // ClearStatus clears the value of the "status" field.
  17566. func (m *LabelMutation) ClearStatus() {
  17567. m.status = nil
  17568. m.addstatus = nil
  17569. m.clearedFields[label.FieldStatus] = struct{}{}
  17570. }
  17571. // StatusCleared returns if the "status" field was cleared in this mutation.
  17572. func (m *LabelMutation) StatusCleared() bool {
  17573. _, ok := m.clearedFields[label.FieldStatus]
  17574. return ok
  17575. }
  17576. // ResetStatus resets all changes to the "status" field.
  17577. func (m *LabelMutation) ResetStatus() {
  17578. m.status = nil
  17579. m.addstatus = nil
  17580. delete(m.clearedFields, label.FieldStatus)
  17581. }
  17582. // SetType sets the "type" field.
  17583. func (m *LabelMutation) SetType(i int) {
  17584. m._type = &i
  17585. m.add_type = nil
  17586. }
  17587. // GetType returns the value of the "type" field in the mutation.
  17588. func (m *LabelMutation) GetType() (r int, exists bool) {
  17589. v := m._type
  17590. if v == nil {
  17591. return
  17592. }
  17593. return *v, true
  17594. }
  17595. // OldType returns the old "type" field's value of the Label entity.
  17596. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17598. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  17599. if !m.op.Is(OpUpdateOne) {
  17600. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17601. }
  17602. if m.id == nil || m.oldValue == nil {
  17603. return v, errors.New("OldType requires an ID field in the mutation")
  17604. }
  17605. oldValue, err := m.oldValue(ctx)
  17606. if err != nil {
  17607. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17608. }
  17609. return oldValue.Type, nil
  17610. }
  17611. // AddType adds i to the "type" field.
  17612. func (m *LabelMutation) AddType(i int) {
  17613. if m.add_type != nil {
  17614. *m.add_type += i
  17615. } else {
  17616. m.add_type = &i
  17617. }
  17618. }
  17619. // AddedType returns the value that was added to the "type" field in this mutation.
  17620. func (m *LabelMutation) AddedType() (r int, exists bool) {
  17621. v := m.add_type
  17622. if v == nil {
  17623. return
  17624. }
  17625. return *v, true
  17626. }
  17627. // ResetType resets all changes to the "type" field.
  17628. func (m *LabelMutation) ResetType() {
  17629. m._type = nil
  17630. m.add_type = nil
  17631. }
  17632. // SetName sets the "name" field.
  17633. func (m *LabelMutation) SetName(s string) {
  17634. m.name = &s
  17635. }
  17636. // Name returns the value of the "name" field in the mutation.
  17637. func (m *LabelMutation) Name() (r string, exists bool) {
  17638. v := m.name
  17639. if v == nil {
  17640. return
  17641. }
  17642. return *v, true
  17643. }
  17644. // OldName returns the old "name" field's value of the Label entity.
  17645. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17647. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  17648. if !m.op.Is(OpUpdateOne) {
  17649. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17650. }
  17651. if m.id == nil || m.oldValue == nil {
  17652. return v, errors.New("OldName requires an ID field in the mutation")
  17653. }
  17654. oldValue, err := m.oldValue(ctx)
  17655. if err != nil {
  17656. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17657. }
  17658. return oldValue.Name, nil
  17659. }
  17660. // ResetName resets all changes to the "name" field.
  17661. func (m *LabelMutation) ResetName() {
  17662. m.name = nil
  17663. }
  17664. // SetFrom sets the "from" field.
  17665. func (m *LabelMutation) SetFrom(i int) {
  17666. m.from = &i
  17667. m.addfrom = nil
  17668. }
  17669. // From returns the value of the "from" field in the mutation.
  17670. func (m *LabelMutation) From() (r int, exists bool) {
  17671. v := m.from
  17672. if v == nil {
  17673. return
  17674. }
  17675. return *v, true
  17676. }
  17677. // OldFrom returns the old "from" field's value of the Label entity.
  17678. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17680. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  17681. if !m.op.Is(OpUpdateOne) {
  17682. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  17683. }
  17684. if m.id == nil || m.oldValue == nil {
  17685. return v, errors.New("OldFrom requires an ID field in the mutation")
  17686. }
  17687. oldValue, err := m.oldValue(ctx)
  17688. if err != nil {
  17689. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  17690. }
  17691. return oldValue.From, nil
  17692. }
  17693. // AddFrom adds i to the "from" field.
  17694. func (m *LabelMutation) AddFrom(i int) {
  17695. if m.addfrom != nil {
  17696. *m.addfrom += i
  17697. } else {
  17698. m.addfrom = &i
  17699. }
  17700. }
  17701. // AddedFrom returns the value that was added to the "from" field in this mutation.
  17702. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  17703. v := m.addfrom
  17704. if v == nil {
  17705. return
  17706. }
  17707. return *v, true
  17708. }
  17709. // ResetFrom resets all changes to the "from" field.
  17710. func (m *LabelMutation) ResetFrom() {
  17711. m.from = nil
  17712. m.addfrom = nil
  17713. }
  17714. // SetMode sets the "mode" field.
  17715. func (m *LabelMutation) SetMode(i int) {
  17716. m.mode = &i
  17717. m.addmode = nil
  17718. }
  17719. // Mode returns the value of the "mode" field in the mutation.
  17720. func (m *LabelMutation) Mode() (r int, exists bool) {
  17721. v := m.mode
  17722. if v == nil {
  17723. return
  17724. }
  17725. return *v, true
  17726. }
  17727. // OldMode returns the old "mode" field's value of the Label entity.
  17728. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17730. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  17731. if !m.op.Is(OpUpdateOne) {
  17732. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  17733. }
  17734. if m.id == nil || m.oldValue == nil {
  17735. return v, errors.New("OldMode requires an ID field in the mutation")
  17736. }
  17737. oldValue, err := m.oldValue(ctx)
  17738. if err != nil {
  17739. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  17740. }
  17741. return oldValue.Mode, nil
  17742. }
  17743. // AddMode adds i to the "mode" field.
  17744. func (m *LabelMutation) AddMode(i int) {
  17745. if m.addmode != nil {
  17746. *m.addmode += i
  17747. } else {
  17748. m.addmode = &i
  17749. }
  17750. }
  17751. // AddedMode returns the value that was added to the "mode" field in this mutation.
  17752. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  17753. v := m.addmode
  17754. if v == nil {
  17755. return
  17756. }
  17757. return *v, true
  17758. }
  17759. // ResetMode resets all changes to the "mode" field.
  17760. func (m *LabelMutation) ResetMode() {
  17761. m.mode = nil
  17762. m.addmode = nil
  17763. }
  17764. // SetConditions sets the "conditions" field.
  17765. func (m *LabelMutation) SetConditions(s string) {
  17766. m.conditions = &s
  17767. }
  17768. // Conditions returns the value of the "conditions" field in the mutation.
  17769. func (m *LabelMutation) Conditions() (r string, exists bool) {
  17770. v := m.conditions
  17771. if v == nil {
  17772. return
  17773. }
  17774. return *v, true
  17775. }
  17776. // OldConditions returns the old "conditions" field's value of the Label entity.
  17777. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17779. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  17780. if !m.op.Is(OpUpdateOne) {
  17781. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  17782. }
  17783. if m.id == nil || m.oldValue == nil {
  17784. return v, errors.New("OldConditions requires an ID field in the mutation")
  17785. }
  17786. oldValue, err := m.oldValue(ctx)
  17787. if err != nil {
  17788. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  17789. }
  17790. return oldValue.Conditions, nil
  17791. }
  17792. // ClearConditions clears the value of the "conditions" field.
  17793. func (m *LabelMutation) ClearConditions() {
  17794. m.conditions = nil
  17795. m.clearedFields[label.FieldConditions] = struct{}{}
  17796. }
  17797. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  17798. func (m *LabelMutation) ConditionsCleared() bool {
  17799. _, ok := m.clearedFields[label.FieldConditions]
  17800. return ok
  17801. }
  17802. // ResetConditions resets all changes to the "conditions" field.
  17803. func (m *LabelMutation) ResetConditions() {
  17804. m.conditions = nil
  17805. delete(m.clearedFields, label.FieldConditions)
  17806. }
  17807. // SetOrganizationID sets the "organization_id" field.
  17808. func (m *LabelMutation) SetOrganizationID(u uint64) {
  17809. m.organization_id = &u
  17810. m.addorganization_id = nil
  17811. }
  17812. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17813. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  17814. v := m.organization_id
  17815. if v == nil {
  17816. return
  17817. }
  17818. return *v, true
  17819. }
  17820. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  17821. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17823. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17824. if !m.op.Is(OpUpdateOne) {
  17825. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17826. }
  17827. if m.id == nil || m.oldValue == nil {
  17828. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17829. }
  17830. oldValue, err := m.oldValue(ctx)
  17831. if err != nil {
  17832. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17833. }
  17834. return oldValue.OrganizationID, nil
  17835. }
  17836. // AddOrganizationID adds u to the "organization_id" field.
  17837. func (m *LabelMutation) AddOrganizationID(u int64) {
  17838. if m.addorganization_id != nil {
  17839. *m.addorganization_id += u
  17840. } else {
  17841. m.addorganization_id = &u
  17842. }
  17843. }
  17844. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17845. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  17846. v := m.addorganization_id
  17847. if v == nil {
  17848. return
  17849. }
  17850. return *v, true
  17851. }
  17852. // ClearOrganizationID clears the value of the "organization_id" field.
  17853. func (m *LabelMutation) ClearOrganizationID() {
  17854. m.organization_id = nil
  17855. m.addorganization_id = nil
  17856. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  17857. }
  17858. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17859. func (m *LabelMutation) OrganizationIDCleared() bool {
  17860. _, ok := m.clearedFields[label.FieldOrganizationID]
  17861. return ok
  17862. }
  17863. // ResetOrganizationID resets all changes to the "organization_id" field.
  17864. func (m *LabelMutation) ResetOrganizationID() {
  17865. m.organization_id = nil
  17866. m.addorganization_id = nil
  17867. delete(m.clearedFields, label.FieldOrganizationID)
  17868. }
  17869. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  17870. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  17871. if m.label_relationships == nil {
  17872. m.label_relationships = make(map[uint64]struct{})
  17873. }
  17874. for i := range ids {
  17875. m.label_relationships[ids[i]] = struct{}{}
  17876. }
  17877. }
  17878. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  17879. func (m *LabelMutation) ClearLabelRelationships() {
  17880. m.clearedlabel_relationships = true
  17881. }
  17882. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  17883. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  17884. return m.clearedlabel_relationships
  17885. }
  17886. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  17887. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  17888. if m.removedlabel_relationships == nil {
  17889. m.removedlabel_relationships = make(map[uint64]struct{})
  17890. }
  17891. for i := range ids {
  17892. delete(m.label_relationships, ids[i])
  17893. m.removedlabel_relationships[ids[i]] = struct{}{}
  17894. }
  17895. }
  17896. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  17897. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  17898. for id := range m.removedlabel_relationships {
  17899. ids = append(ids, id)
  17900. }
  17901. return
  17902. }
  17903. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  17904. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  17905. for id := range m.label_relationships {
  17906. ids = append(ids, id)
  17907. }
  17908. return
  17909. }
  17910. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  17911. func (m *LabelMutation) ResetLabelRelationships() {
  17912. m.label_relationships = nil
  17913. m.clearedlabel_relationships = false
  17914. m.removedlabel_relationships = nil
  17915. }
  17916. // Where appends a list predicates to the LabelMutation builder.
  17917. func (m *LabelMutation) Where(ps ...predicate.Label) {
  17918. m.predicates = append(m.predicates, ps...)
  17919. }
  17920. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  17921. // users can use type-assertion to append predicates that do not depend on any generated package.
  17922. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  17923. p := make([]predicate.Label, len(ps))
  17924. for i := range ps {
  17925. p[i] = ps[i]
  17926. }
  17927. m.Where(p...)
  17928. }
  17929. // Op returns the operation name.
  17930. func (m *LabelMutation) Op() Op {
  17931. return m.op
  17932. }
  17933. // SetOp allows setting the mutation operation.
  17934. func (m *LabelMutation) SetOp(op Op) {
  17935. m.op = op
  17936. }
  17937. // Type returns the node type of this mutation (Label).
  17938. func (m *LabelMutation) Type() string {
  17939. return m.typ
  17940. }
  17941. // Fields returns all fields that were changed during this mutation. Note that in
  17942. // order to get all numeric fields that were incremented/decremented, call
  17943. // AddedFields().
  17944. func (m *LabelMutation) Fields() []string {
  17945. fields := make([]string, 0, 9)
  17946. if m.created_at != nil {
  17947. fields = append(fields, label.FieldCreatedAt)
  17948. }
  17949. if m.updated_at != nil {
  17950. fields = append(fields, label.FieldUpdatedAt)
  17951. }
  17952. if m.status != nil {
  17953. fields = append(fields, label.FieldStatus)
  17954. }
  17955. if m._type != nil {
  17956. fields = append(fields, label.FieldType)
  17957. }
  17958. if m.name != nil {
  17959. fields = append(fields, label.FieldName)
  17960. }
  17961. if m.from != nil {
  17962. fields = append(fields, label.FieldFrom)
  17963. }
  17964. if m.mode != nil {
  17965. fields = append(fields, label.FieldMode)
  17966. }
  17967. if m.conditions != nil {
  17968. fields = append(fields, label.FieldConditions)
  17969. }
  17970. if m.organization_id != nil {
  17971. fields = append(fields, label.FieldOrganizationID)
  17972. }
  17973. return fields
  17974. }
  17975. // Field returns the value of a field with the given name. The second boolean
  17976. // return value indicates that this field was not set, or was not defined in the
  17977. // schema.
  17978. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  17979. switch name {
  17980. case label.FieldCreatedAt:
  17981. return m.CreatedAt()
  17982. case label.FieldUpdatedAt:
  17983. return m.UpdatedAt()
  17984. case label.FieldStatus:
  17985. return m.Status()
  17986. case label.FieldType:
  17987. return m.GetType()
  17988. case label.FieldName:
  17989. return m.Name()
  17990. case label.FieldFrom:
  17991. return m.From()
  17992. case label.FieldMode:
  17993. return m.Mode()
  17994. case label.FieldConditions:
  17995. return m.Conditions()
  17996. case label.FieldOrganizationID:
  17997. return m.OrganizationID()
  17998. }
  17999. return nil, false
  18000. }
  18001. // OldField returns the old value of the field from the database. An error is
  18002. // returned if the mutation operation is not UpdateOne, or the query to the
  18003. // database failed.
  18004. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18005. switch name {
  18006. case label.FieldCreatedAt:
  18007. return m.OldCreatedAt(ctx)
  18008. case label.FieldUpdatedAt:
  18009. return m.OldUpdatedAt(ctx)
  18010. case label.FieldStatus:
  18011. return m.OldStatus(ctx)
  18012. case label.FieldType:
  18013. return m.OldType(ctx)
  18014. case label.FieldName:
  18015. return m.OldName(ctx)
  18016. case label.FieldFrom:
  18017. return m.OldFrom(ctx)
  18018. case label.FieldMode:
  18019. return m.OldMode(ctx)
  18020. case label.FieldConditions:
  18021. return m.OldConditions(ctx)
  18022. case label.FieldOrganizationID:
  18023. return m.OldOrganizationID(ctx)
  18024. }
  18025. return nil, fmt.Errorf("unknown Label field %s", name)
  18026. }
  18027. // SetField sets the value of a field with the given name. It returns an error if
  18028. // the field is not defined in the schema, or if the type mismatched the field
  18029. // type.
  18030. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  18031. switch name {
  18032. case label.FieldCreatedAt:
  18033. v, ok := value.(time.Time)
  18034. if !ok {
  18035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18036. }
  18037. m.SetCreatedAt(v)
  18038. return nil
  18039. case label.FieldUpdatedAt:
  18040. v, ok := value.(time.Time)
  18041. if !ok {
  18042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18043. }
  18044. m.SetUpdatedAt(v)
  18045. return nil
  18046. case label.FieldStatus:
  18047. v, ok := value.(uint8)
  18048. if !ok {
  18049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18050. }
  18051. m.SetStatus(v)
  18052. return nil
  18053. case label.FieldType:
  18054. v, ok := value.(int)
  18055. if !ok {
  18056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18057. }
  18058. m.SetType(v)
  18059. return nil
  18060. case label.FieldName:
  18061. v, ok := value.(string)
  18062. if !ok {
  18063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18064. }
  18065. m.SetName(v)
  18066. return nil
  18067. case label.FieldFrom:
  18068. v, ok := value.(int)
  18069. if !ok {
  18070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18071. }
  18072. m.SetFrom(v)
  18073. return nil
  18074. case label.FieldMode:
  18075. v, ok := value.(int)
  18076. if !ok {
  18077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18078. }
  18079. m.SetMode(v)
  18080. return nil
  18081. case label.FieldConditions:
  18082. v, ok := value.(string)
  18083. if !ok {
  18084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18085. }
  18086. m.SetConditions(v)
  18087. return nil
  18088. case label.FieldOrganizationID:
  18089. v, ok := value.(uint64)
  18090. if !ok {
  18091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18092. }
  18093. m.SetOrganizationID(v)
  18094. return nil
  18095. }
  18096. return fmt.Errorf("unknown Label field %s", name)
  18097. }
  18098. // AddedFields returns all numeric fields that were incremented/decremented during
  18099. // this mutation.
  18100. func (m *LabelMutation) AddedFields() []string {
  18101. var fields []string
  18102. if m.addstatus != nil {
  18103. fields = append(fields, label.FieldStatus)
  18104. }
  18105. if m.add_type != nil {
  18106. fields = append(fields, label.FieldType)
  18107. }
  18108. if m.addfrom != nil {
  18109. fields = append(fields, label.FieldFrom)
  18110. }
  18111. if m.addmode != nil {
  18112. fields = append(fields, label.FieldMode)
  18113. }
  18114. if m.addorganization_id != nil {
  18115. fields = append(fields, label.FieldOrganizationID)
  18116. }
  18117. return fields
  18118. }
  18119. // AddedField returns the numeric value that was incremented/decremented on a field
  18120. // with the given name. The second boolean return value indicates that this field
  18121. // was not set, or was not defined in the schema.
  18122. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  18123. switch name {
  18124. case label.FieldStatus:
  18125. return m.AddedStatus()
  18126. case label.FieldType:
  18127. return m.AddedType()
  18128. case label.FieldFrom:
  18129. return m.AddedFrom()
  18130. case label.FieldMode:
  18131. return m.AddedMode()
  18132. case label.FieldOrganizationID:
  18133. return m.AddedOrganizationID()
  18134. }
  18135. return nil, false
  18136. }
  18137. // AddField adds the value to the field with the given name. It returns an error if
  18138. // the field is not defined in the schema, or if the type mismatched the field
  18139. // type.
  18140. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  18141. switch name {
  18142. case label.FieldStatus:
  18143. v, ok := value.(int8)
  18144. if !ok {
  18145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18146. }
  18147. m.AddStatus(v)
  18148. return nil
  18149. case label.FieldType:
  18150. v, ok := value.(int)
  18151. if !ok {
  18152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18153. }
  18154. m.AddType(v)
  18155. return nil
  18156. case label.FieldFrom:
  18157. v, ok := value.(int)
  18158. if !ok {
  18159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18160. }
  18161. m.AddFrom(v)
  18162. return nil
  18163. case label.FieldMode:
  18164. v, ok := value.(int)
  18165. if !ok {
  18166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18167. }
  18168. m.AddMode(v)
  18169. return nil
  18170. case label.FieldOrganizationID:
  18171. v, ok := value.(int64)
  18172. if !ok {
  18173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18174. }
  18175. m.AddOrganizationID(v)
  18176. return nil
  18177. }
  18178. return fmt.Errorf("unknown Label numeric field %s", name)
  18179. }
  18180. // ClearedFields returns all nullable fields that were cleared during this
  18181. // mutation.
  18182. func (m *LabelMutation) ClearedFields() []string {
  18183. var fields []string
  18184. if m.FieldCleared(label.FieldStatus) {
  18185. fields = append(fields, label.FieldStatus)
  18186. }
  18187. if m.FieldCleared(label.FieldConditions) {
  18188. fields = append(fields, label.FieldConditions)
  18189. }
  18190. if m.FieldCleared(label.FieldOrganizationID) {
  18191. fields = append(fields, label.FieldOrganizationID)
  18192. }
  18193. return fields
  18194. }
  18195. // FieldCleared returns a boolean indicating if a field with the given name was
  18196. // cleared in this mutation.
  18197. func (m *LabelMutation) FieldCleared(name string) bool {
  18198. _, ok := m.clearedFields[name]
  18199. return ok
  18200. }
  18201. // ClearField clears the value of the field with the given name. It returns an
  18202. // error if the field is not defined in the schema.
  18203. func (m *LabelMutation) ClearField(name string) error {
  18204. switch name {
  18205. case label.FieldStatus:
  18206. m.ClearStatus()
  18207. return nil
  18208. case label.FieldConditions:
  18209. m.ClearConditions()
  18210. return nil
  18211. case label.FieldOrganizationID:
  18212. m.ClearOrganizationID()
  18213. return nil
  18214. }
  18215. return fmt.Errorf("unknown Label nullable field %s", name)
  18216. }
  18217. // ResetField resets all changes in the mutation for the field with the given name.
  18218. // It returns an error if the field is not defined in the schema.
  18219. func (m *LabelMutation) ResetField(name string) error {
  18220. switch name {
  18221. case label.FieldCreatedAt:
  18222. m.ResetCreatedAt()
  18223. return nil
  18224. case label.FieldUpdatedAt:
  18225. m.ResetUpdatedAt()
  18226. return nil
  18227. case label.FieldStatus:
  18228. m.ResetStatus()
  18229. return nil
  18230. case label.FieldType:
  18231. m.ResetType()
  18232. return nil
  18233. case label.FieldName:
  18234. m.ResetName()
  18235. return nil
  18236. case label.FieldFrom:
  18237. m.ResetFrom()
  18238. return nil
  18239. case label.FieldMode:
  18240. m.ResetMode()
  18241. return nil
  18242. case label.FieldConditions:
  18243. m.ResetConditions()
  18244. return nil
  18245. case label.FieldOrganizationID:
  18246. m.ResetOrganizationID()
  18247. return nil
  18248. }
  18249. return fmt.Errorf("unknown Label field %s", name)
  18250. }
  18251. // AddedEdges returns all edge names that were set/added in this mutation.
  18252. func (m *LabelMutation) AddedEdges() []string {
  18253. edges := make([]string, 0, 1)
  18254. if m.label_relationships != nil {
  18255. edges = append(edges, label.EdgeLabelRelationships)
  18256. }
  18257. return edges
  18258. }
  18259. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18260. // name in this mutation.
  18261. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  18262. switch name {
  18263. case label.EdgeLabelRelationships:
  18264. ids := make([]ent.Value, 0, len(m.label_relationships))
  18265. for id := range m.label_relationships {
  18266. ids = append(ids, id)
  18267. }
  18268. return ids
  18269. }
  18270. return nil
  18271. }
  18272. // RemovedEdges returns all edge names that were removed in this mutation.
  18273. func (m *LabelMutation) RemovedEdges() []string {
  18274. edges := make([]string, 0, 1)
  18275. if m.removedlabel_relationships != nil {
  18276. edges = append(edges, label.EdgeLabelRelationships)
  18277. }
  18278. return edges
  18279. }
  18280. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18281. // the given name in this mutation.
  18282. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  18283. switch name {
  18284. case label.EdgeLabelRelationships:
  18285. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  18286. for id := range m.removedlabel_relationships {
  18287. ids = append(ids, id)
  18288. }
  18289. return ids
  18290. }
  18291. return nil
  18292. }
  18293. // ClearedEdges returns all edge names that were cleared in this mutation.
  18294. func (m *LabelMutation) ClearedEdges() []string {
  18295. edges := make([]string, 0, 1)
  18296. if m.clearedlabel_relationships {
  18297. edges = append(edges, label.EdgeLabelRelationships)
  18298. }
  18299. return edges
  18300. }
  18301. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18302. // was cleared in this mutation.
  18303. func (m *LabelMutation) EdgeCleared(name string) bool {
  18304. switch name {
  18305. case label.EdgeLabelRelationships:
  18306. return m.clearedlabel_relationships
  18307. }
  18308. return false
  18309. }
  18310. // ClearEdge clears the value of the edge with the given name. It returns an error
  18311. // if that edge is not defined in the schema.
  18312. func (m *LabelMutation) ClearEdge(name string) error {
  18313. switch name {
  18314. }
  18315. return fmt.Errorf("unknown Label unique edge %s", name)
  18316. }
  18317. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18318. // It returns an error if the edge is not defined in the schema.
  18319. func (m *LabelMutation) ResetEdge(name string) error {
  18320. switch name {
  18321. case label.EdgeLabelRelationships:
  18322. m.ResetLabelRelationships()
  18323. return nil
  18324. }
  18325. return fmt.Errorf("unknown Label edge %s", name)
  18326. }
  18327. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  18328. type LabelRelationshipMutation struct {
  18329. config
  18330. op Op
  18331. typ string
  18332. id *uint64
  18333. created_at *time.Time
  18334. updated_at *time.Time
  18335. status *uint8
  18336. addstatus *int8
  18337. organization_id *uint64
  18338. addorganization_id *int64
  18339. clearedFields map[string]struct{}
  18340. contacts *uint64
  18341. clearedcontacts bool
  18342. labels *uint64
  18343. clearedlabels bool
  18344. done bool
  18345. oldValue func(context.Context) (*LabelRelationship, error)
  18346. predicates []predicate.LabelRelationship
  18347. }
  18348. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  18349. // labelrelationshipOption allows management of the mutation configuration using functional options.
  18350. type labelrelationshipOption func(*LabelRelationshipMutation)
  18351. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  18352. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  18353. m := &LabelRelationshipMutation{
  18354. config: c,
  18355. op: op,
  18356. typ: TypeLabelRelationship,
  18357. clearedFields: make(map[string]struct{}),
  18358. }
  18359. for _, opt := range opts {
  18360. opt(m)
  18361. }
  18362. return m
  18363. }
  18364. // withLabelRelationshipID sets the ID field of the mutation.
  18365. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  18366. return func(m *LabelRelationshipMutation) {
  18367. var (
  18368. err error
  18369. once sync.Once
  18370. value *LabelRelationship
  18371. )
  18372. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  18373. once.Do(func() {
  18374. if m.done {
  18375. err = errors.New("querying old values post mutation is not allowed")
  18376. } else {
  18377. value, err = m.Client().LabelRelationship.Get(ctx, id)
  18378. }
  18379. })
  18380. return value, err
  18381. }
  18382. m.id = &id
  18383. }
  18384. }
  18385. // withLabelRelationship sets the old LabelRelationship of the mutation.
  18386. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  18387. return func(m *LabelRelationshipMutation) {
  18388. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  18389. return node, nil
  18390. }
  18391. m.id = &node.ID
  18392. }
  18393. }
  18394. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18395. // executed in a transaction (ent.Tx), a transactional client is returned.
  18396. func (m LabelRelationshipMutation) Client() *Client {
  18397. client := &Client{config: m.config}
  18398. client.init()
  18399. return client
  18400. }
  18401. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18402. // it returns an error otherwise.
  18403. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  18404. if _, ok := m.driver.(*txDriver); !ok {
  18405. return nil, errors.New("ent: mutation is not running in a transaction")
  18406. }
  18407. tx := &Tx{config: m.config}
  18408. tx.init()
  18409. return tx, nil
  18410. }
  18411. // SetID sets the value of the id field. Note that this
  18412. // operation is only accepted on creation of LabelRelationship entities.
  18413. func (m *LabelRelationshipMutation) SetID(id uint64) {
  18414. m.id = &id
  18415. }
  18416. // ID returns the ID value in the mutation. Note that the ID is only available
  18417. // if it was provided to the builder or after it was returned from the database.
  18418. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  18419. if m.id == nil {
  18420. return
  18421. }
  18422. return *m.id, true
  18423. }
  18424. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18425. // That means, if the mutation is applied within a transaction with an isolation level such
  18426. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18427. // or updated by the mutation.
  18428. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  18429. switch {
  18430. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18431. id, exists := m.ID()
  18432. if exists {
  18433. return []uint64{id}, nil
  18434. }
  18435. fallthrough
  18436. case m.op.Is(OpUpdate | OpDelete):
  18437. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  18438. default:
  18439. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18440. }
  18441. }
  18442. // SetCreatedAt sets the "created_at" field.
  18443. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  18444. m.created_at = &t
  18445. }
  18446. // CreatedAt returns the value of the "created_at" field in the mutation.
  18447. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  18448. v := m.created_at
  18449. if v == nil {
  18450. return
  18451. }
  18452. return *v, true
  18453. }
  18454. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  18455. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18457. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18458. if !m.op.Is(OpUpdateOne) {
  18459. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18460. }
  18461. if m.id == nil || m.oldValue == nil {
  18462. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18463. }
  18464. oldValue, err := m.oldValue(ctx)
  18465. if err != nil {
  18466. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18467. }
  18468. return oldValue.CreatedAt, nil
  18469. }
  18470. // ResetCreatedAt resets all changes to the "created_at" field.
  18471. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  18472. m.created_at = nil
  18473. }
  18474. // SetUpdatedAt sets the "updated_at" field.
  18475. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  18476. m.updated_at = &t
  18477. }
  18478. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18479. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  18480. v := m.updated_at
  18481. if v == nil {
  18482. return
  18483. }
  18484. return *v, true
  18485. }
  18486. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  18487. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18489. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18490. if !m.op.Is(OpUpdateOne) {
  18491. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18492. }
  18493. if m.id == nil || m.oldValue == nil {
  18494. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18495. }
  18496. oldValue, err := m.oldValue(ctx)
  18497. if err != nil {
  18498. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18499. }
  18500. return oldValue.UpdatedAt, nil
  18501. }
  18502. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18503. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  18504. m.updated_at = nil
  18505. }
  18506. // SetStatus sets the "status" field.
  18507. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  18508. m.status = &u
  18509. m.addstatus = nil
  18510. }
  18511. // Status returns the value of the "status" field in the mutation.
  18512. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  18513. v := m.status
  18514. if v == nil {
  18515. return
  18516. }
  18517. return *v, true
  18518. }
  18519. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  18520. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18522. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18523. if !m.op.Is(OpUpdateOne) {
  18524. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18525. }
  18526. if m.id == nil || m.oldValue == nil {
  18527. return v, errors.New("OldStatus requires an ID field in the mutation")
  18528. }
  18529. oldValue, err := m.oldValue(ctx)
  18530. if err != nil {
  18531. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18532. }
  18533. return oldValue.Status, nil
  18534. }
  18535. // AddStatus adds u to the "status" field.
  18536. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  18537. if m.addstatus != nil {
  18538. *m.addstatus += u
  18539. } else {
  18540. m.addstatus = &u
  18541. }
  18542. }
  18543. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18544. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  18545. v := m.addstatus
  18546. if v == nil {
  18547. return
  18548. }
  18549. return *v, true
  18550. }
  18551. // ClearStatus clears the value of the "status" field.
  18552. func (m *LabelRelationshipMutation) ClearStatus() {
  18553. m.status = nil
  18554. m.addstatus = nil
  18555. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  18556. }
  18557. // StatusCleared returns if the "status" field was cleared in this mutation.
  18558. func (m *LabelRelationshipMutation) StatusCleared() bool {
  18559. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  18560. return ok
  18561. }
  18562. // ResetStatus resets all changes to the "status" field.
  18563. func (m *LabelRelationshipMutation) ResetStatus() {
  18564. m.status = nil
  18565. m.addstatus = nil
  18566. delete(m.clearedFields, labelrelationship.FieldStatus)
  18567. }
  18568. // SetLabelID sets the "label_id" field.
  18569. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  18570. m.labels = &u
  18571. }
  18572. // LabelID returns the value of the "label_id" field in the mutation.
  18573. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  18574. v := m.labels
  18575. if v == nil {
  18576. return
  18577. }
  18578. return *v, true
  18579. }
  18580. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  18581. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18583. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  18584. if !m.op.Is(OpUpdateOne) {
  18585. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  18586. }
  18587. if m.id == nil || m.oldValue == nil {
  18588. return v, errors.New("OldLabelID requires an ID field in the mutation")
  18589. }
  18590. oldValue, err := m.oldValue(ctx)
  18591. if err != nil {
  18592. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  18593. }
  18594. return oldValue.LabelID, nil
  18595. }
  18596. // ResetLabelID resets all changes to the "label_id" field.
  18597. func (m *LabelRelationshipMutation) ResetLabelID() {
  18598. m.labels = nil
  18599. }
  18600. // SetContactID sets the "contact_id" field.
  18601. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  18602. m.contacts = &u
  18603. }
  18604. // ContactID returns the value of the "contact_id" field in the mutation.
  18605. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  18606. v := m.contacts
  18607. if v == nil {
  18608. return
  18609. }
  18610. return *v, true
  18611. }
  18612. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  18613. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18615. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  18616. if !m.op.Is(OpUpdateOne) {
  18617. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  18618. }
  18619. if m.id == nil || m.oldValue == nil {
  18620. return v, errors.New("OldContactID requires an ID field in the mutation")
  18621. }
  18622. oldValue, err := m.oldValue(ctx)
  18623. if err != nil {
  18624. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  18625. }
  18626. return oldValue.ContactID, nil
  18627. }
  18628. // ResetContactID resets all changes to the "contact_id" field.
  18629. func (m *LabelRelationshipMutation) ResetContactID() {
  18630. m.contacts = nil
  18631. }
  18632. // SetOrganizationID sets the "organization_id" field.
  18633. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  18634. m.organization_id = &u
  18635. m.addorganization_id = nil
  18636. }
  18637. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18638. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  18639. v := m.organization_id
  18640. if v == nil {
  18641. return
  18642. }
  18643. return *v, true
  18644. }
  18645. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  18646. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18648. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18649. if !m.op.Is(OpUpdateOne) {
  18650. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18651. }
  18652. if m.id == nil || m.oldValue == nil {
  18653. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18654. }
  18655. oldValue, err := m.oldValue(ctx)
  18656. if err != nil {
  18657. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18658. }
  18659. return oldValue.OrganizationID, nil
  18660. }
  18661. // AddOrganizationID adds u to the "organization_id" field.
  18662. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  18663. if m.addorganization_id != nil {
  18664. *m.addorganization_id += u
  18665. } else {
  18666. m.addorganization_id = &u
  18667. }
  18668. }
  18669. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18670. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  18671. v := m.addorganization_id
  18672. if v == nil {
  18673. return
  18674. }
  18675. return *v, true
  18676. }
  18677. // ClearOrganizationID clears the value of the "organization_id" field.
  18678. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  18679. m.organization_id = nil
  18680. m.addorganization_id = nil
  18681. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  18682. }
  18683. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18684. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  18685. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  18686. return ok
  18687. }
  18688. // ResetOrganizationID resets all changes to the "organization_id" field.
  18689. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  18690. m.organization_id = nil
  18691. m.addorganization_id = nil
  18692. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  18693. }
  18694. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  18695. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  18696. m.contacts = &id
  18697. }
  18698. // ClearContacts clears the "contacts" edge to the Contact entity.
  18699. func (m *LabelRelationshipMutation) ClearContacts() {
  18700. m.clearedcontacts = true
  18701. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  18702. }
  18703. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  18704. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  18705. return m.clearedcontacts
  18706. }
  18707. // ContactsID returns the "contacts" edge ID in the mutation.
  18708. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  18709. if m.contacts != nil {
  18710. return *m.contacts, true
  18711. }
  18712. return
  18713. }
  18714. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  18715. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18716. // ContactsID instead. It exists only for internal usage by the builders.
  18717. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  18718. if id := m.contacts; id != nil {
  18719. ids = append(ids, *id)
  18720. }
  18721. return
  18722. }
  18723. // ResetContacts resets all changes to the "contacts" edge.
  18724. func (m *LabelRelationshipMutation) ResetContacts() {
  18725. m.contacts = nil
  18726. m.clearedcontacts = false
  18727. }
  18728. // SetLabelsID sets the "labels" edge to the Label entity by id.
  18729. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  18730. m.labels = &id
  18731. }
  18732. // ClearLabels clears the "labels" edge to the Label entity.
  18733. func (m *LabelRelationshipMutation) ClearLabels() {
  18734. m.clearedlabels = true
  18735. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  18736. }
  18737. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  18738. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  18739. return m.clearedlabels
  18740. }
  18741. // LabelsID returns the "labels" edge ID in the mutation.
  18742. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  18743. if m.labels != nil {
  18744. return *m.labels, true
  18745. }
  18746. return
  18747. }
  18748. // LabelsIDs returns the "labels" edge IDs in the mutation.
  18749. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18750. // LabelsID instead. It exists only for internal usage by the builders.
  18751. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  18752. if id := m.labels; id != nil {
  18753. ids = append(ids, *id)
  18754. }
  18755. return
  18756. }
  18757. // ResetLabels resets all changes to the "labels" edge.
  18758. func (m *LabelRelationshipMutation) ResetLabels() {
  18759. m.labels = nil
  18760. m.clearedlabels = false
  18761. }
  18762. // Where appends a list predicates to the LabelRelationshipMutation builder.
  18763. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  18764. m.predicates = append(m.predicates, ps...)
  18765. }
  18766. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  18767. // users can use type-assertion to append predicates that do not depend on any generated package.
  18768. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  18769. p := make([]predicate.LabelRelationship, len(ps))
  18770. for i := range ps {
  18771. p[i] = ps[i]
  18772. }
  18773. m.Where(p...)
  18774. }
  18775. // Op returns the operation name.
  18776. func (m *LabelRelationshipMutation) Op() Op {
  18777. return m.op
  18778. }
  18779. // SetOp allows setting the mutation operation.
  18780. func (m *LabelRelationshipMutation) SetOp(op Op) {
  18781. m.op = op
  18782. }
  18783. // Type returns the node type of this mutation (LabelRelationship).
  18784. func (m *LabelRelationshipMutation) Type() string {
  18785. return m.typ
  18786. }
  18787. // Fields returns all fields that were changed during this mutation. Note that in
  18788. // order to get all numeric fields that were incremented/decremented, call
  18789. // AddedFields().
  18790. func (m *LabelRelationshipMutation) Fields() []string {
  18791. fields := make([]string, 0, 6)
  18792. if m.created_at != nil {
  18793. fields = append(fields, labelrelationship.FieldCreatedAt)
  18794. }
  18795. if m.updated_at != nil {
  18796. fields = append(fields, labelrelationship.FieldUpdatedAt)
  18797. }
  18798. if m.status != nil {
  18799. fields = append(fields, labelrelationship.FieldStatus)
  18800. }
  18801. if m.labels != nil {
  18802. fields = append(fields, labelrelationship.FieldLabelID)
  18803. }
  18804. if m.contacts != nil {
  18805. fields = append(fields, labelrelationship.FieldContactID)
  18806. }
  18807. if m.organization_id != nil {
  18808. fields = append(fields, labelrelationship.FieldOrganizationID)
  18809. }
  18810. return fields
  18811. }
  18812. // Field returns the value of a field with the given name. The second boolean
  18813. // return value indicates that this field was not set, or was not defined in the
  18814. // schema.
  18815. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  18816. switch name {
  18817. case labelrelationship.FieldCreatedAt:
  18818. return m.CreatedAt()
  18819. case labelrelationship.FieldUpdatedAt:
  18820. return m.UpdatedAt()
  18821. case labelrelationship.FieldStatus:
  18822. return m.Status()
  18823. case labelrelationship.FieldLabelID:
  18824. return m.LabelID()
  18825. case labelrelationship.FieldContactID:
  18826. return m.ContactID()
  18827. case labelrelationship.FieldOrganizationID:
  18828. return m.OrganizationID()
  18829. }
  18830. return nil, false
  18831. }
  18832. // OldField returns the old value of the field from the database. An error is
  18833. // returned if the mutation operation is not UpdateOne, or the query to the
  18834. // database failed.
  18835. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18836. switch name {
  18837. case labelrelationship.FieldCreatedAt:
  18838. return m.OldCreatedAt(ctx)
  18839. case labelrelationship.FieldUpdatedAt:
  18840. return m.OldUpdatedAt(ctx)
  18841. case labelrelationship.FieldStatus:
  18842. return m.OldStatus(ctx)
  18843. case labelrelationship.FieldLabelID:
  18844. return m.OldLabelID(ctx)
  18845. case labelrelationship.FieldContactID:
  18846. return m.OldContactID(ctx)
  18847. case labelrelationship.FieldOrganizationID:
  18848. return m.OldOrganizationID(ctx)
  18849. }
  18850. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  18851. }
  18852. // SetField sets the value of a field with the given name. It returns an error if
  18853. // the field is not defined in the schema, or if the type mismatched the field
  18854. // type.
  18855. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  18856. switch name {
  18857. case labelrelationship.FieldCreatedAt:
  18858. v, ok := value.(time.Time)
  18859. if !ok {
  18860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18861. }
  18862. m.SetCreatedAt(v)
  18863. return nil
  18864. case labelrelationship.FieldUpdatedAt:
  18865. v, ok := value.(time.Time)
  18866. if !ok {
  18867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18868. }
  18869. m.SetUpdatedAt(v)
  18870. return nil
  18871. case labelrelationship.FieldStatus:
  18872. v, ok := value.(uint8)
  18873. if !ok {
  18874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18875. }
  18876. m.SetStatus(v)
  18877. return nil
  18878. case labelrelationship.FieldLabelID:
  18879. v, ok := value.(uint64)
  18880. if !ok {
  18881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18882. }
  18883. m.SetLabelID(v)
  18884. return nil
  18885. case labelrelationship.FieldContactID:
  18886. v, ok := value.(uint64)
  18887. if !ok {
  18888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18889. }
  18890. m.SetContactID(v)
  18891. return nil
  18892. case labelrelationship.FieldOrganizationID:
  18893. v, ok := value.(uint64)
  18894. if !ok {
  18895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18896. }
  18897. m.SetOrganizationID(v)
  18898. return nil
  18899. }
  18900. return fmt.Errorf("unknown LabelRelationship field %s", name)
  18901. }
  18902. // AddedFields returns all numeric fields that were incremented/decremented during
  18903. // this mutation.
  18904. func (m *LabelRelationshipMutation) AddedFields() []string {
  18905. var fields []string
  18906. if m.addstatus != nil {
  18907. fields = append(fields, labelrelationship.FieldStatus)
  18908. }
  18909. if m.addorganization_id != nil {
  18910. fields = append(fields, labelrelationship.FieldOrganizationID)
  18911. }
  18912. return fields
  18913. }
  18914. // AddedField returns the numeric value that was incremented/decremented on a field
  18915. // with the given name. The second boolean return value indicates that this field
  18916. // was not set, or was not defined in the schema.
  18917. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  18918. switch name {
  18919. case labelrelationship.FieldStatus:
  18920. return m.AddedStatus()
  18921. case labelrelationship.FieldOrganizationID:
  18922. return m.AddedOrganizationID()
  18923. }
  18924. return nil, false
  18925. }
  18926. // AddField adds the value to the field with the given name. It returns an error if
  18927. // the field is not defined in the schema, or if the type mismatched the field
  18928. // type.
  18929. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  18930. switch name {
  18931. case labelrelationship.FieldStatus:
  18932. v, ok := value.(int8)
  18933. if !ok {
  18934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18935. }
  18936. m.AddStatus(v)
  18937. return nil
  18938. case labelrelationship.FieldOrganizationID:
  18939. v, ok := value.(int64)
  18940. if !ok {
  18941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18942. }
  18943. m.AddOrganizationID(v)
  18944. return nil
  18945. }
  18946. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  18947. }
  18948. // ClearedFields returns all nullable fields that were cleared during this
  18949. // mutation.
  18950. func (m *LabelRelationshipMutation) ClearedFields() []string {
  18951. var fields []string
  18952. if m.FieldCleared(labelrelationship.FieldStatus) {
  18953. fields = append(fields, labelrelationship.FieldStatus)
  18954. }
  18955. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  18956. fields = append(fields, labelrelationship.FieldOrganizationID)
  18957. }
  18958. return fields
  18959. }
  18960. // FieldCleared returns a boolean indicating if a field with the given name was
  18961. // cleared in this mutation.
  18962. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  18963. _, ok := m.clearedFields[name]
  18964. return ok
  18965. }
  18966. // ClearField clears the value of the field with the given name. It returns an
  18967. // error if the field is not defined in the schema.
  18968. func (m *LabelRelationshipMutation) ClearField(name string) error {
  18969. switch name {
  18970. case labelrelationship.FieldStatus:
  18971. m.ClearStatus()
  18972. return nil
  18973. case labelrelationship.FieldOrganizationID:
  18974. m.ClearOrganizationID()
  18975. return nil
  18976. }
  18977. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  18978. }
  18979. // ResetField resets all changes in the mutation for the field with the given name.
  18980. // It returns an error if the field is not defined in the schema.
  18981. func (m *LabelRelationshipMutation) ResetField(name string) error {
  18982. switch name {
  18983. case labelrelationship.FieldCreatedAt:
  18984. m.ResetCreatedAt()
  18985. return nil
  18986. case labelrelationship.FieldUpdatedAt:
  18987. m.ResetUpdatedAt()
  18988. return nil
  18989. case labelrelationship.FieldStatus:
  18990. m.ResetStatus()
  18991. return nil
  18992. case labelrelationship.FieldLabelID:
  18993. m.ResetLabelID()
  18994. return nil
  18995. case labelrelationship.FieldContactID:
  18996. m.ResetContactID()
  18997. return nil
  18998. case labelrelationship.FieldOrganizationID:
  18999. m.ResetOrganizationID()
  19000. return nil
  19001. }
  19002. return fmt.Errorf("unknown LabelRelationship field %s", name)
  19003. }
  19004. // AddedEdges returns all edge names that were set/added in this mutation.
  19005. func (m *LabelRelationshipMutation) AddedEdges() []string {
  19006. edges := make([]string, 0, 2)
  19007. if m.contacts != nil {
  19008. edges = append(edges, labelrelationship.EdgeContacts)
  19009. }
  19010. if m.labels != nil {
  19011. edges = append(edges, labelrelationship.EdgeLabels)
  19012. }
  19013. return edges
  19014. }
  19015. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19016. // name in this mutation.
  19017. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  19018. switch name {
  19019. case labelrelationship.EdgeContacts:
  19020. if id := m.contacts; id != nil {
  19021. return []ent.Value{*id}
  19022. }
  19023. case labelrelationship.EdgeLabels:
  19024. if id := m.labels; id != nil {
  19025. return []ent.Value{*id}
  19026. }
  19027. }
  19028. return nil
  19029. }
  19030. // RemovedEdges returns all edge names that were removed in this mutation.
  19031. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  19032. edges := make([]string, 0, 2)
  19033. return edges
  19034. }
  19035. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19036. // the given name in this mutation.
  19037. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  19038. return nil
  19039. }
  19040. // ClearedEdges returns all edge names that were cleared in this mutation.
  19041. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  19042. edges := make([]string, 0, 2)
  19043. if m.clearedcontacts {
  19044. edges = append(edges, labelrelationship.EdgeContacts)
  19045. }
  19046. if m.clearedlabels {
  19047. edges = append(edges, labelrelationship.EdgeLabels)
  19048. }
  19049. return edges
  19050. }
  19051. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19052. // was cleared in this mutation.
  19053. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  19054. switch name {
  19055. case labelrelationship.EdgeContacts:
  19056. return m.clearedcontacts
  19057. case labelrelationship.EdgeLabels:
  19058. return m.clearedlabels
  19059. }
  19060. return false
  19061. }
  19062. // ClearEdge clears the value of the edge with the given name. It returns an error
  19063. // if that edge is not defined in the schema.
  19064. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  19065. switch name {
  19066. case labelrelationship.EdgeContacts:
  19067. m.ClearContacts()
  19068. return nil
  19069. case labelrelationship.EdgeLabels:
  19070. m.ClearLabels()
  19071. return nil
  19072. }
  19073. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  19074. }
  19075. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19076. // It returns an error if the edge is not defined in the schema.
  19077. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  19078. switch name {
  19079. case labelrelationship.EdgeContacts:
  19080. m.ResetContacts()
  19081. return nil
  19082. case labelrelationship.EdgeLabels:
  19083. m.ResetLabels()
  19084. return nil
  19085. }
  19086. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  19087. }
  19088. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  19089. type LabelTaggingMutation struct {
  19090. config
  19091. op Op
  19092. typ string
  19093. id *uint64
  19094. created_at *time.Time
  19095. updated_at *time.Time
  19096. status *uint8
  19097. addstatus *int8
  19098. deleted_at *time.Time
  19099. organization_id *uint64
  19100. addorganization_id *int64
  19101. _type *int
  19102. add_type *int
  19103. conditions *string
  19104. action_label_add *[]uint64
  19105. appendaction_label_add []uint64
  19106. action_label_del *[]uint64
  19107. appendaction_label_del []uint64
  19108. clearedFields map[string]struct{}
  19109. done bool
  19110. oldValue func(context.Context) (*LabelTagging, error)
  19111. predicates []predicate.LabelTagging
  19112. }
  19113. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  19114. // labeltaggingOption allows management of the mutation configuration using functional options.
  19115. type labeltaggingOption func(*LabelTaggingMutation)
  19116. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  19117. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  19118. m := &LabelTaggingMutation{
  19119. config: c,
  19120. op: op,
  19121. typ: TypeLabelTagging,
  19122. clearedFields: make(map[string]struct{}),
  19123. }
  19124. for _, opt := range opts {
  19125. opt(m)
  19126. }
  19127. return m
  19128. }
  19129. // withLabelTaggingID sets the ID field of the mutation.
  19130. func withLabelTaggingID(id uint64) labeltaggingOption {
  19131. return func(m *LabelTaggingMutation) {
  19132. var (
  19133. err error
  19134. once sync.Once
  19135. value *LabelTagging
  19136. )
  19137. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  19138. once.Do(func() {
  19139. if m.done {
  19140. err = errors.New("querying old values post mutation is not allowed")
  19141. } else {
  19142. value, err = m.Client().LabelTagging.Get(ctx, id)
  19143. }
  19144. })
  19145. return value, err
  19146. }
  19147. m.id = &id
  19148. }
  19149. }
  19150. // withLabelTagging sets the old LabelTagging of the mutation.
  19151. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  19152. return func(m *LabelTaggingMutation) {
  19153. m.oldValue = func(context.Context) (*LabelTagging, error) {
  19154. return node, nil
  19155. }
  19156. m.id = &node.ID
  19157. }
  19158. }
  19159. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19160. // executed in a transaction (ent.Tx), a transactional client is returned.
  19161. func (m LabelTaggingMutation) Client() *Client {
  19162. client := &Client{config: m.config}
  19163. client.init()
  19164. return client
  19165. }
  19166. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19167. // it returns an error otherwise.
  19168. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  19169. if _, ok := m.driver.(*txDriver); !ok {
  19170. return nil, errors.New("ent: mutation is not running in a transaction")
  19171. }
  19172. tx := &Tx{config: m.config}
  19173. tx.init()
  19174. return tx, nil
  19175. }
  19176. // SetID sets the value of the id field. Note that this
  19177. // operation is only accepted on creation of LabelTagging entities.
  19178. func (m *LabelTaggingMutation) SetID(id uint64) {
  19179. m.id = &id
  19180. }
  19181. // ID returns the ID value in the mutation. Note that the ID is only available
  19182. // if it was provided to the builder or after it was returned from the database.
  19183. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  19184. if m.id == nil {
  19185. return
  19186. }
  19187. return *m.id, true
  19188. }
  19189. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19190. // That means, if the mutation is applied within a transaction with an isolation level such
  19191. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19192. // or updated by the mutation.
  19193. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  19194. switch {
  19195. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19196. id, exists := m.ID()
  19197. if exists {
  19198. return []uint64{id}, nil
  19199. }
  19200. fallthrough
  19201. case m.op.Is(OpUpdate | OpDelete):
  19202. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  19203. default:
  19204. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19205. }
  19206. }
  19207. // SetCreatedAt sets the "created_at" field.
  19208. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  19209. m.created_at = &t
  19210. }
  19211. // CreatedAt returns the value of the "created_at" field in the mutation.
  19212. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  19213. v := m.created_at
  19214. if v == nil {
  19215. return
  19216. }
  19217. return *v, true
  19218. }
  19219. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  19220. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19222. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19223. if !m.op.Is(OpUpdateOne) {
  19224. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19225. }
  19226. if m.id == nil || m.oldValue == nil {
  19227. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19228. }
  19229. oldValue, err := m.oldValue(ctx)
  19230. if err != nil {
  19231. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19232. }
  19233. return oldValue.CreatedAt, nil
  19234. }
  19235. // ResetCreatedAt resets all changes to the "created_at" field.
  19236. func (m *LabelTaggingMutation) ResetCreatedAt() {
  19237. m.created_at = nil
  19238. }
  19239. // SetUpdatedAt sets the "updated_at" field.
  19240. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  19241. m.updated_at = &t
  19242. }
  19243. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19244. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  19245. v := m.updated_at
  19246. if v == nil {
  19247. return
  19248. }
  19249. return *v, true
  19250. }
  19251. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  19252. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19254. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19255. if !m.op.Is(OpUpdateOne) {
  19256. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19257. }
  19258. if m.id == nil || m.oldValue == nil {
  19259. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19260. }
  19261. oldValue, err := m.oldValue(ctx)
  19262. if err != nil {
  19263. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19264. }
  19265. return oldValue.UpdatedAt, nil
  19266. }
  19267. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19268. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  19269. m.updated_at = nil
  19270. }
  19271. // SetStatus sets the "status" field.
  19272. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  19273. m.status = &u
  19274. m.addstatus = nil
  19275. }
  19276. // Status returns the value of the "status" field in the mutation.
  19277. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  19278. v := m.status
  19279. if v == nil {
  19280. return
  19281. }
  19282. return *v, true
  19283. }
  19284. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  19285. // If the LabelTagging 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 *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19288. if !m.op.Is(OpUpdateOne) {
  19289. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19290. }
  19291. if m.id == nil || m.oldValue == nil {
  19292. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  19297. }
  19298. return oldValue.Status, nil
  19299. }
  19300. // AddStatus adds u to the "status" field.
  19301. func (m *LabelTaggingMutation) AddStatus(u int8) {
  19302. if m.addstatus != nil {
  19303. *m.addstatus += u
  19304. } else {
  19305. m.addstatus = &u
  19306. }
  19307. }
  19308. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19309. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  19310. v := m.addstatus
  19311. if v == nil {
  19312. return
  19313. }
  19314. return *v, true
  19315. }
  19316. // ClearStatus clears the value of the "status" field.
  19317. func (m *LabelTaggingMutation) ClearStatus() {
  19318. m.status = nil
  19319. m.addstatus = nil
  19320. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  19321. }
  19322. // StatusCleared returns if the "status" field was cleared in this mutation.
  19323. func (m *LabelTaggingMutation) StatusCleared() bool {
  19324. _, ok := m.clearedFields[labeltagging.FieldStatus]
  19325. return ok
  19326. }
  19327. // ResetStatus resets all changes to the "status" field.
  19328. func (m *LabelTaggingMutation) ResetStatus() {
  19329. m.status = nil
  19330. m.addstatus = nil
  19331. delete(m.clearedFields, labeltagging.FieldStatus)
  19332. }
  19333. // SetDeletedAt sets the "deleted_at" field.
  19334. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  19335. m.deleted_at = &t
  19336. }
  19337. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19338. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  19339. v := m.deleted_at
  19340. if v == nil {
  19341. return
  19342. }
  19343. return *v, true
  19344. }
  19345. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  19346. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19348. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19349. if !m.op.Is(OpUpdateOne) {
  19350. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19351. }
  19352. if m.id == nil || m.oldValue == nil {
  19353. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19354. }
  19355. oldValue, err := m.oldValue(ctx)
  19356. if err != nil {
  19357. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19358. }
  19359. return oldValue.DeletedAt, nil
  19360. }
  19361. // ClearDeletedAt clears the value of the "deleted_at" field.
  19362. func (m *LabelTaggingMutation) ClearDeletedAt() {
  19363. m.deleted_at = nil
  19364. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  19365. }
  19366. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19367. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  19368. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  19369. return ok
  19370. }
  19371. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19372. func (m *LabelTaggingMutation) ResetDeletedAt() {
  19373. m.deleted_at = nil
  19374. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  19375. }
  19376. // SetOrganizationID sets the "organization_id" field.
  19377. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  19378. m.organization_id = &u
  19379. m.addorganization_id = nil
  19380. }
  19381. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19382. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  19383. v := m.organization_id
  19384. if v == nil {
  19385. return
  19386. }
  19387. return *v, true
  19388. }
  19389. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  19390. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19392. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19393. if !m.op.Is(OpUpdateOne) {
  19394. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19395. }
  19396. if m.id == nil || m.oldValue == nil {
  19397. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19398. }
  19399. oldValue, err := m.oldValue(ctx)
  19400. if err != nil {
  19401. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19402. }
  19403. return oldValue.OrganizationID, nil
  19404. }
  19405. // AddOrganizationID adds u to the "organization_id" field.
  19406. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  19407. if m.addorganization_id != nil {
  19408. *m.addorganization_id += u
  19409. } else {
  19410. m.addorganization_id = &u
  19411. }
  19412. }
  19413. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19414. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  19415. v := m.addorganization_id
  19416. if v == nil {
  19417. return
  19418. }
  19419. return *v, true
  19420. }
  19421. // ResetOrganizationID resets all changes to the "organization_id" field.
  19422. func (m *LabelTaggingMutation) ResetOrganizationID() {
  19423. m.organization_id = nil
  19424. m.addorganization_id = nil
  19425. }
  19426. // SetType sets the "type" field.
  19427. func (m *LabelTaggingMutation) SetType(i int) {
  19428. m._type = &i
  19429. m.add_type = nil
  19430. }
  19431. // GetType returns the value of the "type" field in the mutation.
  19432. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  19433. v := m._type
  19434. if v == nil {
  19435. return
  19436. }
  19437. return *v, true
  19438. }
  19439. // OldType returns the old "type" field's value of the LabelTagging entity.
  19440. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19442. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  19443. if !m.op.Is(OpUpdateOne) {
  19444. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19445. }
  19446. if m.id == nil || m.oldValue == nil {
  19447. return v, errors.New("OldType requires an ID field in the mutation")
  19448. }
  19449. oldValue, err := m.oldValue(ctx)
  19450. if err != nil {
  19451. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19452. }
  19453. return oldValue.Type, nil
  19454. }
  19455. // AddType adds i to the "type" field.
  19456. func (m *LabelTaggingMutation) AddType(i int) {
  19457. if m.add_type != nil {
  19458. *m.add_type += i
  19459. } else {
  19460. m.add_type = &i
  19461. }
  19462. }
  19463. // AddedType returns the value that was added to the "type" field in this mutation.
  19464. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  19465. v := m.add_type
  19466. if v == nil {
  19467. return
  19468. }
  19469. return *v, true
  19470. }
  19471. // ResetType resets all changes to the "type" field.
  19472. func (m *LabelTaggingMutation) ResetType() {
  19473. m._type = nil
  19474. m.add_type = nil
  19475. }
  19476. // SetConditions sets the "conditions" field.
  19477. func (m *LabelTaggingMutation) SetConditions(s string) {
  19478. m.conditions = &s
  19479. }
  19480. // Conditions returns the value of the "conditions" field in the mutation.
  19481. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  19482. v := m.conditions
  19483. if v == nil {
  19484. return
  19485. }
  19486. return *v, true
  19487. }
  19488. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  19489. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19491. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  19492. if !m.op.Is(OpUpdateOne) {
  19493. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  19494. }
  19495. if m.id == nil || m.oldValue == nil {
  19496. return v, errors.New("OldConditions requires an ID field in the mutation")
  19497. }
  19498. oldValue, err := m.oldValue(ctx)
  19499. if err != nil {
  19500. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19501. }
  19502. return oldValue.Conditions, nil
  19503. }
  19504. // ResetConditions resets all changes to the "conditions" field.
  19505. func (m *LabelTaggingMutation) ResetConditions() {
  19506. m.conditions = nil
  19507. }
  19508. // SetActionLabelAdd sets the "action_label_add" field.
  19509. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  19510. m.action_label_add = &u
  19511. m.appendaction_label_add = nil
  19512. }
  19513. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19514. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19515. v := m.action_label_add
  19516. if v == nil {
  19517. return
  19518. }
  19519. return *v, true
  19520. }
  19521. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  19522. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19524. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19525. if !m.op.Is(OpUpdateOne) {
  19526. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19527. }
  19528. if m.id == nil || m.oldValue == nil {
  19529. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19530. }
  19531. oldValue, err := m.oldValue(ctx)
  19532. if err != nil {
  19533. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19534. }
  19535. return oldValue.ActionLabelAdd, nil
  19536. }
  19537. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19538. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  19539. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19540. }
  19541. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19542. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19543. if len(m.appendaction_label_add) == 0 {
  19544. return nil, false
  19545. }
  19546. return m.appendaction_label_add, true
  19547. }
  19548. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19549. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  19550. m.action_label_add = nil
  19551. m.appendaction_label_add = nil
  19552. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  19553. }
  19554. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19555. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  19556. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  19557. return ok
  19558. }
  19559. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19560. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  19561. m.action_label_add = nil
  19562. m.appendaction_label_add = nil
  19563. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  19564. }
  19565. // SetActionLabelDel sets the "action_label_del" field.
  19566. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  19567. m.action_label_del = &u
  19568. m.appendaction_label_del = nil
  19569. }
  19570. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19571. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  19572. v := m.action_label_del
  19573. if v == nil {
  19574. return
  19575. }
  19576. return *v, true
  19577. }
  19578. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  19579. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19581. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19582. if !m.op.Is(OpUpdateOne) {
  19583. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19584. }
  19585. if m.id == nil || m.oldValue == nil {
  19586. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19587. }
  19588. oldValue, err := m.oldValue(ctx)
  19589. if err != nil {
  19590. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19591. }
  19592. return oldValue.ActionLabelDel, nil
  19593. }
  19594. // AppendActionLabelDel adds u to the "action_label_del" field.
  19595. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  19596. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19597. }
  19598. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19599. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19600. if len(m.appendaction_label_del) == 0 {
  19601. return nil, false
  19602. }
  19603. return m.appendaction_label_del, true
  19604. }
  19605. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19606. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  19607. m.action_label_del = nil
  19608. m.appendaction_label_del = nil
  19609. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  19610. }
  19611. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19612. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  19613. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  19614. return ok
  19615. }
  19616. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19617. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  19618. m.action_label_del = nil
  19619. m.appendaction_label_del = nil
  19620. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  19621. }
  19622. // Where appends a list predicates to the LabelTaggingMutation builder.
  19623. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  19624. m.predicates = append(m.predicates, ps...)
  19625. }
  19626. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  19627. // users can use type-assertion to append predicates that do not depend on any generated package.
  19628. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  19629. p := make([]predicate.LabelTagging, len(ps))
  19630. for i := range ps {
  19631. p[i] = ps[i]
  19632. }
  19633. m.Where(p...)
  19634. }
  19635. // Op returns the operation name.
  19636. func (m *LabelTaggingMutation) Op() Op {
  19637. return m.op
  19638. }
  19639. // SetOp allows setting the mutation operation.
  19640. func (m *LabelTaggingMutation) SetOp(op Op) {
  19641. m.op = op
  19642. }
  19643. // Type returns the node type of this mutation (LabelTagging).
  19644. func (m *LabelTaggingMutation) Type() string {
  19645. return m.typ
  19646. }
  19647. // Fields returns all fields that were changed during this mutation. Note that in
  19648. // order to get all numeric fields that were incremented/decremented, call
  19649. // AddedFields().
  19650. func (m *LabelTaggingMutation) Fields() []string {
  19651. fields := make([]string, 0, 9)
  19652. if m.created_at != nil {
  19653. fields = append(fields, labeltagging.FieldCreatedAt)
  19654. }
  19655. if m.updated_at != nil {
  19656. fields = append(fields, labeltagging.FieldUpdatedAt)
  19657. }
  19658. if m.status != nil {
  19659. fields = append(fields, labeltagging.FieldStatus)
  19660. }
  19661. if m.deleted_at != nil {
  19662. fields = append(fields, labeltagging.FieldDeletedAt)
  19663. }
  19664. if m.organization_id != nil {
  19665. fields = append(fields, labeltagging.FieldOrganizationID)
  19666. }
  19667. if m._type != nil {
  19668. fields = append(fields, labeltagging.FieldType)
  19669. }
  19670. if m.conditions != nil {
  19671. fields = append(fields, labeltagging.FieldConditions)
  19672. }
  19673. if m.action_label_add != nil {
  19674. fields = append(fields, labeltagging.FieldActionLabelAdd)
  19675. }
  19676. if m.action_label_del != nil {
  19677. fields = append(fields, labeltagging.FieldActionLabelDel)
  19678. }
  19679. return fields
  19680. }
  19681. // Field returns the value of a field with the given name. The second boolean
  19682. // return value indicates that this field was not set, or was not defined in the
  19683. // schema.
  19684. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  19685. switch name {
  19686. case labeltagging.FieldCreatedAt:
  19687. return m.CreatedAt()
  19688. case labeltagging.FieldUpdatedAt:
  19689. return m.UpdatedAt()
  19690. case labeltagging.FieldStatus:
  19691. return m.Status()
  19692. case labeltagging.FieldDeletedAt:
  19693. return m.DeletedAt()
  19694. case labeltagging.FieldOrganizationID:
  19695. return m.OrganizationID()
  19696. case labeltagging.FieldType:
  19697. return m.GetType()
  19698. case labeltagging.FieldConditions:
  19699. return m.Conditions()
  19700. case labeltagging.FieldActionLabelAdd:
  19701. return m.ActionLabelAdd()
  19702. case labeltagging.FieldActionLabelDel:
  19703. return m.ActionLabelDel()
  19704. }
  19705. return nil, false
  19706. }
  19707. // OldField returns the old value of the field from the database. An error is
  19708. // returned if the mutation operation is not UpdateOne, or the query to the
  19709. // database failed.
  19710. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19711. switch name {
  19712. case labeltagging.FieldCreatedAt:
  19713. return m.OldCreatedAt(ctx)
  19714. case labeltagging.FieldUpdatedAt:
  19715. return m.OldUpdatedAt(ctx)
  19716. case labeltagging.FieldStatus:
  19717. return m.OldStatus(ctx)
  19718. case labeltagging.FieldDeletedAt:
  19719. return m.OldDeletedAt(ctx)
  19720. case labeltagging.FieldOrganizationID:
  19721. return m.OldOrganizationID(ctx)
  19722. case labeltagging.FieldType:
  19723. return m.OldType(ctx)
  19724. case labeltagging.FieldConditions:
  19725. return m.OldConditions(ctx)
  19726. case labeltagging.FieldActionLabelAdd:
  19727. return m.OldActionLabelAdd(ctx)
  19728. case labeltagging.FieldActionLabelDel:
  19729. return m.OldActionLabelDel(ctx)
  19730. }
  19731. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  19732. }
  19733. // SetField sets the value of a field with the given name. It returns an error if
  19734. // the field is not defined in the schema, or if the type mismatched the field
  19735. // type.
  19736. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  19737. switch name {
  19738. case labeltagging.FieldCreatedAt:
  19739. v, ok := value.(time.Time)
  19740. if !ok {
  19741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19742. }
  19743. m.SetCreatedAt(v)
  19744. return nil
  19745. case labeltagging.FieldUpdatedAt:
  19746. v, ok := value.(time.Time)
  19747. if !ok {
  19748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19749. }
  19750. m.SetUpdatedAt(v)
  19751. return nil
  19752. case labeltagging.FieldStatus:
  19753. v, ok := value.(uint8)
  19754. if !ok {
  19755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19756. }
  19757. m.SetStatus(v)
  19758. return nil
  19759. case labeltagging.FieldDeletedAt:
  19760. v, ok := value.(time.Time)
  19761. if !ok {
  19762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19763. }
  19764. m.SetDeletedAt(v)
  19765. return nil
  19766. case labeltagging.FieldOrganizationID:
  19767. v, ok := value.(uint64)
  19768. if !ok {
  19769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19770. }
  19771. m.SetOrganizationID(v)
  19772. return nil
  19773. case labeltagging.FieldType:
  19774. v, ok := value.(int)
  19775. if !ok {
  19776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19777. }
  19778. m.SetType(v)
  19779. return nil
  19780. case labeltagging.FieldConditions:
  19781. v, ok := value.(string)
  19782. if !ok {
  19783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19784. }
  19785. m.SetConditions(v)
  19786. return nil
  19787. case labeltagging.FieldActionLabelAdd:
  19788. v, ok := value.([]uint64)
  19789. if !ok {
  19790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19791. }
  19792. m.SetActionLabelAdd(v)
  19793. return nil
  19794. case labeltagging.FieldActionLabelDel:
  19795. v, ok := value.([]uint64)
  19796. if !ok {
  19797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19798. }
  19799. m.SetActionLabelDel(v)
  19800. return nil
  19801. }
  19802. return fmt.Errorf("unknown LabelTagging field %s", name)
  19803. }
  19804. // AddedFields returns all numeric fields that were incremented/decremented during
  19805. // this mutation.
  19806. func (m *LabelTaggingMutation) AddedFields() []string {
  19807. var fields []string
  19808. if m.addstatus != nil {
  19809. fields = append(fields, labeltagging.FieldStatus)
  19810. }
  19811. if m.addorganization_id != nil {
  19812. fields = append(fields, labeltagging.FieldOrganizationID)
  19813. }
  19814. if m.add_type != nil {
  19815. fields = append(fields, labeltagging.FieldType)
  19816. }
  19817. return fields
  19818. }
  19819. // AddedField returns the numeric value that was incremented/decremented on a field
  19820. // with the given name. The second boolean return value indicates that this field
  19821. // was not set, or was not defined in the schema.
  19822. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  19823. switch name {
  19824. case labeltagging.FieldStatus:
  19825. return m.AddedStatus()
  19826. case labeltagging.FieldOrganizationID:
  19827. return m.AddedOrganizationID()
  19828. case labeltagging.FieldType:
  19829. return m.AddedType()
  19830. }
  19831. return nil, false
  19832. }
  19833. // AddField adds the value to the field with the given name. It returns an error if
  19834. // the field is not defined in the schema, or if the type mismatched the field
  19835. // type.
  19836. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  19837. switch name {
  19838. case labeltagging.FieldStatus:
  19839. v, ok := value.(int8)
  19840. if !ok {
  19841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19842. }
  19843. m.AddStatus(v)
  19844. return nil
  19845. case labeltagging.FieldOrganizationID:
  19846. v, ok := value.(int64)
  19847. if !ok {
  19848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19849. }
  19850. m.AddOrganizationID(v)
  19851. return nil
  19852. case labeltagging.FieldType:
  19853. v, ok := value.(int)
  19854. if !ok {
  19855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19856. }
  19857. m.AddType(v)
  19858. return nil
  19859. }
  19860. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  19861. }
  19862. // ClearedFields returns all nullable fields that were cleared during this
  19863. // mutation.
  19864. func (m *LabelTaggingMutation) ClearedFields() []string {
  19865. var fields []string
  19866. if m.FieldCleared(labeltagging.FieldStatus) {
  19867. fields = append(fields, labeltagging.FieldStatus)
  19868. }
  19869. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  19870. fields = append(fields, labeltagging.FieldDeletedAt)
  19871. }
  19872. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  19873. fields = append(fields, labeltagging.FieldActionLabelAdd)
  19874. }
  19875. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  19876. fields = append(fields, labeltagging.FieldActionLabelDel)
  19877. }
  19878. return fields
  19879. }
  19880. // FieldCleared returns a boolean indicating if a field with the given name was
  19881. // cleared in this mutation.
  19882. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  19883. _, ok := m.clearedFields[name]
  19884. return ok
  19885. }
  19886. // ClearField clears the value of the field with the given name. It returns an
  19887. // error if the field is not defined in the schema.
  19888. func (m *LabelTaggingMutation) ClearField(name string) error {
  19889. switch name {
  19890. case labeltagging.FieldStatus:
  19891. m.ClearStatus()
  19892. return nil
  19893. case labeltagging.FieldDeletedAt:
  19894. m.ClearDeletedAt()
  19895. return nil
  19896. case labeltagging.FieldActionLabelAdd:
  19897. m.ClearActionLabelAdd()
  19898. return nil
  19899. case labeltagging.FieldActionLabelDel:
  19900. m.ClearActionLabelDel()
  19901. return nil
  19902. }
  19903. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  19904. }
  19905. // ResetField resets all changes in the mutation for the field with the given name.
  19906. // It returns an error if the field is not defined in the schema.
  19907. func (m *LabelTaggingMutation) ResetField(name string) error {
  19908. switch name {
  19909. case labeltagging.FieldCreatedAt:
  19910. m.ResetCreatedAt()
  19911. return nil
  19912. case labeltagging.FieldUpdatedAt:
  19913. m.ResetUpdatedAt()
  19914. return nil
  19915. case labeltagging.FieldStatus:
  19916. m.ResetStatus()
  19917. return nil
  19918. case labeltagging.FieldDeletedAt:
  19919. m.ResetDeletedAt()
  19920. return nil
  19921. case labeltagging.FieldOrganizationID:
  19922. m.ResetOrganizationID()
  19923. return nil
  19924. case labeltagging.FieldType:
  19925. m.ResetType()
  19926. return nil
  19927. case labeltagging.FieldConditions:
  19928. m.ResetConditions()
  19929. return nil
  19930. case labeltagging.FieldActionLabelAdd:
  19931. m.ResetActionLabelAdd()
  19932. return nil
  19933. case labeltagging.FieldActionLabelDel:
  19934. m.ResetActionLabelDel()
  19935. return nil
  19936. }
  19937. return fmt.Errorf("unknown LabelTagging field %s", name)
  19938. }
  19939. // AddedEdges returns all edge names that were set/added in this mutation.
  19940. func (m *LabelTaggingMutation) AddedEdges() []string {
  19941. edges := make([]string, 0, 0)
  19942. return edges
  19943. }
  19944. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19945. // name in this mutation.
  19946. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  19947. return nil
  19948. }
  19949. // RemovedEdges returns all edge names that were removed in this mutation.
  19950. func (m *LabelTaggingMutation) RemovedEdges() []string {
  19951. edges := make([]string, 0, 0)
  19952. return edges
  19953. }
  19954. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19955. // the given name in this mutation.
  19956. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  19957. return nil
  19958. }
  19959. // ClearedEdges returns all edge names that were cleared in this mutation.
  19960. func (m *LabelTaggingMutation) ClearedEdges() []string {
  19961. edges := make([]string, 0, 0)
  19962. return edges
  19963. }
  19964. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19965. // was cleared in this mutation.
  19966. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  19967. return false
  19968. }
  19969. // ClearEdge clears the value of the edge with the given name. It returns an error
  19970. // if that edge is not defined in the schema.
  19971. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  19972. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  19973. }
  19974. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19975. // It returns an error if the edge is not defined in the schema.
  19976. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  19977. return fmt.Errorf("unknown LabelTagging edge %s", name)
  19978. }
  19979. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  19980. type MessageMutation struct {
  19981. config
  19982. op Op
  19983. typ string
  19984. id *int
  19985. wx_wxid *string
  19986. wxid *string
  19987. content *string
  19988. clearedFields map[string]struct{}
  19989. done bool
  19990. oldValue func(context.Context) (*Message, error)
  19991. predicates []predicate.Message
  19992. }
  19993. var _ ent.Mutation = (*MessageMutation)(nil)
  19994. // messageOption allows management of the mutation configuration using functional options.
  19995. type messageOption func(*MessageMutation)
  19996. // newMessageMutation creates new mutation for the Message entity.
  19997. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  19998. m := &MessageMutation{
  19999. config: c,
  20000. op: op,
  20001. typ: TypeMessage,
  20002. clearedFields: make(map[string]struct{}),
  20003. }
  20004. for _, opt := range opts {
  20005. opt(m)
  20006. }
  20007. return m
  20008. }
  20009. // withMessageID sets the ID field of the mutation.
  20010. func withMessageID(id int) messageOption {
  20011. return func(m *MessageMutation) {
  20012. var (
  20013. err error
  20014. once sync.Once
  20015. value *Message
  20016. )
  20017. m.oldValue = func(ctx context.Context) (*Message, error) {
  20018. once.Do(func() {
  20019. if m.done {
  20020. err = errors.New("querying old values post mutation is not allowed")
  20021. } else {
  20022. value, err = m.Client().Message.Get(ctx, id)
  20023. }
  20024. })
  20025. return value, err
  20026. }
  20027. m.id = &id
  20028. }
  20029. }
  20030. // withMessage sets the old Message of the mutation.
  20031. func withMessage(node *Message) messageOption {
  20032. return func(m *MessageMutation) {
  20033. m.oldValue = func(context.Context) (*Message, error) {
  20034. return node, nil
  20035. }
  20036. m.id = &node.ID
  20037. }
  20038. }
  20039. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20040. // executed in a transaction (ent.Tx), a transactional client is returned.
  20041. func (m MessageMutation) Client() *Client {
  20042. client := &Client{config: m.config}
  20043. client.init()
  20044. return client
  20045. }
  20046. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20047. // it returns an error otherwise.
  20048. func (m MessageMutation) Tx() (*Tx, error) {
  20049. if _, ok := m.driver.(*txDriver); !ok {
  20050. return nil, errors.New("ent: mutation is not running in a transaction")
  20051. }
  20052. tx := &Tx{config: m.config}
  20053. tx.init()
  20054. return tx, nil
  20055. }
  20056. // ID returns the ID value in the mutation. Note that the ID is only available
  20057. // if it was provided to the builder or after it was returned from the database.
  20058. func (m *MessageMutation) ID() (id int, exists bool) {
  20059. if m.id == nil {
  20060. return
  20061. }
  20062. return *m.id, true
  20063. }
  20064. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20065. // That means, if the mutation is applied within a transaction with an isolation level such
  20066. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20067. // or updated by the mutation.
  20068. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  20069. switch {
  20070. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20071. id, exists := m.ID()
  20072. if exists {
  20073. return []int{id}, nil
  20074. }
  20075. fallthrough
  20076. case m.op.Is(OpUpdate | OpDelete):
  20077. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  20078. default:
  20079. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20080. }
  20081. }
  20082. // SetWxWxid sets the "wx_wxid" field.
  20083. func (m *MessageMutation) SetWxWxid(s string) {
  20084. m.wx_wxid = &s
  20085. }
  20086. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  20087. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  20088. v := m.wx_wxid
  20089. if v == nil {
  20090. return
  20091. }
  20092. return *v, true
  20093. }
  20094. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  20095. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20097. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  20098. if !m.op.Is(OpUpdateOne) {
  20099. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  20100. }
  20101. if m.id == nil || m.oldValue == nil {
  20102. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  20103. }
  20104. oldValue, err := m.oldValue(ctx)
  20105. if err != nil {
  20106. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  20107. }
  20108. return oldValue.WxWxid, nil
  20109. }
  20110. // ClearWxWxid clears the value of the "wx_wxid" field.
  20111. func (m *MessageMutation) ClearWxWxid() {
  20112. m.wx_wxid = nil
  20113. m.clearedFields[message.FieldWxWxid] = struct{}{}
  20114. }
  20115. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  20116. func (m *MessageMutation) WxWxidCleared() bool {
  20117. _, ok := m.clearedFields[message.FieldWxWxid]
  20118. return ok
  20119. }
  20120. // ResetWxWxid resets all changes to the "wx_wxid" field.
  20121. func (m *MessageMutation) ResetWxWxid() {
  20122. m.wx_wxid = nil
  20123. delete(m.clearedFields, message.FieldWxWxid)
  20124. }
  20125. // SetWxid sets the "wxid" field.
  20126. func (m *MessageMutation) SetWxid(s string) {
  20127. m.wxid = &s
  20128. }
  20129. // Wxid returns the value of the "wxid" field in the mutation.
  20130. func (m *MessageMutation) Wxid() (r string, exists bool) {
  20131. v := m.wxid
  20132. if v == nil {
  20133. return
  20134. }
  20135. return *v, true
  20136. }
  20137. // OldWxid returns the old "wxid" field's value of the Message entity.
  20138. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20140. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  20141. if !m.op.Is(OpUpdateOne) {
  20142. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  20143. }
  20144. if m.id == nil || m.oldValue == nil {
  20145. return v, errors.New("OldWxid requires an ID field in the mutation")
  20146. }
  20147. oldValue, err := m.oldValue(ctx)
  20148. if err != nil {
  20149. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  20150. }
  20151. return oldValue.Wxid, nil
  20152. }
  20153. // ResetWxid resets all changes to the "wxid" field.
  20154. func (m *MessageMutation) ResetWxid() {
  20155. m.wxid = nil
  20156. }
  20157. // SetContent sets the "content" field.
  20158. func (m *MessageMutation) SetContent(s string) {
  20159. m.content = &s
  20160. }
  20161. // Content returns the value of the "content" field in the mutation.
  20162. func (m *MessageMutation) Content() (r string, exists bool) {
  20163. v := m.content
  20164. if v == nil {
  20165. return
  20166. }
  20167. return *v, true
  20168. }
  20169. // OldContent returns the old "content" field's value of the Message entity.
  20170. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20172. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  20173. if !m.op.Is(OpUpdateOne) {
  20174. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20175. }
  20176. if m.id == nil || m.oldValue == nil {
  20177. return v, errors.New("OldContent requires an ID field in the mutation")
  20178. }
  20179. oldValue, err := m.oldValue(ctx)
  20180. if err != nil {
  20181. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20182. }
  20183. return oldValue.Content, nil
  20184. }
  20185. // ResetContent resets all changes to the "content" field.
  20186. func (m *MessageMutation) ResetContent() {
  20187. m.content = nil
  20188. }
  20189. // Where appends a list predicates to the MessageMutation builder.
  20190. func (m *MessageMutation) Where(ps ...predicate.Message) {
  20191. m.predicates = append(m.predicates, ps...)
  20192. }
  20193. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  20194. // users can use type-assertion to append predicates that do not depend on any generated package.
  20195. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  20196. p := make([]predicate.Message, len(ps))
  20197. for i := range ps {
  20198. p[i] = ps[i]
  20199. }
  20200. m.Where(p...)
  20201. }
  20202. // Op returns the operation name.
  20203. func (m *MessageMutation) Op() Op {
  20204. return m.op
  20205. }
  20206. // SetOp allows setting the mutation operation.
  20207. func (m *MessageMutation) SetOp(op Op) {
  20208. m.op = op
  20209. }
  20210. // Type returns the node type of this mutation (Message).
  20211. func (m *MessageMutation) Type() string {
  20212. return m.typ
  20213. }
  20214. // Fields returns all fields that were changed during this mutation. Note that in
  20215. // order to get all numeric fields that were incremented/decremented, call
  20216. // AddedFields().
  20217. func (m *MessageMutation) Fields() []string {
  20218. fields := make([]string, 0, 3)
  20219. if m.wx_wxid != nil {
  20220. fields = append(fields, message.FieldWxWxid)
  20221. }
  20222. if m.wxid != nil {
  20223. fields = append(fields, message.FieldWxid)
  20224. }
  20225. if m.content != nil {
  20226. fields = append(fields, message.FieldContent)
  20227. }
  20228. return fields
  20229. }
  20230. // Field returns the value of a field with the given name. The second boolean
  20231. // return value indicates that this field was not set, or was not defined in the
  20232. // schema.
  20233. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  20234. switch name {
  20235. case message.FieldWxWxid:
  20236. return m.WxWxid()
  20237. case message.FieldWxid:
  20238. return m.Wxid()
  20239. case message.FieldContent:
  20240. return m.Content()
  20241. }
  20242. return nil, false
  20243. }
  20244. // OldField returns the old value of the field from the database. An error is
  20245. // returned if the mutation operation is not UpdateOne, or the query to the
  20246. // database failed.
  20247. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20248. switch name {
  20249. case message.FieldWxWxid:
  20250. return m.OldWxWxid(ctx)
  20251. case message.FieldWxid:
  20252. return m.OldWxid(ctx)
  20253. case message.FieldContent:
  20254. return m.OldContent(ctx)
  20255. }
  20256. return nil, fmt.Errorf("unknown Message field %s", name)
  20257. }
  20258. // SetField sets the value of a field with the given name. It returns an error if
  20259. // the field is not defined in the schema, or if the type mismatched the field
  20260. // type.
  20261. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  20262. switch name {
  20263. case message.FieldWxWxid:
  20264. v, ok := value.(string)
  20265. if !ok {
  20266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20267. }
  20268. m.SetWxWxid(v)
  20269. return nil
  20270. case message.FieldWxid:
  20271. v, ok := value.(string)
  20272. if !ok {
  20273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20274. }
  20275. m.SetWxid(v)
  20276. return nil
  20277. case message.FieldContent:
  20278. v, ok := value.(string)
  20279. if !ok {
  20280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20281. }
  20282. m.SetContent(v)
  20283. return nil
  20284. }
  20285. return fmt.Errorf("unknown Message field %s", name)
  20286. }
  20287. // AddedFields returns all numeric fields that were incremented/decremented during
  20288. // this mutation.
  20289. func (m *MessageMutation) AddedFields() []string {
  20290. return nil
  20291. }
  20292. // AddedField returns the numeric value that was incremented/decremented on a field
  20293. // with the given name. The second boolean return value indicates that this field
  20294. // was not set, or was not defined in the schema.
  20295. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  20296. return nil, false
  20297. }
  20298. // AddField adds the value to the field with the given name. It returns an error if
  20299. // the field is not defined in the schema, or if the type mismatched the field
  20300. // type.
  20301. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  20302. switch name {
  20303. }
  20304. return fmt.Errorf("unknown Message numeric field %s", name)
  20305. }
  20306. // ClearedFields returns all nullable fields that were cleared during this
  20307. // mutation.
  20308. func (m *MessageMutation) ClearedFields() []string {
  20309. var fields []string
  20310. if m.FieldCleared(message.FieldWxWxid) {
  20311. fields = append(fields, message.FieldWxWxid)
  20312. }
  20313. return fields
  20314. }
  20315. // FieldCleared returns a boolean indicating if a field with the given name was
  20316. // cleared in this mutation.
  20317. func (m *MessageMutation) FieldCleared(name string) bool {
  20318. _, ok := m.clearedFields[name]
  20319. return ok
  20320. }
  20321. // ClearField clears the value of the field with the given name. It returns an
  20322. // error if the field is not defined in the schema.
  20323. func (m *MessageMutation) ClearField(name string) error {
  20324. switch name {
  20325. case message.FieldWxWxid:
  20326. m.ClearWxWxid()
  20327. return nil
  20328. }
  20329. return fmt.Errorf("unknown Message nullable field %s", name)
  20330. }
  20331. // ResetField resets all changes in the mutation for the field with the given name.
  20332. // It returns an error if the field is not defined in the schema.
  20333. func (m *MessageMutation) ResetField(name string) error {
  20334. switch name {
  20335. case message.FieldWxWxid:
  20336. m.ResetWxWxid()
  20337. return nil
  20338. case message.FieldWxid:
  20339. m.ResetWxid()
  20340. return nil
  20341. case message.FieldContent:
  20342. m.ResetContent()
  20343. return nil
  20344. }
  20345. return fmt.Errorf("unknown Message field %s", name)
  20346. }
  20347. // AddedEdges returns all edge names that were set/added in this mutation.
  20348. func (m *MessageMutation) AddedEdges() []string {
  20349. edges := make([]string, 0, 0)
  20350. return edges
  20351. }
  20352. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20353. // name in this mutation.
  20354. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  20355. return nil
  20356. }
  20357. // RemovedEdges returns all edge names that were removed in this mutation.
  20358. func (m *MessageMutation) RemovedEdges() []string {
  20359. edges := make([]string, 0, 0)
  20360. return edges
  20361. }
  20362. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20363. // the given name in this mutation.
  20364. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  20365. return nil
  20366. }
  20367. // ClearedEdges returns all edge names that were cleared in this mutation.
  20368. func (m *MessageMutation) ClearedEdges() []string {
  20369. edges := make([]string, 0, 0)
  20370. return edges
  20371. }
  20372. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20373. // was cleared in this mutation.
  20374. func (m *MessageMutation) EdgeCleared(name string) bool {
  20375. return false
  20376. }
  20377. // ClearEdge clears the value of the edge with the given name. It returns an error
  20378. // if that edge is not defined in the schema.
  20379. func (m *MessageMutation) ClearEdge(name string) error {
  20380. return fmt.Errorf("unknown Message unique edge %s", name)
  20381. }
  20382. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20383. // It returns an error if the edge is not defined in the schema.
  20384. func (m *MessageMutation) ResetEdge(name string) error {
  20385. return fmt.Errorf("unknown Message edge %s", name)
  20386. }
  20387. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  20388. type MessageRecordsMutation struct {
  20389. config
  20390. op Op
  20391. typ string
  20392. id *uint64
  20393. created_at *time.Time
  20394. updated_at *time.Time
  20395. status *uint8
  20396. addstatus *int8
  20397. bot_wxid *string
  20398. contact_type *int
  20399. addcontact_type *int
  20400. contact_wxid *string
  20401. content_type *int
  20402. addcontent_type *int
  20403. content *string
  20404. meta *custom_types.Meta
  20405. error_detail *string
  20406. send_time *time.Time
  20407. source_type *int
  20408. addsource_type *int
  20409. organization_id *uint64
  20410. addorganization_id *int64
  20411. clearedFields map[string]struct{}
  20412. sop_stage *uint64
  20413. clearedsop_stage bool
  20414. sop_node *uint64
  20415. clearedsop_node bool
  20416. message_contact *uint64
  20417. clearedmessage_contact bool
  20418. done bool
  20419. oldValue func(context.Context) (*MessageRecords, error)
  20420. predicates []predicate.MessageRecords
  20421. }
  20422. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  20423. // messagerecordsOption allows management of the mutation configuration using functional options.
  20424. type messagerecordsOption func(*MessageRecordsMutation)
  20425. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  20426. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  20427. m := &MessageRecordsMutation{
  20428. config: c,
  20429. op: op,
  20430. typ: TypeMessageRecords,
  20431. clearedFields: make(map[string]struct{}),
  20432. }
  20433. for _, opt := range opts {
  20434. opt(m)
  20435. }
  20436. return m
  20437. }
  20438. // withMessageRecordsID sets the ID field of the mutation.
  20439. func withMessageRecordsID(id uint64) messagerecordsOption {
  20440. return func(m *MessageRecordsMutation) {
  20441. var (
  20442. err error
  20443. once sync.Once
  20444. value *MessageRecords
  20445. )
  20446. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  20447. once.Do(func() {
  20448. if m.done {
  20449. err = errors.New("querying old values post mutation is not allowed")
  20450. } else {
  20451. value, err = m.Client().MessageRecords.Get(ctx, id)
  20452. }
  20453. })
  20454. return value, err
  20455. }
  20456. m.id = &id
  20457. }
  20458. }
  20459. // withMessageRecords sets the old MessageRecords of the mutation.
  20460. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  20461. return func(m *MessageRecordsMutation) {
  20462. m.oldValue = func(context.Context) (*MessageRecords, error) {
  20463. return node, nil
  20464. }
  20465. m.id = &node.ID
  20466. }
  20467. }
  20468. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20469. // executed in a transaction (ent.Tx), a transactional client is returned.
  20470. func (m MessageRecordsMutation) Client() *Client {
  20471. client := &Client{config: m.config}
  20472. client.init()
  20473. return client
  20474. }
  20475. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20476. // it returns an error otherwise.
  20477. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  20478. if _, ok := m.driver.(*txDriver); !ok {
  20479. return nil, errors.New("ent: mutation is not running in a transaction")
  20480. }
  20481. tx := &Tx{config: m.config}
  20482. tx.init()
  20483. return tx, nil
  20484. }
  20485. // SetID sets the value of the id field. Note that this
  20486. // operation is only accepted on creation of MessageRecords entities.
  20487. func (m *MessageRecordsMutation) SetID(id uint64) {
  20488. m.id = &id
  20489. }
  20490. // ID returns the ID value in the mutation. Note that the ID is only available
  20491. // if it was provided to the builder or after it was returned from the database.
  20492. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  20493. if m.id == nil {
  20494. return
  20495. }
  20496. return *m.id, true
  20497. }
  20498. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20499. // That means, if the mutation is applied within a transaction with an isolation level such
  20500. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20501. // or updated by the mutation.
  20502. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  20503. switch {
  20504. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20505. id, exists := m.ID()
  20506. if exists {
  20507. return []uint64{id}, nil
  20508. }
  20509. fallthrough
  20510. case m.op.Is(OpUpdate | OpDelete):
  20511. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  20512. default:
  20513. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20514. }
  20515. }
  20516. // SetCreatedAt sets the "created_at" field.
  20517. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  20518. m.created_at = &t
  20519. }
  20520. // CreatedAt returns the value of the "created_at" field in the mutation.
  20521. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  20522. v := m.created_at
  20523. if v == nil {
  20524. return
  20525. }
  20526. return *v, true
  20527. }
  20528. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  20529. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20531. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20532. if !m.op.Is(OpUpdateOne) {
  20533. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20534. }
  20535. if m.id == nil || m.oldValue == nil {
  20536. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20537. }
  20538. oldValue, err := m.oldValue(ctx)
  20539. if err != nil {
  20540. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20541. }
  20542. return oldValue.CreatedAt, nil
  20543. }
  20544. // ResetCreatedAt resets all changes to the "created_at" field.
  20545. func (m *MessageRecordsMutation) ResetCreatedAt() {
  20546. m.created_at = nil
  20547. }
  20548. // SetUpdatedAt sets the "updated_at" field.
  20549. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  20550. m.updated_at = &t
  20551. }
  20552. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20553. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  20554. v := m.updated_at
  20555. if v == nil {
  20556. return
  20557. }
  20558. return *v, true
  20559. }
  20560. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  20561. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20563. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20564. if !m.op.Is(OpUpdateOne) {
  20565. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20566. }
  20567. if m.id == nil || m.oldValue == nil {
  20568. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20569. }
  20570. oldValue, err := m.oldValue(ctx)
  20571. if err != nil {
  20572. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20573. }
  20574. return oldValue.UpdatedAt, nil
  20575. }
  20576. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20577. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  20578. m.updated_at = nil
  20579. }
  20580. // SetStatus sets the "status" field.
  20581. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  20582. m.status = &u
  20583. m.addstatus = nil
  20584. }
  20585. // Status returns the value of the "status" field in the mutation.
  20586. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  20587. v := m.status
  20588. if v == nil {
  20589. return
  20590. }
  20591. return *v, true
  20592. }
  20593. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  20594. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20596. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20597. if !m.op.Is(OpUpdateOne) {
  20598. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20599. }
  20600. if m.id == nil || m.oldValue == nil {
  20601. return v, errors.New("OldStatus requires an ID field in the mutation")
  20602. }
  20603. oldValue, err := m.oldValue(ctx)
  20604. if err != nil {
  20605. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20606. }
  20607. return oldValue.Status, nil
  20608. }
  20609. // AddStatus adds u to the "status" field.
  20610. func (m *MessageRecordsMutation) AddStatus(u int8) {
  20611. if m.addstatus != nil {
  20612. *m.addstatus += u
  20613. } else {
  20614. m.addstatus = &u
  20615. }
  20616. }
  20617. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20618. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  20619. v := m.addstatus
  20620. if v == nil {
  20621. return
  20622. }
  20623. return *v, true
  20624. }
  20625. // ClearStatus clears the value of the "status" field.
  20626. func (m *MessageRecordsMutation) ClearStatus() {
  20627. m.status = nil
  20628. m.addstatus = nil
  20629. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  20630. }
  20631. // StatusCleared returns if the "status" field was cleared in this mutation.
  20632. func (m *MessageRecordsMutation) StatusCleared() bool {
  20633. _, ok := m.clearedFields[messagerecords.FieldStatus]
  20634. return ok
  20635. }
  20636. // ResetStatus resets all changes to the "status" field.
  20637. func (m *MessageRecordsMutation) ResetStatus() {
  20638. m.status = nil
  20639. m.addstatus = nil
  20640. delete(m.clearedFields, messagerecords.FieldStatus)
  20641. }
  20642. // SetBotWxid sets the "bot_wxid" field.
  20643. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  20644. m.bot_wxid = &s
  20645. }
  20646. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  20647. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  20648. v := m.bot_wxid
  20649. if v == nil {
  20650. return
  20651. }
  20652. return *v, true
  20653. }
  20654. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  20655. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20657. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  20658. if !m.op.Is(OpUpdateOne) {
  20659. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  20660. }
  20661. if m.id == nil || m.oldValue == nil {
  20662. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  20663. }
  20664. oldValue, err := m.oldValue(ctx)
  20665. if err != nil {
  20666. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  20667. }
  20668. return oldValue.BotWxid, nil
  20669. }
  20670. // ResetBotWxid resets all changes to the "bot_wxid" field.
  20671. func (m *MessageRecordsMutation) ResetBotWxid() {
  20672. m.bot_wxid = nil
  20673. }
  20674. // SetContactID sets the "contact_id" field.
  20675. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  20676. m.message_contact = &u
  20677. }
  20678. // ContactID returns the value of the "contact_id" field in the mutation.
  20679. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  20680. v := m.message_contact
  20681. if v == nil {
  20682. return
  20683. }
  20684. return *v, true
  20685. }
  20686. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  20687. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20689. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  20690. if !m.op.Is(OpUpdateOne) {
  20691. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  20692. }
  20693. if m.id == nil || m.oldValue == nil {
  20694. return v, errors.New("OldContactID requires an ID field in the mutation")
  20695. }
  20696. oldValue, err := m.oldValue(ctx)
  20697. if err != nil {
  20698. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  20699. }
  20700. return oldValue.ContactID, nil
  20701. }
  20702. // ClearContactID clears the value of the "contact_id" field.
  20703. func (m *MessageRecordsMutation) ClearContactID() {
  20704. m.message_contact = nil
  20705. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  20706. }
  20707. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  20708. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  20709. _, ok := m.clearedFields[messagerecords.FieldContactID]
  20710. return ok
  20711. }
  20712. // ResetContactID resets all changes to the "contact_id" field.
  20713. func (m *MessageRecordsMutation) ResetContactID() {
  20714. m.message_contact = nil
  20715. delete(m.clearedFields, messagerecords.FieldContactID)
  20716. }
  20717. // SetContactType sets the "contact_type" field.
  20718. func (m *MessageRecordsMutation) SetContactType(i int) {
  20719. m.contact_type = &i
  20720. m.addcontact_type = nil
  20721. }
  20722. // ContactType returns the value of the "contact_type" field in the mutation.
  20723. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  20724. v := m.contact_type
  20725. if v == nil {
  20726. return
  20727. }
  20728. return *v, true
  20729. }
  20730. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  20731. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20733. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  20734. if !m.op.Is(OpUpdateOne) {
  20735. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  20736. }
  20737. if m.id == nil || m.oldValue == nil {
  20738. return v, errors.New("OldContactType requires an ID field in the mutation")
  20739. }
  20740. oldValue, err := m.oldValue(ctx)
  20741. if err != nil {
  20742. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  20743. }
  20744. return oldValue.ContactType, nil
  20745. }
  20746. // AddContactType adds i to the "contact_type" field.
  20747. func (m *MessageRecordsMutation) AddContactType(i int) {
  20748. if m.addcontact_type != nil {
  20749. *m.addcontact_type += i
  20750. } else {
  20751. m.addcontact_type = &i
  20752. }
  20753. }
  20754. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  20755. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  20756. v := m.addcontact_type
  20757. if v == nil {
  20758. return
  20759. }
  20760. return *v, true
  20761. }
  20762. // ResetContactType resets all changes to the "contact_type" field.
  20763. func (m *MessageRecordsMutation) ResetContactType() {
  20764. m.contact_type = nil
  20765. m.addcontact_type = nil
  20766. }
  20767. // SetContactWxid sets the "contact_wxid" field.
  20768. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  20769. m.contact_wxid = &s
  20770. }
  20771. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  20772. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  20773. v := m.contact_wxid
  20774. if v == nil {
  20775. return
  20776. }
  20777. return *v, true
  20778. }
  20779. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  20780. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20782. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  20783. if !m.op.Is(OpUpdateOne) {
  20784. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  20785. }
  20786. if m.id == nil || m.oldValue == nil {
  20787. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  20788. }
  20789. oldValue, err := m.oldValue(ctx)
  20790. if err != nil {
  20791. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  20792. }
  20793. return oldValue.ContactWxid, nil
  20794. }
  20795. // ResetContactWxid resets all changes to the "contact_wxid" field.
  20796. func (m *MessageRecordsMutation) ResetContactWxid() {
  20797. m.contact_wxid = nil
  20798. }
  20799. // SetContentType sets the "content_type" field.
  20800. func (m *MessageRecordsMutation) SetContentType(i int) {
  20801. m.content_type = &i
  20802. m.addcontent_type = nil
  20803. }
  20804. // ContentType returns the value of the "content_type" field in the mutation.
  20805. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  20806. v := m.content_type
  20807. if v == nil {
  20808. return
  20809. }
  20810. return *v, true
  20811. }
  20812. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  20813. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20815. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  20816. if !m.op.Is(OpUpdateOne) {
  20817. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  20818. }
  20819. if m.id == nil || m.oldValue == nil {
  20820. return v, errors.New("OldContentType requires an ID field in the mutation")
  20821. }
  20822. oldValue, err := m.oldValue(ctx)
  20823. if err != nil {
  20824. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  20825. }
  20826. return oldValue.ContentType, nil
  20827. }
  20828. // AddContentType adds i to the "content_type" field.
  20829. func (m *MessageRecordsMutation) AddContentType(i int) {
  20830. if m.addcontent_type != nil {
  20831. *m.addcontent_type += i
  20832. } else {
  20833. m.addcontent_type = &i
  20834. }
  20835. }
  20836. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  20837. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  20838. v := m.addcontent_type
  20839. if v == nil {
  20840. return
  20841. }
  20842. return *v, true
  20843. }
  20844. // ResetContentType resets all changes to the "content_type" field.
  20845. func (m *MessageRecordsMutation) ResetContentType() {
  20846. m.content_type = nil
  20847. m.addcontent_type = nil
  20848. }
  20849. // SetContent sets the "content" field.
  20850. func (m *MessageRecordsMutation) SetContent(s string) {
  20851. m.content = &s
  20852. }
  20853. // Content returns the value of the "content" field in the mutation.
  20854. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  20855. v := m.content
  20856. if v == nil {
  20857. return
  20858. }
  20859. return *v, true
  20860. }
  20861. // OldContent returns the old "content" field's value of the MessageRecords entity.
  20862. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20864. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  20865. if !m.op.Is(OpUpdateOne) {
  20866. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20867. }
  20868. if m.id == nil || m.oldValue == nil {
  20869. return v, errors.New("OldContent requires an ID field in the mutation")
  20870. }
  20871. oldValue, err := m.oldValue(ctx)
  20872. if err != nil {
  20873. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20874. }
  20875. return oldValue.Content, nil
  20876. }
  20877. // ResetContent resets all changes to the "content" field.
  20878. func (m *MessageRecordsMutation) ResetContent() {
  20879. m.content = nil
  20880. }
  20881. // SetMeta sets the "meta" field.
  20882. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  20883. m.meta = &ct
  20884. }
  20885. // Meta returns the value of the "meta" field in the mutation.
  20886. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  20887. v := m.meta
  20888. if v == nil {
  20889. return
  20890. }
  20891. return *v, true
  20892. }
  20893. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  20894. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20896. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  20897. if !m.op.Is(OpUpdateOne) {
  20898. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  20899. }
  20900. if m.id == nil || m.oldValue == nil {
  20901. return v, errors.New("OldMeta requires an ID field in the mutation")
  20902. }
  20903. oldValue, err := m.oldValue(ctx)
  20904. if err != nil {
  20905. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  20906. }
  20907. return oldValue.Meta, nil
  20908. }
  20909. // ClearMeta clears the value of the "meta" field.
  20910. func (m *MessageRecordsMutation) ClearMeta() {
  20911. m.meta = nil
  20912. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  20913. }
  20914. // MetaCleared returns if the "meta" field was cleared in this mutation.
  20915. func (m *MessageRecordsMutation) MetaCleared() bool {
  20916. _, ok := m.clearedFields[messagerecords.FieldMeta]
  20917. return ok
  20918. }
  20919. // ResetMeta resets all changes to the "meta" field.
  20920. func (m *MessageRecordsMutation) ResetMeta() {
  20921. m.meta = nil
  20922. delete(m.clearedFields, messagerecords.FieldMeta)
  20923. }
  20924. // SetErrorDetail sets the "error_detail" field.
  20925. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  20926. m.error_detail = &s
  20927. }
  20928. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  20929. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  20930. v := m.error_detail
  20931. if v == nil {
  20932. return
  20933. }
  20934. return *v, true
  20935. }
  20936. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  20937. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20939. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  20940. if !m.op.Is(OpUpdateOne) {
  20941. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  20942. }
  20943. if m.id == nil || m.oldValue == nil {
  20944. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  20945. }
  20946. oldValue, err := m.oldValue(ctx)
  20947. if err != nil {
  20948. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  20949. }
  20950. return oldValue.ErrorDetail, nil
  20951. }
  20952. // ResetErrorDetail resets all changes to the "error_detail" field.
  20953. func (m *MessageRecordsMutation) ResetErrorDetail() {
  20954. m.error_detail = nil
  20955. }
  20956. // SetSendTime sets the "send_time" field.
  20957. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  20958. m.send_time = &t
  20959. }
  20960. // SendTime returns the value of the "send_time" field in the mutation.
  20961. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  20962. v := m.send_time
  20963. if v == nil {
  20964. return
  20965. }
  20966. return *v, true
  20967. }
  20968. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  20969. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20971. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  20972. if !m.op.Is(OpUpdateOne) {
  20973. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  20974. }
  20975. if m.id == nil || m.oldValue == nil {
  20976. return v, errors.New("OldSendTime requires an ID field in the mutation")
  20977. }
  20978. oldValue, err := m.oldValue(ctx)
  20979. if err != nil {
  20980. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  20981. }
  20982. return oldValue.SendTime, nil
  20983. }
  20984. // ClearSendTime clears the value of the "send_time" field.
  20985. func (m *MessageRecordsMutation) ClearSendTime() {
  20986. m.send_time = nil
  20987. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  20988. }
  20989. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  20990. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  20991. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  20992. return ok
  20993. }
  20994. // ResetSendTime resets all changes to the "send_time" field.
  20995. func (m *MessageRecordsMutation) ResetSendTime() {
  20996. m.send_time = nil
  20997. delete(m.clearedFields, messagerecords.FieldSendTime)
  20998. }
  20999. // SetSourceType sets the "source_type" field.
  21000. func (m *MessageRecordsMutation) SetSourceType(i int) {
  21001. m.source_type = &i
  21002. m.addsource_type = nil
  21003. }
  21004. // SourceType returns the value of the "source_type" field in the mutation.
  21005. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  21006. v := m.source_type
  21007. if v == nil {
  21008. return
  21009. }
  21010. return *v, true
  21011. }
  21012. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  21013. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21015. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  21016. if !m.op.Is(OpUpdateOne) {
  21017. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  21018. }
  21019. if m.id == nil || m.oldValue == nil {
  21020. return v, errors.New("OldSourceType requires an ID field in the mutation")
  21021. }
  21022. oldValue, err := m.oldValue(ctx)
  21023. if err != nil {
  21024. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  21025. }
  21026. return oldValue.SourceType, nil
  21027. }
  21028. // AddSourceType adds i to the "source_type" field.
  21029. func (m *MessageRecordsMutation) AddSourceType(i int) {
  21030. if m.addsource_type != nil {
  21031. *m.addsource_type += i
  21032. } else {
  21033. m.addsource_type = &i
  21034. }
  21035. }
  21036. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  21037. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  21038. v := m.addsource_type
  21039. if v == nil {
  21040. return
  21041. }
  21042. return *v, true
  21043. }
  21044. // ResetSourceType resets all changes to the "source_type" field.
  21045. func (m *MessageRecordsMutation) ResetSourceType() {
  21046. m.source_type = nil
  21047. m.addsource_type = nil
  21048. }
  21049. // SetSourceID sets the "source_id" field.
  21050. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  21051. m.sop_stage = &u
  21052. }
  21053. // SourceID returns the value of the "source_id" field in the mutation.
  21054. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  21055. v := m.sop_stage
  21056. if v == nil {
  21057. return
  21058. }
  21059. return *v, true
  21060. }
  21061. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  21062. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21064. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  21065. if !m.op.Is(OpUpdateOne) {
  21066. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  21067. }
  21068. if m.id == nil || m.oldValue == nil {
  21069. return v, errors.New("OldSourceID requires an ID field in the mutation")
  21070. }
  21071. oldValue, err := m.oldValue(ctx)
  21072. if err != nil {
  21073. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  21074. }
  21075. return oldValue.SourceID, nil
  21076. }
  21077. // ClearSourceID clears the value of the "source_id" field.
  21078. func (m *MessageRecordsMutation) ClearSourceID() {
  21079. m.sop_stage = nil
  21080. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21081. }
  21082. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  21083. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  21084. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  21085. return ok
  21086. }
  21087. // ResetSourceID resets all changes to the "source_id" field.
  21088. func (m *MessageRecordsMutation) ResetSourceID() {
  21089. m.sop_stage = nil
  21090. delete(m.clearedFields, messagerecords.FieldSourceID)
  21091. }
  21092. // SetSubSourceID sets the "sub_source_id" field.
  21093. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  21094. m.sop_node = &u
  21095. }
  21096. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  21097. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  21098. v := m.sop_node
  21099. if v == nil {
  21100. return
  21101. }
  21102. return *v, true
  21103. }
  21104. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  21105. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21107. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  21108. if !m.op.Is(OpUpdateOne) {
  21109. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  21110. }
  21111. if m.id == nil || m.oldValue == nil {
  21112. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  21113. }
  21114. oldValue, err := m.oldValue(ctx)
  21115. if err != nil {
  21116. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  21117. }
  21118. return oldValue.SubSourceID, nil
  21119. }
  21120. // ClearSubSourceID clears the value of the "sub_source_id" field.
  21121. func (m *MessageRecordsMutation) ClearSubSourceID() {
  21122. m.sop_node = nil
  21123. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21124. }
  21125. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  21126. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  21127. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  21128. return ok
  21129. }
  21130. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  21131. func (m *MessageRecordsMutation) ResetSubSourceID() {
  21132. m.sop_node = nil
  21133. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  21134. }
  21135. // SetOrganizationID sets the "organization_id" field.
  21136. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  21137. m.organization_id = &u
  21138. m.addorganization_id = nil
  21139. }
  21140. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21141. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  21142. v := m.organization_id
  21143. if v == nil {
  21144. return
  21145. }
  21146. return *v, true
  21147. }
  21148. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  21149. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21151. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21152. if !m.op.Is(OpUpdateOne) {
  21153. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21154. }
  21155. if m.id == nil || m.oldValue == nil {
  21156. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21157. }
  21158. oldValue, err := m.oldValue(ctx)
  21159. if err != nil {
  21160. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21161. }
  21162. return oldValue.OrganizationID, nil
  21163. }
  21164. // AddOrganizationID adds u to the "organization_id" field.
  21165. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  21166. if m.addorganization_id != nil {
  21167. *m.addorganization_id += u
  21168. } else {
  21169. m.addorganization_id = &u
  21170. }
  21171. }
  21172. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21173. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  21174. v := m.addorganization_id
  21175. if v == nil {
  21176. return
  21177. }
  21178. return *v, true
  21179. }
  21180. // ClearOrganizationID clears the value of the "organization_id" field.
  21181. func (m *MessageRecordsMutation) ClearOrganizationID() {
  21182. m.organization_id = nil
  21183. m.addorganization_id = nil
  21184. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  21185. }
  21186. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21187. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  21188. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  21189. return ok
  21190. }
  21191. // ResetOrganizationID resets all changes to the "organization_id" field.
  21192. func (m *MessageRecordsMutation) ResetOrganizationID() {
  21193. m.organization_id = nil
  21194. m.addorganization_id = nil
  21195. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  21196. }
  21197. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21198. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  21199. m.sop_stage = &id
  21200. }
  21201. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21202. func (m *MessageRecordsMutation) ClearSopStage() {
  21203. m.clearedsop_stage = true
  21204. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21205. }
  21206. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21207. func (m *MessageRecordsMutation) SopStageCleared() bool {
  21208. return m.SourceIDCleared() || m.clearedsop_stage
  21209. }
  21210. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21211. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  21212. if m.sop_stage != nil {
  21213. return *m.sop_stage, true
  21214. }
  21215. return
  21216. }
  21217. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21218. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21219. // SopStageID instead. It exists only for internal usage by the builders.
  21220. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  21221. if id := m.sop_stage; id != nil {
  21222. ids = append(ids, *id)
  21223. }
  21224. return
  21225. }
  21226. // ResetSopStage resets all changes to the "sop_stage" edge.
  21227. func (m *MessageRecordsMutation) ResetSopStage() {
  21228. m.sop_stage = nil
  21229. m.clearedsop_stage = false
  21230. }
  21231. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  21232. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  21233. m.sop_node = &id
  21234. }
  21235. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  21236. func (m *MessageRecordsMutation) ClearSopNode() {
  21237. m.clearedsop_node = true
  21238. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21239. }
  21240. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  21241. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  21242. return m.SubSourceIDCleared() || m.clearedsop_node
  21243. }
  21244. // SopNodeID returns the "sop_node" edge ID in the mutation.
  21245. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  21246. if m.sop_node != nil {
  21247. return *m.sop_node, true
  21248. }
  21249. return
  21250. }
  21251. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  21252. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21253. // SopNodeID instead. It exists only for internal usage by the builders.
  21254. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  21255. if id := m.sop_node; id != nil {
  21256. ids = append(ids, *id)
  21257. }
  21258. return
  21259. }
  21260. // ResetSopNode resets all changes to the "sop_node" edge.
  21261. func (m *MessageRecordsMutation) ResetSopNode() {
  21262. m.sop_node = nil
  21263. m.clearedsop_node = false
  21264. }
  21265. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  21266. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  21267. m.message_contact = &id
  21268. }
  21269. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  21270. func (m *MessageRecordsMutation) ClearMessageContact() {
  21271. m.clearedmessage_contact = true
  21272. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  21273. }
  21274. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  21275. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  21276. return m.ContactIDCleared() || m.clearedmessage_contact
  21277. }
  21278. // MessageContactID returns the "message_contact" edge ID in the mutation.
  21279. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  21280. if m.message_contact != nil {
  21281. return *m.message_contact, true
  21282. }
  21283. return
  21284. }
  21285. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  21286. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21287. // MessageContactID instead. It exists only for internal usage by the builders.
  21288. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  21289. if id := m.message_contact; id != nil {
  21290. ids = append(ids, *id)
  21291. }
  21292. return
  21293. }
  21294. // ResetMessageContact resets all changes to the "message_contact" edge.
  21295. func (m *MessageRecordsMutation) ResetMessageContact() {
  21296. m.message_contact = nil
  21297. m.clearedmessage_contact = false
  21298. }
  21299. // Where appends a list predicates to the MessageRecordsMutation builder.
  21300. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  21301. m.predicates = append(m.predicates, ps...)
  21302. }
  21303. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  21304. // users can use type-assertion to append predicates that do not depend on any generated package.
  21305. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  21306. p := make([]predicate.MessageRecords, len(ps))
  21307. for i := range ps {
  21308. p[i] = ps[i]
  21309. }
  21310. m.Where(p...)
  21311. }
  21312. // Op returns the operation name.
  21313. func (m *MessageRecordsMutation) Op() Op {
  21314. return m.op
  21315. }
  21316. // SetOp allows setting the mutation operation.
  21317. func (m *MessageRecordsMutation) SetOp(op Op) {
  21318. m.op = op
  21319. }
  21320. // Type returns the node type of this mutation (MessageRecords).
  21321. func (m *MessageRecordsMutation) Type() string {
  21322. return m.typ
  21323. }
  21324. // Fields returns all fields that were changed during this mutation. Note that in
  21325. // order to get all numeric fields that were incremented/decremented, call
  21326. // AddedFields().
  21327. func (m *MessageRecordsMutation) Fields() []string {
  21328. fields := make([]string, 0, 16)
  21329. if m.created_at != nil {
  21330. fields = append(fields, messagerecords.FieldCreatedAt)
  21331. }
  21332. if m.updated_at != nil {
  21333. fields = append(fields, messagerecords.FieldUpdatedAt)
  21334. }
  21335. if m.status != nil {
  21336. fields = append(fields, messagerecords.FieldStatus)
  21337. }
  21338. if m.bot_wxid != nil {
  21339. fields = append(fields, messagerecords.FieldBotWxid)
  21340. }
  21341. if m.message_contact != nil {
  21342. fields = append(fields, messagerecords.FieldContactID)
  21343. }
  21344. if m.contact_type != nil {
  21345. fields = append(fields, messagerecords.FieldContactType)
  21346. }
  21347. if m.contact_wxid != nil {
  21348. fields = append(fields, messagerecords.FieldContactWxid)
  21349. }
  21350. if m.content_type != nil {
  21351. fields = append(fields, messagerecords.FieldContentType)
  21352. }
  21353. if m.content != nil {
  21354. fields = append(fields, messagerecords.FieldContent)
  21355. }
  21356. if m.meta != nil {
  21357. fields = append(fields, messagerecords.FieldMeta)
  21358. }
  21359. if m.error_detail != nil {
  21360. fields = append(fields, messagerecords.FieldErrorDetail)
  21361. }
  21362. if m.send_time != nil {
  21363. fields = append(fields, messagerecords.FieldSendTime)
  21364. }
  21365. if m.source_type != nil {
  21366. fields = append(fields, messagerecords.FieldSourceType)
  21367. }
  21368. if m.sop_stage != nil {
  21369. fields = append(fields, messagerecords.FieldSourceID)
  21370. }
  21371. if m.sop_node != nil {
  21372. fields = append(fields, messagerecords.FieldSubSourceID)
  21373. }
  21374. if m.organization_id != nil {
  21375. fields = append(fields, messagerecords.FieldOrganizationID)
  21376. }
  21377. return fields
  21378. }
  21379. // Field returns the value of a field with the given name. The second boolean
  21380. // return value indicates that this field was not set, or was not defined in the
  21381. // schema.
  21382. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  21383. switch name {
  21384. case messagerecords.FieldCreatedAt:
  21385. return m.CreatedAt()
  21386. case messagerecords.FieldUpdatedAt:
  21387. return m.UpdatedAt()
  21388. case messagerecords.FieldStatus:
  21389. return m.Status()
  21390. case messagerecords.FieldBotWxid:
  21391. return m.BotWxid()
  21392. case messagerecords.FieldContactID:
  21393. return m.ContactID()
  21394. case messagerecords.FieldContactType:
  21395. return m.ContactType()
  21396. case messagerecords.FieldContactWxid:
  21397. return m.ContactWxid()
  21398. case messagerecords.FieldContentType:
  21399. return m.ContentType()
  21400. case messagerecords.FieldContent:
  21401. return m.Content()
  21402. case messagerecords.FieldMeta:
  21403. return m.Meta()
  21404. case messagerecords.FieldErrorDetail:
  21405. return m.ErrorDetail()
  21406. case messagerecords.FieldSendTime:
  21407. return m.SendTime()
  21408. case messagerecords.FieldSourceType:
  21409. return m.SourceType()
  21410. case messagerecords.FieldSourceID:
  21411. return m.SourceID()
  21412. case messagerecords.FieldSubSourceID:
  21413. return m.SubSourceID()
  21414. case messagerecords.FieldOrganizationID:
  21415. return m.OrganizationID()
  21416. }
  21417. return nil, false
  21418. }
  21419. // OldField returns the old value of the field from the database. An error is
  21420. // returned if the mutation operation is not UpdateOne, or the query to the
  21421. // database failed.
  21422. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21423. switch name {
  21424. case messagerecords.FieldCreatedAt:
  21425. return m.OldCreatedAt(ctx)
  21426. case messagerecords.FieldUpdatedAt:
  21427. return m.OldUpdatedAt(ctx)
  21428. case messagerecords.FieldStatus:
  21429. return m.OldStatus(ctx)
  21430. case messagerecords.FieldBotWxid:
  21431. return m.OldBotWxid(ctx)
  21432. case messagerecords.FieldContactID:
  21433. return m.OldContactID(ctx)
  21434. case messagerecords.FieldContactType:
  21435. return m.OldContactType(ctx)
  21436. case messagerecords.FieldContactWxid:
  21437. return m.OldContactWxid(ctx)
  21438. case messagerecords.FieldContentType:
  21439. return m.OldContentType(ctx)
  21440. case messagerecords.FieldContent:
  21441. return m.OldContent(ctx)
  21442. case messagerecords.FieldMeta:
  21443. return m.OldMeta(ctx)
  21444. case messagerecords.FieldErrorDetail:
  21445. return m.OldErrorDetail(ctx)
  21446. case messagerecords.FieldSendTime:
  21447. return m.OldSendTime(ctx)
  21448. case messagerecords.FieldSourceType:
  21449. return m.OldSourceType(ctx)
  21450. case messagerecords.FieldSourceID:
  21451. return m.OldSourceID(ctx)
  21452. case messagerecords.FieldSubSourceID:
  21453. return m.OldSubSourceID(ctx)
  21454. case messagerecords.FieldOrganizationID:
  21455. return m.OldOrganizationID(ctx)
  21456. }
  21457. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  21458. }
  21459. // SetField sets the value of a field with the given name. It returns an error if
  21460. // the field is not defined in the schema, or if the type mismatched the field
  21461. // type.
  21462. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  21463. switch name {
  21464. case messagerecords.FieldCreatedAt:
  21465. v, ok := value.(time.Time)
  21466. if !ok {
  21467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21468. }
  21469. m.SetCreatedAt(v)
  21470. return nil
  21471. case messagerecords.FieldUpdatedAt:
  21472. v, ok := value.(time.Time)
  21473. if !ok {
  21474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21475. }
  21476. m.SetUpdatedAt(v)
  21477. return nil
  21478. case messagerecords.FieldStatus:
  21479. v, ok := value.(uint8)
  21480. if !ok {
  21481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21482. }
  21483. m.SetStatus(v)
  21484. return nil
  21485. case messagerecords.FieldBotWxid:
  21486. v, ok := value.(string)
  21487. if !ok {
  21488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21489. }
  21490. m.SetBotWxid(v)
  21491. return nil
  21492. case messagerecords.FieldContactID:
  21493. v, ok := value.(uint64)
  21494. if !ok {
  21495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21496. }
  21497. m.SetContactID(v)
  21498. return nil
  21499. case messagerecords.FieldContactType:
  21500. v, ok := value.(int)
  21501. if !ok {
  21502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21503. }
  21504. m.SetContactType(v)
  21505. return nil
  21506. case messagerecords.FieldContactWxid:
  21507. v, ok := value.(string)
  21508. if !ok {
  21509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21510. }
  21511. m.SetContactWxid(v)
  21512. return nil
  21513. case messagerecords.FieldContentType:
  21514. v, ok := value.(int)
  21515. if !ok {
  21516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21517. }
  21518. m.SetContentType(v)
  21519. return nil
  21520. case messagerecords.FieldContent:
  21521. v, ok := value.(string)
  21522. if !ok {
  21523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21524. }
  21525. m.SetContent(v)
  21526. return nil
  21527. case messagerecords.FieldMeta:
  21528. v, ok := value.(custom_types.Meta)
  21529. if !ok {
  21530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21531. }
  21532. m.SetMeta(v)
  21533. return nil
  21534. case messagerecords.FieldErrorDetail:
  21535. v, ok := value.(string)
  21536. if !ok {
  21537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21538. }
  21539. m.SetErrorDetail(v)
  21540. return nil
  21541. case messagerecords.FieldSendTime:
  21542. v, ok := value.(time.Time)
  21543. if !ok {
  21544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21545. }
  21546. m.SetSendTime(v)
  21547. return nil
  21548. case messagerecords.FieldSourceType:
  21549. v, ok := value.(int)
  21550. if !ok {
  21551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21552. }
  21553. m.SetSourceType(v)
  21554. return nil
  21555. case messagerecords.FieldSourceID:
  21556. v, ok := value.(uint64)
  21557. if !ok {
  21558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21559. }
  21560. m.SetSourceID(v)
  21561. return nil
  21562. case messagerecords.FieldSubSourceID:
  21563. v, ok := value.(uint64)
  21564. if !ok {
  21565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21566. }
  21567. m.SetSubSourceID(v)
  21568. return nil
  21569. case messagerecords.FieldOrganizationID:
  21570. v, ok := value.(uint64)
  21571. if !ok {
  21572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21573. }
  21574. m.SetOrganizationID(v)
  21575. return nil
  21576. }
  21577. return fmt.Errorf("unknown MessageRecords field %s", name)
  21578. }
  21579. // AddedFields returns all numeric fields that were incremented/decremented during
  21580. // this mutation.
  21581. func (m *MessageRecordsMutation) AddedFields() []string {
  21582. var fields []string
  21583. if m.addstatus != nil {
  21584. fields = append(fields, messagerecords.FieldStatus)
  21585. }
  21586. if m.addcontact_type != nil {
  21587. fields = append(fields, messagerecords.FieldContactType)
  21588. }
  21589. if m.addcontent_type != nil {
  21590. fields = append(fields, messagerecords.FieldContentType)
  21591. }
  21592. if m.addsource_type != nil {
  21593. fields = append(fields, messagerecords.FieldSourceType)
  21594. }
  21595. if m.addorganization_id != nil {
  21596. fields = append(fields, messagerecords.FieldOrganizationID)
  21597. }
  21598. return fields
  21599. }
  21600. // AddedField returns the numeric value that was incremented/decremented on a field
  21601. // with the given name. The second boolean return value indicates that this field
  21602. // was not set, or was not defined in the schema.
  21603. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  21604. switch name {
  21605. case messagerecords.FieldStatus:
  21606. return m.AddedStatus()
  21607. case messagerecords.FieldContactType:
  21608. return m.AddedContactType()
  21609. case messagerecords.FieldContentType:
  21610. return m.AddedContentType()
  21611. case messagerecords.FieldSourceType:
  21612. return m.AddedSourceType()
  21613. case messagerecords.FieldOrganizationID:
  21614. return m.AddedOrganizationID()
  21615. }
  21616. return nil, false
  21617. }
  21618. // AddField adds the value to the field with the given name. It returns an error if
  21619. // the field is not defined in the schema, or if the type mismatched the field
  21620. // type.
  21621. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  21622. switch name {
  21623. case messagerecords.FieldStatus:
  21624. v, ok := value.(int8)
  21625. if !ok {
  21626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21627. }
  21628. m.AddStatus(v)
  21629. return nil
  21630. case messagerecords.FieldContactType:
  21631. v, ok := value.(int)
  21632. if !ok {
  21633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21634. }
  21635. m.AddContactType(v)
  21636. return nil
  21637. case messagerecords.FieldContentType:
  21638. v, ok := value.(int)
  21639. if !ok {
  21640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21641. }
  21642. m.AddContentType(v)
  21643. return nil
  21644. case messagerecords.FieldSourceType:
  21645. v, ok := value.(int)
  21646. if !ok {
  21647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21648. }
  21649. m.AddSourceType(v)
  21650. return nil
  21651. case messagerecords.FieldOrganizationID:
  21652. v, ok := value.(int64)
  21653. if !ok {
  21654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21655. }
  21656. m.AddOrganizationID(v)
  21657. return nil
  21658. }
  21659. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  21660. }
  21661. // ClearedFields returns all nullable fields that were cleared during this
  21662. // mutation.
  21663. func (m *MessageRecordsMutation) ClearedFields() []string {
  21664. var fields []string
  21665. if m.FieldCleared(messagerecords.FieldStatus) {
  21666. fields = append(fields, messagerecords.FieldStatus)
  21667. }
  21668. if m.FieldCleared(messagerecords.FieldContactID) {
  21669. fields = append(fields, messagerecords.FieldContactID)
  21670. }
  21671. if m.FieldCleared(messagerecords.FieldMeta) {
  21672. fields = append(fields, messagerecords.FieldMeta)
  21673. }
  21674. if m.FieldCleared(messagerecords.FieldSendTime) {
  21675. fields = append(fields, messagerecords.FieldSendTime)
  21676. }
  21677. if m.FieldCleared(messagerecords.FieldSourceID) {
  21678. fields = append(fields, messagerecords.FieldSourceID)
  21679. }
  21680. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  21681. fields = append(fields, messagerecords.FieldSubSourceID)
  21682. }
  21683. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  21684. fields = append(fields, messagerecords.FieldOrganizationID)
  21685. }
  21686. return fields
  21687. }
  21688. // FieldCleared returns a boolean indicating if a field with the given name was
  21689. // cleared in this mutation.
  21690. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  21691. _, ok := m.clearedFields[name]
  21692. return ok
  21693. }
  21694. // ClearField clears the value of the field with the given name. It returns an
  21695. // error if the field is not defined in the schema.
  21696. func (m *MessageRecordsMutation) ClearField(name string) error {
  21697. switch name {
  21698. case messagerecords.FieldStatus:
  21699. m.ClearStatus()
  21700. return nil
  21701. case messagerecords.FieldContactID:
  21702. m.ClearContactID()
  21703. return nil
  21704. case messagerecords.FieldMeta:
  21705. m.ClearMeta()
  21706. return nil
  21707. case messagerecords.FieldSendTime:
  21708. m.ClearSendTime()
  21709. return nil
  21710. case messagerecords.FieldSourceID:
  21711. m.ClearSourceID()
  21712. return nil
  21713. case messagerecords.FieldSubSourceID:
  21714. m.ClearSubSourceID()
  21715. return nil
  21716. case messagerecords.FieldOrganizationID:
  21717. m.ClearOrganizationID()
  21718. return nil
  21719. }
  21720. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  21721. }
  21722. // ResetField resets all changes in the mutation for the field with the given name.
  21723. // It returns an error if the field is not defined in the schema.
  21724. func (m *MessageRecordsMutation) ResetField(name string) error {
  21725. switch name {
  21726. case messagerecords.FieldCreatedAt:
  21727. m.ResetCreatedAt()
  21728. return nil
  21729. case messagerecords.FieldUpdatedAt:
  21730. m.ResetUpdatedAt()
  21731. return nil
  21732. case messagerecords.FieldStatus:
  21733. m.ResetStatus()
  21734. return nil
  21735. case messagerecords.FieldBotWxid:
  21736. m.ResetBotWxid()
  21737. return nil
  21738. case messagerecords.FieldContactID:
  21739. m.ResetContactID()
  21740. return nil
  21741. case messagerecords.FieldContactType:
  21742. m.ResetContactType()
  21743. return nil
  21744. case messagerecords.FieldContactWxid:
  21745. m.ResetContactWxid()
  21746. return nil
  21747. case messagerecords.FieldContentType:
  21748. m.ResetContentType()
  21749. return nil
  21750. case messagerecords.FieldContent:
  21751. m.ResetContent()
  21752. return nil
  21753. case messagerecords.FieldMeta:
  21754. m.ResetMeta()
  21755. return nil
  21756. case messagerecords.FieldErrorDetail:
  21757. m.ResetErrorDetail()
  21758. return nil
  21759. case messagerecords.FieldSendTime:
  21760. m.ResetSendTime()
  21761. return nil
  21762. case messagerecords.FieldSourceType:
  21763. m.ResetSourceType()
  21764. return nil
  21765. case messagerecords.FieldSourceID:
  21766. m.ResetSourceID()
  21767. return nil
  21768. case messagerecords.FieldSubSourceID:
  21769. m.ResetSubSourceID()
  21770. return nil
  21771. case messagerecords.FieldOrganizationID:
  21772. m.ResetOrganizationID()
  21773. return nil
  21774. }
  21775. return fmt.Errorf("unknown MessageRecords field %s", name)
  21776. }
  21777. // AddedEdges returns all edge names that were set/added in this mutation.
  21778. func (m *MessageRecordsMutation) AddedEdges() []string {
  21779. edges := make([]string, 0, 3)
  21780. if m.sop_stage != nil {
  21781. edges = append(edges, messagerecords.EdgeSopStage)
  21782. }
  21783. if m.sop_node != nil {
  21784. edges = append(edges, messagerecords.EdgeSopNode)
  21785. }
  21786. if m.message_contact != nil {
  21787. edges = append(edges, messagerecords.EdgeMessageContact)
  21788. }
  21789. return edges
  21790. }
  21791. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21792. // name in this mutation.
  21793. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  21794. switch name {
  21795. case messagerecords.EdgeSopStage:
  21796. if id := m.sop_stage; id != nil {
  21797. return []ent.Value{*id}
  21798. }
  21799. case messagerecords.EdgeSopNode:
  21800. if id := m.sop_node; id != nil {
  21801. return []ent.Value{*id}
  21802. }
  21803. case messagerecords.EdgeMessageContact:
  21804. if id := m.message_contact; id != nil {
  21805. return []ent.Value{*id}
  21806. }
  21807. }
  21808. return nil
  21809. }
  21810. // RemovedEdges returns all edge names that were removed in this mutation.
  21811. func (m *MessageRecordsMutation) RemovedEdges() []string {
  21812. edges := make([]string, 0, 3)
  21813. return edges
  21814. }
  21815. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21816. // the given name in this mutation.
  21817. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  21818. return nil
  21819. }
  21820. // ClearedEdges returns all edge names that were cleared in this mutation.
  21821. func (m *MessageRecordsMutation) ClearedEdges() []string {
  21822. edges := make([]string, 0, 3)
  21823. if m.clearedsop_stage {
  21824. edges = append(edges, messagerecords.EdgeSopStage)
  21825. }
  21826. if m.clearedsop_node {
  21827. edges = append(edges, messagerecords.EdgeSopNode)
  21828. }
  21829. if m.clearedmessage_contact {
  21830. edges = append(edges, messagerecords.EdgeMessageContact)
  21831. }
  21832. return edges
  21833. }
  21834. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21835. // was cleared in this mutation.
  21836. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  21837. switch name {
  21838. case messagerecords.EdgeSopStage:
  21839. return m.clearedsop_stage
  21840. case messagerecords.EdgeSopNode:
  21841. return m.clearedsop_node
  21842. case messagerecords.EdgeMessageContact:
  21843. return m.clearedmessage_contact
  21844. }
  21845. return false
  21846. }
  21847. // ClearEdge clears the value of the edge with the given name. It returns an error
  21848. // if that edge is not defined in the schema.
  21849. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  21850. switch name {
  21851. case messagerecords.EdgeSopStage:
  21852. m.ClearSopStage()
  21853. return nil
  21854. case messagerecords.EdgeSopNode:
  21855. m.ClearSopNode()
  21856. return nil
  21857. case messagerecords.EdgeMessageContact:
  21858. m.ClearMessageContact()
  21859. return nil
  21860. }
  21861. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  21862. }
  21863. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21864. // It returns an error if the edge is not defined in the schema.
  21865. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  21866. switch name {
  21867. case messagerecords.EdgeSopStage:
  21868. m.ResetSopStage()
  21869. return nil
  21870. case messagerecords.EdgeSopNode:
  21871. m.ResetSopNode()
  21872. return nil
  21873. case messagerecords.EdgeMessageContact:
  21874. m.ResetMessageContact()
  21875. return nil
  21876. }
  21877. return fmt.Errorf("unknown MessageRecords edge %s", name)
  21878. }
  21879. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  21880. type MsgMutation struct {
  21881. config
  21882. op Op
  21883. typ string
  21884. id *uint64
  21885. created_at *time.Time
  21886. updated_at *time.Time
  21887. deleted_at *time.Time
  21888. status *uint8
  21889. addstatus *int8
  21890. fromwxid *string
  21891. toid *string
  21892. msgtype *int32
  21893. addmsgtype *int32
  21894. msg *string
  21895. batch_no *string
  21896. cc *string
  21897. phone *string
  21898. clearedFields map[string]struct{}
  21899. done bool
  21900. oldValue func(context.Context) (*Msg, error)
  21901. predicates []predicate.Msg
  21902. }
  21903. var _ ent.Mutation = (*MsgMutation)(nil)
  21904. // msgOption allows management of the mutation configuration using functional options.
  21905. type msgOption func(*MsgMutation)
  21906. // newMsgMutation creates new mutation for the Msg entity.
  21907. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  21908. m := &MsgMutation{
  21909. config: c,
  21910. op: op,
  21911. typ: TypeMsg,
  21912. clearedFields: make(map[string]struct{}),
  21913. }
  21914. for _, opt := range opts {
  21915. opt(m)
  21916. }
  21917. return m
  21918. }
  21919. // withMsgID sets the ID field of the mutation.
  21920. func withMsgID(id uint64) msgOption {
  21921. return func(m *MsgMutation) {
  21922. var (
  21923. err error
  21924. once sync.Once
  21925. value *Msg
  21926. )
  21927. m.oldValue = func(ctx context.Context) (*Msg, error) {
  21928. once.Do(func() {
  21929. if m.done {
  21930. err = errors.New("querying old values post mutation is not allowed")
  21931. } else {
  21932. value, err = m.Client().Msg.Get(ctx, id)
  21933. }
  21934. })
  21935. return value, err
  21936. }
  21937. m.id = &id
  21938. }
  21939. }
  21940. // withMsg sets the old Msg of the mutation.
  21941. func withMsg(node *Msg) msgOption {
  21942. return func(m *MsgMutation) {
  21943. m.oldValue = func(context.Context) (*Msg, error) {
  21944. return node, nil
  21945. }
  21946. m.id = &node.ID
  21947. }
  21948. }
  21949. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21950. // executed in a transaction (ent.Tx), a transactional client is returned.
  21951. func (m MsgMutation) Client() *Client {
  21952. client := &Client{config: m.config}
  21953. client.init()
  21954. return client
  21955. }
  21956. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21957. // it returns an error otherwise.
  21958. func (m MsgMutation) Tx() (*Tx, error) {
  21959. if _, ok := m.driver.(*txDriver); !ok {
  21960. return nil, errors.New("ent: mutation is not running in a transaction")
  21961. }
  21962. tx := &Tx{config: m.config}
  21963. tx.init()
  21964. return tx, nil
  21965. }
  21966. // SetID sets the value of the id field. Note that this
  21967. // operation is only accepted on creation of Msg entities.
  21968. func (m *MsgMutation) SetID(id uint64) {
  21969. m.id = &id
  21970. }
  21971. // ID returns the ID value in the mutation. Note that the ID is only available
  21972. // if it was provided to the builder or after it was returned from the database.
  21973. func (m *MsgMutation) ID() (id uint64, exists bool) {
  21974. if m.id == nil {
  21975. return
  21976. }
  21977. return *m.id, true
  21978. }
  21979. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21980. // That means, if the mutation is applied within a transaction with an isolation level such
  21981. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21982. // or updated by the mutation.
  21983. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  21984. switch {
  21985. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21986. id, exists := m.ID()
  21987. if exists {
  21988. return []uint64{id}, nil
  21989. }
  21990. fallthrough
  21991. case m.op.Is(OpUpdate | OpDelete):
  21992. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  21993. default:
  21994. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21995. }
  21996. }
  21997. // SetCreatedAt sets the "created_at" field.
  21998. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  21999. m.created_at = &t
  22000. }
  22001. // CreatedAt returns the value of the "created_at" field in the mutation.
  22002. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  22003. v := m.created_at
  22004. if v == nil {
  22005. return
  22006. }
  22007. return *v, true
  22008. }
  22009. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  22010. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22012. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22013. if !m.op.Is(OpUpdateOne) {
  22014. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22015. }
  22016. if m.id == nil || m.oldValue == nil {
  22017. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22018. }
  22019. oldValue, err := m.oldValue(ctx)
  22020. if err != nil {
  22021. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22022. }
  22023. return oldValue.CreatedAt, nil
  22024. }
  22025. // ResetCreatedAt resets all changes to the "created_at" field.
  22026. func (m *MsgMutation) ResetCreatedAt() {
  22027. m.created_at = nil
  22028. }
  22029. // SetUpdatedAt sets the "updated_at" field.
  22030. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  22031. m.updated_at = &t
  22032. }
  22033. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22034. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  22035. v := m.updated_at
  22036. if v == nil {
  22037. return
  22038. }
  22039. return *v, true
  22040. }
  22041. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  22042. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22044. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22045. if !m.op.Is(OpUpdateOne) {
  22046. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22047. }
  22048. if m.id == nil || m.oldValue == nil {
  22049. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22050. }
  22051. oldValue, err := m.oldValue(ctx)
  22052. if err != nil {
  22053. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22054. }
  22055. return oldValue.UpdatedAt, nil
  22056. }
  22057. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22058. func (m *MsgMutation) ResetUpdatedAt() {
  22059. m.updated_at = nil
  22060. }
  22061. // SetDeletedAt sets the "deleted_at" field.
  22062. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  22063. m.deleted_at = &t
  22064. }
  22065. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22066. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  22067. v := m.deleted_at
  22068. if v == nil {
  22069. return
  22070. }
  22071. return *v, true
  22072. }
  22073. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  22074. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22076. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22077. if !m.op.Is(OpUpdateOne) {
  22078. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22079. }
  22080. if m.id == nil || m.oldValue == nil {
  22081. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22082. }
  22083. oldValue, err := m.oldValue(ctx)
  22084. if err != nil {
  22085. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22086. }
  22087. return oldValue.DeletedAt, nil
  22088. }
  22089. // ClearDeletedAt clears the value of the "deleted_at" field.
  22090. func (m *MsgMutation) ClearDeletedAt() {
  22091. m.deleted_at = nil
  22092. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  22093. }
  22094. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22095. func (m *MsgMutation) DeletedAtCleared() bool {
  22096. _, ok := m.clearedFields[msg.FieldDeletedAt]
  22097. return ok
  22098. }
  22099. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22100. func (m *MsgMutation) ResetDeletedAt() {
  22101. m.deleted_at = nil
  22102. delete(m.clearedFields, msg.FieldDeletedAt)
  22103. }
  22104. // SetStatus sets the "status" field.
  22105. func (m *MsgMutation) SetStatus(u uint8) {
  22106. m.status = &u
  22107. m.addstatus = nil
  22108. }
  22109. // Status returns the value of the "status" field in the mutation.
  22110. func (m *MsgMutation) Status() (r uint8, exists bool) {
  22111. v := m.status
  22112. if v == nil {
  22113. return
  22114. }
  22115. return *v, true
  22116. }
  22117. // OldStatus returns the old "status" field's value of the Msg entity.
  22118. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22120. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22121. if !m.op.Is(OpUpdateOne) {
  22122. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22123. }
  22124. if m.id == nil || m.oldValue == nil {
  22125. return v, errors.New("OldStatus requires an ID field in the mutation")
  22126. }
  22127. oldValue, err := m.oldValue(ctx)
  22128. if err != nil {
  22129. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22130. }
  22131. return oldValue.Status, nil
  22132. }
  22133. // AddStatus adds u to the "status" field.
  22134. func (m *MsgMutation) AddStatus(u int8) {
  22135. if m.addstatus != nil {
  22136. *m.addstatus += u
  22137. } else {
  22138. m.addstatus = &u
  22139. }
  22140. }
  22141. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22142. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  22143. v := m.addstatus
  22144. if v == nil {
  22145. return
  22146. }
  22147. return *v, true
  22148. }
  22149. // ClearStatus clears the value of the "status" field.
  22150. func (m *MsgMutation) ClearStatus() {
  22151. m.status = nil
  22152. m.addstatus = nil
  22153. m.clearedFields[msg.FieldStatus] = struct{}{}
  22154. }
  22155. // StatusCleared returns if the "status" field was cleared in this mutation.
  22156. func (m *MsgMutation) StatusCleared() bool {
  22157. _, ok := m.clearedFields[msg.FieldStatus]
  22158. return ok
  22159. }
  22160. // ResetStatus resets all changes to the "status" field.
  22161. func (m *MsgMutation) ResetStatus() {
  22162. m.status = nil
  22163. m.addstatus = nil
  22164. delete(m.clearedFields, msg.FieldStatus)
  22165. }
  22166. // SetFromwxid sets the "fromwxid" field.
  22167. func (m *MsgMutation) SetFromwxid(s string) {
  22168. m.fromwxid = &s
  22169. }
  22170. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  22171. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  22172. v := m.fromwxid
  22173. if v == nil {
  22174. return
  22175. }
  22176. return *v, true
  22177. }
  22178. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  22179. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22181. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  22182. if !m.op.Is(OpUpdateOne) {
  22183. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  22184. }
  22185. if m.id == nil || m.oldValue == nil {
  22186. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  22187. }
  22188. oldValue, err := m.oldValue(ctx)
  22189. if err != nil {
  22190. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  22191. }
  22192. return oldValue.Fromwxid, nil
  22193. }
  22194. // ClearFromwxid clears the value of the "fromwxid" field.
  22195. func (m *MsgMutation) ClearFromwxid() {
  22196. m.fromwxid = nil
  22197. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  22198. }
  22199. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  22200. func (m *MsgMutation) FromwxidCleared() bool {
  22201. _, ok := m.clearedFields[msg.FieldFromwxid]
  22202. return ok
  22203. }
  22204. // ResetFromwxid resets all changes to the "fromwxid" field.
  22205. func (m *MsgMutation) ResetFromwxid() {
  22206. m.fromwxid = nil
  22207. delete(m.clearedFields, msg.FieldFromwxid)
  22208. }
  22209. // SetToid sets the "toid" field.
  22210. func (m *MsgMutation) SetToid(s string) {
  22211. m.toid = &s
  22212. }
  22213. // Toid returns the value of the "toid" field in the mutation.
  22214. func (m *MsgMutation) Toid() (r string, exists bool) {
  22215. v := m.toid
  22216. if v == nil {
  22217. return
  22218. }
  22219. return *v, true
  22220. }
  22221. // OldToid returns the old "toid" field's value of the Msg entity.
  22222. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22224. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  22225. if !m.op.Is(OpUpdateOne) {
  22226. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  22227. }
  22228. if m.id == nil || m.oldValue == nil {
  22229. return v, errors.New("OldToid requires an ID field in the mutation")
  22230. }
  22231. oldValue, err := m.oldValue(ctx)
  22232. if err != nil {
  22233. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  22234. }
  22235. return oldValue.Toid, nil
  22236. }
  22237. // ClearToid clears the value of the "toid" field.
  22238. func (m *MsgMutation) ClearToid() {
  22239. m.toid = nil
  22240. m.clearedFields[msg.FieldToid] = struct{}{}
  22241. }
  22242. // ToidCleared returns if the "toid" field was cleared in this mutation.
  22243. func (m *MsgMutation) ToidCleared() bool {
  22244. _, ok := m.clearedFields[msg.FieldToid]
  22245. return ok
  22246. }
  22247. // ResetToid resets all changes to the "toid" field.
  22248. func (m *MsgMutation) ResetToid() {
  22249. m.toid = nil
  22250. delete(m.clearedFields, msg.FieldToid)
  22251. }
  22252. // SetMsgtype sets the "msgtype" field.
  22253. func (m *MsgMutation) SetMsgtype(i int32) {
  22254. m.msgtype = &i
  22255. m.addmsgtype = nil
  22256. }
  22257. // Msgtype returns the value of the "msgtype" field in the mutation.
  22258. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  22259. v := m.msgtype
  22260. if v == nil {
  22261. return
  22262. }
  22263. return *v, true
  22264. }
  22265. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  22266. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22268. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  22269. if !m.op.Is(OpUpdateOne) {
  22270. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  22271. }
  22272. if m.id == nil || m.oldValue == nil {
  22273. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  22274. }
  22275. oldValue, err := m.oldValue(ctx)
  22276. if err != nil {
  22277. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  22278. }
  22279. return oldValue.Msgtype, nil
  22280. }
  22281. // AddMsgtype adds i to the "msgtype" field.
  22282. func (m *MsgMutation) AddMsgtype(i int32) {
  22283. if m.addmsgtype != nil {
  22284. *m.addmsgtype += i
  22285. } else {
  22286. m.addmsgtype = &i
  22287. }
  22288. }
  22289. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  22290. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  22291. v := m.addmsgtype
  22292. if v == nil {
  22293. return
  22294. }
  22295. return *v, true
  22296. }
  22297. // ClearMsgtype clears the value of the "msgtype" field.
  22298. func (m *MsgMutation) ClearMsgtype() {
  22299. m.msgtype = nil
  22300. m.addmsgtype = nil
  22301. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  22302. }
  22303. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  22304. func (m *MsgMutation) MsgtypeCleared() bool {
  22305. _, ok := m.clearedFields[msg.FieldMsgtype]
  22306. return ok
  22307. }
  22308. // ResetMsgtype resets all changes to the "msgtype" field.
  22309. func (m *MsgMutation) ResetMsgtype() {
  22310. m.msgtype = nil
  22311. m.addmsgtype = nil
  22312. delete(m.clearedFields, msg.FieldMsgtype)
  22313. }
  22314. // SetMsg sets the "msg" field.
  22315. func (m *MsgMutation) SetMsg(s string) {
  22316. m.msg = &s
  22317. }
  22318. // Msg returns the value of the "msg" field in the mutation.
  22319. func (m *MsgMutation) Msg() (r string, exists bool) {
  22320. v := m.msg
  22321. if v == nil {
  22322. return
  22323. }
  22324. return *v, true
  22325. }
  22326. // OldMsg returns the old "msg" field's value of the Msg entity.
  22327. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22329. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  22330. if !m.op.Is(OpUpdateOne) {
  22331. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  22332. }
  22333. if m.id == nil || m.oldValue == nil {
  22334. return v, errors.New("OldMsg requires an ID field in the mutation")
  22335. }
  22336. oldValue, err := m.oldValue(ctx)
  22337. if err != nil {
  22338. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  22339. }
  22340. return oldValue.Msg, nil
  22341. }
  22342. // ClearMsg clears the value of the "msg" field.
  22343. func (m *MsgMutation) ClearMsg() {
  22344. m.msg = nil
  22345. m.clearedFields[msg.FieldMsg] = struct{}{}
  22346. }
  22347. // MsgCleared returns if the "msg" field was cleared in this mutation.
  22348. func (m *MsgMutation) MsgCleared() bool {
  22349. _, ok := m.clearedFields[msg.FieldMsg]
  22350. return ok
  22351. }
  22352. // ResetMsg resets all changes to the "msg" field.
  22353. func (m *MsgMutation) ResetMsg() {
  22354. m.msg = nil
  22355. delete(m.clearedFields, msg.FieldMsg)
  22356. }
  22357. // SetBatchNo sets the "batch_no" field.
  22358. func (m *MsgMutation) SetBatchNo(s string) {
  22359. m.batch_no = &s
  22360. }
  22361. // BatchNo returns the value of the "batch_no" field in the mutation.
  22362. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  22363. v := m.batch_no
  22364. if v == nil {
  22365. return
  22366. }
  22367. return *v, true
  22368. }
  22369. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  22370. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22372. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  22373. if !m.op.Is(OpUpdateOne) {
  22374. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  22375. }
  22376. if m.id == nil || m.oldValue == nil {
  22377. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  22378. }
  22379. oldValue, err := m.oldValue(ctx)
  22380. if err != nil {
  22381. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  22382. }
  22383. return oldValue.BatchNo, nil
  22384. }
  22385. // ClearBatchNo clears the value of the "batch_no" field.
  22386. func (m *MsgMutation) ClearBatchNo() {
  22387. m.batch_no = nil
  22388. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  22389. }
  22390. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  22391. func (m *MsgMutation) BatchNoCleared() bool {
  22392. _, ok := m.clearedFields[msg.FieldBatchNo]
  22393. return ok
  22394. }
  22395. // ResetBatchNo resets all changes to the "batch_no" field.
  22396. func (m *MsgMutation) ResetBatchNo() {
  22397. m.batch_no = nil
  22398. delete(m.clearedFields, msg.FieldBatchNo)
  22399. }
  22400. // SetCc sets the "cc" field.
  22401. func (m *MsgMutation) SetCc(s string) {
  22402. m.cc = &s
  22403. }
  22404. // Cc returns the value of the "cc" field in the mutation.
  22405. func (m *MsgMutation) Cc() (r string, exists bool) {
  22406. v := m.cc
  22407. if v == nil {
  22408. return
  22409. }
  22410. return *v, true
  22411. }
  22412. // OldCc returns the old "cc" field's value of the Msg entity.
  22413. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22415. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  22416. if !m.op.Is(OpUpdateOne) {
  22417. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  22418. }
  22419. if m.id == nil || m.oldValue == nil {
  22420. return v, errors.New("OldCc requires an ID field in the mutation")
  22421. }
  22422. oldValue, err := m.oldValue(ctx)
  22423. if err != nil {
  22424. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  22425. }
  22426. return oldValue.Cc, nil
  22427. }
  22428. // ResetCc resets all changes to the "cc" field.
  22429. func (m *MsgMutation) ResetCc() {
  22430. m.cc = nil
  22431. }
  22432. // SetPhone sets the "phone" field.
  22433. func (m *MsgMutation) SetPhone(s string) {
  22434. m.phone = &s
  22435. }
  22436. // Phone returns the value of the "phone" field in the mutation.
  22437. func (m *MsgMutation) Phone() (r string, exists bool) {
  22438. v := m.phone
  22439. if v == nil {
  22440. return
  22441. }
  22442. return *v, true
  22443. }
  22444. // OldPhone returns the old "phone" field's value of the Msg entity.
  22445. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22447. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  22448. if !m.op.Is(OpUpdateOne) {
  22449. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  22450. }
  22451. if m.id == nil || m.oldValue == nil {
  22452. return v, errors.New("OldPhone requires an ID field in the mutation")
  22453. }
  22454. oldValue, err := m.oldValue(ctx)
  22455. if err != nil {
  22456. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  22457. }
  22458. return oldValue.Phone, nil
  22459. }
  22460. // ResetPhone resets all changes to the "phone" field.
  22461. func (m *MsgMutation) ResetPhone() {
  22462. m.phone = nil
  22463. }
  22464. // Where appends a list predicates to the MsgMutation builder.
  22465. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  22466. m.predicates = append(m.predicates, ps...)
  22467. }
  22468. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  22469. // users can use type-assertion to append predicates that do not depend on any generated package.
  22470. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  22471. p := make([]predicate.Msg, len(ps))
  22472. for i := range ps {
  22473. p[i] = ps[i]
  22474. }
  22475. m.Where(p...)
  22476. }
  22477. // Op returns the operation name.
  22478. func (m *MsgMutation) Op() Op {
  22479. return m.op
  22480. }
  22481. // SetOp allows setting the mutation operation.
  22482. func (m *MsgMutation) SetOp(op Op) {
  22483. m.op = op
  22484. }
  22485. // Type returns the node type of this mutation (Msg).
  22486. func (m *MsgMutation) Type() string {
  22487. return m.typ
  22488. }
  22489. // Fields returns all fields that were changed during this mutation. Note that in
  22490. // order to get all numeric fields that were incremented/decremented, call
  22491. // AddedFields().
  22492. func (m *MsgMutation) Fields() []string {
  22493. fields := make([]string, 0, 11)
  22494. if m.created_at != nil {
  22495. fields = append(fields, msg.FieldCreatedAt)
  22496. }
  22497. if m.updated_at != nil {
  22498. fields = append(fields, msg.FieldUpdatedAt)
  22499. }
  22500. if m.deleted_at != nil {
  22501. fields = append(fields, msg.FieldDeletedAt)
  22502. }
  22503. if m.status != nil {
  22504. fields = append(fields, msg.FieldStatus)
  22505. }
  22506. if m.fromwxid != nil {
  22507. fields = append(fields, msg.FieldFromwxid)
  22508. }
  22509. if m.toid != nil {
  22510. fields = append(fields, msg.FieldToid)
  22511. }
  22512. if m.msgtype != nil {
  22513. fields = append(fields, msg.FieldMsgtype)
  22514. }
  22515. if m.msg != nil {
  22516. fields = append(fields, msg.FieldMsg)
  22517. }
  22518. if m.batch_no != nil {
  22519. fields = append(fields, msg.FieldBatchNo)
  22520. }
  22521. if m.cc != nil {
  22522. fields = append(fields, msg.FieldCc)
  22523. }
  22524. if m.phone != nil {
  22525. fields = append(fields, msg.FieldPhone)
  22526. }
  22527. return fields
  22528. }
  22529. // Field returns the value of a field with the given name. The second boolean
  22530. // return value indicates that this field was not set, or was not defined in the
  22531. // schema.
  22532. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  22533. switch name {
  22534. case msg.FieldCreatedAt:
  22535. return m.CreatedAt()
  22536. case msg.FieldUpdatedAt:
  22537. return m.UpdatedAt()
  22538. case msg.FieldDeletedAt:
  22539. return m.DeletedAt()
  22540. case msg.FieldStatus:
  22541. return m.Status()
  22542. case msg.FieldFromwxid:
  22543. return m.Fromwxid()
  22544. case msg.FieldToid:
  22545. return m.Toid()
  22546. case msg.FieldMsgtype:
  22547. return m.Msgtype()
  22548. case msg.FieldMsg:
  22549. return m.Msg()
  22550. case msg.FieldBatchNo:
  22551. return m.BatchNo()
  22552. case msg.FieldCc:
  22553. return m.Cc()
  22554. case msg.FieldPhone:
  22555. return m.Phone()
  22556. }
  22557. return nil, false
  22558. }
  22559. // OldField returns the old value of the field from the database. An error is
  22560. // returned if the mutation operation is not UpdateOne, or the query to the
  22561. // database failed.
  22562. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22563. switch name {
  22564. case msg.FieldCreatedAt:
  22565. return m.OldCreatedAt(ctx)
  22566. case msg.FieldUpdatedAt:
  22567. return m.OldUpdatedAt(ctx)
  22568. case msg.FieldDeletedAt:
  22569. return m.OldDeletedAt(ctx)
  22570. case msg.FieldStatus:
  22571. return m.OldStatus(ctx)
  22572. case msg.FieldFromwxid:
  22573. return m.OldFromwxid(ctx)
  22574. case msg.FieldToid:
  22575. return m.OldToid(ctx)
  22576. case msg.FieldMsgtype:
  22577. return m.OldMsgtype(ctx)
  22578. case msg.FieldMsg:
  22579. return m.OldMsg(ctx)
  22580. case msg.FieldBatchNo:
  22581. return m.OldBatchNo(ctx)
  22582. case msg.FieldCc:
  22583. return m.OldCc(ctx)
  22584. case msg.FieldPhone:
  22585. return m.OldPhone(ctx)
  22586. }
  22587. return nil, fmt.Errorf("unknown Msg field %s", name)
  22588. }
  22589. // SetField sets the value of a field with the given name. It returns an error if
  22590. // the field is not defined in the schema, or if the type mismatched the field
  22591. // type.
  22592. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  22593. switch name {
  22594. case msg.FieldCreatedAt:
  22595. v, ok := value.(time.Time)
  22596. if !ok {
  22597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22598. }
  22599. m.SetCreatedAt(v)
  22600. return nil
  22601. case msg.FieldUpdatedAt:
  22602. v, ok := value.(time.Time)
  22603. if !ok {
  22604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22605. }
  22606. m.SetUpdatedAt(v)
  22607. return nil
  22608. case msg.FieldDeletedAt:
  22609. v, ok := value.(time.Time)
  22610. if !ok {
  22611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22612. }
  22613. m.SetDeletedAt(v)
  22614. return nil
  22615. case msg.FieldStatus:
  22616. v, ok := value.(uint8)
  22617. if !ok {
  22618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22619. }
  22620. m.SetStatus(v)
  22621. return nil
  22622. case msg.FieldFromwxid:
  22623. v, ok := value.(string)
  22624. if !ok {
  22625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22626. }
  22627. m.SetFromwxid(v)
  22628. return nil
  22629. case msg.FieldToid:
  22630. v, ok := value.(string)
  22631. if !ok {
  22632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22633. }
  22634. m.SetToid(v)
  22635. return nil
  22636. case msg.FieldMsgtype:
  22637. v, ok := value.(int32)
  22638. if !ok {
  22639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22640. }
  22641. m.SetMsgtype(v)
  22642. return nil
  22643. case msg.FieldMsg:
  22644. v, ok := value.(string)
  22645. if !ok {
  22646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22647. }
  22648. m.SetMsg(v)
  22649. return nil
  22650. case msg.FieldBatchNo:
  22651. v, ok := value.(string)
  22652. if !ok {
  22653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22654. }
  22655. m.SetBatchNo(v)
  22656. return nil
  22657. case msg.FieldCc:
  22658. v, ok := value.(string)
  22659. if !ok {
  22660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22661. }
  22662. m.SetCc(v)
  22663. return nil
  22664. case msg.FieldPhone:
  22665. v, ok := value.(string)
  22666. if !ok {
  22667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22668. }
  22669. m.SetPhone(v)
  22670. return nil
  22671. }
  22672. return fmt.Errorf("unknown Msg field %s", name)
  22673. }
  22674. // AddedFields returns all numeric fields that were incremented/decremented during
  22675. // this mutation.
  22676. func (m *MsgMutation) AddedFields() []string {
  22677. var fields []string
  22678. if m.addstatus != nil {
  22679. fields = append(fields, msg.FieldStatus)
  22680. }
  22681. if m.addmsgtype != nil {
  22682. fields = append(fields, msg.FieldMsgtype)
  22683. }
  22684. return fields
  22685. }
  22686. // AddedField returns the numeric value that was incremented/decremented on a field
  22687. // with the given name. The second boolean return value indicates that this field
  22688. // was not set, or was not defined in the schema.
  22689. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  22690. switch name {
  22691. case msg.FieldStatus:
  22692. return m.AddedStatus()
  22693. case msg.FieldMsgtype:
  22694. return m.AddedMsgtype()
  22695. }
  22696. return nil, false
  22697. }
  22698. // AddField adds the value to the field with the given name. It returns an error if
  22699. // the field is not defined in the schema, or if the type mismatched the field
  22700. // type.
  22701. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  22702. switch name {
  22703. case msg.FieldStatus:
  22704. v, ok := value.(int8)
  22705. if !ok {
  22706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22707. }
  22708. m.AddStatus(v)
  22709. return nil
  22710. case msg.FieldMsgtype:
  22711. v, ok := value.(int32)
  22712. if !ok {
  22713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22714. }
  22715. m.AddMsgtype(v)
  22716. return nil
  22717. }
  22718. return fmt.Errorf("unknown Msg numeric field %s", name)
  22719. }
  22720. // ClearedFields returns all nullable fields that were cleared during this
  22721. // mutation.
  22722. func (m *MsgMutation) ClearedFields() []string {
  22723. var fields []string
  22724. if m.FieldCleared(msg.FieldDeletedAt) {
  22725. fields = append(fields, msg.FieldDeletedAt)
  22726. }
  22727. if m.FieldCleared(msg.FieldStatus) {
  22728. fields = append(fields, msg.FieldStatus)
  22729. }
  22730. if m.FieldCleared(msg.FieldFromwxid) {
  22731. fields = append(fields, msg.FieldFromwxid)
  22732. }
  22733. if m.FieldCleared(msg.FieldToid) {
  22734. fields = append(fields, msg.FieldToid)
  22735. }
  22736. if m.FieldCleared(msg.FieldMsgtype) {
  22737. fields = append(fields, msg.FieldMsgtype)
  22738. }
  22739. if m.FieldCleared(msg.FieldMsg) {
  22740. fields = append(fields, msg.FieldMsg)
  22741. }
  22742. if m.FieldCleared(msg.FieldBatchNo) {
  22743. fields = append(fields, msg.FieldBatchNo)
  22744. }
  22745. return fields
  22746. }
  22747. // FieldCleared returns a boolean indicating if a field with the given name was
  22748. // cleared in this mutation.
  22749. func (m *MsgMutation) FieldCleared(name string) bool {
  22750. _, ok := m.clearedFields[name]
  22751. return ok
  22752. }
  22753. // ClearField clears the value of the field with the given name. It returns an
  22754. // error if the field is not defined in the schema.
  22755. func (m *MsgMutation) ClearField(name string) error {
  22756. switch name {
  22757. case msg.FieldDeletedAt:
  22758. m.ClearDeletedAt()
  22759. return nil
  22760. case msg.FieldStatus:
  22761. m.ClearStatus()
  22762. return nil
  22763. case msg.FieldFromwxid:
  22764. m.ClearFromwxid()
  22765. return nil
  22766. case msg.FieldToid:
  22767. m.ClearToid()
  22768. return nil
  22769. case msg.FieldMsgtype:
  22770. m.ClearMsgtype()
  22771. return nil
  22772. case msg.FieldMsg:
  22773. m.ClearMsg()
  22774. return nil
  22775. case msg.FieldBatchNo:
  22776. m.ClearBatchNo()
  22777. return nil
  22778. }
  22779. return fmt.Errorf("unknown Msg nullable field %s", name)
  22780. }
  22781. // ResetField resets all changes in the mutation for the field with the given name.
  22782. // It returns an error if the field is not defined in the schema.
  22783. func (m *MsgMutation) ResetField(name string) error {
  22784. switch name {
  22785. case msg.FieldCreatedAt:
  22786. m.ResetCreatedAt()
  22787. return nil
  22788. case msg.FieldUpdatedAt:
  22789. m.ResetUpdatedAt()
  22790. return nil
  22791. case msg.FieldDeletedAt:
  22792. m.ResetDeletedAt()
  22793. return nil
  22794. case msg.FieldStatus:
  22795. m.ResetStatus()
  22796. return nil
  22797. case msg.FieldFromwxid:
  22798. m.ResetFromwxid()
  22799. return nil
  22800. case msg.FieldToid:
  22801. m.ResetToid()
  22802. return nil
  22803. case msg.FieldMsgtype:
  22804. m.ResetMsgtype()
  22805. return nil
  22806. case msg.FieldMsg:
  22807. m.ResetMsg()
  22808. return nil
  22809. case msg.FieldBatchNo:
  22810. m.ResetBatchNo()
  22811. return nil
  22812. case msg.FieldCc:
  22813. m.ResetCc()
  22814. return nil
  22815. case msg.FieldPhone:
  22816. m.ResetPhone()
  22817. return nil
  22818. }
  22819. return fmt.Errorf("unknown Msg field %s", name)
  22820. }
  22821. // AddedEdges returns all edge names that were set/added in this mutation.
  22822. func (m *MsgMutation) AddedEdges() []string {
  22823. edges := make([]string, 0, 0)
  22824. return edges
  22825. }
  22826. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22827. // name in this mutation.
  22828. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  22829. return nil
  22830. }
  22831. // RemovedEdges returns all edge names that were removed in this mutation.
  22832. func (m *MsgMutation) RemovedEdges() []string {
  22833. edges := make([]string, 0, 0)
  22834. return edges
  22835. }
  22836. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22837. // the given name in this mutation.
  22838. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  22839. return nil
  22840. }
  22841. // ClearedEdges returns all edge names that were cleared in this mutation.
  22842. func (m *MsgMutation) ClearedEdges() []string {
  22843. edges := make([]string, 0, 0)
  22844. return edges
  22845. }
  22846. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22847. // was cleared in this mutation.
  22848. func (m *MsgMutation) EdgeCleared(name string) bool {
  22849. return false
  22850. }
  22851. // ClearEdge clears the value of the edge with the given name. It returns an error
  22852. // if that edge is not defined in the schema.
  22853. func (m *MsgMutation) ClearEdge(name string) error {
  22854. return fmt.Errorf("unknown Msg unique edge %s", name)
  22855. }
  22856. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22857. // It returns an error if the edge is not defined in the schema.
  22858. func (m *MsgMutation) ResetEdge(name string) error {
  22859. return fmt.Errorf("unknown Msg edge %s", name)
  22860. }
  22861. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  22862. type PayRechargeMutation struct {
  22863. config
  22864. op Op
  22865. typ string
  22866. id *uint64
  22867. created_at *time.Time
  22868. updated_at *time.Time
  22869. deleted_at *time.Time
  22870. user_id *string
  22871. number *float32
  22872. addnumber *float32
  22873. status *int
  22874. addstatus *int
  22875. money *float32
  22876. addmoney *float32
  22877. out_trade_no *string
  22878. organization_id *uint64
  22879. addorganization_id *int64
  22880. clearedFields map[string]struct{}
  22881. done bool
  22882. oldValue func(context.Context) (*PayRecharge, error)
  22883. predicates []predicate.PayRecharge
  22884. }
  22885. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  22886. // payrechargeOption allows management of the mutation configuration using functional options.
  22887. type payrechargeOption func(*PayRechargeMutation)
  22888. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  22889. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  22890. m := &PayRechargeMutation{
  22891. config: c,
  22892. op: op,
  22893. typ: TypePayRecharge,
  22894. clearedFields: make(map[string]struct{}),
  22895. }
  22896. for _, opt := range opts {
  22897. opt(m)
  22898. }
  22899. return m
  22900. }
  22901. // withPayRechargeID sets the ID field of the mutation.
  22902. func withPayRechargeID(id uint64) payrechargeOption {
  22903. return func(m *PayRechargeMutation) {
  22904. var (
  22905. err error
  22906. once sync.Once
  22907. value *PayRecharge
  22908. )
  22909. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  22910. once.Do(func() {
  22911. if m.done {
  22912. err = errors.New("querying old values post mutation is not allowed")
  22913. } else {
  22914. value, err = m.Client().PayRecharge.Get(ctx, id)
  22915. }
  22916. })
  22917. return value, err
  22918. }
  22919. m.id = &id
  22920. }
  22921. }
  22922. // withPayRecharge sets the old PayRecharge of the mutation.
  22923. func withPayRecharge(node *PayRecharge) payrechargeOption {
  22924. return func(m *PayRechargeMutation) {
  22925. m.oldValue = func(context.Context) (*PayRecharge, error) {
  22926. return node, nil
  22927. }
  22928. m.id = &node.ID
  22929. }
  22930. }
  22931. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22932. // executed in a transaction (ent.Tx), a transactional client is returned.
  22933. func (m PayRechargeMutation) Client() *Client {
  22934. client := &Client{config: m.config}
  22935. client.init()
  22936. return client
  22937. }
  22938. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22939. // it returns an error otherwise.
  22940. func (m PayRechargeMutation) Tx() (*Tx, error) {
  22941. if _, ok := m.driver.(*txDriver); !ok {
  22942. return nil, errors.New("ent: mutation is not running in a transaction")
  22943. }
  22944. tx := &Tx{config: m.config}
  22945. tx.init()
  22946. return tx, nil
  22947. }
  22948. // SetID sets the value of the id field. Note that this
  22949. // operation is only accepted on creation of PayRecharge entities.
  22950. func (m *PayRechargeMutation) SetID(id uint64) {
  22951. m.id = &id
  22952. }
  22953. // ID returns the ID value in the mutation. Note that the ID is only available
  22954. // if it was provided to the builder or after it was returned from the database.
  22955. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  22956. if m.id == nil {
  22957. return
  22958. }
  22959. return *m.id, true
  22960. }
  22961. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22962. // That means, if the mutation is applied within a transaction with an isolation level such
  22963. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22964. // or updated by the mutation.
  22965. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  22966. switch {
  22967. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22968. id, exists := m.ID()
  22969. if exists {
  22970. return []uint64{id}, nil
  22971. }
  22972. fallthrough
  22973. case m.op.Is(OpUpdate | OpDelete):
  22974. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  22975. default:
  22976. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22977. }
  22978. }
  22979. // SetCreatedAt sets the "created_at" field.
  22980. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  22981. m.created_at = &t
  22982. }
  22983. // CreatedAt returns the value of the "created_at" field in the mutation.
  22984. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  22985. v := m.created_at
  22986. if v == nil {
  22987. return
  22988. }
  22989. return *v, true
  22990. }
  22991. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  22992. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22994. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22995. if !m.op.Is(OpUpdateOne) {
  22996. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22997. }
  22998. if m.id == nil || m.oldValue == nil {
  22999. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23000. }
  23001. oldValue, err := m.oldValue(ctx)
  23002. if err != nil {
  23003. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23004. }
  23005. return oldValue.CreatedAt, nil
  23006. }
  23007. // ResetCreatedAt resets all changes to the "created_at" field.
  23008. func (m *PayRechargeMutation) ResetCreatedAt() {
  23009. m.created_at = nil
  23010. }
  23011. // SetUpdatedAt sets the "updated_at" field.
  23012. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  23013. m.updated_at = &t
  23014. }
  23015. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23016. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  23017. v := m.updated_at
  23018. if v == nil {
  23019. return
  23020. }
  23021. return *v, true
  23022. }
  23023. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  23024. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23026. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23027. if !m.op.Is(OpUpdateOne) {
  23028. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23029. }
  23030. if m.id == nil || m.oldValue == nil {
  23031. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23032. }
  23033. oldValue, err := m.oldValue(ctx)
  23034. if err != nil {
  23035. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23036. }
  23037. return oldValue.UpdatedAt, nil
  23038. }
  23039. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23040. func (m *PayRechargeMutation) ResetUpdatedAt() {
  23041. m.updated_at = nil
  23042. }
  23043. // SetDeletedAt sets the "deleted_at" field.
  23044. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  23045. m.deleted_at = &t
  23046. }
  23047. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23048. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  23049. v := m.deleted_at
  23050. if v == nil {
  23051. return
  23052. }
  23053. return *v, true
  23054. }
  23055. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  23056. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23058. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23059. if !m.op.Is(OpUpdateOne) {
  23060. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23061. }
  23062. if m.id == nil || m.oldValue == nil {
  23063. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23064. }
  23065. oldValue, err := m.oldValue(ctx)
  23066. if err != nil {
  23067. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23068. }
  23069. return oldValue.DeletedAt, nil
  23070. }
  23071. // ClearDeletedAt clears the value of the "deleted_at" field.
  23072. func (m *PayRechargeMutation) ClearDeletedAt() {
  23073. m.deleted_at = nil
  23074. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  23075. }
  23076. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23077. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  23078. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  23079. return ok
  23080. }
  23081. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23082. func (m *PayRechargeMutation) ResetDeletedAt() {
  23083. m.deleted_at = nil
  23084. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  23085. }
  23086. // SetUserID sets the "user_id" field.
  23087. func (m *PayRechargeMutation) SetUserID(s string) {
  23088. m.user_id = &s
  23089. }
  23090. // UserID returns the value of the "user_id" field in the mutation.
  23091. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  23092. v := m.user_id
  23093. if v == nil {
  23094. return
  23095. }
  23096. return *v, true
  23097. }
  23098. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  23099. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23101. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  23102. if !m.op.Is(OpUpdateOne) {
  23103. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  23104. }
  23105. if m.id == nil || m.oldValue == nil {
  23106. return v, errors.New("OldUserID requires an ID field in the mutation")
  23107. }
  23108. oldValue, err := m.oldValue(ctx)
  23109. if err != nil {
  23110. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  23111. }
  23112. return oldValue.UserID, nil
  23113. }
  23114. // ResetUserID resets all changes to the "user_id" field.
  23115. func (m *PayRechargeMutation) ResetUserID() {
  23116. m.user_id = nil
  23117. }
  23118. // SetNumber sets the "number" field.
  23119. func (m *PayRechargeMutation) SetNumber(f float32) {
  23120. m.number = &f
  23121. m.addnumber = nil
  23122. }
  23123. // Number returns the value of the "number" field in the mutation.
  23124. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  23125. v := m.number
  23126. if v == nil {
  23127. return
  23128. }
  23129. return *v, true
  23130. }
  23131. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  23132. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23134. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  23135. if !m.op.Is(OpUpdateOne) {
  23136. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  23137. }
  23138. if m.id == nil || m.oldValue == nil {
  23139. return v, errors.New("OldNumber requires an ID field in the mutation")
  23140. }
  23141. oldValue, err := m.oldValue(ctx)
  23142. if err != nil {
  23143. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  23144. }
  23145. return oldValue.Number, nil
  23146. }
  23147. // AddNumber adds f to the "number" field.
  23148. func (m *PayRechargeMutation) AddNumber(f float32) {
  23149. if m.addnumber != nil {
  23150. *m.addnumber += f
  23151. } else {
  23152. m.addnumber = &f
  23153. }
  23154. }
  23155. // AddedNumber returns the value that was added to the "number" field in this mutation.
  23156. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  23157. v := m.addnumber
  23158. if v == nil {
  23159. return
  23160. }
  23161. return *v, true
  23162. }
  23163. // ResetNumber resets all changes to the "number" field.
  23164. func (m *PayRechargeMutation) ResetNumber() {
  23165. m.number = nil
  23166. m.addnumber = nil
  23167. }
  23168. // SetStatus sets the "status" field.
  23169. func (m *PayRechargeMutation) SetStatus(i int) {
  23170. m.status = &i
  23171. m.addstatus = nil
  23172. }
  23173. // Status returns the value of the "status" field in the mutation.
  23174. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  23175. v := m.status
  23176. if v == nil {
  23177. return
  23178. }
  23179. return *v, true
  23180. }
  23181. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  23182. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23184. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  23185. if !m.op.Is(OpUpdateOne) {
  23186. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23187. }
  23188. if m.id == nil || m.oldValue == nil {
  23189. return v, errors.New("OldStatus requires an ID field in the mutation")
  23190. }
  23191. oldValue, err := m.oldValue(ctx)
  23192. if err != nil {
  23193. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23194. }
  23195. return oldValue.Status, nil
  23196. }
  23197. // AddStatus adds i to the "status" field.
  23198. func (m *PayRechargeMutation) AddStatus(i int) {
  23199. if m.addstatus != nil {
  23200. *m.addstatus += i
  23201. } else {
  23202. m.addstatus = &i
  23203. }
  23204. }
  23205. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23206. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  23207. v := m.addstatus
  23208. if v == nil {
  23209. return
  23210. }
  23211. return *v, true
  23212. }
  23213. // ClearStatus clears the value of the "status" field.
  23214. func (m *PayRechargeMutation) ClearStatus() {
  23215. m.status = nil
  23216. m.addstatus = nil
  23217. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  23218. }
  23219. // StatusCleared returns if the "status" field was cleared in this mutation.
  23220. func (m *PayRechargeMutation) StatusCleared() bool {
  23221. _, ok := m.clearedFields[payrecharge.FieldStatus]
  23222. return ok
  23223. }
  23224. // ResetStatus resets all changes to the "status" field.
  23225. func (m *PayRechargeMutation) ResetStatus() {
  23226. m.status = nil
  23227. m.addstatus = nil
  23228. delete(m.clearedFields, payrecharge.FieldStatus)
  23229. }
  23230. // SetMoney sets the "money" field.
  23231. func (m *PayRechargeMutation) SetMoney(f float32) {
  23232. m.money = &f
  23233. m.addmoney = nil
  23234. }
  23235. // Money returns the value of the "money" field in the mutation.
  23236. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  23237. v := m.money
  23238. if v == nil {
  23239. return
  23240. }
  23241. return *v, true
  23242. }
  23243. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  23244. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23246. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  23247. if !m.op.Is(OpUpdateOne) {
  23248. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  23249. }
  23250. if m.id == nil || m.oldValue == nil {
  23251. return v, errors.New("OldMoney requires an ID field in the mutation")
  23252. }
  23253. oldValue, err := m.oldValue(ctx)
  23254. if err != nil {
  23255. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  23256. }
  23257. return oldValue.Money, nil
  23258. }
  23259. // AddMoney adds f to the "money" field.
  23260. func (m *PayRechargeMutation) AddMoney(f float32) {
  23261. if m.addmoney != nil {
  23262. *m.addmoney += f
  23263. } else {
  23264. m.addmoney = &f
  23265. }
  23266. }
  23267. // AddedMoney returns the value that was added to the "money" field in this mutation.
  23268. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  23269. v := m.addmoney
  23270. if v == nil {
  23271. return
  23272. }
  23273. return *v, true
  23274. }
  23275. // ClearMoney clears the value of the "money" field.
  23276. func (m *PayRechargeMutation) ClearMoney() {
  23277. m.money = nil
  23278. m.addmoney = nil
  23279. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  23280. }
  23281. // MoneyCleared returns if the "money" field was cleared in this mutation.
  23282. func (m *PayRechargeMutation) MoneyCleared() bool {
  23283. _, ok := m.clearedFields[payrecharge.FieldMoney]
  23284. return ok
  23285. }
  23286. // ResetMoney resets all changes to the "money" field.
  23287. func (m *PayRechargeMutation) ResetMoney() {
  23288. m.money = nil
  23289. m.addmoney = nil
  23290. delete(m.clearedFields, payrecharge.FieldMoney)
  23291. }
  23292. // SetOutTradeNo sets the "out_trade_no" field.
  23293. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  23294. m.out_trade_no = &s
  23295. }
  23296. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  23297. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  23298. v := m.out_trade_no
  23299. if v == nil {
  23300. return
  23301. }
  23302. return *v, true
  23303. }
  23304. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  23305. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23307. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  23308. if !m.op.Is(OpUpdateOne) {
  23309. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  23310. }
  23311. if m.id == nil || m.oldValue == nil {
  23312. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  23313. }
  23314. oldValue, err := m.oldValue(ctx)
  23315. if err != nil {
  23316. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  23317. }
  23318. return oldValue.OutTradeNo, nil
  23319. }
  23320. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  23321. func (m *PayRechargeMutation) ClearOutTradeNo() {
  23322. m.out_trade_no = nil
  23323. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  23324. }
  23325. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  23326. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  23327. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  23328. return ok
  23329. }
  23330. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  23331. func (m *PayRechargeMutation) ResetOutTradeNo() {
  23332. m.out_trade_no = nil
  23333. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  23334. }
  23335. // SetOrganizationID sets the "organization_id" field.
  23336. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  23337. m.organization_id = &u
  23338. m.addorganization_id = nil
  23339. }
  23340. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23341. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  23342. v := m.organization_id
  23343. if v == nil {
  23344. return
  23345. }
  23346. return *v, true
  23347. }
  23348. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  23349. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23351. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23352. if !m.op.Is(OpUpdateOne) {
  23353. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23354. }
  23355. if m.id == nil || m.oldValue == nil {
  23356. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23357. }
  23358. oldValue, err := m.oldValue(ctx)
  23359. if err != nil {
  23360. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23361. }
  23362. return oldValue.OrganizationID, nil
  23363. }
  23364. // AddOrganizationID adds u to the "organization_id" field.
  23365. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  23366. if m.addorganization_id != nil {
  23367. *m.addorganization_id += u
  23368. } else {
  23369. m.addorganization_id = &u
  23370. }
  23371. }
  23372. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23373. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  23374. v := m.addorganization_id
  23375. if v == nil {
  23376. return
  23377. }
  23378. return *v, true
  23379. }
  23380. // ResetOrganizationID resets all changes to the "organization_id" field.
  23381. func (m *PayRechargeMutation) ResetOrganizationID() {
  23382. m.organization_id = nil
  23383. m.addorganization_id = nil
  23384. }
  23385. // Where appends a list predicates to the PayRechargeMutation builder.
  23386. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  23387. m.predicates = append(m.predicates, ps...)
  23388. }
  23389. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  23390. // users can use type-assertion to append predicates that do not depend on any generated package.
  23391. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  23392. p := make([]predicate.PayRecharge, len(ps))
  23393. for i := range ps {
  23394. p[i] = ps[i]
  23395. }
  23396. m.Where(p...)
  23397. }
  23398. // Op returns the operation name.
  23399. func (m *PayRechargeMutation) Op() Op {
  23400. return m.op
  23401. }
  23402. // SetOp allows setting the mutation operation.
  23403. func (m *PayRechargeMutation) SetOp(op Op) {
  23404. m.op = op
  23405. }
  23406. // Type returns the node type of this mutation (PayRecharge).
  23407. func (m *PayRechargeMutation) Type() string {
  23408. return m.typ
  23409. }
  23410. // Fields returns all fields that were changed during this mutation. Note that in
  23411. // order to get all numeric fields that were incremented/decremented, call
  23412. // AddedFields().
  23413. func (m *PayRechargeMutation) Fields() []string {
  23414. fields := make([]string, 0, 9)
  23415. if m.created_at != nil {
  23416. fields = append(fields, payrecharge.FieldCreatedAt)
  23417. }
  23418. if m.updated_at != nil {
  23419. fields = append(fields, payrecharge.FieldUpdatedAt)
  23420. }
  23421. if m.deleted_at != nil {
  23422. fields = append(fields, payrecharge.FieldDeletedAt)
  23423. }
  23424. if m.user_id != nil {
  23425. fields = append(fields, payrecharge.FieldUserID)
  23426. }
  23427. if m.number != nil {
  23428. fields = append(fields, payrecharge.FieldNumber)
  23429. }
  23430. if m.status != nil {
  23431. fields = append(fields, payrecharge.FieldStatus)
  23432. }
  23433. if m.money != nil {
  23434. fields = append(fields, payrecharge.FieldMoney)
  23435. }
  23436. if m.out_trade_no != nil {
  23437. fields = append(fields, payrecharge.FieldOutTradeNo)
  23438. }
  23439. if m.organization_id != nil {
  23440. fields = append(fields, payrecharge.FieldOrganizationID)
  23441. }
  23442. return fields
  23443. }
  23444. // Field returns the value of a field with the given name. The second boolean
  23445. // return value indicates that this field was not set, or was not defined in the
  23446. // schema.
  23447. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  23448. switch name {
  23449. case payrecharge.FieldCreatedAt:
  23450. return m.CreatedAt()
  23451. case payrecharge.FieldUpdatedAt:
  23452. return m.UpdatedAt()
  23453. case payrecharge.FieldDeletedAt:
  23454. return m.DeletedAt()
  23455. case payrecharge.FieldUserID:
  23456. return m.UserID()
  23457. case payrecharge.FieldNumber:
  23458. return m.Number()
  23459. case payrecharge.FieldStatus:
  23460. return m.Status()
  23461. case payrecharge.FieldMoney:
  23462. return m.Money()
  23463. case payrecharge.FieldOutTradeNo:
  23464. return m.OutTradeNo()
  23465. case payrecharge.FieldOrganizationID:
  23466. return m.OrganizationID()
  23467. }
  23468. return nil, false
  23469. }
  23470. // OldField returns the old value of the field from the database. An error is
  23471. // returned if the mutation operation is not UpdateOne, or the query to the
  23472. // database failed.
  23473. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23474. switch name {
  23475. case payrecharge.FieldCreatedAt:
  23476. return m.OldCreatedAt(ctx)
  23477. case payrecharge.FieldUpdatedAt:
  23478. return m.OldUpdatedAt(ctx)
  23479. case payrecharge.FieldDeletedAt:
  23480. return m.OldDeletedAt(ctx)
  23481. case payrecharge.FieldUserID:
  23482. return m.OldUserID(ctx)
  23483. case payrecharge.FieldNumber:
  23484. return m.OldNumber(ctx)
  23485. case payrecharge.FieldStatus:
  23486. return m.OldStatus(ctx)
  23487. case payrecharge.FieldMoney:
  23488. return m.OldMoney(ctx)
  23489. case payrecharge.FieldOutTradeNo:
  23490. return m.OldOutTradeNo(ctx)
  23491. case payrecharge.FieldOrganizationID:
  23492. return m.OldOrganizationID(ctx)
  23493. }
  23494. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  23495. }
  23496. // SetField sets the value of a field with the given name. It returns an error if
  23497. // the field is not defined in the schema, or if the type mismatched the field
  23498. // type.
  23499. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  23500. switch name {
  23501. case payrecharge.FieldCreatedAt:
  23502. v, ok := value.(time.Time)
  23503. if !ok {
  23504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23505. }
  23506. m.SetCreatedAt(v)
  23507. return nil
  23508. case payrecharge.FieldUpdatedAt:
  23509. v, ok := value.(time.Time)
  23510. if !ok {
  23511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23512. }
  23513. m.SetUpdatedAt(v)
  23514. return nil
  23515. case payrecharge.FieldDeletedAt:
  23516. v, ok := value.(time.Time)
  23517. if !ok {
  23518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23519. }
  23520. m.SetDeletedAt(v)
  23521. return nil
  23522. case payrecharge.FieldUserID:
  23523. v, ok := value.(string)
  23524. if !ok {
  23525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23526. }
  23527. m.SetUserID(v)
  23528. return nil
  23529. case payrecharge.FieldNumber:
  23530. v, ok := value.(float32)
  23531. if !ok {
  23532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23533. }
  23534. m.SetNumber(v)
  23535. return nil
  23536. case payrecharge.FieldStatus:
  23537. v, ok := value.(int)
  23538. if !ok {
  23539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23540. }
  23541. m.SetStatus(v)
  23542. return nil
  23543. case payrecharge.FieldMoney:
  23544. v, ok := value.(float32)
  23545. if !ok {
  23546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23547. }
  23548. m.SetMoney(v)
  23549. return nil
  23550. case payrecharge.FieldOutTradeNo:
  23551. v, ok := value.(string)
  23552. if !ok {
  23553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23554. }
  23555. m.SetOutTradeNo(v)
  23556. return nil
  23557. case payrecharge.FieldOrganizationID:
  23558. v, ok := value.(uint64)
  23559. if !ok {
  23560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23561. }
  23562. m.SetOrganizationID(v)
  23563. return nil
  23564. }
  23565. return fmt.Errorf("unknown PayRecharge field %s", name)
  23566. }
  23567. // AddedFields returns all numeric fields that were incremented/decremented during
  23568. // this mutation.
  23569. func (m *PayRechargeMutation) AddedFields() []string {
  23570. var fields []string
  23571. if m.addnumber != nil {
  23572. fields = append(fields, payrecharge.FieldNumber)
  23573. }
  23574. if m.addstatus != nil {
  23575. fields = append(fields, payrecharge.FieldStatus)
  23576. }
  23577. if m.addmoney != nil {
  23578. fields = append(fields, payrecharge.FieldMoney)
  23579. }
  23580. if m.addorganization_id != nil {
  23581. fields = append(fields, payrecharge.FieldOrganizationID)
  23582. }
  23583. return fields
  23584. }
  23585. // AddedField returns the numeric value that was incremented/decremented on a field
  23586. // with the given name. The second boolean return value indicates that this field
  23587. // was not set, or was not defined in the schema.
  23588. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  23589. switch name {
  23590. case payrecharge.FieldNumber:
  23591. return m.AddedNumber()
  23592. case payrecharge.FieldStatus:
  23593. return m.AddedStatus()
  23594. case payrecharge.FieldMoney:
  23595. return m.AddedMoney()
  23596. case payrecharge.FieldOrganizationID:
  23597. return m.AddedOrganizationID()
  23598. }
  23599. return nil, false
  23600. }
  23601. // AddField adds the value to the field with the given name. It returns an error if
  23602. // the field is not defined in the schema, or if the type mismatched the field
  23603. // type.
  23604. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  23605. switch name {
  23606. case payrecharge.FieldNumber:
  23607. v, ok := value.(float32)
  23608. if !ok {
  23609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23610. }
  23611. m.AddNumber(v)
  23612. return nil
  23613. case payrecharge.FieldStatus:
  23614. v, ok := value.(int)
  23615. if !ok {
  23616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23617. }
  23618. m.AddStatus(v)
  23619. return nil
  23620. case payrecharge.FieldMoney:
  23621. v, ok := value.(float32)
  23622. if !ok {
  23623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23624. }
  23625. m.AddMoney(v)
  23626. return nil
  23627. case payrecharge.FieldOrganizationID:
  23628. v, ok := value.(int64)
  23629. if !ok {
  23630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23631. }
  23632. m.AddOrganizationID(v)
  23633. return nil
  23634. }
  23635. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  23636. }
  23637. // ClearedFields returns all nullable fields that were cleared during this
  23638. // mutation.
  23639. func (m *PayRechargeMutation) ClearedFields() []string {
  23640. var fields []string
  23641. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  23642. fields = append(fields, payrecharge.FieldDeletedAt)
  23643. }
  23644. if m.FieldCleared(payrecharge.FieldStatus) {
  23645. fields = append(fields, payrecharge.FieldStatus)
  23646. }
  23647. if m.FieldCleared(payrecharge.FieldMoney) {
  23648. fields = append(fields, payrecharge.FieldMoney)
  23649. }
  23650. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  23651. fields = append(fields, payrecharge.FieldOutTradeNo)
  23652. }
  23653. return fields
  23654. }
  23655. // FieldCleared returns a boolean indicating if a field with the given name was
  23656. // cleared in this mutation.
  23657. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  23658. _, ok := m.clearedFields[name]
  23659. return ok
  23660. }
  23661. // ClearField clears the value of the field with the given name. It returns an
  23662. // error if the field is not defined in the schema.
  23663. func (m *PayRechargeMutation) ClearField(name string) error {
  23664. switch name {
  23665. case payrecharge.FieldDeletedAt:
  23666. m.ClearDeletedAt()
  23667. return nil
  23668. case payrecharge.FieldStatus:
  23669. m.ClearStatus()
  23670. return nil
  23671. case payrecharge.FieldMoney:
  23672. m.ClearMoney()
  23673. return nil
  23674. case payrecharge.FieldOutTradeNo:
  23675. m.ClearOutTradeNo()
  23676. return nil
  23677. }
  23678. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  23679. }
  23680. // ResetField resets all changes in the mutation for the field with the given name.
  23681. // It returns an error if the field is not defined in the schema.
  23682. func (m *PayRechargeMutation) ResetField(name string) error {
  23683. switch name {
  23684. case payrecharge.FieldCreatedAt:
  23685. m.ResetCreatedAt()
  23686. return nil
  23687. case payrecharge.FieldUpdatedAt:
  23688. m.ResetUpdatedAt()
  23689. return nil
  23690. case payrecharge.FieldDeletedAt:
  23691. m.ResetDeletedAt()
  23692. return nil
  23693. case payrecharge.FieldUserID:
  23694. m.ResetUserID()
  23695. return nil
  23696. case payrecharge.FieldNumber:
  23697. m.ResetNumber()
  23698. return nil
  23699. case payrecharge.FieldStatus:
  23700. m.ResetStatus()
  23701. return nil
  23702. case payrecharge.FieldMoney:
  23703. m.ResetMoney()
  23704. return nil
  23705. case payrecharge.FieldOutTradeNo:
  23706. m.ResetOutTradeNo()
  23707. return nil
  23708. case payrecharge.FieldOrganizationID:
  23709. m.ResetOrganizationID()
  23710. return nil
  23711. }
  23712. return fmt.Errorf("unknown PayRecharge field %s", name)
  23713. }
  23714. // AddedEdges returns all edge names that were set/added in this mutation.
  23715. func (m *PayRechargeMutation) AddedEdges() []string {
  23716. edges := make([]string, 0, 0)
  23717. return edges
  23718. }
  23719. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23720. // name in this mutation.
  23721. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  23722. return nil
  23723. }
  23724. // RemovedEdges returns all edge names that were removed in this mutation.
  23725. func (m *PayRechargeMutation) RemovedEdges() []string {
  23726. edges := make([]string, 0, 0)
  23727. return edges
  23728. }
  23729. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23730. // the given name in this mutation.
  23731. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  23732. return nil
  23733. }
  23734. // ClearedEdges returns all edge names that were cleared in this mutation.
  23735. func (m *PayRechargeMutation) ClearedEdges() []string {
  23736. edges := make([]string, 0, 0)
  23737. return edges
  23738. }
  23739. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23740. // was cleared in this mutation.
  23741. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  23742. return false
  23743. }
  23744. // ClearEdge clears the value of the edge with the given name. It returns an error
  23745. // if that edge is not defined in the schema.
  23746. func (m *PayRechargeMutation) ClearEdge(name string) error {
  23747. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  23748. }
  23749. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23750. // It returns an error if the edge is not defined in the schema.
  23751. func (m *PayRechargeMutation) ResetEdge(name string) error {
  23752. return fmt.Errorf("unknown PayRecharge edge %s", name)
  23753. }
  23754. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  23755. type ServerMutation struct {
  23756. config
  23757. op Op
  23758. typ string
  23759. id *uint64
  23760. created_at *time.Time
  23761. updated_at *time.Time
  23762. status *uint8
  23763. addstatus *int8
  23764. deleted_at *time.Time
  23765. name *string
  23766. public_ip *string
  23767. private_ip *string
  23768. admin_port *string
  23769. clearedFields map[string]struct{}
  23770. wxs map[uint64]struct{}
  23771. removedwxs map[uint64]struct{}
  23772. clearedwxs bool
  23773. done bool
  23774. oldValue func(context.Context) (*Server, error)
  23775. predicates []predicate.Server
  23776. }
  23777. var _ ent.Mutation = (*ServerMutation)(nil)
  23778. // serverOption allows management of the mutation configuration using functional options.
  23779. type serverOption func(*ServerMutation)
  23780. // newServerMutation creates new mutation for the Server entity.
  23781. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  23782. m := &ServerMutation{
  23783. config: c,
  23784. op: op,
  23785. typ: TypeServer,
  23786. clearedFields: make(map[string]struct{}),
  23787. }
  23788. for _, opt := range opts {
  23789. opt(m)
  23790. }
  23791. return m
  23792. }
  23793. // withServerID sets the ID field of the mutation.
  23794. func withServerID(id uint64) serverOption {
  23795. return func(m *ServerMutation) {
  23796. var (
  23797. err error
  23798. once sync.Once
  23799. value *Server
  23800. )
  23801. m.oldValue = func(ctx context.Context) (*Server, error) {
  23802. once.Do(func() {
  23803. if m.done {
  23804. err = errors.New("querying old values post mutation is not allowed")
  23805. } else {
  23806. value, err = m.Client().Server.Get(ctx, id)
  23807. }
  23808. })
  23809. return value, err
  23810. }
  23811. m.id = &id
  23812. }
  23813. }
  23814. // withServer sets the old Server of the mutation.
  23815. func withServer(node *Server) serverOption {
  23816. return func(m *ServerMutation) {
  23817. m.oldValue = func(context.Context) (*Server, error) {
  23818. return node, nil
  23819. }
  23820. m.id = &node.ID
  23821. }
  23822. }
  23823. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23824. // executed in a transaction (ent.Tx), a transactional client is returned.
  23825. func (m ServerMutation) Client() *Client {
  23826. client := &Client{config: m.config}
  23827. client.init()
  23828. return client
  23829. }
  23830. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23831. // it returns an error otherwise.
  23832. func (m ServerMutation) Tx() (*Tx, error) {
  23833. if _, ok := m.driver.(*txDriver); !ok {
  23834. return nil, errors.New("ent: mutation is not running in a transaction")
  23835. }
  23836. tx := &Tx{config: m.config}
  23837. tx.init()
  23838. return tx, nil
  23839. }
  23840. // SetID sets the value of the id field. Note that this
  23841. // operation is only accepted on creation of Server entities.
  23842. func (m *ServerMutation) SetID(id uint64) {
  23843. m.id = &id
  23844. }
  23845. // ID returns the ID value in the mutation. Note that the ID is only available
  23846. // if it was provided to the builder or after it was returned from the database.
  23847. func (m *ServerMutation) ID() (id uint64, exists bool) {
  23848. if m.id == nil {
  23849. return
  23850. }
  23851. return *m.id, true
  23852. }
  23853. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23854. // That means, if the mutation is applied within a transaction with an isolation level such
  23855. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23856. // or updated by the mutation.
  23857. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  23858. switch {
  23859. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23860. id, exists := m.ID()
  23861. if exists {
  23862. return []uint64{id}, nil
  23863. }
  23864. fallthrough
  23865. case m.op.Is(OpUpdate | OpDelete):
  23866. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  23867. default:
  23868. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23869. }
  23870. }
  23871. // SetCreatedAt sets the "created_at" field.
  23872. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  23873. m.created_at = &t
  23874. }
  23875. // CreatedAt returns the value of the "created_at" field in the mutation.
  23876. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  23877. v := m.created_at
  23878. if v == nil {
  23879. return
  23880. }
  23881. return *v, true
  23882. }
  23883. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  23884. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23886. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23887. if !m.op.Is(OpUpdateOne) {
  23888. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23889. }
  23890. if m.id == nil || m.oldValue == nil {
  23891. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23892. }
  23893. oldValue, err := m.oldValue(ctx)
  23894. if err != nil {
  23895. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23896. }
  23897. return oldValue.CreatedAt, nil
  23898. }
  23899. // ResetCreatedAt resets all changes to the "created_at" field.
  23900. func (m *ServerMutation) ResetCreatedAt() {
  23901. m.created_at = nil
  23902. }
  23903. // SetUpdatedAt sets the "updated_at" field.
  23904. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  23905. m.updated_at = &t
  23906. }
  23907. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23908. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  23909. v := m.updated_at
  23910. if v == nil {
  23911. return
  23912. }
  23913. return *v, true
  23914. }
  23915. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  23916. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23918. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23919. if !m.op.Is(OpUpdateOne) {
  23920. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23921. }
  23922. if m.id == nil || m.oldValue == nil {
  23923. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23924. }
  23925. oldValue, err := m.oldValue(ctx)
  23926. if err != nil {
  23927. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23928. }
  23929. return oldValue.UpdatedAt, nil
  23930. }
  23931. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23932. func (m *ServerMutation) ResetUpdatedAt() {
  23933. m.updated_at = nil
  23934. }
  23935. // SetStatus sets the "status" field.
  23936. func (m *ServerMutation) SetStatus(u uint8) {
  23937. m.status = &u
  23938. m.addstatus = nil
  23939. }
  23940. // Status returns the value of the "status" field in the mutation.
  23941. func (m *ServerMutation) Status() (r uint8, exists bool) {
  23942. v := m.status
  23943. if v == nil {
  23944. return
  23945. }
  23946. return *v, true
  23947. }
  23948. // OldStatus returns the old "status" field's value of the Server entity.
  23949. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23951. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23952. if !m.op.Is(OpUpdateOne) {
  23953. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23954. }
  23955. if m.id == nil || m.oldValue == nil {
  23956. return v, errors.New("OldStatus requires an ID field in the mutation")
  23957. }
  23958. oldValue, err := m.oldValue(ctx)
  23959. if err != nil {
  23960. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23961. }
  23962. return oldValue.Status, nil
  23963. }
  23964. // AddStatus adds u to the "status" field.
  23965. func (m *ServerMutation) AddStatus(u int8) {
  23966. if m.addstatus != nil {
  23967. *m.addstatus += u
  23968. } else {
  23969. m.addstatus = &u
  23970. }
  23971. }
  23972. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23973. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  23974. v := m.addstatus
  23975. if v == nil {
  23976. return
  23977. }
  23978. return *v, true
  23979. }
  23980. // ClearStatus clears the value of the "status" field.
  23981. func (m *ServerMutation) ClearStatus() {
  23982. m.status = nil
  23983. m.addstatus = nil
  23984. m.clearedFields[server.FieldStatus] = struct{}{}
  23985. }
  23986. // StatusCleared returns if the "status" field was cleared in this mutation.
  23987. func (m *ServerMutation) StatusCleared() bool {
  23988. _, ok := m.clearedFields[server.FieldStatus]
  23989. return ok
  23990. }
  23991. // ResetStatus resets all changes to the "status" field.
  23992. func (m *ServerMutation) ResetStatus() {
  23993. m.status = nil
  23994. m.addstatus = nil
  23995. delete(m.clearedFields, server.FieldStatus)
  23996. }
  23997. // SetDeletedAt sets the "deleted_at" field.
  23998. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  23999. m.deleted_at = &t
  24000. }
  24001. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24002. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  24003. v := m.deleted_at
  24004. if v == nil {
  24005. return
  24006. }
  24007. return *v, true
  24008. }
  24009. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  24010. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24012. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24013. if !m.op.Is(OpUpdateOne) {
  24014. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24015. }
  24016. if m.id == nil || m.oldValue == nil {
  24017. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24018. }
  24019. oldValue, err := m.oldValue(ctx)
  24020. if err != nil {
  24021. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24022. }
  24023. return oldValue.DeletedAt, nil
  24024. }
  24025. // ClearDeletedAt clears the value of the "deleted_at" field.
  24026. func (m *ServerMutation) ClearDeletedAt() {
  24027. m.deleted_at = nil
  24028. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  24029. }
  24030. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24031. func (m *ServerMutation) DeletedAtCleared() bool {
  24032. _, ok := m.clearedFields[server.FieldDeletedAt]
  24033. return ok
  24034. }
  24035. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24036. func (m *ServerMutation) ResetDeletedAt() {
  24037. m.deleted_at = nil
  24038. delete(m.clearedFields, server.FieldDeletedAt)
  24039. }
  24040. // SetName sets the "name" field.
  24041. func (m *ServerMutation) SetName(s string) {
  24042. m.name = &s
  24043. }
  24044. // Name returns the value of the "name" field in the mutation.
  24045. func (m *ServerMutation) Name() (r string, exists bool) {
  24046. v := m.name
  24047. if v == nil {
  24048. return
  24049. }
  24050. return *v, true
  24051. }
  24052. // OldName returns the old "name" field's value of the Server entity.
  24053. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24055. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  24056. if !m.op.Is(OpUpdateOne) {
  24057. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24058. }
  24059. if m.id == nil || m.oldValue == nil {
  24060. return v, errors.New("OldName requires an ID field in the mutation")
  24061. }
  24062. oldValue, err := m.oldValue(ctx)
  24063. if err != nil {
  24064. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24065. }
  24066. return oldValue.Name, nil
  24067. }
  24068. // ResetName resets all changes to the "name" field.
  24069. func (m *ServerMutation) ResetName() {
  24070. m.name = nil
  24071. }
  24072. // SetPublicIP sets the "public_ip" field.
  24073. func (m *ServerMutation) SetPublicIP(s string) {
  24074. m.public_ip = &s
  24075. }
  24076. // PublicIP returns the value of the "public_ip" field in the mutation.
  24077. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  24078. v := m.public_ip
  24079. if v == nil {
  24080. return
  24081. }
  24082. return *v, true
  24083. }
  24084. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  24085. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24087. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  24088. if !m.op.Is(OpUpdateOne) {
  24089. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  24090. }
  24091. if m.id == nil || m.oldValue == nil {
  24092. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  24093. }
  24094. oldValue, err := m.oldValue(ctx)
  24095. if err != nil {
  24096. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  24097. }
  24098. return oldValue.PublicIP, nil
  24099. }
  24100. // ResetPublicIP resets all changes to the "public_ip" field.
  24101. func (m *ServerMutation) ResetPublicIP() {
  24102. m.public_ip = nil
  24103. }
  24104. // SetPrivateIP sets the "private_ip" field.
  24105. func (m *ServerMutation) SetPrivateIP(s string) {
  24106. m.private_ip = &s
  24107. }
  24108. // PrivateIP returns the value of the "private_ip" field in the mutation.
  24109. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  24110. v := m.private_ip
  24111. if v == nil {
  24112. return
  24113. }
  24114. return *v, true
  24115. }
  24116. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  24117. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24119. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  24120. if !m.op.Is(OpUpdateOne) {
  24121. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  24122. }
  24123. if m.id == nil || m.oldValue == nil {
  24124. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  24125. }
  24126. oldValue, err := m.oldValue(ctx)
  24127. if err != nil {
  24128. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  24129. }
  24130. return oldValue.PrivateIP, nil
  24131. }
  24132. // ResetPrivateIP resets all changes to the "private_ip" field.
  24133. func (m *ServerMutation) ResetPrivateIP() {
  24134. m.private_ip = nil
  24135. }
  24136. // SetAdminPort sets the "admin_port" field.
  24137. func (m *ServerMutation) SetAdminPort(s string) {
  24138. m.admin_port = &s
  24139. }
  24140. // AdminPort returns the value of the "admin_port" field in the mutation.
  24141. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  24142. v := m.admin_port
  24143. if v == nil {
  24144. return
  24145. }
  24146. return *v, true
  24147. }
  24148. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  24149. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24151. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  24152. if !m.op.Is(OpUpdateOne) {
  24153. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  24154. }
  24155. if m.id == nil || m.oldValue == nil {
  24156. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  24157. }
  24158. oldValue, err := m.oldValue(ctx)
  24159. if err != nil {
  24160. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  24161. }
  24162. return oldValue.AdminPort, nil
  24163. }
  24164. // ResetAdminPort resets all changes to the "admin_port" field.
  24165. func (m *ServerMutation) ResetAdminPort() {
  24166. m.admin_port = nil
  24167. }
  24168. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  24169. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  24170. if m.wxs == nil {
  24171. m.wxs = make(map[uint64]struct{})
  24172. }
  24173. for i := range ids {
  24174. m.wxs[ids[i]] = struct{}{}
  24175. }
  24176. }
  24177. // ClearWxs clears the "wxs" edge to the Wx entity.
  24178. func (m *ServerMutation) ClearWxs() {
  24179. m.clearedwxs = true
  24180. }
  24181. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  24182. func (m *ServerMutation) WxsCleared() bool {
  24183. return m.clearedwxs
  24184. }
  24185. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  24186. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  24187. if m.removedwxs == nil {
  24188. m.removedwxs = make(map[uint64]struct{})
  24189. }
  24190. for i := range ids {
  24191. delete(m.wxs, ids[i])
  24192. m.removedwxs[ids[i]] = struct{}{}
  24193. }
  24194. }
  24195. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  24196. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  24197. for id := range m.removedwxs {
  24198. ids = append(ids, id)
  24199. }
  24200. return
  24201. }
  24202. // WxsIDs returns the "wxs" edge IDs in the mutation.
  24203. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  24204. for id := range m.wxs {
  24205. ids = append(ids, id)
  24206. }
  24207. return
  24208. }
  24209. // ResetWxs resets all changes to the "wxs" edge.
  24210. func (m *ServerMutation) ResetWxs() {
  24211. m.wxs = nil
  24212. m.clearedwxs = false
  24213. m.removedwxs = nil
  24214. }
  24215. // Where appends a list predicates to the ServerMutation builder.
  24216. func (m *ServerMutation) Where(ps ...predicate.Server) {
  24217. m.predicates = append(m.predicates, ps...)
  24218. }
  24219. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  24220. // users can use type-assertion to append predicates that do not depend on any generated package.
  24221. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  24222. p := make([]predicate.Server, len(ps))
  24223. for i := range ps {
  24224. p[i] = ps[i]
  24225. }
  24226. m.Where(p...)
  24227. }
  24228. // Op returns the operation name.
  24229. func (m *ServerMutation) Op() Op {
  24230. return m.op
  24231. }
  24232. // SetOp allows setting the mutation operation.
  24233. func (m *ServerMutation) SetOp(op Op) {
  24234. m.op = op
  24235. }
  24236. // Type returns the node type of this mutation (Server).
  24237. func (m *ServerMutation) Type() string {
  24238. return m.typ
  24239. }
  24240. // Fields returns all fields that were changed during this mutation. Note that in
  24241. // order to get all numeric fields that were incremented/decremented, call
  24242. // AddedFields().
  24243. func (m *ServerMutation) Fields() []string {
  24244. fields := make([]string, 0, 8)
  24245. if m.created_at != nil {
  24246. fields = append(fields, server.FieldCreatedAt)
  24247. }
  24248. if m.updated_at != nil {
  24249. fields = append(fields, server.FieldUpdatedAt)
  24250. }
  24251. if m.status != nil {
  24252. fields = append(fields, server.FieldStatus)
  24253. }
  24254. if m.deleted_at != nil {
  24255. fields = append(fields, server.FieldDeletedAt)
  24256. }
  24257. if m.name != nil {
  24258. fields = append(fields, server.FieldName)
  24259. }
  24260. if m.public_ip != nil {
  24261. fields = append(fields, server.FieldPublicIP)
  24262. }
  24263. if m.private_ip != nil {
  24264. fields = append(fields, server.FieldPrivateIP)
  24265. }
  24266. if m.admin_port != nil {
  24267. fields = append(fields, server.FieldAdminPort)
  24268. }
  24269. return fields
  24270. }
  24271. // Field returns the value of a field with the given name. The second boolean
  24272. // return value indicates that this field was not set, or was not defined in the
  24273. // schema.
  24274. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  24275. switch name {
  24276. case server.FieldCreatedAt:
  24277. return m.CreatedAt()
  24278. case server.FieldUpdatedAt:
  24279. return m.UpdatedAt()
  24280. case server.FieldStatus:
  24281. return m.Status()
  24282. case server.FieldDeletedAt:
  24283. return m.DeletedAt()
  24284. case server.FieldName:
  24285. return m.Name()
  24286. case server.FieldPublicIP:
  24287. return m.PublicIP()
  24288. case server.FieldPrivateIP:
  24289. return m.PrivateIP()
  24290. case server.FieldAdminPort:
  24291. return m.AdminPort()
  24292. }
  24293. return nil, false
  24294. }
  24295. // OldField returns the old value of the field from the database. An error is
  24296. // returned if the mutation operation is not UpdateOne, or the query to the
  24297. // database failed.
  24298. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24299. switch name {
  24300. case server.FieldCreatedAt:
  24301. return m.OldCreatedAt(ctx)
  24302. case server.FieldUpdatedAt:
  24303. return m.OldUpdatedAt(ctx)
  24304. case server.FieldStatus:
  24305. return m.OldStatus(ctx)
  24306. case server.FieldDeletedAt:
  24307. return m.OldDeletedAt(ctx)
  24308. case server.FieldName:
  24309. return m.OldName(ctx)
  24310. case server.FieldPublicIP:
  24311. return m.OldPublicIP(ctx)
  24312. case server.FieldPrivateIP:
  24313. return m.OldPrivateIP(ctx)
  24314. case server.FieldAdminPort:
  24315. return m.OldAdminPort(ctx)
  24316. }
  24317. return nil, fmt.Errorf("unknown Server field %s", name)
  24318. }
  24319. // SetField sets the value of a field with the given name. It returns an error if
  24320. // the field is not defined in the schema, or if the type mismatched the field
  24321. // type.
  24322. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  24323. switch name {
  24324. case server.FieldCreatedAt:
  24325. v, ok := value.(time.Time)
  24326. if !ok {
  24327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24328. }
  24329. m.SetCreatedAt(v)
  24330. return nil
  24331. case server.FieldUpdatedAt:
  24332. v, ok := value.(time.Time)
  24333. if !ok {
  24334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24335. }
  24336. m.SetUpdatedAt(v)
  24337. return nil
  24338. case server.FieldStatus:
  24339. v, ok := value.(uint8)
  24340. if !ok {
  24341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24342. }
  24343. m.SetStatus(v)
  24344. return nil
  24345. case server.FieldDeletedAt:
  24346. v, ok := value.(time.Time)
  24347. if !ok {
  24348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24349. }
  24350. m.SetDeletedAt(v)
  24351. return nil
  24352. case server.FieldName:
  24353. v, ok := value.(string)
  24354. if !ok {
  24355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24356. }
  24357. m.SetName(v)
  24358. return nil
  24359. case server.FieldPublicIP:
  24360. v, ok := value.(string)
  24361. if !ok {
  24362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24363. }
  24364. m.SetPublicIP(v)
  24365. return nil
  24366. case server.FieldPrivateIP:
  24367. v, ok := value.(string)
  24368. if !ok {
  24369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24370. }
  24371. m.SetPrivateIP(v)
  24372. return nil
  24373. case server.FieldAdminPort:
  24374. v, ok := value.(string)
  24375. if !ok {
  24376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24377. }
  24378. m.SetAdminPort(v)
  24379. return nil
  24380. }
  24381. return fmt.Errorf("unknown Server field %s", name)
  24382. }
  24383. // AddedFields returns all numeric fields that were incremented/decremented during
  24384. // this mutation.
  24385. func (m *ServerMutation) AddedFields() []string {
  24386. var fields []string
  24387. if m.addstatus != nil {
  24388. fields = append(fields, server.FieldStatus)
  24389. }
  24390. return fields
  24391. }
  24392. // AddedField returns the numeric value that was incremented/decremented on a field
  24393. // with the given name. The second boolean return value indicates that this field
  24394. // was not set, or was not defined in the schema.
  24395. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  24396. switch name {
  24397. case server.FieldStatus:
  24398. return m.AddedStatus()
  24399. }
  24400. return nil, false
  24401. }
  24402. // AddField adds the value to the field with the given name. It returns an error if
  24403. // the field is not defined in the schema, or if the type mismatched the field
  24404. // type.
  24405. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  24406. switch name {
  24407. case server.FieldStatus:
  24408. v, ok := value.(int8)
  24409. if !ok {
  24410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24411. }
  24412. m.AddStatus(v)
  24413. return nil
  24414. }
  24415. return fmt.Errorf("unknown Server numeric field %s", name)
  24416. }
  24417. // ClearedFields returns all nullable fields that were cleared during this
  24418. // mutation.
  24419. func (m *ServerMutation) ClearedFields() []string {
  24420. var fields []string
  24421. if m.FieldCleared(server.FieldStatus) {
  24422. fields = append(fields, server.FieldStatus)
  24423. }
  24424. if m.FieldCleared(server.FieldDeletedAt) {
  24425. fields = append(fields, server.FieldDeletedAt)
  24426. }
  24427. return fields
  24428. }
  24429. // FieldCleared returns a boolean indicating if a field with the given name was
  24430. // cleared in this mutation.
  24431. func (m *ServerMutation) FieldCleared(name string) bool {
  24432. _, ok := m.clearedFields[name]
  24433. return ok
  24434. }
  24435. // ClearField clears the value of the field with the given name. It returns an
  24436. // error if the field is not defined in the schema.
  24437. func (m *ServerMutation) ClearField(name string) error {
  24438. switch name {
  24439. case server.FieldStatus:
  24440. m.ClearStatus()
  24441. return nil
  24442. case server.FieldDeletedAt:
  24443. m.ClearDeletedAt()
  24444. return nil
  24445. }
  24446. return fmt.Errorf("unknown Server nullable field %s", name)
  24447. }
  24448. // ResetField resets all changes in the mutation for the field with the given name.
  24449. // It returns an error if the field is not defined in the schema.
  24450. func (m *ServerMutation) ResetField(name string) error {
  24451. switch name {
  24452. case server.FieldCreatedAt:
  24453. m.ResetCreatedAt()
  24454. return nil
  24455. case server.FieldUpdatedAt:
  24456. m.ResetUpdatedAt()
  24457. return nil
  24458. case server.FieldStatus:
  24459. m.ResetStatus()
  24460. return nil
  24461. case server.FieldDeletedAt:
  24462. m.ResetDeletedAt()
  24463. return nil
  24464. case server.FieldName:
  24465. m.ResetName()
  24466. return nil
  24467. case server.FieldPublicIP:
  24468. m.ResetPublicIP()
  24469. return nil
  24470. case server.FieldPrivateIP:
  24471. m.ResetPrivateIP()
  24472. return nil
  24473. case server.FieldAdminPort:
  24474. m.ResetAdminPort()
  24475. return nil
  24476. }
  24477. return fmt.Errorf("unknown Server field %s", name)
  24478. }
  24479. // AddedEdges returns all edge names that were set/added in this mutation.
  24480. func (m *ServerMutation) AddedEdges() []string {
  24481. edges := make([]string, 0, 1)
  24482. if m.wxs != nil {
  24483. edges = append(edges, server.EdgeWxs)
  24484. }
  24485. return edges
  24486. }
  24487. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24488. // name in this mutation.
  24489. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  24490. switch name {
  24491. case server.EdgeWxs:
  24492. ids := make([]ent.Value, 0, len(m.wxs))
  24493. for id := range m.wxs {
  24494. ids = append(ids, id)
  24495. }
  24496. return ids
  24497. }
  24498. return nil
  24499. }
  24500. // RemovedEdges returns all edge names that were removed in this mutation.
  24501. func (m *ServerMutation) RemovedEdges() []string {
  24502. edges := make([]string, 0, 1)
  24503. if m.removedwxs != nil {
  24504. edges = append(edges, server.EdgeWxs)
  24505. }
  24506. return edges
  24507. }
  24508. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24509. // the given name in this mutation.
  24510. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  24511. switch name {
  24512. case server.EdgeWxs:
  24513. ids := make([]ent.Value, 0, len(m.removedwxs))
  24514. for id := range m.removedwxs {
  24515. ids = append(ids, id)
  24516. }
  24517. return ids
  24518. }
  24519. return nil
  24520. }
  24521. // ClearedEdges returns all edge names that were cleared in this mutation.
  24522. func (m *ServerMutation) ClearedEdges() []string {
  24523. edges := make([]string, 0, 1)
  24524. if m.clearedwxs {
  24525. edges = append(edges, server.EdgeWxs)
  24526. }
  24527. return edges
  24528. }
  24529. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24530. // was cleared in this mutation.
  24531. func (m *ServerMutation) EdgeCleared(name string) bool {
  24532. switch name {
  24533. case server.EdgeWxs:
  24534. return m.clearedwxs
  24535. }
  24536. return false
  24537. }
  24538. // ClearEdge clears the value of the edge with the given name. It returns an error
  24539. // if that edge is not defined in the schema.
  24540. func (m *ServerMutation) ClearEdge(name string) error {
  24541. switch name {
  24542. }
  24543. return fmt.Errorf("unknown Server unique edge %s", name)
  24544. }
  24545. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24546. // It returns an error if the edge is not defined in the schema.
  24547. func (m *ServerMutation) ResetEdge(name string) error {
  24548. switch name {
  24549. case server.EdgeWxs:
  24550. m.ResetWxs()
  24551. return nil
  24552. }
  24553. return fmt.Errorf("unknown Server edge %s", name)
  24554. }
  24555. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  24556. type SopNodeMutation struct {
  24557. config
  24558. op Op
  24559. typ string
  24560. id *uint64
  24561. created_at *time.Time
  24562. updated_at *time.Time
  24563. status *uint8
  24564. addstatus *int8
  24565. deleted_at *time.Time
  24566. parent_id *uint64
  24567. addparent_id *int64
  24568. name *string
  24569. condition_type *int
  24570. addcondition_type *int
  24571. condition_list *[]string
  24572. appendcondition_list []string
  24573. no_reply_condition *uint64
  24574. addno_reply_condition *int64
  24575. no_reply_unit *string
  24576. action_message *[]custom_types.Action
  24577. appendaction_message []custom_types.Action
  24578. action_label_add *[]uint64
  24579. appendaction_label_add []uint64
  24580. action_label_del *[]uint64
  24581. appendaction_label_del []uint64
  24582. action_forward **custom_types.ActionForward
  24583. clearedFields map[string]struct{}
  24584. sop_stage *uint64
  24585. clearedsop_stage bool
  24586. node_messages map[uint64]struct{}
  24587. removednode_messages map[uint64]struct{}
  24588. clearednode_messages bool
  24589. done bool
  24590. oldValue func(context.Context) (*SopNode, error)
  24591. predicates []predicate.SopNode
  24592. }
  24593. var _ ent.Mutation = (*SopNodeMutation)(nil)
  24594. // sopnodeOption allows management of the mutation configuration using functional options.
  24595. type sopnodeOption func(*SopNodeMutation)
  24596. // newSopNodeMutation creates new mutation for the SopNode entity.
  24597. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  24598. m := &SopNodeMutation{
  24599. config: c,
  24600. op: op,
  24601. typ: TypeSopNode,
  24602. clearedFields: make(map[string]struct{}),
  24603. }
  24604. for _, opt := range opts {
  24605. opt(m)
  24606. }
  24607. return m
  24608. }
  24609. // withSopNodeID sets the ID field of the mutation.
  24610. func withSopNodeID(id uint64) sopnodeOption {
  24611. return func(m *SopNodeMutation) {
  24612. var (
  24613. err error
  24614. once sync.Once
  24615. value *SopNode
  24616. )
  24617. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  24618. once.Do(func() {
  24619. if m.done {
  24620. err = errors.New("querying old values post mutation is not allowed")
  24621. } else {
  24622. value, err = m.Client().SopNode.Get(ctx, id)
  24623. }
  24624. })
  24625. return value, err
  24626. }
  24627. m.id = &id
  24628. }
  24629. }
  24630. // withSopNode sets the old SopNode of the mutation.
  24631. func withSopNode(node *SopNode) sopnodeOption {
  24632. return func(m *SopNodeMutation) {
  24633. m.oldValue = func(context.Context) (*SopNode, error) {
  24634. return node, nil
  24635. }
  24636. m.id = &node.ID
  24637. }
  24638. }
  24639. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24640. // executed in a transaction (ent.Tx), a transactional client is returned.
  24641. func (m SopNodeMutation) Client() *Client {
  24642. client := &Client{config: m.config}
  24643. client.init()
  24644. return client
  24645. }
  24646. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24647. // it returns an error otherwise.
  24648. func (m SopNodeMutation) Tx() (*Tx, error) {
  24649. if _, ok := m.driver.(*txDriver); !ok {
  24650. return nil, errors.New("ent: mutation is not running in a transaction")
  24651. }
  24652. tx := &Tx{config: m.config}
  24653. tx.init()
  24654. return tx, nil
  24655. }
  24656. // SetID sets the value of the id field. Note that this
  24657. // operation is only accepted on creation of SopNode entities.
  24658. func (m *SopNodeMutation) SetID(id uint64) {
  24659. m.id = &id
  24660. }
  24661. // ID returns the ID value in the mutation. Note that the ID is only available
  24662. // if it was provided to the builder or after it was returned from the database.
  24663. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  24664. if m.id == nil {
  24665. return
  24666. }
  24667. return *m.id, true
  24668. }
  24669. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24670. // That means, if the mutation is applied within a transaction with an isolation level such
  24671. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24672. // or updated by the mutation.
  24673. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  24674. switch {
  24675. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24676. id, exists := m.ID()
  24677. if exists {
  24678. return []uint64{id}, nil
  24679. }
  24680. fallthrough
  24681. case m.op.Is(OpUpdate | OpDelete):
  24682. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  24683. default:
  24684. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24685. }
  24686. }
  24687. // SetCreatedAt sets the "created_at" field.
  24688. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  24689. m.created_at = &t
  24690. }
  24691. // CreatedAt returns the value of the "created_at" field in the mutation.
  24692. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  24693. v := m.created_at
  24694. if v == nil {
  24695. return
  24696. }
  24697. return *v, true
  24698. }
  24699. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  24700. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24702. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24703. if !m.op.Is(OpUpdateOne) {
  24704. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24705. }
  24706. if m.id == nil || m.oldValue == nil {
  24707. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24708. }
  24709. oldValue, err := m.oldValue(ctx)
  24710. if err != nil {
  24711. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24712. }
  24713. return oldValue.CreatedAt, nil
  24714. }
  24715. // ResetCreatedAt resets all changes to the "created_at" field.
  24716. func (m *SopNodeMutation) ResetCreatedAt() {
  24717. m.created_at = nil
  24718. }
  24719. // SetUpdatedAt sets the "updated_at" field.
  24720. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  24721. m.updated_at = &t
  24722. }
  24723. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24724. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  24725. v := m.updated_at
  24726. if v == nil {
  24727. return
  24728. }
  24729. return *v, true
  24730. }
  24731. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  24732. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24734. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24735. if !m.op.Is(OpUpdateOne) {
  24736. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24737. }
  24738. if m.id == nil || m.oldValue == nil {
  24739. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24740. }
  24741. oldValue, err := m.oldValue(ctx)
  24742. if err != nil {
  24743. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24744. }
  24745. return oldValue.UpdatedAt, nil
  24746. }
  24747. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24748. func (m *SopNodeMutation) ResetUpdatedAt() {
  24749. m.updated_at = nil
  24750. }
  24751. // SetStatus sets the "status" field.
  24752. func (m *SopNodeMutation) SetStatus(u uint8) {
  24753. m.status = &u
  24754. m.addstatus = nil
  24755. }
  24756. // Status returns the value of the "status" field in the mutation.
  24757. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  24758. v := m.status
  24759. if v == nil {
  24760. return
  24761. }
  24762. return *v, true
  24763. }
  24764. // OldStatus returns the old "status" field's value of the SopNode entity.
  24765. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24767. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24768. if !m.op.Is(OpUpdateOne) {
  24769. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24770. }
  24771. if m.id == nil || m.oldValue == nil {
  24772. return v, errors.New("OldStatus requires an ID field in the mutation")
  24773. }
  24774. oldValue, err := m.oldValue(ctx)
  24775. if err != nil {
  24776. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24777. }
  24778. return oldValue.Status, nil
  24779. }
  24780. // AddStatus adds u to the "status" field.
  24781. func (m *SopNodeMutation) AddStatus(u int8) {
  24782. if m.addstatus != nil {
  24783. *m.addstatus += u
  24784. } else {
  24785. m.addstatus = &u
  24786. }
  24787. }
  24788. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24789. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  24790. v := m.addstatus
  24791. if v == nil {
  24792. return
  24793. }
  24794. return *v, true
  24795. }
  24796. // ClearStatus clears the value of the "status" field.
  24797. func (m *SopNodeMutation) ClearStatus() {
  24798. m.status = nil
  24799. m.addstatus = nil
  24800. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  24801. }
  24802. // StatusCleared returns if the "status" field was cleared in this mutation.
  24803. func (m *SopNodeMutation) StatusCleared() bool {
  24804. _, ok := m.clearedFields[sopnode.FieldStatus]
  24805. return ok
  24806. }
  24807. // ResetStatus resets all changes to the "status" field.
  24808. func (m *SopNodeMutation) ResetStatus() {
  24809. m.status = nil
  24810. m.addstatus = nil
  24811. delete(m.clearedFields, sopnode.FieldStatus)
  24812. }
  24813. // SetDeletedAt sets the "deleted_at" field.
  24814. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  24815. m.deleted_at = &t
  24816. }
  24817. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24818. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  24819. v := m.deleted_at
  24820. if v == nil {
  24821. return
  24822. }
  24823. return *v, true
  24824. }
  24825. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  24826. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24828. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24829. if !m.op.Is(OpUpdateOne) {
  24830. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24831. }
  24832. if m.id == nil || m.oldValue == nil {
  24833. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24834. }
  24835. oldValue, err := m.oldValue(ctx)
  24836. if err != nil {
  24837. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24838. }
  24839. return oldValue.DeletedAt, nil
  24840. }
  24841. // ClearDeletedAt clears the value of the "deleted_at" field.
  24842. func (m *SopNodeMutation) ClearDeletedAt() {
  24843. m.deleted_at = nil
  24844. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  24845. }
  24846. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24847. func (m *SopNodeMutation) DeletedAtCleared() bool {
  24848. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  24849. return ok
  24850. }
  24851. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24852. func (m *SopNodeMutation) ResetDeletedAt() {
  24853. m.deleted_at = nil
  24854. delete(m.clearedFields, sopnode.FieldDeletedAt)
  24855. }
  24856. // SetStageID sets the "stage_id" field.
  24857. func (m *SopNodeMutation) SetStageID(u uint64) {
  24858. m.sop_stage = &u
  24859. }
  24860. // StageID returns the value of the "stage_id" field in the mutation.
  24861. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  24862. v := m.sop_stage
  24863. if v == nil {
  24864. return
  24865. }
  24866. return *v, true
  24867. }
  24868. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  24869. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24871. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  24872. if !m.op.Is(OpUpdateOne) {
  24873. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  24874. }
  24875. if m.id == nil || m.oldValue == nil {
  24876. return v, errors.New("OldStageID requires an ID field in the mutation")
  24877. }
  24878. oldValue, err := m.oldValue(ctx)
  24879. if err != nil {
  24880. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  24881. }
  24882. return oldValue.StageID, nil
  24883. }
  24884. // ResetStageID resets all changes to the "stage_id" field.
  24885. func (m *SopNodeMutation) ResetStageID() {
  24886. m.sop_stage = nil
  24887. }
  24888. // SetParentID sets the "parent_id" field.
  24889. func (m *SopNodeMutation) SetParentID(u uint64) {
  24890. m.parent_id = &u
  24891. m.addparent_id = nil
  24892. }
  24893. // ParentID returns the value of the "parent_id" field in the mutation.
  24894. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  24895. v := m.parent_id
  24896. if v == nil {
  24897. return
  24898. }
  24899. return *v, true
  24900. }
  24901. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  24902. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24904. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  24905. if !m.op.Is(OpUpdateOne) {
  24906. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  24907. }
  24908. if m.id == nil || m.oldValue == nil {
  24909. return v, errors.New("OldParentID requires an ID field in the mutation")
  24910. }
  24911. oldValue, err := m.oldValue(ctx)
  24912. if err != nil {
  24913. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  24914. }
  24915. return oldValue.ParentID, nil
  24916. }
  24917. // AddParentID adds u to the "parent_id" field.
  24918. func (m *SopNodeMutation) AddParentID(u int64) {
  24919. if m.addparent_id != nil {
  24920. *m.addparent_id += u
  24921. } else {
  24922. m.addparent_id = &u
  24923. }
  24924. }
  24925. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  24926. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  24927. v := m.addparent_id
  24928. if v == nil {
  24929. return
  24930. }
  24931. return *v, true
  24932. }
  24933. // ResetParentID resets all changes to the "parent_id" field.
  24934. func (m *SopNodeMutation) ResetParentID() {
  24935. m.parent_id = nil
  24936. m.addparent_id = nil
  24937. }
  24938. // SetName sets the "name" field.
  24939. func (m *SopNodeMutation) SetName(s string) {
  24940. m.name = &s
  24941. }
  24942. // Name returns the value of the "name" field in the mutation.
  24943. func (m *SopNodeMutation) Name() (r string, exists bool) {
  24944. v := m.name
  24945. if v == nil {
  24946. return
  24947. }
  24948. return *v, true
  24949. }
  24950. // OldName returns the old "name" field's value of the SopNode entity.
  24951. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24953. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  24954. if !m.op.Is(OpUpdateOne) {
  24955. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24956. }
  24957. if m.id == nil || m.oldValue == nil {
  24958. return v, errors.New("OldName requires an ID field in the mutation")
  24959. }
  24960. oldValue, err := m.oldValue(ctx)
  24961. if err != nil {
  24962. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24963. }
  24964. return oldValue.Name, nil
  24965. }
  24966. // ResetName resets all changes to the "name" field.
  24967. func (m *SopNodeMutation) ResetName() {
  24968. m.name = nil
  24969. }
  24970. // SetConditionType sets the "condition_type" field.
  24971. func (m *SopNodeMutation) SetConditionType(i int) {
  24972. m.condition_type = &i
  24973. m.addcondition_type = nil
  24974. }
  24975. // ConditionType returns the value of the "condition_type" field in the mutation.
  24976. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  24977. v := m.condition_type
  24978. if v == nil {
  24979. return
  24980. }
  24981. return *v, true
  24982. }
  24983. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  24984. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24986. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  24987. if !m.op.Is(OpUpdateOne) {
  24988. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  24989. }
  24990. if m.id == nil || m.oldValue == nil {
  24991. return v, errors.New("OldConditionType requires an ID field in the mutation")
  24992. }
  24993. oldValue, err := m.oldValue(ctx)
  24994. if err != nil {
  24995. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  24996. }
  24997. return oldValue.ConditionType, nil
  24998. }
  24999. // AddConditionType adds i to the "condition_type" field.
  25000. func (m *SopNodeMutation) AddConditionType(i int) {
  25001. if m.addcondition_type != nil {
  25002. *m.addcondition_type += i
  25003. } else {
  25004. m.addcondition_type = &i
  25005. }
  25006. }
  25007. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  25008. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  25009. v := m.addcondition_type
  25010. if v == nil {
  25011. return
  25012. }
  25013. return *v, true
  25014. }
  25015. // ResetConditionType resets all changes to the "condition_type" field.
  25016. func (m *SopNodeMutation) ResetConditionType() {
  25017. m.condition_type = nil
  25018. m.addcondition_type = nil
  25019. }
  25020. // SetConditionList sets the "condition_list" field.
  25021. func (m *SopNodeMutation) SetConditionList(s []string) {
  25022. m.condition_list = &s
  25023. m.appendcondition_list = nil
  25024. }
  25025. // ConditionList returns the value of the "condition_list" field in the mutation.
  25026. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  25027. v := m.condition_list
  25028. if v == nil {
  25029. return
  25030. }
  25031. return *v, true
  25032. }
  25033. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  25034. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25036. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  25037. if !m.op.Is(OpUpdateOne) {
  25038. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  25039. }
  25040. if m.id == nil || m.oldValue == nil {
  25041. return v, errors.New("OldConditionList requires an ID field in the mutation")
  25042. }
  25043. oldValue, err := m.oldValue(ctx)
  25044. if err != nil {
  25045. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  25046. }
  25047. return oldValue.ConditionList, nil
  25048. }
  25049. // AppendConditionList adds s to the "condition_list" field.
  25050. func (m *SopNodeMutation) AppendConditionList(s []string) {
  25051. m.appendcondition_list = append(m.appendcondition_list, s...)
  25052. }
  25053. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25054. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  25055. if len(m.appendcondition_list) == 0 {
  25056. return nil, false
  25057. }
  25058. return m.appendcondition_list, true
  25059. }
  25060. // ClearConditionList clears the value of the "condition_list" field.
  25061. func (m *SopNodeMutation) ClearConditionList() {
  25062. m.condition_list = nil
  25063. m.appendcondition_list = nil
  25064. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  25065. }
  25066. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  25067. func (m *SopNodeMutation) ConditionListCleared() bool {
  25068. _, ok := m.clearedFields[sopnode.FieldConditionList]
  25069. return ok
  25070. }
  25071. // ResetConditionList resets all changes to the "condition_list" field.
  25072. func (m *SopNodeMutation) ResetConditionList() {
  25073. m.condition_list = nil
  25074. m.appendcondition_list = nil
  25075. delete(m.clearedFields, sopnode.FieldConditionList)
  25076. }
  25077. // SetNoReplyCondition sets the "no_reply_condition" field.
  25078. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  25079. m.no_reply_condition = &u
  25080. m.addno_reply_condition = nil
  25081. }
  25082. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  25083. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  25084. v := m.no_reply_condition
  25085. if v == nil {
  25086. return
  25087. }
  25088. return *v, true
  25089. }
  25090. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  25091. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25093. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  25094. if !m.op.Is(OpUpdateOne) {
  25095. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  25096. }
  25097. if m.id == nil || m.oldValue == nil {
  25098. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  25099. }
  25100. oldValue, err := m.oldValue(ctx)
  25101. if err != nil {
  25102. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  25103. }
  25104. return oldValue.NoReplyCondition, nil
  25105. }
  25106. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  25107. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  25108. if m.addno_reply_condition != nil {
  25109. *m.addno_reply_condition += u
  25110. } else {
  25111. m.addno_reply_condition = &u
  25112. }
  25113. }
  25114. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  25115. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  25116. v := m.addno_reply_condition
  25117. if v == nil {
  25118. return
  25119. }
  25120. return *v, true
  25121. }
  25122. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  25123. func (m *SopNodeMutation) ResetNoReplyCondition() {
  25124. m.no_reply_condition = nil
  25125. m.addno_reply_condition = nil
  25126. }
  25127. // SetNoReplyUnit sets the "no_reply_unit" field.
  25128. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  25129. m.no_reply_unit = &s
  25130. }
  25131. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  25132. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  25133. v := m.no_reply_unit
  25134. if v == nil {
  25135. return
  25136. }
  25137. return *v, true
  25138. }
  25139. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  25140. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25142. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  25143. if !m.op.Is(OpUpdateOne) {
  25144. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  25145. }
  25146. if m.id == nil || m.oldValue == nil {
  25147. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  25148. }
  25149. oldValue, err := m.oldValue(ctx)
  25150. if err != nil {
  25151. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  25152. }
  25153. return oldValue.NoReplyUnit, nil
  25154. }
  25155. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  25156. func (m *SopNodeMutation) ResetNoReplyUnit() {
  25157. m.no_reply_unit = nil
  25158. }
  25159. // SetActionMessage sets the "action_message" field.
  25160. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  25161. m.action_message = &ct
  25162. m.appendaction_message = nil
  25163. }
  25164. // ActionMessage returns the value of the "action_message" field in the mutation.
  25165. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  25166. v := m.action_message
  25167. if v == nil {
  25168. return
  25169. }
  25170. return *v, true
  25171. }
  25172. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  25173. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25175. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25176. if !m.op.Is(OpUpdateOne) {
  25177. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25178. }
  25179. if m.id == nil || m.oldValue == nil {
  25180. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25181. }
  25182. oldValue, err := m.oldValue(ctx)
  25183. if err != nil {
  25184. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25185. }
  25186. return oldValue.ActionMessage, nil
  25187. }
  25188. // AppendActionMessage adds ct to the "action_message" field.
  25189. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  25190. m.appendaction_message = append(m.appendaction_message, ct...)
  25191. }
  25192. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25193. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25194. if len(m.appendaction_message) == 0 {
  25195. return nil, false
  25196. }
  25197. return m.appendaction_message, true
  25198. }
  25199. // ClearActionMessage clears the value of the "action_message" field.
  25200. func (m *SopNodeMutation) ClearActionMessage() {
  25201. m.action_message = nil
  25202. m.appendaction_message = nil
  25203. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  25204. }
  25205. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25206. func (m *SopNodeMutation) ActionMessageCleared() bool {
  25207. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  25208. return ok
  25209. }
  25210. // ResetActionMessage resets all changes to the "action_message" field.
  25211. func (m *SopNodeMutation) ResetActionMessage() {
  25212. m.action_message = nil
  25213. m.appendaction_message = nil
  25214. delete(m.clearedFields, sopnode.FieldActionMessage)
  25215. }
  25216. // SetActionLabelAdd sets the "action_label_add" field.
  25217. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  25218. m.action_label_add = &u
  25219. m.appendaction_label_add = nil
  25220. }
  25221. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25222. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25223. v := m.action_label_add
  25224. if v == nil {
  25225. return
  25226. }
  25227. return *v, true
  25228. }
  25229. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  25230. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25232. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25233. if !m.op.Is(OpUpdateOne) {
  25234. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25235. }
  25236. if m.id == nil || m.oldValue == nil {
  25237. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25238. }
  25239. oldValue, err := m.oldValue(ctx)
  25240. if err != nil {
  25241. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25242. }
  25243. return oldValue.ActionLabelAdd, nil
  25244. }
  25245. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25246. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  25247. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25248. }
  25249. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25250. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25251. if len(m.appendaction_label_add) == 0 {
  25252. return nil, false
  25253. }
  25254. return m.appendaction_label_add, true
  25255. }
  25256. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25257. func (m *SopNodeMutation) ClearActionLabelAdd() {
  25258. m.action_label_add = nil
  25259. m.appendaction_label_add = nil
  25260. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  25261. }
  25262. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25263. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  25264. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  25265. return ok
  25266. }
  25267. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25268. func (m *SopNodeMutation) ResetActionLabelAdd() {
  25269. m.action_label_add = nil
  25270. m.appendaction_label_add = nil
  25271. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  25272. }
  25273. // SetActionLabelDel sets the "action_label_del" field.
  25274. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  25275. m.action_label_del = &u
  25276. m.appendaction_label_del = nil
  25277. }
  25278. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25279. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  25280. v := m.action_label_del
  25281. if v == nil {
  25282. return
  25283. }
  25284. return *v, true
  25285. }
  25286. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  25287. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25289. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25290. if !m.op.Is(OpUpdateOne) {
  25291. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25292. }
  25293. if m.id == nil || m.oldValue == nil {
  25294. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25295. }
  25296. oldValue, err := m.oldValue(ctx)
  25297. if err != nil {
  25298. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25299. }
  25300. return oldValue.ActionLabelDel, nil
  25301. }
  25302. // AppendActionLabelDel adds u to the "action_label_del" field.
  25303. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  25304. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25305. }
  25306. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25307. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25308. if len(m.appendaction_label_del) == 0 {
  25309. return nil, false
  25310. }
  25311. return m.appendaction_label_del, true
  25312. }
  25313. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25314. func (m *SopNodeMutation) ClearActionLabelDel() {
  25315. m.action_label_del = nil
  25316. m.appendaction_label_del = nil
  25317. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  25318. }
  25319. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25320. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  25321. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  25322. return ok
  25323. }
  25324. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25325. func (m *SopNodeMutation) ResetActionLabelDel() {
  25326. m.action_label_del = nil
  25327. m.appendaction_label_del = nil
  25328. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  25329. }
  25330. // SetActionForward sets the "action_forward" field.
  25331. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25332. m.action_forward = &ctf
  25333. }
  25334. // ActionForward returns the value of the "action_forward" field in the mutation.
  25335. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25336. v := m.action_forward
  25337. if v == nil {
  25338. return
  25339. }
  25340. return *v, true
  25341. }
  25342. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  25343. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25345. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25346. if !m.op.Is(OpUpdateOne) {
  25347. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25348. }
  25349. if m.id == nil || m.oldValue == nil {
  25350. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25351. }
  25352. oldValue, err := m.oldValue(ctx)
  25353. if err != nil {
  25354. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25355. }
  25356. return oldValue.ActionForward, nil
  25357. }
  25358. // ClearActionForward clears the value of the "action_forward" field.
  25359. func (m *SopNodeMutation) ClearActionForward() {
  25360. m.action_forward = nil
  25361. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  25362. }
  25363. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25364. func (m *SopNodeMutation) ActionForwardCleared() bool {
  25365. _, ok := m.clearedFields[sopnode.FieldActionForward]
  25366. return ok
  25367. }
  25368. // ResetActionForward resets all changes to the "action_forward" field.
  25369. func (m *SopNodeMutation) ResetActionForward() {
  25370. m.action_forward = nil
  25371. delete(m.clearedFields, sopnode.FieldActionForward)
  25372. }
  25373. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  25374. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  25375. m.sop_stage = &id
  25376. }
  25377. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  25378. func (m *SopNodeMutation) ClearSopStage() {
  25379. m.clearedsop_stage = true
  25380. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  25381. }
  25382. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  25383. func (m *SopNodeMutation) SopStageCleared() bool {
  25384. return m.clearedsop_stage
  25385. }
  25386. // SopStageID returns the "sop_stage" edge ID in the mutation.
  25387. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  25388. if m.sop_stage != nil {
  25389. return *m.sop_stage, true
  25390. }
  25391. return
  25392. }
  25393. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  25394. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25395. // SopStageID instead. It exists only for internal usage by the builders.
  25396. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  25397. if id := m.sop_stage; id != nil {
  25398. ids = append(ids, *id)
  25399. }
  25400. return
  25401. }
  25402. // ResetSopStage resets all changes to the "sop_stage" edge.
  25403. func (m *SopNodeMutation) ResetSopStage() {
  25404. m.sop_stage = nil
  25405. m.clearedsop_stage = false
  25406. }
  25407. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  25408. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  25409. if m.node_messages == nil {
  25410. m.node_messages = make(map[uint64]struct{})
  25411. }
  25412. for i := range ids {
  25413. m.node_messages[ids[i]] = struct{}{}
  25414. }
  25415. }
  25416. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  25417. func (m *SopNodeMutation) ClearNodeMessages() {
  25418. m.clearednode_messages = true
  25419. }
  25420. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  25421. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  25422. return m.clearednode_messages
  25423. }
  25424. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  25425. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  25426. if m.removednode_messages == nil {
  25427. m.removednode_messages = make(map[uint64]struct{})
  25428. }
  25429. for i := range ids {
  25430. delete(m.node_messages, ids[i])
  25431. m.removednode_messages[ids[i]] = struct{}{}
  25432. }
  25433. }
  25434. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  25435. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  25436. for id := range m.removednode_messages {
  25437. ids = append(ids, id)
  25438. }
  25439. return
  25440. }
  25441. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  25442. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  25443. for id := range m.node_messages {
  25444. ids = append(ids, id)
  25445. }
  25446. return
  25447. }
  25448. // ResetNodeMessages resets all changes to the "node_messages" edge.
  25449. func (m *SopNodeMutation) ResetNodeMessages() {
  25450. m.node_messages = nil
  25451. m.clearednode_messages = false
  25452. m.removednode_messages = nil
  25453. }
  25454. // Where appends a list predicates to the SopNodeMutation builder.
  25455. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  25456. m.predicates = append(m.predicates, ps...)
  25457. }
  25458. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  25459. // users can use type-assertion to append predicates that do not depend on any generated package.
  25460. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  25461. p := make([]predicate.SopNode, len(ps))
  25462. for i := range ps {
  25463. p[i] = ps[i]
  25464. }
  25465. m.Where(p...)
  25466. }
  25467. // Op returns the operation name.
  25468. func (m *SopNodeMutation) Op() Op {
  25469. return m.op
  25470. }
  25471. // SetOp allows setting the mutation operation.
  25472. func (m *SopNodeMutation) SetOp(op Op) {
  25473. m.op = op
  25474. }
  25475. // Type returns the node type of this mutation (SopNode).
  25476. func (m *SopNodeMutation) Type() string {
  25477. return m.typ
  25478. }
  25479. // Fields returns all fields that were changed during this mutation. Note that in
  25480. // order to get all numeric fields that were incremented/decremented, call
  25481. // AddedFields().
  25482. func (m *SopNodeMutation) Fields() []string {
  25483. fields := make([]string, 0, 15)
  25484. if m.created_at != nil {
  25485. fields = append(fields, sopnode.FieldCreatedAt)
  25486. }
  25487. if m.updated_at != nil {
  25488. fields = append(fields, sopnode.FieldUpdatedAt)
  25489. }
  25490. if m.status != nil {
  25491. fields = append(fields, sopnode.FieldStatus)
  25492. }
  25493. if m.deleted_at != nil {
  25494. fields = append(fields, sopnode.FieldDeletedAt)
  25495. }
  25496. if m.sop_stage != nil {
  25497. fields = append(fields, sopnode.FieldStageID)
  25498. }
  25499. if m.parent_id != nil {
  25500. fields = append(fields, sopnode.FieldParentID)
  25501. }
  25502. if m.name != nil {
  25503. fields = append(fields, sopnode.FieldName)
  25504. }
  25505. if m.condition_type != nil {
  25506. fields = append(fields, sopnode.FieldConditionType)
  25507. }
  25508. if m.condition_list != nil {
  25509. fields = append(fields, sopnode.FieldConditionList)
  25510. }
  25511. if m.no_reply_condition != nil {
  25512. fields = append(fields, sopnode.FieldNoReplyCondition)
  25513. }
  25514. if m.no_reply_unit != nil {
  25515. fields = append(fields, sopnode.FieldNoReplyUnit)
  25516. }
  25517. if m.action_message != nil {
  25518. fields = append(fields, sopnode.FieldActionMessage)
  25519. }
  25520. if m.action_label_add != nil {
  25521. fields = append(fields, sopnode.FieldActionLabelAdd)
  25522. }
  25523. if m.action_label_del != nil {
  25524. fields = append(fields, sopnode.FieldActionLabelDel)
  25525. }
  25526. if m.action_forward != nil {
  25527. fields = append(fields, sopnode.FieldActionForward)
  25528. }
  25529. return fields
  25530. }
  25531. // Field returns the value of a field with the given name. The second boolean
  25532. // return value indicates that this field was not set, or was not defined in the
  25533. // schema.
  25534. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  25535. switch name {
  25536. case sopnode.FieldCreatedAt:
  25537. return m.CreatedAt()
  25538. case sopnode.FieldUpdatedAt:
  25539. return m.UpdatedAt()
  25540. case sopnode.FieldStatus:
  25541. return m.Status()
  25542. case sopnode.FieldDeletedAt:
  25543. return m.DeletedAt()
  25544. case sopnode.FieldStageID:
  25545. return m.StageID()
  25546. case sopnode.FieldParentID:
  25547. return m.ParentID()
  25548. case sopnode.FieldName:
  25549. return m.Name()
  25550. case sopnode.FieldConditionType:
  25551. return m.ConditionType()
  25552. case sopnode.FieldConditionList:
  25553. return m.ConditionList()
  25554. case sopnode.FieldNoReplyCondition:
  25555. return m.NoReplyCondition()
  25556. case sopnode.FieldNoReplyUnit:
  25557. return m.NoReplyUnit()
  25558. case sopnode.FieldActionMessage:
  25559. return m.ActionMessage()
  25560. case sopnode.FieldActionLabelAdd:
  25561. return m.ActionLabelAdd()
  25562. case sopnode.FieldActionLabelDel:
  25563. return m.ActionLabelDel()
  25564. case sopnode.FieldActionForward:
  25565. return m.ActionForward()
  25566. }
  25567. return nil, false
  25568. }
  25569. // OldField returns the old value of the field from the database. An error is
  25570. // returned if the mutation operation is not UpdateOne, or the query to the
  25571. // database failed.
  25572. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25573. switch name {
  25574. case sopnode.FieldCreatedAt:
  25575. return m.OldCreatedAt(ctx)
  25576. case sopnode.FieldUpdatedAt:
  25577. return m.OldUpdatedAt(ctx)
  25578. case sopnode.FieldStatus:
  25579. return m.OldStatus(ctx)
  25580. case sopnode.FieldDeletedAt:
  25581. return m.OldDeletedAt(ctx)
  25582. case sopnode.FieldStageID:
  25583. return m.OldStageID(ctx)
  25584. case sopnode.FieldParentID:
  25585. return m.OldParentID(ctx)
  25586. case sopnode.FieldName:
  25587. return m.OldName(ctx)
  25588. case sopnode.FieldConditionType:
  25589. return m.OldConditionType(ctx)
  25590. case sopnode.FieldConditionList:
  25591. return m.OldConditionList(ctx)
  25592. case sopnode.FieldNoReplyCondition:
  25593. return m.OldNoReplyCondition(ctx)
  25594. case sopnode.FieldNoReplyUnit:
  25595. return m.OldNoReplyUnit(ctx)
  25596. case sopnode.FieldActionMessage:
  25597. return m.OldActionMessage(ctx)
  25598. case sopnode.FieldActionLabelAdd:
  25599. return m.OldActionLabelAdd(ctx)
  25600. case sopnode.FieldActionLabelDel:
  25601. return m.OldActionLabelDel(ctx)
  25602. case sopnode.FieldActionForward:
  25603. return m.OldActionForward(ctx)
  25604. }
  25605. return nil, fmt.Errorf("unknown SopNode field %s", name)
  25606. }
  25607. // SetField sets the value of a field with the given name. It returns an error if
  25608. // the field is not defined in the schema, or if the type mismatched the field
  25609. // type.
  25610. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  25611. switch name {
  25612. case sopnode.FieldCreatedAt:
  25613. v, ok := value.(time.Time)
  25614. if !ok {
  25615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25616. }
  25617. m.SetCreatedAt(v)
  25618. return nil
  25619. case sopnode.FieldUpdatedAt:
  25620. v, ok := value.(time.Time)
  25621. if !ok {
  25622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25623. }
  25624. m.SetUpdatedAt(v)
  25625. return nil
  25626. case sopnode.FieldStatus:
  25627. v, ok := value.(uint8)
  25628. if !ok {
  25629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25630. }
  25631. m.SetStatus(v)
  25632. return nil
  25633. case sopnode.FieldDeletedAt:
  25634. v, ok := value.(time.Time)
  25635. if !ok {
  25636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25637. }
  25638. m.SetDeletedAt(v)
  25639. return nil
  25640. case sopnode.FieldStageID:
  25641. v, ok := value.(uint64)
  25642. if !ok {
  25643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25644. }
  25645. m.SetStageID(v)
  25646. return nil
  25647. case sopnode.FieldParentID:
  25648. v, ok := value.(uint64)
  25649. if !ok {
  25650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25651. }
  25652. m.SetParentID(v)
  25653. return nil
  25654. case sopnode.FieldName:
  25655. v, ok := value.(string)
  25656. if !ok {
  25657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25658. }
  25659. m.SetName(v)
  25660. return nil
  25661. case sopnode.FieldConditionType:
  25662. v, ok := value.(int)
  25663. if !ok {
  25664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25665. }
  25666. m.SetConditionType(v)
  25667. return nil
  25668. case sopnode.FieldConditionList:
  25669. v, ok := value.([]string)
  25670. if !ok {
  25671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25672. }
  25673. m.SetConditionList(v)
  25674. return nil
  25675. case sopnode.FieldNoReplyCondition:
  25676. v, ok := value.(uint64)
  25677. if !ok {
  25678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25679. }
  25680. m.SetNoReplyCondition(v)
  25681. return nil
  25682. case sopnode.FieldNoReplyUnit:
  25683. v, ok := value.(string)
  25684. if !ok {
  25685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25686. }
  25687. m.SetNoReplyUnit(v)
  25688. return nil
  25689. case sopnode.FieldActionMessage:
  25690. v, ok := value.([]custom_types.Action)
  25691. if !ok {
  25692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25693. }
  25694. m.SetActionMessage(v)
  25695. return nil
  25696. case sopnode.FieldActionLabelAdd:
  25697. v, ok := value.([]uint64)
  25698. if !ok {
  25699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25700. }
  25701. m.SetActionLabelAdd(v)
  25702. return nil
  25703. case sopnode.FieldActionLabelDel:
  25704. v, ok := value.([]uint64)
  25705. if !ok {
  25706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25707. }
  25708. m.SetActionLabelDel(v)
  25709. return nil
  25710. case sopnode.FieldActionForward:
  25711. v, ok := value.(*custom_types.ActionForward)
  25712. if !ok {
  25713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25714. }
  25715. m.SetActionForward(v)
  25716. return nil
  25717. }
  25718. return fmt.Errorf("unknown SopNode field %s", name)
  25719. }
  25720. // AddedFields returns all numeric fields that were incremented/decremented during
  25721. // this mutation.
  25722. func (m *SopNodeMutation) AddedFields() []string {
  25723. var fields []string
  25724. if m.addstatus != nil {
  25725. fields = append(fields, sopnode.FieldStatus)
  25726. }
  25727. if m.addparent_id != nil {
  25728. fields = append(fields, sopnode.FieldParentID)
  25729. }
  25730. if m.addcondition_type != nil {
  25731. fields = append(fields, sopnode.FieldConditionType)
  25732. }
  25733. if m.addno_reply_condition != nil {
  25734. fields = append(fields, sopnode.FieldNoReplyCondition)
  25735. }
  25736. return fields
  25737. }
  25738. // AddedField returns the numeric value that was incremented/decremented on a field
  25739. // with the given name. The second boolean return value indicates that this field
  25740. // was not set, or was not defined in the schema.
  25741. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  25742. switch name {
  25743. case sopnode.FieldStatus:
  25744. return m.AddedStatus()
  25745. case sopnode.FieldParentID:
  25746. return m.AddedParentID()
  25747. case sopnode.FieldConditionType:
  25748. return m.AddedConditionType()
  25749. case sopnode.FieldNoReplyCondition:
  25750. return m.AddedNoReplyCondition()
  25751. }
  25752. return nil, false
  25753. }
  25754. // AddField adds the value to the field with the given name. It returns an error if
  25755. // the field is not defined in the schema, or if the type mismatched the field
  25756. // type.
  25757. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  25758. switch name {
  25759. case sopnode.FieldStatus:
  25760. v, ok := value.(int8)
  25761. if !ok {
  25762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25763. }
  25764. m.AddStatus(v)
  25765. return nil
  25766. case sopnode.FieldParentID:
  25767. v, ok := value.(int64)
  25768. if !ok {
  25769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25770. }
  25771. m.AddParentID(v)
  25772. return nil
  25773. case sopnode.FieldConditionType:
  25774. v, ok := value.(int)
  25775. if !ok {
  25776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25777. }
  25778. m.AddConditionType(v)
  25779. return nil
  25780. case sopnode.FieldNoReplyCondition:
  25781. v, ok := value.(int64)
  25782. if !ok {
  25783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25784. }
  25785. m.AddNoReplyCondition(v)
  25786. return nil
  25787. }
  25788. return fmt.Errorf("unknown SopNode numeric field %s", name)
  25789. }
  25790. // ClearedFields returns all nullable fields that were cleared during this
  25791. // mutation.
  25792. func (m *SopNodeMutation) ClearedFields() []string {
  25793. var fields []string
  25794. if m.FieldCleared(sopnode.FieldStatus) {
  25795. fields = append(fields, sopnode.FieldStatus)
  25796. }
  25797. if m.FieldCleared(sopnode.FieldDeletedAt) {
  25798. fields = append(fields, sopnode.FieldDeletedAt)
  25799. }
  25800. if m.FieldCleared(sopnode.FieldConditionList) {
  25801. fields = append(fields, sopnode.FieldConditionList)
  25802. }
  25803. if m.FieldCleared(sopnode.FieldActionMessage) {
  25804. fields = append(fields, sopnode.FieldActionMessage)
  25805. }
  25806. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  25807. fields = append(fields, sopnode.FieldActionLabelAdd)
  25808. }
  25809. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  25810. fields = append(fields, sopnode.FieldActionLabelDel)
  25811. }
  25812. if m.FieldCleared(sopnode.FieldActionForward) {
  25813. fields = append(fields, sopnode.FieldActionForward)
  25814. }
  25815. return fields
  25816. }
  25817. // FieldCleared returns a boolean indicating if a field with the given name was
  25818. // cleared in this mutation.
  25819. func (m *SopNodeMutation) FieldCleared(name string) bool {
  25820. _, ok := m.clearedFields[name]
  25821. return ok
  25822. }
  25823. // ClearField clears the value of the field with the given name. It returns an
  25824. // error if the field is not defined in the schema.
  25825. func (m *SopNodeMutation) ClearField(name string) error {
  25826. switch name {
  25827. case sopnode.FieldStatus:
  25828. m.ClearStatus()
  25829. return nil
  25830. case sopnode.FieldDeletedAt:
  25831. m.ClearDeletedAt()
  25832. return nil
  25833. case sopnode.FieldConditionList:
  25834. m.ClearConditionList()
  25835. return nil
  25836. case sopnode.FieldActionMessage:
  25837. m.ClearActionMessage()
  25838. return nil
  25839. case sopnode.FieldActionLabelAdd:
  25840. m.ClearActionLabelAdd()
  25841. return nil
  25842. case sopnode.FieldActionLabelDel:
  25843. m.ClearActionLabelDel()
  25844. return nil
  25845. case sopnode.FieldActionForward:
  25846. m.ClearActionForward()
  25847. return nil
  25848. }
  25849. return fmt.Errorf("unknown SopNode nullable field %s", name)
  25850. }
  25851. // ResetField resets all changes in the mutation for the field with the given name.
  25852. // It returns an error if the field is not defined in the schema.
  25853. func (m *SopNodeMutation) ResetField(name string) error {
  25854. switch name {
  25855. case sopnode.FieldCreatedAt:
  25856. m.ResetCreatedAt()
  25857. return nil
  25858. case sopnode.FieldUpdatedAt:
  25859. m.ResetUpdatedAt()
  25860. return nil
  25861. case sopnode.FieldStatus:
  25862. m.ResetStatus()
  25863. return nil
  25864. case sopnode.FieldDeletedAt:
  25865. m.ResetDeletedAt()
  25866. return nil
  25867. case sopnode.FieldStageID:
  25868. m.ResetStageID()
  25869. return nil
  25870. case sopnode.FieldParentID:
  25871. m.ResetParentID()
  25872. return nil
  25873. case sopnode.FieldName:
  25874. m.ResetName()
  25875. return nil
  25876. case sopnode.FieldConditionType:
  25877. m.ResetConditionType()
  25878. return nil
  25879. case sopnode.FieldConditionList:
  25880. m.ResetConditionList()
  25881. return nil
  25882. case sopnode.FieldNoReplyCondition:
  25883. m.ResetNoReplyCondition()
  25884. return nil
  25885. case sopnode.FieldNoReplyUnit:
  25886. m.ResetNoReplyUnit()
  25887. return nil
  25888. case sopnode.FieldActionMessage:
  25889. m.ResetActionMessage()
  25890. return nil
  25891. case sopnode.FieldActionLabelAdd:
  25892. m.ResetActionLabelAdd()
  25893. return nil
  25894. case sopnode.FieldActionLabelDel:
  25895. m.ResetActionLabelDel()
  25896. return nil
  25897. case sopnode.FieldActionForward:
  25898. m.ResetActionForward()
  25899. return nil
  25900. }
  25901. return fmt.Errorf("unknown SopNode field %s", name)
  25902. }
  25903. // AddedEdges returns all edge names that were set/added in this mutation.
  25904. func (m *SopNodeMutation) AddedEdges() []string {
  25905. edges := make([]string, 0, 2)
  25906. if m.sop_stage != nil {
  25907. edges = append(edges, sopnode.EdgeSopStage)
  25908. }
  25909. if m.node_messages != nil {
  25910. edges = append(edges, sopnode.EdgeNodeMessages)
  25911. }
  25912. return edges
  25913. }
  25914. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25915. // name in this mutation.
  25916. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  25917. switch name {
  25918. case sopnode.EdgeSopStage:
  25919. if id := m.sop_stage; id != nil {
  25920. return []ent.Value{*id}
  25921. }
  25922. case sopnode.EdgeNodeMessages:
  25923. ids := make([]ent.Value, 0, len(m.node_messages))
  25924. for id := range m.node_messages {
  25925. ids = append(ids, id)
  25926. }
  25927. return ids
  25928. }
  25929. return nil
  25930. }
  25931. // RemovedEdges returns all edge names that were removed in this mutation.
  25932. func (m *SopNodeMutation) RemovedEdges() []string {
  25933. edges := make([]string, 0, 2)
  25934. if m.removednode_messages != nil {
  25935. edges = append(edges, sopnode.EdgeNodeMessages)
  25936. }
  25937. return edges
  25938. }
  25939. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25940. // the given name in this mutation.
  25941. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  25942. switch name {
  25943. case sopnode.EdgeNodeMessages:
  25944. ids := make([]ent.Value, 0, len(m.removednode_messages))
  25945. for id := range m.removednode_messages {
  25946. ids = append(ids, id)
  25947. }
  25948. return ids
  25949. }
  25950. return nil
  25951. }
  25952. // ClearedEdges returns all edge names that were cleared in this mutation.
  25953. func (m *SopNodeMutation) ClearedEdges() []string {
  25954. edges := make([]string, 0, 2)
  25955. if m.clearedsop_stage {
  25956. edges = append(edges, sopnode.EdgeSopStage)
  25957. }
  25958. if m.clearednode_messages {
  25959. edges = append(edges, sopnode.EdgeNodeMessages)
  25960. }
  25961. return edges
  25962. }
  25963. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25964. // was cleared in this mutation.
  25965. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  25966. switch name {
  25967. case sopnode.EdgeSopStage:
  25968. return m.clearedsop_stage
  25969. case sopnode.EdgeNodeMessages:
  25970. return m.clearednode_messages
  25971. }
  25972. return false
  25973. }
  25974. // ClearEdge clears the value of the edge with the given name. It returns an error
  25975. // if that edge is not defined in the schema.
  25976. func (m *SopNodeMutation) ClearEdge(name string) error {
  25977. switch name {
  25978. case sopnode.EdgeSopStage:
  25979. m.ClearSopStage()
  25980. return nil
  25981. }
  25982. return fmt.Errorf("unknown SopNode unique edge %s", name)
  25983. }
  25984. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25985. // It returns an error if the edge is not defined in the schema.
  25986. func (m *SopNodeMutation) ResetEdge(name string) error {
  25987. switch name {
  25988. case sopnode.EdgeSopStage:
  25989. m.ResetSopStage()
  25990. return nil
  25991. case sopnode.EdgeNodeMessages:
  25992. m.ResetNodeMessages()
  25993. return nil
  25994. }
  25995. return fmt.Errorf("unknown SopNode edge %s", name)
  25996. }
  25997. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  25998. type SopStageMutation struct {
  25999. config
  26000. op Op
  26001. typ string
  26002. id *uint64
  26003. created_at *time.Time
  26004. updated_at *time.Time
  26005. status *uint8
  26006. addstatus *int8
  26007. deleted_at *time.Time
  26008. name *string
  26009. condition_type *int
  26010. addcondition_type *int
  26011. condition_operator *int
  26012. addcondition_operator *int
  26013. condition_list *[]custom_types.Condition
  26014. appendcondition_list []custom_types.Condition
  26015. action_message *[]custom_types.Action
  26016. appendaction_message []custom_types.Action
  26017. action_label_add *[]uint64
  26018. appendaction_label_add []uint64
  26019. action_label_del *[]uint64
  26020. appendaction_label_del []uint64
  26021. action_forward **custom_types.ActionForward
  26022. index_sort *int
  26023. addindex_sort *int
  26024. clearedFields map[string]struct{}
  26025. sop_task *uint64
  26026. clearedsop_task bool
  26027. stage_nodes map[uint64]struct{}
  26028. removedstage_nodes map[uint64]struct{}
  26029. clearedstage_nodes bool
  26030. stage_messages map[uint64]struct{}
  26031. removedstage_messages map[uint64]struct{}
  26032. clearedstage_messages bool
  26033. done bool
  26034. oldValue func(context.Context) (*SopStage, error)
  26035. predicates []predicate.SopStage
  26036. }
  26037. var _ ent.Mutation = (*SopStageMutation)(nil)
  26038. // sopstageOption allows management of the mutation configuration using functional options.
  26039. type sopstageOption func(*SopStageMutation)
  26040. // newSopStageMutation creates new mutation for the SopStage entity.
  26041. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  26042. m := &SopStageMutation{
  26043. config: c,
  26044. op: op,
  26045. typ: TypeSopStage,
  26046. clearedFields: make(map[string]struct{}),
  26047. }
  26048. for _, opt := range opts {
  26049. opt(m)
  26050. }
  26051. return m
  26052. }
  26053. // withSopStageID sets the ID field of the mutation.
  26054. func withSopStageID(id uint64) sopstageOption {
  26055. return func(m *SopStageMutation) {
  26056. var (
  26057. err error
  26058. once sync.Once
  26059. value *SopStage
  26060. )
  26061. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  26062. once.Do(func() {
  26063. if m.done {
  26064. err = errors.New("querying old values post mutation is not allowed")
  26065. } else {
  26066. value, err = m.Client().SopStage.Get(ctx, id)
  26067. }
  26068. })
  26069. return value, err
  26070. }
  26071. m.id = &id
  26072. }
  26073. }
  26074. // withSopStage sets the old SopStage of the mutation.
  26075. func withSopStage(node *SopStage) sopstageOption {
  26076. return func(m *SopStageMutation) {
  26077. m.oldValue = func(context.Context) (*SopStage, error) {
  26078. return node, nil
  26079. }
  26080. m.id = &node.ID
  26081. }
  26082. }
  26083. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26084. // executed in a transaction (ent.Tx), a transactional client is returned.
  26085. func (m SopStageMutation) Client() *Client {
  26086. client := &Client{config: m.config}
  26087. client.init()
  26088. return client
  26089. }
  26090. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26091. // it returns an error otherwise.
  26092. func (m SopStageMutation) Tx() (*Tx, error) {
  26093. if _, ok := m.driver.(*txDriver); !ok {
  26094. return nil, errors.New("ent: mutation is not running in a transaction")
  26095. }
  26096. tx := &Tx{config: m.config}
  26097. tx.init()
  26098. return tx, nil
  26099. }
  26100. // SetID sets the value of the id field. Note that this
  26101. // operation is only accepted on creation of SopStage entities.
  26102. func (m *SopStageMutation) SetID(id uint64) {
  26103. m.id = &id
  26104. }
  26105. // ID returns the ID value in the mutation. Note that the ID is only available
  26106. // if it was provided to the builder or after it was returned from the database.
  26107. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  26108. if m.id == nil {
  26109. return
  26110. }
  26111. return *m.id, true
  26112. }
  26113. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26114. // That means, if the mutation is applied within a transaction with an isolation level such
  26115. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26116. // or updated by the mutation.
  26117. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  26118. switch {
  26119. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26120. id, exists := m.ID()
  26121. if exists {
  26122. return []uint64{id}, nil
  26123. }
  26124. fallthrough
  26125. case m.op.Is(OpUpdate | OpDelete):
  26126. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  26127. default:
  26128. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26129. }
  26130. }
  26131. // SetCreatedAt sets the "created_at" field.
  26132. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  26133. m.created_at = &t
  26134. }
  26135. // CreatedAt returns the value of the "created_at" field in the mutation.
  26136. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  26137. v := m.created_at
  26138. if v == nil {
  26139. return
  26140. }
  26141. return *v, true
  26142. }
  26143. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  26144. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26146. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26147. if !m.op.Is(OpUpdateOne) {
  26148. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26149. }
  26150. if m.id == nil || m.oldValue == nil {
  26151. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26152. }
  26153. oldValue, err := m.oldValue(ctx)
  26154. if err != nil {
  26155. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26156. }
  26157. return oldValue.CreatedAt, nil
  26158. }
  26159. // ResetCreatedAt resets all changes to the "created_at" field.
  26160. func (m *SopStageMutation) ResetCreatedAt() {
  26161. m.created_at = nil
  26162. }
  26163. // SetUpdatedAt sets the "updated_at" field.
  26164. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  26165. m.updated_at = &t
  26166. }
  26167. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26168. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  26169. v := m.updated_at
  26170. if v == nil {
  26171. return
  26172. }
  26173. return *v, true
  26174. }
  26175. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  26176. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26178. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26179. if !m.op.Is(OpUpdateOne) {
  26180. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26181. }
  26182. if m.id == nil || m.oldValue == nil {
  26183. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26184. }
  26185. oldValue, err := m.oldValue(ctx)
  26186. if err != nil {
  26187. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26188. }
  26189. return oldValue.UpdatedAt, nil
  26190. }
  26191. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26192. func (m *SopStageMutation) ResetUpdatedAt() {
  26193. m.updated_at = nil
  26194. }
  26195. // SetStatus sets the "status" field.
  26196. func (m *SopStageMutation) SetStatus(u uint8) {
  26197. m.status = &u
  26198. m.addstatus = nil
  26199. }
  26200. // Status returns the value of the "status" field in the mutation.
  26201. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  26202. v := m.status
  26203. if v == nil {
  26204. return
  26205. }
  26206. return *v, true
  26207. }
  26208. // OldStatus returns the old "status" field's value of the SopStage entity.
  26209. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26211. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26212. if !m.op.Is(OpUpdateOne) {
  26213. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26214. }
  26215. if m.id == nil || m.oldValue == nil {
  26216. return v, errors.New("OldStatus requires an ID field in the mutation")
  26217. }
  26218. oldValue, err := m.oldValue(ctx)
  26219. if err != nil {
  26220. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26221. }
  26222. return oldValue.Status, nil
  26223. }
  26224. // AddStatus adds u to the "status" field.
  26225. func (m *SopStageMutation) AddStatus(u int8) {
  26226. if m.addstatus != nil {
  26227. *m.addstatus += u
  26228. } else {
  26229. m.addstatus = &u
  26230. }
  26231. }
  26232. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26233. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  26234. v := m.addstatus
  26235. if v == nil {
  26236. return
  26237. }
  26238. return *v, true
  26239. }
  26240. // ClearStatus clears the value of the "status" field.
  26241. func (m *SopStageMutation) ClearStatus() {
  26242. m.status = nil
  26243. m.addstatus = nil
  26244. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  26245. }
  26246. // StatusCleared returns if the "status" field was cleared in this mutation.
  26247. func (m *SopStageMutation) StatusCleared() bool {
  26248. _, ok := m.clearedFields[sopstage.FieldStatus]
  26249. return ok
  26250. }
  26251. // ResetStatus resets all changes to the "status" field.
  26252. func (m *SopStageMutation) ResetStatus() {
  26253. m.status = nil
  26254. m.addstatus = nil
  26255. delete(m.clearedFields, sopstage.FieldStatus)
  26256. }
  26257. // SetDeletedAt sets the "deleted_at" field.
  26258. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  26259. m.deleted_at = &t
  26260. }
  26261. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26262. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  26263. v := m.deleted_at
  26264. if v == nil {
  26265. return
  26266. }
  26267. return *v, true
  26268. }
  26269. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  26270. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26272. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26273. if !m.op.Is(OpUpdateOne) {
  26274. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26275. }
  26276. if m.id == nil || m.oldValue == nil {
  26277. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26278. }
  26279. oldValue, err := m.oldValue(ctx)
  26280. if err != nil {
  26281. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26282. }
  26283. return oldValue.DeletedAt, nil
  26284. }
  26285. // ClearDeletedAt clears the value of the "deleted_at" field.
  26286. func (m *SopStageMutation) ClearDeletedAt() {
  26287. m.deleted_at = nil
  26288. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  26289. }
  26290. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26291. func (m *SopStageMutation) DeletedAtCleared() bool {
  26292. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  26293. return ok
  26294. }
  26295. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26296. func (m *SopStageMutation) ResetDeletedAt() {
  26297. m.deleted_at = nil
  26298. delete(m.clearedFields, sopstage.FieldDeletedAt)
  26299. }
  26300. // SetTaskID sets the "task_id" field.
  26301. func (m *SopStageMutation) SetTaskID(u uint64) {
  26302. m.sop_task = &u
  26303. }
  26304. // TaskID returns the value of the "task_id" field in the mutation.
  26305. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  26306. v := m.sop_task
  26307. if v == nil {
  26308. return
  26309. }
  26310. return *v, true
  26311. }
  26312. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  26313. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26315. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  26316. if !m.op.Is(OpUpdateOne) {
  26317. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  26318. }
  26319. if m.id == nil || m.oldValue == nil {
  26320. return v, errors.New("OldTaskID requires an ID field in the mutation")
  26321. }
  26322. oldValue, err := m.oldValue(ctx)
  26323. if err != nil {
  26324. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  26325. }
  26326. return oldValue.TaskID, nil
  26327. }
  26328. // ResetTaskID resets all changes to the "task_id" field.
  26329. func (m *SopStageMutation) ResetTaskID() {
  26330. m.sop_task = nil
  26331. }
  26332. // SetName sets the "name" field.
  26333. func (m *SopStageMutation) SetName(s string) {
  26334. m.name = &s
  26335. }
  26336. // Name returns the value of the "name" field in the mutation.
  26337. func (m *SopStageMutation) Name() (r string, exists bool) {
  26338. v := m.name
  26339. if v == nil {
  26340. return
  26341. }
  26342. return *v, true
  26343. }
  26344. // OldName returns the old "name" field's value of the SopStage entity.
  26345. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26347. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  26348. if !m.op.Is(OpUpdateOne) {
  26349. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26350. }
  26351. if m.id == nil || m.oldValue == nil {
  26352. return v, errors.New("OldName requires an ID field in the mutation")
  26353. }
  26354. oldValue, err := m.oldValue(ctx)
  26355. if err != nil {
  26356. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26357. }
  26358. return oldValue.Name, nil
  26359. }
  26360. // ResetName resets all changes to the "name" field.
  26361. func (m *SopStageMutation) ResetName() {
  26362. m.name = nil
  26363. }
  26364. // SetConditionType sets the "condition_type" field.
  26365. func (m *SopStageMutation) SetConditionType(i int) {
  26366. m.condition_type = &i
  26367. m.addcondition_type = nil
  26368. }
  26369. // ConditionType returns the value of the "condition_type" field in the mutation.
  26370. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  26371. v := m.condition_type
  26372. if v == nil {
  26373. return
  26374. }
  26375. return *v, true
  26376. }
  26377. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  26378. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26380. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  26381. if !m.op.Is(OpUpdateOne) {
  26382. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  26383. }
  26384. if m.id == nil || m.oldValue == nil {
  26385. return v, errors.New("OldConditionType requires an ID field in the mutation")
  26386. }
  26387. oldValue, err := m.oldValue(ctx)
  26388. if err != nil {
  26389. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  26390. }
  26391. return oldValue.ConditionType, nil
  26392. }
  26393. // AddConditionType adds i to the "condition_type" field.
  26394. func (m *SopStageMutation) AddConditionType(i int) {
  26395. if m.addcondition_type != nil {
  26396. *m.addcondition_type += i
  26397. } else {
  26398. m.addcondition_type = &i
  26399. }
  26400. }
  26401. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  26402. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  26403. v := m.addcondition_type
  26404. if v == nil {
  26405. return
  26406. }
  26407. return *v, true
  26408. }
  26409. // ResetConditionType resets all changes to the "condition_type" field.
  26410. func (m *SopStageMutation) ResetConditionType() {
  26411. m.condition_type = nil
  26412. m.addcondition_type = nil
  26413. }
  26414. // SetConditionOperator sets the "condition_operator" field.
  26415. func (m *SopStageMutation) SetConditionOperator(i int) {
  26416. m.condition_operator = &i
  26417. m.addcondition_operator = nil
  26418. }
  26419. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  26420. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  26421. v := m.condition_operator
  26422. if v == nil {
  26423. return
  26424. }
  26425. return *v, true
  26426. }
  26427. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  26428. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26430. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  26431. if !m.op.Is(OpUpdateOne) {
  26432. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  26433. }
  26434. if m.id == nil || m.oldValue == nil {
  26435. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  26436. }
  26437. oldValue, err := m.oldValue(ctx)
  26438. if err != nil {
  26439. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  26440. }
  26441. return oldValue.ConditionOperator, nil
  26442. }
  26443. // AddConditionOperator adds i to the "condition_operator" field.
  26444. func (m *SopStageMutation) AddConditionOperator(i int) {
  26445. if m.addcondition_operator != nil {
  26446. *m.addcondition_operator += i
  26447. } else {
  26448. m.addcondition_operator = &i
  26449. }
  26450. }
  26451. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  26452. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  26453. v := m.addcondition_operator
  26454. if v == nil {
  26455. return
  26456. }
  26457. return *v, true
  26458. }
  26459. // ResetConditionOperator resets all changes to the "condition_operator" field.
  26460. func (m *SopStageMutation) ResetConditionOperator() {
  26461. m.condition_operator = nil
  26462. m.addcondition_operator = nil
  26463. }
  26464. // SetConditionList sets the "condition_list" field.
  26465. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  26466. m.condition_list = &ct
  26467. m.appendcondition_list = nil
  26468. }
  26469. // ConditionList returns the value of the "condition_list" field in the mutation.
  26470. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  26471. v := m.condition_list
  26472. if v == nil {
  26473. return
  26474. }
  26475. return *v, true
  26476. }
  26477. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  26478. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26480. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  26481. if !m.op.Is(OpUpdateOne) {
  26482. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  26483. }
  26484. if m.id == nil || m.oldValue == nil {
  26485. return v, errors.New("OldConditionList requires an ID field in the mutation")
  26486. }
  26487. oldValue, err := m.oldValue(ctx)
  26488. if err != nil {
  26489. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  26490. }
  26491. return oldValue.ConditionList, nil
  26492. }
  26493. // AppendConditionList adds ct to the "condition_list" field.
  26494. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  26495. m.appendcondition_list = append(m.appendcondition_list, ct...)
  26496. }
  26497. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  26498. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  26499. if len(m.appendcondition_list) == 0 {
  26500. return nil, false
  26501. }
  26502. return m.appendcondition_list, true
  26503. }
  26504. // ResetConditionList resets all changes to the "condition_list" field.
  26505. func (m *SopStageMutation) ResetConditionList() {
  26506. m.condition_list = nil
  26507. m.appendcondition_list = nil
  26508. }
  26509. // SetActionMessage sets the "action_message" field.
  26510. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  26511. m.action_message = &ct
  26512. m.appendaction_message = nil
  26513. }
  26514. // ActionMessage returns the value of the "action_message" field in the mutation.
  26515. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  26516. v := m.action_message
  26517. if v == nil {
  26518. return
  26519. }
  26520. return *v, true
  26521. }
  26522. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  26523. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26525. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  26526. if !m.op.Is(OpUpdateOne) {
  26527. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  26528. }
  26529. if m.id == nil || m.oldValue == nil {
  26530. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  26531. }
  26532. oldValue, err := m.oldValue(ctx)
  26533. if err != nil {
  26534. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  26535. }
  26536. return oldValue.ActionMessage, nil
  26537. }
  26538. // AppendActionMessage adds ct to the "action_message" field.
  26539. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  26540. m.appendaction_message = append(m.appendaction_message, ct...)
  26541. }
  26542. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  26543. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  26544. if len(m.appendaction_message) == 0 {
  26545. return nil, false
  26546. }
  26547. return m.appendaction_message, true
  26548. }
  26549. // ClearActionMessage clears the value of the "action_message" field.
  26550. func (m *SopStageMutation) ClearActionMessage() {
  26551. m.action_message = nil
  26552. m.appendaction_message = nil
  26553. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  26554. }
  26555. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  26556. func (m *SopStageMutation) ActionMessageCleared() bool {
  26557. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  26558. return ok
  26559. }
  26560. // ResetActionMessage resets all changes to the "action_message" field.
  26561. func (m *SopStageMutation) ResetActionMessage() {
  26562. m.action_message = nil
  26563. m.appendaction_message = nil
  26564. delete(m.clearedFields, sopstage.FieldActionMessage)
  26565. }
  26566. // SetActionLabelAdd sets the "action_label_add" field.
  26567. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  26568. m.action_label_add = &u
  26569. m.appendaction_label_add = nil
  26570. }
  26571. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  26572. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  26573. v := m.action_label_add
  26574. if v == nil {
  26575. return
  26576. }
  26577. return *v, true
  26578. }
  26579. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  26580. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26582. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  26583. if !m.op.Is(OpUpdateOne) {
  26584. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  26585. }
  26586. if m.id == nil || m.oldValue == nil {
  26587. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  26588. }
  26589. oldValue, err := m.oldValue(ctx)
  26590. if err != nil {
  26591. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  26592. }
  26593. return oldValue.ActionLabelAdd, nil
  26594. }
  26595. // AppendActionLabelAdd adds u to the "action_label_add" field.
  26596. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  26597. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  26598. }
  26599. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  26600. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  26601. if len(m.appendaction_label_add) == 0 {
  26602. return nil, false
  26603. }
  26604. return m.appendaction_label_add, true
  26605. }
  26606. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  26607. func (m *SopStageMutation) ClearActionLabelAdd() {
  26608. m.action_label_add = nil
  26609. m.appendaction_label_add = nil
  26610. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  26611. }
  26612. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  26613. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  26614. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  26615. return ok
  26616. }
  26617. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  26618. func (m *SopStageMutation) ResetActionLabelAdd() {
  26619. m.action_label_add = nil
  26620. m.appendaction_label_add = nil
  26621. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  26622. }
  26623. // SetActionLabelDel sets the "action_label_del" field.
  26624. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  26625. m.action_label_del = &u
  26626. m.appendaction_label_del = nil
  26627. }
  26628. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  26629. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  26630. v := m.action_label_del
  26631. if v == nil {
  26632. return
  26633. }
  26634. return *v, true
  26635. }
  26636. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  26637. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26639. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  26640. if !m.op.Is(OpUpdateOne) {
  26641. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  26642. }
  26643. if m.id == nil || m.oldValue == nil {
  26644. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  26645. }
  26646. oldValue, err := m.oldValue(ctx)
  26647. if err != nil {
  26648. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  26649. }
  26650. return oldValue.ActionLabelDel, nil
  26651. }
  26652. // AppendActionLabelDel adds u to the "action_label_del" field.
  26653. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  26654. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  26655. }
  26656. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  26657. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  26658. if len(m.appendaction_label_del) == 0 {
  26659. return nil, false
  26660. }
  26661. return m.appendaction_label_del, true
  26662. }
  26663. // ClearActionLabelDel clears the value of the "action_label_del" field.
  26664. func (m *SopStageMutation) ClearActionLabelDel() {
  26665. m.action_label_del = nil
  26666. m.appendaction_label_del = nil
  26667. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  26668. }
  26669. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  26670. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  26671. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  26672. return ok
  26673. }
  26674. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  26675. func (m *SopStageMutation) ResetActionLabelDel() {
  26676. m.action_label_del = nil
  26677. m.appendaction_label_del = nil
  26678. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  26679. }
  26680. // SetActionForward sets the "action_forward" field.
  26681. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  26682. m.action_forward = &ctf
  26683. }
  26684. // ActionForward returns the value of the "action_forward" field in the mutation.
  26685. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  26686. v := m.action_forward
  26687. if v == nil {
  26688. return
  26689. }
  26690. return *v, true
  26691. }
  26692. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  26693. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26695. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  26696. if !m.op.Is(OpUpdateOne) {
  26697. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  26698. }
  26699. if m.id == nil || m.oldValue == nil {
  26700. return v, errors.New("OldActionForward requires an ID field in the mutation")
  26701. }
  26702. oldValue, err := m.oldValue(ctx)
  26703. if err != nil {
  26704. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  26705. }
  26706. return oldValue.ActionForward, nil
  26707. }
  26708. // ClearActionForward clears the value of the "action_forward" field.
  26709. func (m *SopStageMutation) ClearActionForward() {
  26710. m.action_forward = nil
  26711. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  26712. }
  26713. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  26714. func (m *SopStageMutation) ActionForwardCleared() bool {
  26715. _, ok := m.clearedFields[sopstage.FieldActionForward]
  26716. return ok
  26717. }
  26718. // ResetActionForward resets all changes to the "action_forward" field.
  26719. func (m *SopStageMutation) ResetActionForward() {
  26720. m.action_forward = nil
  26721. delete(m.clearedFields, sopstage.FieldActionForward)
  26722. }
  26723. // SetIndexSort sets the "index_sort" field.
  26724. func (m *SopStageMutation) SetIndexSort(i int) {
  26725. m.index_sort = &i
  26726. m.addindex_sort = nil
  26727. }
  26728. // IndexSort returns the value of the "index_sort" field in the mutation.
  26729. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  26730. v := m.index_sort
  26731. if v == nil {
  26732. return
  26733. }
  26734. return *v, true
  26735. }
  26736. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  26737. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26739. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  26740. if !m.op.Is(OpUpdateOne) {
  26741. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  26742. }
  26743. if m.id == nil || m.oldValue == nil {
  26744. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  26745. }
  26746. oldValue, err := m.oldValue(ctx)
  26747. if err != nil {
  26748. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  26749. }
  26750. return oldValue.IndexSort, nil
  26751. }
  26752. // AddIndexSort adds i to the "index_sort" field.
  26753. func (m *SopStageMutation) AddIndexSort(i int) {
  26754. if m.addindex_sort != nil {
  26755. *m.addindex_sort += i
  26756. } else {
  26757. m.addindex_sort = &i
  26758. }
  26759. }
  26760. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  26761. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  26762. v := m.addindex_sort
  26763. if v == nil {
  26764. return
  26765. }
  26766. return *v, true
  26767. }
  26768. // ClearIndexSort clears the value of the "index_sort" field.
  26769. func (m *SopStageMutation) ClearIndexSort() {
  26770. m.index_sort = nil
  26771. m.addindex_sort = nil
  26772. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  26773. }
  26774. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  26775. func (m *SopStageMutation) IndexSortCleared() bool {
  26776. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  26777. return ok
  26778. }
  26779. // ResetIndexSort resets all changes to the "index_sort" field.
  26780. func (m *SopStageMutation) ResetIndexSort() {
  26781. m.index_sort = nil
  26782. m.addindex_sort = nil
  26783. delete(m.clearedFields, sopstage.FieldIndexSort)
  26784. }
  26785. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  26786. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  26787. m.sop_task = &id
  26788. }
  26789. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  26790. func (m *SopStageMutation) ClearSopTask() {
  26791. m.clearedsop_task = true
  26792. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  26793. }
  26794. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  26795. func (m *SopStageMutation) SopTaskCleared() bool {
  26796. return m.clearedsop_task
  26797. }
  26798. // SopTaskID returns the "sop_task" edge ID in the mutation.
  26799. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  26800. if m.sop_task != nil {
  26801. return *m.sop_task, true
  26802. }
  26803. return
  26804. }
  26805. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  26806. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26807. // SopTaskID instead. It exists only for internal usage by the builders.
  26808. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  26809. if id := m.sop_task; id != nil {
  26810. ids = append(ids, *id)
  26811. }
  26812. return
  26813. }
  26814. // ResetSopTask resets all changes to the "sop_task" edge.
  26815. func (m *SopStageMutation) ResetSopTask() {
  26816. m.sop_task = nil
  26817. m.clearedsop_task = false
  26818. }
  26819. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  26820. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  26821. if m.stage_nodes == nil {
  26822. m.stage_nodes = make(map[uint64]struct{})
  26823. }
  26824. for i := range ids {
  26825. m.stage_nodes[ids[i]] = struct{}{}
  26826. }
  26827. }
  26828. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  26829. func (m *SopStageMutation) ClearStageNodes() {
  26830. m.clearedstage_nodes = true
  26831. }
  26832. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  26833. func (m *SopStageMutation) StageNodesCleared() bool {
  26834. return m.clearedstage_nodes
  26835. }
  26836. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  26837. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  26838. if m.removedstage_nodes == nil {
  26839. m.removedstage_nodes = make(map[uint64]struct{})
  26840. }
  26841. for i := range ids {
  26842. delete(m.stage_nodes, ids[i])
  26843. m.removedstage_nodes[ids[i]] = struct{}{}
  26844. }
  26845. }
  26846. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  26847. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  26848. for id := range m.removedstage_nodes {
  26849. ids = append(ids, id)
  26850. }
  26851. return
  26852. }
  26853. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  26854. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  26855. for id := range m.stage_nodes {
  26856. ids = append(ids, id)
  26857. }
  26858. return
  26859. }
  26860. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  26861. func (m *SopStageMutation) ResetStageNodes() {
  26862. m.stage_nodes = nil
  26863. m.clearedstage_nodes = false
  26864. m.removedstage_nodes = nil
  26865. }
  26866. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  26867. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  26868. if m.stage_messages == nil {
  26869. m.stage_messages = make(map[uint64]struct{})
  26870. }
  26871. for i := range ids {
  26872. m.stage_messages[ids[i]] = struct{}{}
  26873. }
  26874. }
  26875. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  26876. func (m *SopStageMutation) ClearStageMessages() {
  26877. m.clearedstage_messages = true
  26878. }
  26879. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  26880. func (m *SopStageMutation) StageMessagesCleared() bool {
  26881. return m.clearedstage_messages
  26882. }
  26883. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  26884. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  26885. if m.removedstage_messages == nil {
  26886. m.removedstage_messages = make(map[uint64]struct{})
  26887. }
  26888. for i := range ids {
  26889. delete(m.stage_messages, ids[i])
  26890. m.removedstage_messages[ids[i]] = struct{}{}
  26891. }
  26892. }
  26893. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  26894. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  26895. for id := range m.removedstage_messages {
  26896. ids = append(ids, id)
  26897. }
  26898. return
  26899. }
  26900. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  26901. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  26902. for id := range m.stage_messages {
  26903. ids = append(ids, id)
  26904. }
  26905. return
  26906. }
  26907. // ResetStageMessages resets all changes to the "stage_messages" edge.
  26908. func (m *SopStageMutation) ResetStageMessages() {
  26909. m.stage_messages = nil
  26910. m.clearedstage_messages = false
  26911. m.removedstage_messages = nil
  26912. }
  26913. // Where appends a list predicates to the SopStageMutation builder.
  26914. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  26915. m.predicates = append(m.predicates, ps...)
  26916. }
  26917. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  26918. // users can use type-assertion to append predicates that do not depend on any generated package.
  26919. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  26920. p := make([]predicate.SopStage, len(ps))
  26921. for i := range ps {
  26922. p[i] = ps[i]
  26923. }
  26924. m.Where(p...)
  26925. }
  26926. // Op returns the operation name.
  26927. func (m *SopStageMutation) Op() Op {
  26928. return m.op
  26929. }
  26930. // SetOp allows setting the mutation operation.
  26931. func (m *SopStageMutation) SetOp(op Op) {
  26932. m.op = op
  26933. }
  26934. // Type returns the node type of this mutation (SopStage).
  26935. func (m *SopStageMutation) Type() string {
  26936. return m.typ
  26937. }
  26938. // Fields returns all fields that were changed during this mutation. Note that in
  26939. // order to get all numeric fields that were incremented/decremented, call
  26940. // AddedFields().
  26941. func (m *SopStageMutation) Fields() []string {
  26942. fields := make([]string, 0, 14)
  26943. if m.created_at != nil {
  26944. fields = append(fields, sopstage.FieldCreatedAt)
  26945. }
  26946. if m.updated_at != nil {
  26947. fields = append(fields, sopstage.FieldUpdatedAt)
  26948. }
  26949. if m.status != nil {
  26950. fields = append(fields, sopstage.FieldStatus)
  26951. }
  26952. if m.deleted_at != nil {
  26953. fields = append(fields, sopstage.FieldDeletedAt)
  26954. }
  26955. if m.sop_task != nil {
  26956. fields = append(fields, sopstage.FieldTaskID)
  26957. }
  26958. if m.name != nil {
  26959. fields = append(fields, sopstage.FieldName)
  26960. }
  26961. if m.condition_type != nil {
  26962. fields = append(fields, sopstage.FieldConditionType)
  26963. }
  26964. if m.condition_operator != nil {
  26965. fields = append(fields, sopstage.FieldConditionOperator)
  26966. }
  26967. if m.condition_list != nil {
  26968. fields = append(fields, sopstage.FieldConditionList)
  26969. }
  26970. if m.action_message != nil {
  26971. fields = append(fields, sopstage.FieldActionMessage)
  26972. }
  26973. if m.action_label_add != nil {
  26974. fields = append(fields, sopstage.FieldActionLabelAdd)
  26975. }
  26976. if m.action_label_del != nil {
  26977. fields = append(fields, sopstage.FieldActionLabelDel)
  26978. }
  26979. if m.action_forward != nil {
  26980. fields = append(fields, sopstage.FieldActionForward)
  26981. }
  26982. if m.index_sort != nil {
  26983. fields = append(fields, sopstage.FieldIndexSort)
  26984. }
  26985. return fields
  26986. }
  26987. // Field returns the value of a field with the given name. The second boolean
  26988. // return value indicates that this field was not set, or was not defined in the
  26989. // schema.
  26990. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  26991. switch name {
  26992. case sopstage.FieldCreatedAt:
  26993. return m.CreatedAt()
  26994. case sopstage.FieldUpdatedAt:
  26995. return m.UpdatedAt()
  26996. case sopstage.FieldStatus:
  26997. return m.Status()
  26998. case sopstage.FieldDeletedAt:
  26999. return m.DeletedAt()
  27000. case sopstage.FieldTaskID:
  27001. return m.TaskID()
  27002. case sopstage.FieldName:
  27003. return m.Name()
  27004. case sopstage.FieldConditionType:
  27005. return m.ConditionType()
  27006. case sopstage.FieldConditionOperator:
  27007. return m.ConditionOperator()
  27008. case sopstage.FieldConditionList:
  27009. return m.ConditionList()
  27010. case sopstage.FieldActionMessage:
  27011. return m.ActionMessage()
  27012. case sopstage.FieldActionLabelAdd:
  27013. return m.ActionLabelAdd()
  27014. case sopstage.FieldActionLabelDel:
  27015. return m.ActionLabelDel()
  27016. case sopstage.FieldActionForward:
  27017. return m.ActionForward()
  27018. case sopstage.FieldIndexSort:
  27019. return m.IndexSort()
  27020. }
  27021. return nil, false
  27022. }
  27023. // OldField returns the old value of the field from the database. An error is
  27024. // returned if the mutation operation is not UpdateOne, or the query to the
  27025. // database failed.
  27026. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27027. switch name {
  27028. case sopstage.FieldCreatedAt:
  27029. return m.OldCreatedAt(ctx)
  27030. case sopstage.FieldUpdatedAt:
  27031. return m.OldUpdatedAt(ctx)
  27032. case sopstage.FieldStatus:
  27033. return m.OldStatus(ctx)
  27034. case sopstage.FieldDeletedAt:
  27035. return m.OldDeletedAt(ctx)
  27036. case sopstage.FieldTaskID:
  27037. return m.OldTaskID(ctx)
  27038. case sopstage.FieldName:
  27039. return m.OldName(ctx)
  27040. case sopstage.FieldConditionType:
  27041. return m.OldConditionType(ctx)
  27042. case sopstage.FieldConditionOperator:
  27043. return m.OldConditionOperator(ctx)
  27044. case sopstage.FieldConditionList:
  27045. return m.OldConditionList(ctx)
  27046. case sopstage.FieldActionMessage:
  27047. return m.OldActionMessage(ctx)
  27048. case sopstage.FieldActionLabelAdd:
  27049. return m.OldActionLabelAdd(ctx)
  27050. case sopstage.FieldActionLabelDel:
  27051. return m.OldActionLabelDel(ctx)
  27052. case sopstage.FieldActionForward:
  27053. return m.OldActionForward(ctx)
  27054. case sopstage.FieldIndexSort:
  27055. return m.OldIndexSort(ctx)
  27056. }
  27057. return nil, fmt.Errorf("unknown SopStage field %s", name)
  27058. }
  27059. // SetField sets the value of a field with the given name. It returns an error if
  27060. // the field is not defined in the schema, or if the type mismatched the field
  27061. // type.
  27062. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  27063. switch name {
  27064. case sopstage.FieldCreatedAt:
  27065. v, ok := value.(time.Time)
  27066. if !ok {
  27067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27068. }
  27069. m.SetCreatedAt(v)
  27070. return nil
  27071. case sopstage.FieldUpdatedAt:
  27072. v, ok := value.(time.Time)
  27073. if !ok {
  27074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27075. }
  27076. m.SetUpdatedAt(v)
  27077. return nil
  27078. case sopstage.FieldStatus:
  27079. v, ok := value.(uint8)
  27080. if !ok {
  27081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27082. }
  27083. m.SetStatus(v)
  27084. return nil
  27085. case sopstage.FieldDeletedAt:
  27086. v, ok := value.(time.Time)
  27087. if !ok {
  27088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27089. }
  27090. m.SetDeletedAt(v)
  27091. return nil
  27092. case sopstage.FieldTaskID:
  27093. v, ok := value.(uint64)
  27094. if !ok {
  27095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27096. }
  27097. m.SetTaskID(v)
  27098. return nil
  27099. case sopstage.FieldName:
  27100. v, ok := value.(string)
  27101. if !ok {
  27102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27103. }
  27104. m.SetName(v)
  27105. return nil
  27106. case sopstage.FieldConditionType:
  27107. v, ok := value.(int)
  27108. if !ok {
  27109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27110. }
  27111. m.SetConditionType(v)
  27112. return nil
  27113. case sopstage.FieldConditionOperator:
  27114. v, ok := value.(int)
  27115. if !ok {
  27116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27117. }
  27118. m.SetConditionOperator(v)
  27119. return nil
  27120. case sopstage.FieldConditionList:
  27121. v, ok := value.([]custom_types.Condition)
  27122. if !ok {
  27123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27124. }
  27125. m.SetConditionList(v)
  27126. return nil
  27127. case sopstage.FieldActionMessage:
  27128. v, ok := value.([]custom_types.Action)
  27129. if !ok {
  27130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27131. }
  27132. m.SetActionMessage(v)
  27133. return nil
  27134. case sopstage.FieldActionLabelAdd:
  27135. v, ok := value.([]uint64)
  27136. if !ok {
  27137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27138. }
  27139. m.SetActionLabelAdd(v)
  27140. return nil
  27141. case sopstage.FieldActionLabelDel:
  27142. v, ok := value.([]uint64)
  27143. if !ok {
  27144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27145. }
  27146. m.SetActionLabelDel(v)
  27147. return nil
  27148. case sopstage.FieldActionForward:
  27149. v, ok := value.(*custom_types.ActionForward)
  27150. if !ok {
  27151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27152. }
  27153. m.SetActionForward(v)
  27154. return nil
  27155. case sopstage.FieldIndexSort:
  27156. v, ok := value.(int)
  27157. if !ok {
  27158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27159. }
  27160. m.SetIndexSort(v)
  27161. return nil
  27162. }
  27163. return fmt.Errorf("unknown SopStage field %s", name)
  27164. }
  27165. // AddedFields returns all numeric fields that were incremented/decremented during
  27166. // this mutation.
  27167. func (m *SopStageMutation) AddedFields() []string {
  27168. var fields []string
  27169. if m.addstatus != nil {
  27170. fields = append(fields, sopstage.FieldStatus)
  27171. }
  27172. if m.addcondition_type != nil {
  27173. fields = append(fields, sopstage.FieldConditionType)
  27174. }
  27175. if m.addcondition_operator != nil {
  27176. fields = append(fields, sopstage.FieldConditionOperator)
  27177. }
  27178. if m.addindex_sort != nil {
  27179. fields = append(fields, sopstage.FieldIndexSort)
  27180. }
  27181. return fields
  27182. }
  27183. // AddedField returns the numeric value that was incremented/decremented on a field
  27184. // with the given name. The second boolean return value indicates that this field
  27185. // was not set, or was not defined in the schema.
  27186. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  27187. switch name {
  27188. case sopstage.FieldStatus:
  27189. return m.AddedStatus()
  27190. case sopstage.FieldConditionType:
  27191. return m.AddedConditionType()
  27192. case sopstage.FieldConditionOperator:
  27193. return m.AddedConditionOperator()
  27194. case sopstage.FieldIndexSort:
  27195. return m.AddedIndexSort()
  27196. }
  27197. return nil, false
  27198. }
  27199. // AddField adds the value to the field with the given name. It returns an error if
  27200. // the field is not defined in the schema, or if the type mismatched the field
  27201. // type.
  27202. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  27203. switch name {
  27204. case sopstage.FieldStatus:
  27205. v, ok := value.(int8)
  27206. if !ok {
  27207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27208. }
  27209. m.AddStatus(v)
  27210. return nil
  27211. case sopstage.FieldConditionType:
  27212. v, ok := value.(int)
  27213. if !ok {
  27214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27215. }
  27216. m.AddConditionType(v)
  27217. return nil
  27218. case sopstage.FieldConditionOperator:
  27219. v, ok := value.(int)
  27220. if !ok {
  27221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27222. }
  27223. m.AddConditionOperator(v)
  27224. return nil
  27225. case sopstage.FieldIndexSort:
  27226. v, ok := value.(int)
  27227. if !ok {
  27228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27229. }
  27230. m.AddIndexSort(v)
  27231. return nil
  27232. }
  27233. return fmt.Errorf("unknown SopStage numeric field %s", name)
  27234. }
  27235. // ClearedFields returns all nullable fields that were cleared during this
  27236. // mutation.
  27237. func (m *SopStageMutation) ClearedFields() []string {
  27238. var fields []string
  27239. if m.FieldCleared(sopstage.FieldStatus) {
  27240. fields = append(fields, sopstage.FieldStatus)
  27241. }
  27242. if m.FieldCleared(sopstage.FieldDeletedAt) {
  27243. fields = append(fields, sopstage.FieldDeletedAt)
  27244. }
  27245. if m.FieldCleared(sopstage.FieldActionMessage) {
  27246. fields = append(fields, sopstage.FieldActionMessage)
  27247. }
  27248. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  27249. fields = append(fields, sopstage.FieldActionLabelAdd)
  27250. }
  27251. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  27252. fields = append(fields, sopstage.FieldActionLabelDel)
  27253. }
  27254. if m.FieldCleared(sopstage.FieldActionForward) {
  27255. fields = append(fields, sopstage.FieldActionForward)
  27256. }
  27257. if m.FieldCleared(sopstage.FieldIndexSort) {
  27258. fields = append(fields, sopstage.FieldIndexSort)
  27259. }
  27260. return fields
  27261. }
  27262. // FieldCleared returns a boolean indicating if a field with the given name was
  27263. // cleared in this mutation.
  27264. func (m *SopStageMutation) FieldCleared(name string) bool {
  27265. _, ok := m.clearedFields[name]
  27266. return ok
  27267. }
  27268. // ClearField clears the value of the field with the given name. It returns an
  27269. // error if the field is not defined in the schema.
  27270. func (m *SopStageMutation) ClearField(name string) error {
  27271. switch name {
  27272. case sopstage.FieldStatus:
  27273. m.ClearStatus()
  27274. return nil
  27275. case sopstage.FieldDeletedAt:
  27276. m.ClearDeletedAt()
  27277. return nil
  27278. case sopstage.FieldActionMessage:
  27279. m.ClearActionMessage()
  27280. return nil
  27281. case sopstage.FieldActionLabelAdd:
  27282. m.ClearActionLabelAdd()
  27283. return nil
  27284. case sopstage.FieldActionLabelDel:
  27285. m.ClearActionLabelDel()
  27286. return nil
  27287. case sopstage.FieldActionForward:
  27288. m.ClearActionForward()
  27289. return nil
  27290. case sopstage.FieldIndexSort:
  27291. m.ClearIndexSort()
  27292. return nil
  27293. }
  27294. return fmt.Errorf("unknown SopStage nullable field %s", name)
  27295. }
  27296. // ResetField resets all changes in the mutation for the field with the given name.
  27297. // It returns an error if the field is not defined in the schema.
  27298. func (m *SopStageMutation) ResetField(name string) error {
  27299. switch name {
  27300. case sopstage.FieldCreatedAt:
  27301. m.ResetCreatedAt()
  27302. return nil
  27303. case sopstage.FieldUpdatedAt:
  27304. m.ResetUpdatedAt()
  27305. return nil
  27306. case sopstage.FieldStatus:
  27307. m.ResetStatus()
  27308. return nil
  27309. case sopstage.FieldDeletedAt:
  27310. m.ResetDeletedAt()
  27311. return nil
  27312. case sopstage.FieldTaskID:
  27313. m.ResetTaskID()
  27314. return nil
  27315. case sopstage.FieldName:
  27316. m.ResetName()
  27317. return nil
  27318. case sopstage.FieldConditionType:
  27319. m.ResetConditionType()
  27320. return nil
  27321. case sopstage.FieldConditionOperator:
  27322. m.ResetConditionOperator()
  27323. return nil
  27324. case sopstage.FieldConditionList:
  27325. m.ResetConditionList()
  27326. return nil
  27327. case sopstage.FieldActionMessage:
  27328. m.ResetActionMessage()
  27329. return nil
  27330. case sopstage.FieldActionLabelAdd:
  27331. m.ResetActionLabelAdd()
  27332. return nil
  27333. case sopstage.FieldActionLabelDel:
  27334. m.ResetActionLabelDel()
  27335. return nil
  27336. case sopstage.FieldActionForward:
  27337. m.ResetActionForward()
  27338. return nil
  27339. case sopstage.FieldIndexSort:
  27340. m.ResetIndexSort()
  27341. return nil
  27342. }
  27343. return fmt.Errorf("unknown SopStage field %s", name)
  27344. }
  27345. // AddedEdges returns all edge names that were set/added in this mutation.
  27346. func (m *SopStageMutation) AddedEdges() []string {
  27347. edges := make([]string, 0, 3)
  27348. if m.sop_task != nil {
  27349. edges = append(edges, sopstage.EdgeSopTask)
  27350. }
  27351. if m.stage_nodes != nil {
  27352. edges = append(edges, sopstage.EdgeStageNodes)
  27353. }
  27354. if m.stage_messages != nil {
  27355. edges = append(edges, sopstage.EdgeStageMessages)
  27356. }
  27357. return edges
  27358. }
  27359. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27360. // name in this mutation.
  27361. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  27362. switch name {
  27363. case sopstage.EdgeSopTask:
  27364. if id := m.sop_task; id != nil {
  27365. return []ent.Value{*id}
  27366. }
  27367. case sopstage.EdgeStageNodes:
  27368. ids := make([]ent.Value, 0, len(m.stage_nodes))
  27369. for id := range m.stage_nodes {
  27370. ids = append(ids, id)
  27371. }
  27372. return ids
  27373. case sopstage.EdgeStageMessages:
  27374. ids := make([]ent.Value, 0, len(m.stage_messages))
  27375. for id := range m.stage_messages {
  27376. ids = append(ids, id)
  27377. }
  27378. return ids
  27379. }
  27380. return nil
  27381. }
  27382. // RemovedEdges returns all edge names that were removed in this mutation.
  27383. func (m *SopStageMutation) RemovedEdges() []string {
  27384. edges := make([]string, 0, 3)
  27385. if m.removedstage_nodes != nil {
  27386. edges = append(edges, sopstage.EdgeStageNodes)
  27387. }
  27388. if m.removedstage_messages != nil {
  27389. edges = append(edges, sopstage.EdgeStageMessages)
  27390. }
  27391. return edges
  27392. }
  27393. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27394. // the given name in this mutation.
  27395. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  27396. switch name {
  27397. case sopstage.EdgeStageNodes:
  27398. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  27399. for id := range m.removedstage_nodes {
  27400. ids = append(ids, id)
  27401. }
  27402. return ids
  27403. case sopstage.EdgeStageMessages:
  27404. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  27405. for id := range m.removedstage_messages {
  27406. ids = append(ids, id)
  27407. }
  27408. return ids
  27409. }
  27410. return nil
  27411. }
  27412. // ClearedEdges returns all edge names that were cleared in this mutation.
  27413. func (m *SopStageMutation) ClearedEdges() []string {
  27414. edges := make([]string, 0, 3)
  27415. if m.clearedsop_task {
  27416. edges = append(edges, sopstage.EdgeSopTask)
  27417. }
  27418. if m.clearedstage_nodes {
  27419. edges = append(edges, sopstage.EdgeStageNodes)
  27420. }
  27421. if m.clearedstage_messages {
  27422. edges = append(edges, sopstage.EdgeStageMessages)
  27423. }
  27424. return edges
  27425. }
  27426. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27427. // was cleared in this mutation.
  27428. func (m *SopStageMutation) EdgeCleared(name string) bool {
  27429. switch name {
  27430. case sopstage.EdgeSopTask:
  27431. return m.clearedsop_task
  27432. case sopstage.EdgeStageNodes:
  27433. return m.clearedstage_nodes
  27434. case sopstage.EdgeStageMessages:
  27435. return m.clearedstage_messages
  27436. }
  27437. return false
  27438. }
  27439. // ClearEdge clears the value of the edge with the given name. It returns an error
  27440. // if that edge is not defined in the schema.
  27441. func (m *SopStageMutation) ClearEdge(name string) error {
  27442. switch name {
  27443. case sopstage.EdgeSopTask:
  27444. m.ClearSopTask()
  27445. return nil
  27446. }
  27447. return fmt.Errorf("unknown SopStage unique edge %s", name)
  27448. }
  27449. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27450. // It returns an error if the edge is not defined in the schema.
  27451. func (m *SopStageMutation) ResetEdge(name string) error {
  27452. switch name {
  27453. case sopstage.EdgeSopTask:
  27454. m.ResetSopTask()
  27455. return nil
  27456. case sopstage.EdgeStageNodes:
  27457. m.ResetStageNodes()
  27458. return nil
  27459. case sopstage.EdgeStageMessages:
  27460. m.ResetStageMessages()
  27461. return nil
  27462. }
  27463. return fmt.Errorf("unknown SopStage edge %s", name)
  27464. }
  27465. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  27466. type SopTaskMutation struct {
  27467. config
  27468. op Op
  27469. typ string
  27470. id *uint64
  27471. created_at *time.Time
  27472. updated_at *time.Time
  27473. status *uint8
  27474. addstatus *int8
  27475. deleted_at *time.Time
  27476. name *string
  27477. bot_wxid_list *[]string
  27478. appendbot_wxid_list []string
  27479. _type *int
  27480. add_type *int
  27481. plan_start_time *time.Time
  27482. plan_end_time *time.Time
  27483. creator_id *string
  27484. organization_id *uint64
  27485. addorganization_id *int64
  27486. token *[]string
  27487. appendtoken []string
  27488. clearedFields map[string]struct{}
  27489. task_stages map[uint64]struct{}
  27490. removedtask_stages map[uint64]struct{}
  27491. clearedtask_stages bool
  27492. done bool
  27493. oldValue func(context.Context) (*SopTask, error)
  27494. predicates []predicate.SopTask
  27495. }
  27496. var _ ent.Mutation = (*SopTaskMutation)(nil)
  27497. // soptaskOption allows management of the mutation configuration using functional options.
  27498. type soptaskOption func(*SopTaskMutation)
  27499. // newSopTaskMutation creates new mutation for the SopTask entity.
  27500. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  27501. m := &SopTaskMutation{
  27502. config: c,
  27503. op: op,
  27504. typ: TypeSopTask,
  27505. clearedFields: make(map[string]struct{}),
  27506. }
  27507. for _, opt := range opts {
  27508. opt(m)
  27509. }
  27510. return m
  27511. }
  27512. // withSopTaskID sets the ID field of the mutation.
  27513. func withSopTaskID(id uint64) soptaskOption {
  27514. return func(m *SopTaskMutation) {
  27515. var (
  27516. err error
  27517. once sync.Once
  27518. value *SopTask
  27519. )
  27520. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  27521. once.Do(func() {
  27522. if m.done {
  27523. err = errors.New("querying old values post mutation is not allowed")
  27524. } else {
  27525. value, err = m.Client().SopTask.Get(ctx, id)
  27526. }
  27527. })
  27528. return value, err
  27529. }
  27530. m.id = &id
  27531. }
  27532. }
  27533. // withSopTask sets the old SopTask of the mutation.
  27534. func withSopTask(node *SopTask) soptaskOption {
  27535. return func(m *SopTaskMutation) {
  27536. m.oldValue = func(context.Context) (*SopTask, error) {
  27537. return node, nil
  27538. }
  27539. m.id = &node.ID
  27540. }
  27541. }
  27542. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27543. // executed in a transaction (ent.Tx), a transactional client is returned.
  27544. func (m SopTaskMutation) Client() *Client {
  27545. client := &Client{config: m.config}
  27546. client.init()
  27547. return client
  27548. }
  27549. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27550. // it returns an error otherwise.
  27551. func (m SopTaskMutation) Tx() (*Tx, error) {
  27552. if _, ok := m.driver.(*txDriver); !ok {
  27553. return nil, errors.New("ent: mutation is not running in a transaction")
  27554. }
  27555. tx := &Tx{config: m.config}
  27556. tx.init()
  27557. return tx, nil
  27558. }
  27559. // SetID sets the value of the id field. Note that this
  27560. // operation is only accepted on creation of SopTask entities.
  27561. func (m *SopTaskMutation) SetID(id uint64) {
  27562. m.id = &id
  27563. }
  27564. // ID returns the ID value in the mutation. Note that the ID is only available
  27565. // if it was provided to the builder or after it was returned from the database.
  27566. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  27567. if m.id == nil {
  27568. return
  27569. }
  27570. return *m.id, true
  27571. }
  27572. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27573. // That means, if the mutation is applied within a transaction with an isolation level such
  27574. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27575. // or updated by the mutation.
  27576. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  27577. switch {
  27578. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27579. id, exists := m.ID()
  27580. if exists {
  27581. return []uint64{id}, nil
  27582. }
  27583. fallthrough
  27584. case m.op.Is(OpUpdate | OpDelete):
  27585. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  27586. default:
  27587. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27588. }
  27589. }
  27590. // SetCreatedAt sets the "created_at" field.
  27591. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  27592. m.created_at = &t
  27593. }
  27594. // CreatedAt returns the value of the "created_at" field in the mutation.
  27595. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  27596. v := m.created_at
  27597. if v == nil {
  27598. return
  27599. }
  27600. return *v, true
  27601. }
  27602. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  27603. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27605. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27606. if !m.op.Is(OpUpdateOne) {
  27607. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27608. }
  27609. if m.id == nil || m.oldValue == nil {
  27610. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27611. }
  27612. oldValue, err := m.oldValue(ctx)
  27613. if err != nil {
  27614. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27615. }
  27616. return oldValue.CreatedAt, nil
  27617. }
  27618. // ResetCreatedAt resets all changes to the "created_at" field.
  27619. func (m *SopTaskMutation) ResetCreatedAt() {
  27620. m.created_at = nil
  27621. }
  27622. // SetUpdatedAt sets the "updated_at" field.
  27623. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  27624. m.updated_at = &t
  27625. }
  27626. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27627. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  27628. v := m.updated_at
  27629. if v == nil {
  27630. return
  27631. }
  27632. return *v, true
  27633. }
  27634. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  27635. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27637. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27638. if !m.op.Is(OpUpdateOne) {
  27639. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27640. }
  27641. if m.id == nil || m.oldValue == nil {
  27642. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27643. }
  27644. oldValue, err := m.oldValue(ctx)
  27645. if err != nil {
  27646. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27647. }
  27648. return oldValue.UpdatedAt, nil
  27649. }
  27650. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27651. func (m *SopTaskMutation) ResetUpdatedAt() {
  27652. m.updated_at = nil
  27653. }
  27654. // SetStatus sets the "status" field.
  27655. func (m *SopTaskMutation) SetStatus(u uint8) {
  27656. m.status = &u
  27657. m.addstatus = nil
  27658. }
  27659. // Status returns the value of the "status" field in the mutation.
  27660. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  27661. v := m.status
  27662. if v == nil {
  27663. return
  27664. }
  27665. return *v, true
  27666. }
  27667. // OldStatus returns the old "status" field's value of the SopTask entity.
  27668. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27670. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27671. if !m.op.Is(OpUpdateOne) {
  27672. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27673. }
  27674. if m.id == nil || m.oldValue == nil {
  27675. return v, errors.New("OldStatus requires an ID field in the mutation")
  27676. }
  27677. oldValue, err := m.oldValue(ctx)
  27678. if err != nil {
  27679. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27680. }
  27681. return oldValue.Status, nil
  27682. }
  27683. // AddStatus adds u to the "status" field.
  27684. func (m *SopTaskMutation) AddStatus(u int8) {
  27685. if m.addstatus != nil {
  27686. *m.addstatus += u
  27687. } else {
  27688. m.addstatus = &u
  27689. }
  27690. }
  27691. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27692. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  27693. v := m.addstatus
  27694. if v == nil {
  27695. return
  27696. }
  27697. return *v, true
  27698. }
  27699. // ClearStatus clears the value of the "status" field.
  27700. func (m *SopTaskMutation) ClearStatus() {
  27701. m.status = nil
  27702. m.addstatus = nil
  27703. m.clearedFields[soptask.FieldStatus] = struct{}{}
  27704. }
  27705. // StatusCleared returns if the "status" field was cleared in this mutation.
  27706. func (m *SopTaskMutation) StatusCleared() bool {
  27707. _, ok := m.clearedFields[soptask.FieldStatus]
  27708. return ok
  27709. }
  27710. // ResetStatus resets all changes to the "status" field.
  27711. func (m *SopTaskMutation) ResetStatus() {
  27712. m.status = nil
  27713. m.addstatus = nil
  27714. delete(m.clearedFields, soptask.FieldStatus)
  27715. }
  27716. // SetDeletedAt sets the "deleted_at" field.
  27717. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  27718. m.deleted_at = &t
  27719. }
  27720. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27721. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  27722. v := m.deleted_at
  27723. if v == nil {
  27724. return
  27725. }
  27726. return *v, true
  27727. }
  27728. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  27729. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27731. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27732. if !m.op.Is(OpUpdateOne) {
  27733. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27734. }
  27735. if m.id == nil || m.oldValue == nil {
  27736. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27737. }
  27738. oldValue, err := m.oldValue(ctx)
  27739. if err != nil {
  27740. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27741. }
  27742. return oldValue.DeletedAt, nil
  27743. }
  27744. // ClearDeletedAt clears the value of the "deleted_at" field.
  27745. func (m *SopTaskMutation) ClearDeletedAt() {
  27746. m.deleted_at = nil
  27747. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  27748. }
  27749. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27750. func (m *SopTaskMutation) DeletedAtCleared() bool {
  27751. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  27752. return ok
  27753. }
  27754. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27755. func (m *SopTaskMutation) ResetDeletedAt() {
  27756. m.deleted_at = nil
  27757. delete(m.clearedFields, soptask.FieldDeletedAt)
  27758. }
  27759. // SetName sets the "name" field.
  27760. func (m *SopTaskMutation) SetName(s string) {
  27761. m.name = &s
  27762. }
  27763. // Name returns the value of the "name" field in the mutation.
  27764. func (m *SopTaskMutation) Name() (r string, exists bool) {
  27765. v := m.name
  27766. if v == nil {
  27767. return
  27768. }
  27769. return *v, true
  27770. }
  27771. // OldName returns the old "name" field's value of the SopTask entity.
  27772. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27774. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  27775. if !m.op.Is(OpUpdateOne) {
  27776. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27777. }
  27778. if m.id == nil || m.oldValue == nil {
  27779. return v, errors.New("OldName requires an ID field in the mutation")
  27780. }
  27781. oldValue, err := m.oldValue(ctx)
  27782. if err != nil {
  27783. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27784. }
  27785. return oldValue.Name, nil
  27786. }
  27787. // ResetName resets all changes to the "name" field.
  27788. func (m *SopTaskMutation) ResetName() {
  27789. m.name = nil
  27790. }
  27791. // SetBotWxidList sets the "bot_wxid_list" field.
  27792. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  27793. m.bot_wxid_list = &s
  27794. m.appendbot_wxid_list = nil
  27795. }
  27796. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  27797. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  27798. v := m.bot_wxid_list
  27799. if v == nil {
  27800. return
  27801. }
  27802. return *v, true
  27803. }
  27804. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  27805. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27807. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  27808. if !m.op.Is(OpUpdateOne) {
  27809. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  27810. }
  27811. if m.id == nil || m.oldValue == nil {
  27812. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  27813. }
  27814. oldValue, err := m.oldValue(ctx)
  27815. if err != nil {
  27816. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  27817. }
  27818. return oldValue.BotWxidList, nil
  27819. }
  27820. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  27821. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  27822. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  27823. }
  27824. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  27825. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  27826. if len(m.appendbot_wxid_list) == 0 {
  27827. return nil, false
  27828. }
  27829. return m.appendbot_wxid_list, true
  27830. }
  27831. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  27832. func (m *SopTaskMutation) ClearBotWxidList() {
  27833. m.bot_wxid_list = nil
  27834. m.appendbot_wxid_list = nil
  27835. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  27836. }
  27837. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  27838. func (m *SopTaskMutation) BotWxidListCleared() bool {
  27839. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  27840. return ok
  27841. }
  27842. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  27843. func (m *SopTaskMutation) ResetBotWxidList() {
  27844. m.bot_wxid_list = nil
  27845. m.appendbot_wxid_list = nil
  27846. delete(m.clearedFields, soptask.FieldBotWxidList)
  27847. }
  27848. // SetType sets the "type" field.
  27849. func (m *SopTaskMutation) SetType(i int) {
  27850. m._type = &i
  27851. m.add_type = nil
  27852. }
  27853. // GetType returns the value of the "type" field in the mutation.
  27854. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  27855. v := m._type
  27856. if v == nil {
  27857. return
  27858. }
  27859. return *v, true
  27860. }
  27861. // OldType returns the old "type" field's value of the SopTask entity.
  27862. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27864. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  27865. if !m.op.Is(OpUpdateOne) {
  27866. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27867. }
  27868. if m.id == nil || m.oldValue == nil {
  27869. return v, errors.New("OldType requires an ID field in the mutation")
  27870. }
  27871. oldValue, err := m.oldValue(ctx)
  27872. if err != nil {
  27873. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27874. }
  27875. return oldValue.Type, nil
  27876. }
  27877. // AddType adds i to the "type" field.
  27878. func (m *SopTaskMutation) AddType(i int) {
  27879. if m.add_type != nil {
  27880. *m.add_type += i
  27881. } else {
  27882. m.add_type = &i
  27883. }
  27884. }
  27885. // AddedType returns the value that was added to the "type" field in this mutation.
  27886. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  27887. v := m.add_type
  27888. if v == nil {
  27889. return
  27890. }
  27891. return *v, true
  27892. }
  27893. // ResetType resets all changes to the "type" field.
  27894. func (m *SopTaskMutation) ResetType() {
  27895. m._type = nil
  27896. m.add_type = nil
  27897. }
  27898. // SetPlanStartTime sets the "plan_start_time" field.
  27899. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  27900. m.plan_start_time = &t
  27901. }
  27902. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  27903. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  27904. v := m.plan_start_time
  27905. if v == nil {
  27906. return
  27907. }
  27908. return *v, true
  27909. }
  27910. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  27911. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27913. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  27914. if !m.op.Is(OpUpdateOne) {
  27915. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  27916. }
  27917. if m.id == nil || m.oldValue == nil {
  27918. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  27919. }
  27920. oldValue, err := m.oldValue(ctx)
  27921. if err != nil {
  27922. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  27923. }
  27924. return oldValue.PlanStartTime, nil
  27925. }
  27926. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  27927. func (m *SopTaskMutation) ClearPlanStartTime() {
  27928. m.plan_start_time = nil
  27929. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  27930. }
  27931. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  27932. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  27933. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  27934. return ok
  27935. }
  27936. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  27937. func (m *SopTaskMutation) ResetPlanStartTime() {
  27938. m.plan_start_time = nil
  27939. delete(m.clearedFields, soptask.FieldPlanStartTime)
  27940. }
  27941. // SetPlanEndTime sets the "plan_end_time" field.
  27942. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  27943. m.plan_end_time = &t
  27944. }
  27945. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  27946. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  27947. v := m.plan_end_time
  27948. if v == nil {
  27949. return
  27950. }
  27951. return *v, true
  27952. }
  27953. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  27954. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27956. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  27957. if !m.op.Is(OpUpdateOne) {
  27958. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  27959. }
  27960. if m.id == nil || m.oldValue == nil {
  27961. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  27962. }
  27963. oldValue, err := m.oldValue(ctx)
  27964. if err != nil {
  27965. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  27966. }
  27967. return oldValue.PlanEndTime, nil
  27968. }
  27969. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  27970. func (m *SopTaskMutation) ClearPlanEndTime() {
  27971. m.plan_end_time = nil
  27972. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  27973. }
  27974. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  27975. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  27976. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  27977. return ok
  27978. }
  27979. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  27980. func (m *SopTaskMutation) ResetPlanEndTime() {
  27981. m.plan_end_time = nil
  27982. delete(m.clearedFields, soptask.FieldPlanEndTime)
  27983. }
  27984. // SetCreatorID sets the "creator_id" field.
  27985. func (m *SopTaskMutation) SetCreatorID(s string) {
  27986. m.creator_id = &s
  27987. }
  27988. // CreatorID returns the value of the "creator_id" field in the mutation.
  27989. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  27990. v := m.creator_id
  27991. if v == nil {
  27992. return
  27993. }
  27994. return *v, true
  27995. }
  27996. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  27997. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27999. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  28000. if !m.op.Is(OpUpdateOne) {
  28001. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  28002. }
  28003. if m.id == nil || m.oldValue == nil {
  28004. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  28005. }
  28006. oldValue, err := m.oldValue(ctx)
  28007. if err != nil {
  28008. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  28009. }
  28010. return oldValue.CreatorID, nil
  28011. }
  28012. // ClearCreatorID clears the value of the "creator_id" field.
  28013. func (m *SopTaskMutation) ClearCreatorID() {
  28014. m.creator_id = nil
  28015. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  28016. }
  28017. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  28018. func (m *SopTaskMutation) CreatorIDCleared() bool {
  28019. _, ok := m.clearedFields[soptask.FieldCreatorID]
  28020. return ok
  28021. }
  28022. // ResetCreatorID resets all changes to the "creator_id" field.
  28023. func (m *SopTaskMutation) ResetCreatorID() {
  28024. m.creator_id = nil
  28025. delete(m.clearedFields, soptask.FieldCreatorID)
  28026. }
  28027. // SetOrganizationID sets the "organization_id" field.
  28028. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  28029. m.organization_id = &u
  28030. m.addorganization_id = nil
  28031. }
  28032. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28033. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  28034. v := m.organization_id
  28035. if v == nil {
  28036. return
  28037. }
  28038. return *v, true
  28039. }
  28040. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  28041. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28043. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28044. if !m.op.Is(OpUpdateOne) {
  28045. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28046. }
  28047. if m.id == nil || m.oldValue == nil {
  28048. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28049. }
  28050. oldValue, err := m.oldValue(ctx)
  28051. if err != nil {
  28052. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28053. }
  28054. return oldValue.OrganizationID, nil
  28055. }
  28056. // AddOrganizationID adds u to the "organization_id" field.
  28057. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  28058. if m.addorganization_id != nil {
  28059. *m.addorganization_id += u
  28060. } else {
  28061. m.addorganization_id = &u
  28062. }
  28063. }
  28064. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28065. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  28066. v := m.addorganization_id
  28067. if v == nil {
  28068. return
  28069. }
  28070. return *v, true
  28071. }
  28072. // ClearOrganizationID clears the value of the "organization_id" field.
  28073. func (m *SopTaskMutation) ClearOrganizationID() {
  28074. m.organization_id = nil
  28075. m.addorganization_id = nil
  28076. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  28077. }
  28078. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28079. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  28080. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  28081. return ok
  28082. }
  28083. // ResetOrganizationID resets all changes to the "organization_id" field.
  28084. func (m *SopTaskMutation) ResetOrganizationID() {
  28085. m.organization_id = nil
  28086. m.addorganization_id = nil
  28087. delete(m.clearedFields, soptask.FieldOrganizationID)
  28088. }
  28089. // SetToken sets the "token" field.
  28090. func (m *SopTaskMutation) SetToken(s []string) {
  28091. m.token = &s
  28092. m.appendtoken = nil
  28093. }
  28094. // Token returns the value of the "token" field in the mutation.
  28095. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  28096. v := m.token
  28097. if v == nil {
  28098. return
  28099. }
  28100. return *v, true
  28101. }
  28102. // OldToken returns the old "token" field's value of the SopTask entity.
  28103. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28105. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  28106. if !m.op.Is(OpUpdateOne) {
  28107. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  28108. }
  28109. if m.id == nil || m.oldValue == nil {
  28110. return v, errors.New("OldToken requires an ID field in the mutation")
  28111. }
  28112. oldValue, err := m.oldValue(ctx)
  28113. if err != nil {
  28114. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  28115. }
  28116. return oldValue.Token, nil
  28117. }
  28118. // AppendToken adds s to the "token" field.
  28119. func (m *SopTaskMutation) AppendToken(s []string) {
  28120. m.appendtoken = append(m.appendtoken, s...)
  28121. }
  28122. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  28123. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  28124. if len(m.appendtoken) == 0 {
  28125. return nil, false
  28126. }
  28127. return m.appendtoken, true
  28128. }
  28129. // ClearToken clears the value of the "token" field.
  28130. func (m *SopTaskMutation) ClearToken() {
  28131. m.token = nil
  28132. m.appendtoken = nil
  28133. m.clearedFields[soptask.FieldToken] = struct{}{}
  28134. }
  28135. // TokenCleared returns if the "token" field was cleared in this mutation.
  28136. func (m *SopTaskMutation) TokenCleared() bool {
  28137. _, ok := m.clearedFields[soptask.FieldToken]
  28138. return ok
  28139. }
  28140. // ResetToken resets all changes to the "token" field.
  28141. func (m *SopTaskMutation) ResetToken() {
  28142. m.token = nil
  28143. m.appendtoken = nil
  28144. delete(m.clearedFields, soptask.FieldToken)
  28145. }
  28146. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  28147. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  28148. if m.task_stages == nil {
  28149. m.task_stages = make(map[uint64]struct{})
  28150. }
  28151. for i := range ids {
  28152. m.task_stages[ids[i]] = struct{}{}
  28153. }
  28154. }
  28155. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  28156. func (m *SopTaskMutation) ClearTaskStages() {
  28157. m.clearedtask_stages = true
  28158. }
  28159. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  28160. func (m *SopTaskMutation) TaskStagesCleared() bool {
  28161. return m.clearedtask_stages
  28162. }
  28163. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  28164. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  28165. if m.removedtask_stages == nil {
  28166. m.removedtask_stages = make(map[uint64]struct{})
  28167. }
  28168. for i := range ids {
  28169. delete(m.task_stages, ids[i])
  28170. m.removedtask_stages[ids[i]] = struct{}{}
  28171. }
  28172. }
  28173. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  28174. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  28175. for id := range m.removedtask_stages {
  28176. ids = append(ids, id)
  28177. }
  28178. return
  28179. }
  28180. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  28181. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  28182. for id := range m.task_stages {
  28183. ids = append(ids, id)
  28184. }
  28185. return
  28186. }
  28187. // ResetTaskStages resets all changes to the "task_stages" edge.
  28188. func (m *SopTaskMutation) ResetTaskStages() {
  28189. m.task_stages = nil
  28190. m.clearedtask_stages = false
  28191. m.removedtask_stages = nil
  28192. }
  28193. // Where appends a list predicates to the SopTaskMutation builder.
  28194. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  28195. m.predicates = append(m.predicates, ps...)
  28196. }
  28197. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  28198. // users can use type-assertion to append predicates that do not depend on any generated package.
  28199. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  28200. p := make([]predicate.SopTask, len(ps))
  28201. for i := range ps {
  28202. p[i] = ps[i]
  28203. }
  28204. m.Where(p...)
  28205. }
  28206. // Op returns the operation name.
  28207. func (m *SopTaskMutation) Op() Op {
  28208. return m.op
  28209. }
  28210. // SetOp allows setting the mutation operation.
  28211. func (m *SopTaskMutation) SetOp(op Op) {
  28212. m.op = op
  28213. }
  28214. // Type returns the node type of this mutation (SopTask).
  28215. func (m *SopTaskMutation) Type() string {
  28216. return m.typ
  28217. }
  28218. // Fields returns all fields that were changed during this mutation. Note that in
  28219. // order to get all numeric fields that were incremented/decremented, call
  28220. // AddedFields().
  28221. func (m *SopTaskMutation) Fields() []string {
  28222. fields := make([]string, 0, 12)
  28223. if m.created_at != nil {
  28224. fields = append(fields, soptask.FieldCreatedAt)
  28225. }
  28226. if m.updated_at != nil {
  28227. fields = append(fields, soptask.FieldUpdatedAt)
  28228. }
  28229. if m.status != nil {
  28230. fields = append(fields, soptask.FieldStatus)
  28231. }
  28232. if m.deleted_at != nil {
  28233. fields = append(fields, soptask.FieldDeletedAt)
  28234. }
  28235. if m.name != nil {
  28236. fields = append(fields, soptask.FieldName)
  28237. }
  28238. if m.bot_wxid_list != nil {
  28239. fields = append(fields, soptask.FieldBotWxidList)
  28240. }
  28241. if m._type != nil {
  28242. fields = append(fields, soptask.FieldType)
  28243. }
  28244. if m.plan_start_time != nil {
  28245. fields = append(fields, soptask.FieldPlanStartTime)
  28246. }
  28247. if m.plan_end_time != nil {
  28248. fields = append(fields, soptask.FieldPlanEndTime)
  28249. }
  28250. if m.creator_id != nil {
  28251. fields = append(fields, soptask.FieldCreatorID)
  28252. }
  28253. if m.organization_id != nil {
  28254. fields = append(fields, soptask.FieldOrganizationID)
  28255. }
  28256. if m.token != nil {
  28257. fields = append(fields, soptask.FieldToken)
  28258. }
  28259. return fields
  28260. }
  28261. // Field returns the value of a field with the given name. The second boolean
  28262. // return value indicates that this field was not set, or was not defined in the
  28263. // schema.
  28264. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  28265. switch name {
  28266. case soptask.FieldCreatedAt:
  28267. return m.CreatedAt()
  28268. case soptask.FieldUpdatedAt:
  28269. return m.UpdatedAt()
  28270. case soptask.FieldStatus:
  28271. return m.Status()
  28272. case soptask.FieldDeletedAt:
  28273. return m.DeletedAt()
  28274. case soptask.FieldName:
  28275. return m.Name()
  28276. case soptask.FieldBotWxidList:
  28277. return m.BotWxidList()
  28278. case soptask.FieldType:
  28279. return m.GetType()
  28280. case soptask.FieldPlanStartTime:
  28281. return m.PlanStartTime()
  28282. case soptask.FieldPlanEndTime:
  28283. return m.PlanEndTime()
  28284. case soptask.FieldCreatorID:
  28285. return m.CreatorID()
  28286. case soptask.FieldOrganizationID:
  28287. return m.OrganizationID()
  28288. case soptask.FieldToken:
  28289. return m.Token()
  28290. }
  28291. return nil, false
  28292. }
  28293. // OldField returns the old value of the field from the database. An error is
  28294. // returned if the mutation operation is not UpdateOne, or the query to the
  28295. // database failed.
  28296. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28297. switch name {
  28298. case soptask.FieldCreatedAt:
  28299. return m.OldCreatedAt(ctx)
  28300. case soptask.FieldUpdatedAt:
  28301. return m.OldUpdatedAt(ctx)
  28302. case soptask.FieldStatus:
  28303. return m.OldStatus(ctx)
  28304. case soptask.FieldDeletedAt:
  28305. return m.OldDeletedAt(ctx)
  28306. case soptask.FieldName:
  28307. return m.OldName(ctx)
  28308. case soptask.FieldBotWxidList:
  28309. return m.OldBotWxidList(ctx)
  28310. case soptask.FieldType:
  28311. return m.OldType(ctx)
  28312. case soptask.FieldPlanStartTime:
  28313. return m.OldPlanStartTime(ctx)
  28314. case soptask.FieldPlanEndTime:
  28315. return m.OldPlanEndTime(ctx)
  28316. case soptask.FieldCreatorID:
  28317. return m.OldCreatorID(ctx)
  28318. case soptask.FieldOrganizationID:
  28319. return m.OldOrganizationID(ctx)
  28320. case soptask.FieldToken:
  28321. return m.OldToken(ctx)
  28322. }
  28323. return nil, fmt.Errorf("unknown SopTask field %s", name)
  28324. }
  28325. // SetField sets the value of a field with the given name. It returns an error if
  28326. // the field is not defined in the schema, or if the type mismatched the field
  28327. // type.
  28328. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  28329. switch name {
  28330. case soptask.FieldCreatedAt:
  28331. v, ok := value.(time.Time)
  28332. if !ok {
  28333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28334. }
  28335. m.SetCreatedAt(v)
  28336. return nil
  28337. case soptask.FieldUpdatedAt:
  28338. v, ok := value.(time.Time)
  28339. if !ok {
  28340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28341. }
  28342. m.SetUpdatedAt(v)
  28343. return nil
  28344. case soptask.FieldStatus:
  28345. v, ok := value.(uint8)
  28346. if !ok {
  28347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28348. }
  28349. m.SetStatus(v)
  28350. return nil
  28351. case soptask.FieldDeletedAt:
  28352. v, ok := value.(time.Time)
  28353. if !ok {
  28354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28355. }
  28356. m.SetDeletedAt(v)
  28357. return nil
  28358. case soptask.FieldName:
  28359. v, ok := value.(string)
  28360. if !ok {
  28361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28362. }
  28363. m.SetName(v)
  28364. return nil
  28365. case soptask.FieldBotWxidList:
  28366. v, ok := value.([]string)
  28367. if !ok {
  28368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28369. }
  28370. m.SetBotWxidList(v)
  28371. return nil
  28372. case soptask.FieldType:
  28373. v, ok := value.(int)
  28374. if !ok {
  28375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28376. }
  28377. m.SetType(v)
  28378. return nil
  28379. case soptask.FieldPlanStartTime:
  28380. v, ok := value.(time.Time)
  28381. if !ok {
  28382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28383. }
  28384. m.SetPlanStartTime(v)
  28385. return nil
  28386. case soptask.FieldPlanEndTime:
  28387. v, ok := value.(time.Time)
  28388. if !ok {
  28389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28390. }
  28391. m.SetPlanEndTime(v)
  28392. return nil
  28393. case soptask.FieldCreatorID:
  28394. v, ok := value.(string)
  28395. if !ok {
  28396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28397. }
  28398. m.SetCreatorID(v)
  28399. return nil
  28400. case soptask.FieldOrganizationID:
  28401. v, ok := value.(uint64)
  28402. if !ok {
  28403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28404. }
  28405. m.SetOrganizationID(v)
  28406. return nil
  28407. case soptask.FieldToken:
  28408. v, ok := value.([]string)
  28409. if !ok {
  28410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28411. }
  28412. m.SetToken(v)
  28413. return nil
  28414. }
  28415. return fmt.Errorf("unknown SopTask field %s", name)
  28416. }
  28417. // AddedFields returns all numeric fields that were incremented/decremented during
  28418. // this mutation.
  28419. func (m *SopTaskMutation) AddedFields() []string {
  28420. var fields []string
  28421. if m.addstatus != nil {
  28422. fields = append(fields, soptask.FieldStatus)
  28423. }
  28424. if m.add_type != nil {
  28425. fields = append(fields, soptask.FieldType)
  28426. }
  28427. if m.addorganization_id != nil {
  28428. fields = append(fields, soptask.FieldOrganizationID)
  28429. }
  28430. return fields
  28431. }
  28432. // AddedField returns the numeric value that was incremented/decremented on a field
  28433. // with the given name. The second boolean return value indicates that this field
  28434. // was not set, or was not defined in the schema.
  28435. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  28436. switch name {
  28437. case soptask.FieldStatus:
  28438. return m.AddedStatus()
  28439. case soptask.FieldType:
  28440. return m.AddedType()
  28441. case soptask.FieldOrganizationID:
  28442. return m.AddedOrganizationID()
  28443. }
  28444. return nil, false
  28445. }
  28446. // AddField adds the value to the field with the given name. It returns an error if
  28447. // the field is not defined in the schema, or if the type mismatched the field
  28448. // type.
  28449. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  28450. switch name {
  28451. case soptask.FieldStatus:
  28452. v, ok := value.(int8)
  28453. if !ok {
  28454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28455. }
  28456. m.AddStatus(v)
  28457. return nil
  28458. case soptask.FieldType:
  28459. v, ok := value.(int)
  28460. if !ok {
  28461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28462. }
  28463. m.AddType(v)
  28464. return nil
  28465. case soptask.FieldOrganizationID:
  28466. v, ok := value.(int64)
  28467. if !ok {
  28468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28469. }
  28470. m.AddOrganizationID(v)
  28471. return nil
  28472. }
  28473. return fmt.Errorf("unknown SopTask numeric field %s", name)
  28474. }
  28475. // ClearedFields returns all nullable fields that were cleared during this
  28476. // mutation.
  28477. func (m *SopTaskMutation) ClearedFields() []string {
  28478. var fields []string
  28479. if m.FieldCleared(soptask.FieldStatus) {
  28480. fields = append(fields, soptask.FieldStatus)
  28481. }
  28482. if m.FieldCleared(soptask.FieldDeletedAt) {
  28483. fields = append(fields, soptask.FieldDeletedAt)
  28484. }
  28485. if m.FieldCleared(soptask.FieldBotWxidList) {
  28486. fields = append(fields, soptask.FieldBotWxidList)
  28487. }
  28488. if m.FieldCleared(soptask.FieldPlanStartTime) {
  28489. fields = append(fields, soptask.FieldPlanStartTime)
  28490. }
  28491. if m.FieldCleared(soptask.FieldPlanEndTime) {
  28492. fields = append(fields, soptask.FieldPlanEndTime)
  28493. }
  28494. if m.FieldCleared(soptask.FieldCreatorID) {
  28495. fields = append(fields, soptask.FieldCreatorID)
  28496. }
  28497. if m.FieldCleared(soptask.FieldOrganizationID) {
  28498. fields = append(fields, soptask.FieldOrganizationID)
  28499. }
  28500. if m.FieldCleared(soptask.FieldToken) {
  28501. fields = append(fields, soptask.FieldToken)
  28502. }
  28503. return fields
  28504. }
  28505. // FieldCleared returns a boolean indicating if a field with the given name was
  28506. // cleared in this mutation.
  28507. func (m *SopTaskMutation) FieldCleared(name string) bool {
  28508. _, ok := m.clearedFields[name]
  28509. return ok
  28510. }
  28511. // ClearField clears the value of the field with the given name. It returns an
  28512. // error if the field is not defined in the schema.
  28513. func (m *SopTaskMutation) ClearField(name string) error {
  28514. switch name {
  28515. case soptask.FieldStatus:
  28516. m.ClearStatus()
  28517. return nil
  28518. case soptask.FieldDeletedAt:
  28519. m.ClearDeletedAt()
  28520. return nil
  28521. case soptask.FieldBotWxidList:
  28522. m.ClearBotWxidList()
  28523. return nil
  28524. case soptask.FieldPlanStartTime:
  28525. m.ClearPlanStartTime()
  28526. return nil
  28527. case soptask.FieldPlanEndTime:
  28528. m.ClearPlanEndTime()
  28529. return nil
  28530. case soptask.FieldCreatorID:
  28531. m.ClearCreatorID()
  28532. return nil
  28533. case soptask.FieldOrganizationID:
  28534. m.ClearOrganizationID()
  28535. return nil
  28536. case soptask.FieldToken:
  28537. m.ClearToken()
  28538. return nil
  28539. }
  28540. return fmt.Errorf("unknown SopTask nullable field %s", name)
  28541. }
  28542. // ResetField resets all changes in the mutation for the field with the given name.
  28543. // It returns an error if the field is not defined in the schema.
  28544. func (m *SopTaskMutation) ResetField(name string) error {
  28545. switch name {
  28546. case soptask.FieldCreatedAt:
  28547. m.ResetCreatedAt()
  28548. return nil
  28549. case soptask.FieldUpdatedAt:
  28550. m.ResetUpdatedAt()
  28551. return nil
  28552. case soptask.FieldStatus:
  28553. m.ResetStatus()
  28554. return nil
  28555. case soptask.FieldDeletedAt:
  28556. m.ResetDeletedAt()
  28557. return nil
  28558. case soptask.FieldName:
  28559. m.ResetName()
  28560. return nil
  28561. case soptask.FieldBotWxidList:
  28562. m.ResetBotWxidList()
  28563. return nil
  28564. case soptask.FieldType:
  28565. m.ResetType()
  28566. return nil
  28567. case soptask.FieldPlanStartTime:
  28568. m.ResetPlanStartTime()
  28569. return nil
  28570. case soptask.FieldPlanEndTime:
  28571. m.ResetPlanEndTime()
  28572. return nil
  28573. case soptask.FieldCreatorID:
  28574. m.ResetCreatorID()
  28575. return nil
  28576. case soptask.FieldOrganizationID:
  28577. m.ResetOrganizationID()
  28578. return nil
  28579. case soptask.FieldToken:
  28580. m.ResetToken()
  28581. return nil
  28582. }
  28583. return fmt.Errorf("unknown SopTask field %s", name)
  28584. }
  28585. // AddedEdges returns all edge names that were set/added in this mutation.
  28586. func (m *SopTaskMutation) AddedEdges() []string {
  28587. edges := make([]string, 0, 1)
  28588. if m.task_stages != nil {
  28589. edges = append(edges, soptask.EdgeTaskStages)
  28590. }
  28591. return edges
  28592. }
  28593. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28594. // name in this mutation.
  28595. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  28596. switch name {
  28597. case soptask.EdgeTaskStages:
  28598. ids := make([]ent.Value, 0, len(m.task_stages))
  28599. for id := range m.task_stages {
  28600. ids = append(ids, id)
  28601. }
  28602. return ids
  28603. }
  28604. return nil
  28605. }
  28606. // RemovedEdges returns all edge names that were removed in this mutation.
  28607. func (m *SopTaskMutation) RemovedEdges() []string {
  28608. edges := make([]string, 0, 1)
  28609. if m.removedtask_stages != nil {
  28610. edges = append(edges, soptask.EdgeTaskStages)
  28611. }
  28612. return edges
  28613. }
  28614. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28615. // the given name in this mutation.
  28616. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  28617. switch name {
  28618. case soptask.EdgeTaskStages:
  28619. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  28620. for id := range m.removedtask_stages {
  28621. ids = append(ids, id)
  28622. }
  28623. return ids
  28624. }
  28625. return nil
  28626. }
  28627. // ClearedEdges returns all edge names that were cleared in this mutation.
  28628. func (m *SopTaskMutation) ClearedEdges() []string {
  28629. edges := make([]string, 0, 1)
  28630. if m.clearedtask_stages {
  28631. edges = append(edges, soptask.EdgeTaskStages)
  28632. }
  28633. return edges
  28634. }
  28635. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28636. // was cleared in this mutation.
  28637. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  28638. switch name {
  28639. case soptask.EdgeTaskStages:
  28640. return m.clearedtask_stages
  28641. }
  28642. return false
  28643. }
  28644. // ClearEdge clears the value of the edge with the given name. It returns an error
  28645. // if that edge is not defined in the schema.
  28646. func (m *SopTaskMutation) ClearEdge(name string) error {
  28647. switch name {
  28648. }
  28649. return fmt.Errorf("unknown SopTask unique edge %s", name)
  28650. }
  28651. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28652. // It returns an error if the edge is not defined in the schema.
  28653. func (m *SopTaskMutation) ResetEdge(name string) error {
  28654. switch name {
  28655. case soptask.EdgeTaskStages:
  28656. m.ResetTaskStages()
  28657. return nil
  28658. }
  28659. return fmt.Errorf("unknown SopTask edge %s", name)
  28660. }
  28661. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  28662. type TokenMutation struct {
  28663. config
  28664. op Op
  28665. typ string
  28666. id *uint64
  28667. created_at *time.Time
  28668. updated_at *time.Time
  28669. deleted_at *time.Time
  28670. expire_at *time.Time
  28671. token *string
  28672. mac *string
  28673. organization_id *uint64
  28674. addorganization_id *int64
  28675. custom_agent_base *string
  28676. custom_agent_key *string
  28677. openai_base *string
  28678. openai_key *string
  28679. clearedFields map[string]struct{}
  28680. agent *uint64
  28681. clearedagent bool
  28682. done bool
  28683. oldValue func(context.Context) (*Token, error)
  28684. predicates []predicate.Token
  28685. }
  28686. var _ ent.Mutation = (*TokenMutation)(nil)
  28687. // tokenOption allows management of the mutation configuration using functional options.
  28688. type tokenOption func(*TokenMutation)
  28689. // newTokenMutation creates new mutation for the Token entity.
  28690. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  28691. m := &TokenMutation{
  28692. config: c,
  28693. op: op,
  28694. typ: TypeToken,
  28695. clearedFields: make(map[string]struct{}),
  28696. }
  28697. for _, opt := range opts {
  28698. opt(m)
  28699. }
  28700. return m
  28701. }
  28702. // withTokenID sets the ID field of the mutation.
  28703. func withTokenID(id uint64) tokenOption {
  28704. return func(m *TokenMutation) {
  28705. var (
  28706. err error
  28707. once sync.Once
  28708. value *Token
  28709. )
  28710. m.oldValue = func(ctx context.Context) (*Token, error) {
  28711. once.Do(func() {
  28712. if m.done {
  28713. err = errors.New("querying old values post mutation is not allowed")
  28714. } else {
  28715. value, err = m.Client().Token.Get(ctx, id)
  28716. }
  28717. })
  28718. return value, err
  28719. }
  28720. m.id = &id
  28721. }
  28722. }
  28723. // withToken sets the old Token of the mutation.
  28724. func withToken(node *Token) tokenOption {
  28725. return func(m *TokenMutation) {
  28726. m.oldValue = func(context.Context) (*Token, error) {
  28727. return node, nil
  28728. }
  28729. m.id = &node.ID
  28730. }
  28731. }
  28732. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28733. // executed in a transaction (ent.Tx), a transactional client is returned.
  28734. func (m TokenMutation) Client() *Client {
  28735. client := &Client{config: m.config}
  28736. client.init()
  28737. return client
  28738. }
  28739. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28740. // it returns an error otherwise.
  28741. func (m TokenMutation) Tx() (*Tx, error) {
  28742. if _, ok := m.driver.(*txDriver); !ok {
  28743. return nil, errors.New("ent: mutation is not running in a transaction")
  28744. }
  28745. tx := &Tx{config: m.config}
  28746. tx.init()
  28747. return tx, nil
  28748. }
  28749. // SetID sets the value of the id field. Note that this
  28750. // operation is only accepted on creation of Token entities.
  28751. func (m *TokenMutation) SetID(id uint64) {
  28752. m.id = &id
  28753. }
  28754. // ID returns the ID value in the mutation. Note that the ID is only available
  28755. // if it was provided to the builder or after it was returned from the database.
  28756. func (m *TokenMutation) ID() (id uint64, exists bool) {
  28757. if m.id == nil {
  28758. return
  28759. }
  28760. return *m.id, true
  28761. }
  28762. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28763. // That means, if the mutation is applied within a transaction with an isolation level such
  28764. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28765. // or updated by the mutation.
  28766. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  28767. switch {
  28768. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28769. id, exists := m.ID()
  28770. if exists {
  28771. return []uint64{id}, nil
  28772. }
  28773. fallthrough
  28774. case m.op.Is(OpUpdate | OpDelete):
  28775. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  28776. default:
  28777. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28778. }
  28779. }
  28780. // SetCreatedAt sets the "created_at" field.
  28781. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  28782. m.created_at = &t
  28783. }
  28784. // CreatedAt returns the value of the "created_at" field in the mutation.
  28785. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  28786. v := m.created_at
  28787. if v == nil {
  28788. return
  28789. }
  28790. return *v, true
  28791. }
  28792. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  28793. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28795. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28796. if !m.op.Is(OpUpdateOne) {
  28797. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28798. }
  28799. if m.id == nil || m.oldValue == nil {
  28800. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28801. }
  28802. oldValue, err := m.oldValue(ctx)
  28803. if err != nil {
  28804. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28805. }
  28806. return oldValue.CreatedAt, nil
  28807. }
  28808. // ResetCreatedAt resets all changes to the "created_at" field.
  28809. func (m *TokenMutation) ResetCreatedAt() {
  28810. m.created_at = nil
  28811. }
  28812. // SetUpdatedAt sets the "updated_at" field.
  28813. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  28814. m.updated_at = &t
  28815. }
  28816. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28817. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  28818. v := m.updated_at
  28819. if v == nil {
  28820. return
  28821. }
  28822. return *v, true
  28823. }
  28824. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  28825. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28827. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28828. if !m.op.Is(OpUpdateOne) {
  28829. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28830. }
  28831. if m.id == nil || m.oldValue == nil {
  28832. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28833. }
  28834. oldValue, err := m.oldValue(ctx)
  28835. if err != nil {
  28836. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28837. }
  28838. return oldValue.UpdatedAt, nil
  28839. }
  28840. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28841. func (m *TokenMutation) ResetUpdatedAt() {
  28842. m.updated_at = nil
  28843. }
  28844. // SetDeletedAt sets the "deleted_at" field.
  28845. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  28846. m.deleted_at = &t
  28847. }
  28848. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28849. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  28850. v := m.deleted_at
  28851. if v == nil {
  28852. return
  28853. }
  28854. return *v, true
  28855. }
  28856. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  28857. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28859. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28860. if !m.op.Is(OpUpdateOne) {
  28861. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28862. }
  28863. if m.id == nil || m.oldValue == nil {
  28864. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28865. }
  28866. oldValue, err := m.oldValue(ctx)
  28867. if err != nil {
  28868. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28869. }
  28870. return oldValue.DeletedAt, nil
  28871. }
  28872. // ClearDeletedAt clears the value of the "deleted_at" field.
  28873. func (m *TokenMutation) ClearDeletedAt() {
  28874. m.deleted_at = nil
  28875. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  28876. }
  28877. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28878. func (m *TokenMutation) DeletedAtCleared() bool {
  28879. _, ok := m.clearedFields[token.FieldDeletedAt]
  28880. return ok
  28881. }
  28882. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28883. func (m *TokenMutation) ResetDeletedAt() {
  28884. m.deleted_at = nil
  28885. delete(m.clearedFields, token.FieldDeletedAt)
  28886. }
  28887. // SetExpireAt sets the "expire_at" field.
  28888. func (m *TokenMutation) SetExpireAt(t time.Time) {
  28889. m.expire_at = &t
  28890. }
  28891. // ExpireAt returns the value of the "expire_at" field in the mutation.
  28892. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  28893. v := m.expire_at
  28894. if v == nil {
  28895. return
  28896. }
  28897. return *v, true
  28898. }
  28899. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  28900. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28902. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  28903. if !m.op.Is(OpUpdateOne) {
  28904. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  28905. }
  28906. if m.id == nil || m.oldValue == nil {
  28907. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  28908. }
  28909. oldValue, err := m.oldValue(ctx)
  28910. if err != nil {
  28911. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  28912. }
  28913. return oldValue.ExpireAt, nil
  28914. }
  28915. // ClearExpireAt clears the value of the "expire_at" field.
  28916. func (m *TokenMutation) ClearExpireAt() {
  28917. m.expire_at = nil
  28918. m.clearedFields[token.FieldExpireAt] = struct{}{}
  28919. }
  28920. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  28921. func (m *TokenMutation) ExpireAtCleared() bool {
  28922. _, ok := m.clearedFields[token.FieldExpireAt]
  28923. return ok
  28924. }
  28925. // ResetExpireAt resets all changes to the "expire_at" field.
  28926. func (m *TokenMutation) ResetExpireAt() {
  28927. m.expire_at = nil
  28928. delete(m.clearedFields, token.FieldExpireAt)
  28929. }
  28930. // SetToken sets the "token" field.
  28931. func (m *TokenMutation) SetToken(s string) {
  28932. m.token = &s
  28933. }
  28934. // Token returns the value of the "token" field in the mutation.
  28935. func (m *TokenMutation) Token() (r string, exists bool) {
  28936. v := m.token
  28937. if v == nil {
  28938. return
  28939. }
  28940. return *v, true
  28941. }
  28942. // OldToken returns the old "token" field's value of the Token entity.
  28943. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28945. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  28946. if !m.op.Is(OpUpdateOne) {
  28947. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  28948. }
  28949. if m.id == nil || m.oldValue == nil {
  28950. return v, errors.New("OldToken requires an ID field in the mutation")
  28951. }
  28952. oldValue, err := m.oldValue(ctx)
  28953. if err != nil {
  28954. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  28955. }
  28956. return oldValue.Token, nil
  28957. }
  28958. // ClearToken clears the value of the "token" field.
  28959. func (m *TokenMutation) ClearToken() {
  28960. m.token = nil
  28961. m.clearedFields[token.FieldToken] = struct{}{}
  28962. }
  28963. // TokenCleared returns if the "token" field was cleared in this mutation.
  28964. func (m *TokenMutation) TokenCleared() bool {
  28965. _, ok := m.clearedFields[token.FieldToken]
  28966. return ok
  28967. }
  28968. // ResetToken resets all changes to the "token" field.
  28969. func (m *TokenMutation) ResetToken() {
  28970. m.token = nil
  28971. delete(m.clearedFields, token.FieldToken)
  28972. }
  28973. // SetMAC sets the "mac" field.
  28974. func (m *TokenMutation) SetMAC(s string) {
  28975. m.mac = &s
  28976. }
  28977. // MAC returns the value of the "mac" field in the mutation.
  28978. func (m *TokenMutation) MAC() (r string, exists bool) {
  28979. v := m.mac
  28980. if v == nil {
  28981. return
  28982. }
  28983. return *v, true
  28984. }
  28985. // OldMAC returns the old "mac" field's value of the Token entity.
  28986. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28988. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  28989. if !m.op.Is(OpUpdateOne) {
  28990. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  28991. }
  28992. if m.id == nil || m.oldValue == nil {
  28993. return v, errors.New("OldMAC requires an ID field in the mutation")
  28994. }
  28995. oldValue, err := m.oldValue(ctx)
  28996. if err != nil {
  28997. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  28998. }
  28999. return oldValue.MAC, nil
  29000. }
  29001. // ClearMAC clears the value of the "mac" field.
  29002. func (m *TokenMutation) ClearMAC() {
  29003. m.mac = nil
  29004. m.clearedFields[token.FieldMAC] = struct{}{}
  29005. }
  29006. // MACCleared returns if the "mac" field was cleared in this mutation.
  29007. func (m *TokenMutation) MACCleared() bool {
  29008. _, ok := m.clearedFields[token.FieldMAC]
  29009. return ok
  29010. }
  29011. // ResetMAC resets all changes to the "mac" field.
  29012. func (m *TokenMutation) ResetMAC() {
  29013. m.mac = nil
  29014. delete(m.clearedFields, token.FieldMAC)
  29015. }
  29016. // SetOrganizationID sets the "organization_id" field.
  29017. func (m *TokenMutation) SetOrganizationID(u uint64) {
  29018. m.organization_id = &u
  29019. m.addorganization_id = nil
  29020. }
  29021. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29022. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  29023. v := m.organization_id
  29024. if v == nil {
  29025. return
  29026. }
  29027. return *v, true
  29028. }
  29029. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  29030. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29032. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29033. if !m.op.Is(OpUpdateOne) {
  29034. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29035. }
  29036. if m.id == nil || m.oldValue == nil {
  29037. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29038. }
  29039. oldValue, err := m.oldValue(ctx)
  29040. if err != nil {
  29041. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29042. }
  29043. return oldValue.OrganizationID, nil
  29044. }
  29045. // AddOrganizationID adds u to the "organization_id" field.
  29046. func (m *TokenMutation) AddOrganizationID(u int64) {
  29047. if m.addorganization_id != nil {
  29048. *m.addorganization_id += u
  29049. } else {
  29050. m.addorganization_id = &u
  29051. }
  29052. }
  29053. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29054. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  29055. v := m.addorganization_id
  29056. if v == nil {
  29057. return
  29058. }
  29059. return *v, true
  29060. }
  29061. // ResetOrganizationID resets all changes to the "organization_id" field.
  29062. func (m *TokenMutation) ResetOrganizationID() {
  29063. m.organization_id = nil
  29064. m.addorganization_id = nil
  29065. }
  29066. // SetAgentID sets the "agent_id" field.
  29067. func (m *TokenMutation) SetAgentID(u uint64) {
  29068. m.agent = &u
  29069. }
  29070. // AgentID returns the value of the "agent_id" field in the mutation.
  29071. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  29072. v := m.agent
  29073. if v == nil {
  29074. return
  29075. }
  29076. return *v, true
  29077. }
  29078. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  29079. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29081. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  29082. if !m.op.Is(OpUpdateOne) {
  29083. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  29084. }
  29085. if m.id == nil || m.oldValue == nil {
  29086. return v, errors.New("OldAgentID requires an ID field in the mutation")
  29087. }
  29088. oldValue, err := m.oldValue(ctx)
  29089. if err != nil {
  29090. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  29091. }
  29092. return oldValue.AgentID, nil
  29093. }
  29094. // ResetAgentID resets all changes to the "agent_id" field.
  29095. func (m *TokenMutation) ResetAgentID() {
  29096. m.agent = nil
  29097. }
  29098. // SetCustomAgentBase sets the "custom_agent_base" field.
  29099. func (m *TokenMutation) SetCustomAgentBase(s string) {
  29100. m.custom_agent_base = &s
  29101. }
  29102. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  29103. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  29104. v := m.custom_agent_base
  29105. if v == nil {
  29106. return
  29107. }
  29108. return *v, true
  29109. }
  29110. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  29111. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29113. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  29114. if !m.op.Is(OpUpdateOne) {
  29115. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  29116. }
  29117. if m.id == nil || m.oldValue == nil {
  29118. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  29119. }
  29120. oldValue, err := m.oldValue(ctx)
  29121. if err != nil {
  29122. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  29123. }
  29124. return oldValue.CustomAgentBase, nil
  29125. }
  29126. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  29127. func (m *TokenMutation) ClearCustomAgentBase() {
  29128. m.custom_agent_base = nil
  29129. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  29130. }
  29131. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  29132. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  29133. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  29134. return ok
  29135. }
  29136. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  29137. func (m *TokenMutation) ResetCustomAgentBase() {
  29138. m.custom_agent_base = nil
  29139. delete(m.clearedFields, token.FieldCustomAgentBase)
  29140. }
  29141. // SetCustomAgentKey sets the "custom_agent_key" field.
  29142. func (m *TokenMutation) SetCustomAgentKey(s string) {
  29143. m.custom_agent_key = &s
  29144. }
  29145. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  29146. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  29147. v := m.custom_agent_key
  29148. if v == nil {
  29149. return
  29150. }
  29151. return *v, true
  29152. }
  29153. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  29154. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29156. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  29157. if !m.op.Is(OpUpdateOne) {
  29158. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  29159. }
  29160. if m.id == nil || m.oldValue == nil {
  29161. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  29162. }
  29163. oldValue, err := m.oldValue(ctx)
  29164. if err != nil {
  29165. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  29166. }
  29167. return oldValue.CustomAgentKey, nil
  29168. }
  29169. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  29170. func (m *TokenMutation) ClearCustomAgentKey() {
  29171. m.custom_agent_key = nil
  29172. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  29173. }
  29174. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  29175. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  29176. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  29177. return ok
  29178. }
  29179. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  29180. func (m *TokenMutation) ResetCustomAgentKey() {
  29181. m.custom_agent_key = nil
  29182. delete(m.clearedFields, token.FieldCustomAgentKey)
  29183. }
  29184. // SetOpenaiBase sets the "openai_base" field.
  29185. func (m *TokenMutation) SetOpenaiBase(s string) {
  29186. m.openai_base = &s
  29187. }
  29188. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  29189. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  29190. v := m.openai_base
  29191. if v == nil {
  29192. return
  29193. }
  29194. return *v, true
  29195. }
  29196. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  29197. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29199. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  29200. if !m.op.Is(OpUpdateOne) {
  29201. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  29202. }
  29203. if m.id == nil || m.oldValue == nil {
  29204. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  29205. }
  29206. oldValue, err := m.oldValue(ctx)
  29207. if err != nil {
  29208. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  29209. }
  29210. return oldValue.OpenaiBase, nil
  29211. }
  29212. // ClearOpenaiBase clears the value of the "openai_base" field.
  29213. func (m *TokenMutation) ClearOpenaiBase() {
  29214. m.openai_base = nil
  29215. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  29216. }
  29217. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  29218. func (m *TokenMutation) OpenaiBaseCleared() bool {
  29219. _, ok := m.clearedFields[token.FieldOpenaiBase]
  29220. return ok
  29221. }
  29222. // ResetOpenaiBase resets all changes to the "openai_base" field.
  29223. func (m *TokenMutation) ResetOpenaiBase() {
  29224. m.openai_base = nil
  29225. delete(m.clearedFields, token.FieldOpenaiBase)
  29226. }
  29227. // SetOpenaiKey sets the "openai_key" field.
  29228. func (m *TokenMutation) SetOpenaiKey(s string) {
  29229. m.openai_key = &s
  29230. }
  29231. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  29232. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  29233. v := m.openai_key
  29234. if v == nil {
  29235. return
  29236. }
  29237. return *v, true
  29238. }
  29239. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  29240. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29242. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  29243. if !m.op.Is(OpUpdateOne) {
  29244. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  29245. }
  29246. if m.id == nil || m.oldValue == nil {
  29247. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  29248. }
  29249. oldValue, err := m.oldValue(ctx)
  29250. if err != nil {
  29251. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  29252. }
  29253. return oldValue.OpenaiKey, nil
  29254. }
  29255. // ClearOpenaiKey clears the value of the "openai_key" field.
  29256. func (m *TokenMutation) ClearOpenaiKey() {
  29257. m.openai_key = nil
  29258. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  29259. }
  29260. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  29261. func (m *TokenMutation) OpenaiKeyCleared() bool {
  29262. _, ok := m.clearedFields[token.FieldOpenaiKey]
  29263. return ok
  29264. }
  29265. // ResetOpenaiKey resets all changes to the "openai_key" field.
  29266. func (m *TokenMutation) ResetOpenaiKey() {
  29267. m.openai_key = nil
  29268. delete(m.clearedFields, token.FieldOpenaiKey)
  29269. }
  29270. // ClearAgent clears the "agent" edge to the Agent entity.
  29271. func (m *TokenMutation) ClearAgent() {
  29272. m.clearedagent = true
  29273. m.clearedFields[token.FieldAgentID] = struct{}{}
  29274. }
  29275. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  29276. func (m *TokenMutation) AgentCleared() bool {
  29277. return m.clearedagent
  29278. }
  29279. // AgentIDs returns the "agent" edge IDs in the mutation.
  29280. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29281. // AgentID instead. It exists only for internal usage by the builders.
  29282. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  29283. if id := m.agent; id != nil {
  29284. ids = append(ids, *id)
  29285. }
  29286. return
  29287. }
  29288. // ResetAgent resets all changes to the "agent" edge.
  29289. func (m *TokenMutation) ResetAgent() {
  29290. m.agent = nil
  29291. m.clearedagent = false
  29292. }
  29293. // Where appends a list predicates to the TokenMutation builder.
  29294. func (m *TokenMutation) Where(ps ...predicate.Token) {
  29295. m.predicates = append(m.predicates, ps...)
  29296. }
  29297. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  29298. // users can use type-assertion to append predicates that do not depend on any generated package.
  29299. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  29300. p := make([]predicate.Token, len(ps))
  29301. for i := range ps {
  29302. p[i] = ps[i]
  29303. }
  29304. m.Where(p...)
  29305. }
  29306. // Op returns the operation name.
  29307. func (m *TokenMutation) Op() Op {
  29308. return m.op
  29309. }
  29310. // SetOp allows setting the mutation operation.
  29311. func (m *TokenMutation) SetOp(op Op) {
  29312. m.op = op
  29313. }
  29314. // Type returns the node type of this mutation (Token).
  29315. func (m *TokenMutation) Type() string {
  29316. return m.typ
  29317. }
  29318. // Fields returns all fields that were changed during this mutation. Note that in
  29319. // order to get all numeric fields that were incremented/decremented, call
  29320. // AddedFields().
  29321. func (m *TokenMutation) Fields() []string {
  29322. fields := make([]string, 0, 12)
  29323. if m.created_at != nil {
  29324. fields = append(fields, token.FieldCreatedAt)
  29325. }
  29326. if m.updated_at != nil {
  29327. fields = append(fields, token.FieldUpdatedAt)
  29328. }
  29329. if m.deleted_at != nil {
  29330. fields = append(fields, token.FieldDeletedAt)
  29331. }
  29332. if m.expire_at != nil {
  29333. fields = append(fields, token.FieldExpireAt)
  29334. }
  29335. if m.token != nil {
  29336. fields = append(fields, token.FieldToken)
  29337. }
  29338. if m.mac != nil {
  29339. fields = append(fields, token.FieldMAC)
  29340. }
  29341. if m.organization_id != nil {
  29342. fields = append(fields, token.FieldOrganizationID)
  29343. }
  29344. if m.agent != nil {
  29345. fields = append(fields, token.FieldAgentID)
  29346. }
  29347. if m.custom_agent_base != nil {
  29348. fields = append(fields, token.FieldCustomAgentBase)
  29349. }
  29350. if m.custom_agent_key != nil {
  29351. fields = append(fields, token.FieldCustomAgentKey)
  29352. }
  29353. if m.openai_base != nil {
  29354. fields = append(fields, token.FieldOpenaiBase)
  29355. }
  29356. if m.openai_key != nil {
  29357. fields = append(fields, token.FieldOpenaiKey)
  29358. }
  29359. return fields
  29360. }
  29361. // Field returns the value of a field with the given name. The second boolean
  29362. // return value indicates that this field was not set, or was not defined in the
  29363. // schema.
  29364. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  29365. switch name {
  29366. case token.FieldCreatedAt:
  29367. return m.CreatedAt()
  29368. case token.FieldUpdatedAt:
  29369. return m.UpdatedAt()
  29370. case token.FieldDeletedAt:
  29371. return m.DeletedAt()
  29372. case token.FieldExpireAt:
  29373. return m.ExpireAt()
  29374. case token.FieldToken:
  29375. return m.Token()
  29376. case token.FieldMAC:
  29377. return m.MAC()
  29378. case token.FieldOrganizationID:
  29379. return m.OrganizationID()
  29380. case token.FieldAgentID:
  29381. return m.AgentID()
  29382. case token.FieldCustomAgentBase:
  29383. return m.CustomAgentBase()
  29384. case token.FieldCustomAgentKey:
  29385. return m.CustomAgentKey()
  29386. case token.FieldOpenaiBase:
  29387. return m.OpenaiBase()
  29388. case token.FieldOpenaiKey:
  29389. return m.OpenaiKey()
  29390. }
  29391. return nil, false
  29392. }
  29393. // OldField returns the old value of the field from the database. An error is
  29394. // returned if the mutation operation is not UpdateOne, or the query to the
  29395. // database failed.
  29396. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29397. switch name {
  29398. case token.FieldCreatedAt:
  29399. return m.OldCreatedAt(ctx)
  29400. case token.FieldUpdatedAt:
  29401. return m.OldUpdatedAt(ctx)
  29402. case token.FieldDeletedAt:
  29403. return m.OldDeletedAt(ctx)
  29404. case token.FieldExpireAt:
  29405. return m.OldExpireAt(ctx)
  29406. case token.FieldToken:
  29407. return m.OldToken(ctx)
  29408. case token.FieldMAC:
  29409. return m.OldMAC(ctx)
  29410. case token.FieldOrganizationID:
  29411. return m.OldOrganizationID(ctx)
  29412. case token.FieldAgentID:
  29413. return m.OldAgentID(ctx)
  29414. case token.FieldCustomAgentBase:
  29415. return m.OldCustomAgentBase(ctx)
  29416. case token.FieldCustomAgentKey:
  29417. return m.OldCustomAgentKey(ctx)
  29418. case token.FieldOpenaiBase:
  29419. return m.OldOpenaiBase(ctx)
  29420. case token.FieldOpenaiKey:
  29421. return m.OldOpenaiKey(ctx)
  29422. }
  29423. return nil, fmt.Errorf("unknown Token field %s", name)
  29424. }
  29425. // SetField sets the value of a field with the given name. It returns an error if
  29426. // the field is not defined in the schema, or if the type mismatched the field
  29427. // type.
  29428. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  29429. switch name {
  29430. case token.FieldCreatedAt:
  29431. v, ok := value.(time.Time)
  29432. if !ok {
  29433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29434. }
  29435. m.SetCreatedAt(v)
  29436. return nil
  29437. case token.FieldUpdatedAt:
  29438. v, ok := value.(time.Time)
  29439. if !ok {
  29440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29441. }
  29442. m.SetUpdatedAt(v)
  29443. return nil
  29444. case token.FieldDeletedAt:
  29445. v, ok := value.(time.Time)
  29446. if !ok {
  29447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29448. }
  29449. m.SetDeletedAt(v)
  29450. return nil
  29451. case token.FieldExpireAt:
  29452. v, ok := value.(time.Time)
  29453. if !ok {
  29454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29455. }
  29456. m.SetExpireAt(v)
  29457. return nil
  29458. case token.FieldToken:
  29459. v, ok := value.(string)
  29460. if !ok {
  29461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29462. }
  29463. m.SetToken(v)
  29464. return nil
  29465. case token.FieldMAC:
  29466. v, ok := value.(string)
  29467. if !ok {
  29468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29469. }
  29470. m.SetMAC(v)
  29471. return nil
  29472. case token.FieldOrganizationID:
  29473. v, ok := value.(uint64)
  29474. if !ok {
  29475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29476. }
  29477. m.SetOrganizationID(v)
  29478. return nil
  29479. case token.FieldAgentID:
  29480. v, ok := value.(uint64)
  29481. if !ok {
  29482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29483. }
  29484. m.SetAgentID(v)
  29485. return nil
  29486. case token.FieldCustomAgentBase:
  29487. v, ok := value.(string)
  29488. if !ok {
  29489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29490. }
  29491. m.SetCustomAgentBase(v)
  29492. return nil
  29493. case token.FieldCustomAgentKey:
  29494. v, ok := value.(string)
  29495. if !ok {
  29496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29497. }
  29498. m.SetCustomAgentKey(v)
  29499. return nil
  29500. case token.FieldOpenaiBase:
  29501. v, ok := value.(string)
  29502. if !ok {
  29503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29504. }
  29505. m.SetOpenaiBase(v)
  29506. return nil
  29507. case token.FieldOpenaiKey:
  29508. v, ok := value.(string)
  29509. if !ok {
  29510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29511. }
  29512. m.SetOpenaiKey(v)
  29513. return nil
  29514. }
  29515. return fmt.Errorf("unknown Token field %s", name)
  29516. }
  29517. // AddedFields returns all numeric fields that were incremented/decremented during
  29518. // this mutation.
  29519. func (m *TokenMutation) AddedFields() []string {
  29520. var fields []string
  29521. if m.addorganization_id != nil {
  29522. fields = append(fields, token.FieldOrganizationID)
  29523. }
  29524. return fields
  29525. }
  29526. // AddedField returns the numeric value that was incremented/decremented on a field
  29527. // with the given name. The second boolean return value indicates that this field
  29528. // was not set, or was not defined in the schema.
  29529. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  29530. switch name {
  29531. case token.FieldOrganizationID:
  29532. return m.AddedOrganizationID()
  29533. }
  29534. return nil, false
  29535. }
  29536. // AddField adds the value to the field with the given name. It returns an error if
  29537. // the field is not defined in the schema, or if the type mismatched the field
  29538. // type.
  29539. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  29540. switch name {
  29541. case token.FieldOrganizationID:
  29542. v, ok := value.(int64)
  29543. if !ok {
  29544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29545. }
  29546. m.AddOrganizationID(v)
  29547. return nil
  29548. }
  29549. return fmt.Errorf("unknown Token numeric field %s", name)
  29550. }
  29551. // ClearedFields returns all nullable fields that were cleared during this
  29552. // mutation.
  29553. func (m *TokenMutation) ClearedFields() []string {
  29554. var fields []string
  29555. if m.FieldCleared(token.FieldDeletedAt) {
  29556. fields = append(fields, token.FieldDeletedAt)
  29557. }
  29558. if m.FieldCleared(token.FieldExpireAt) {
  29559. fields = append(fields, token.FieldExpireAt)
  29560. }
  29561. if m.FieldCleared(token.FieldToken) {
  29562. fields = append(fields, token.FieldToken)
  29563. }
  29564. if m.FieldCleared(token.FieldMAC) {
  29565. fields = append(fields, token.FieldMAC)
  29566. }
  29567. if m.FieldCleared(token.FieldCustomAgentBase) {
  29568. fields = append(fields, token.FieldCustomAgentBase)
  29569. }
  29570. if m.FieldCleared(token.FieldCustomAgentKey) {
  29571. fields = append(fields, token.FieldCustomAgentKey)
  29572. }
  29573. if m.FieldCleared(token.FieldOpenaiBase) {
  29574. fields = append(fields, token.FieldOpenaiBase)
  29575. }
  29576. if m.FieldCleared(token.FieldOpenaiKey) {
  29577. fields = append(fields, token.FieldOpenaiKey)
  29578. }
  29579. return fields
  29580. }
  29581. // FieldCleared returns a boolean indicating if a field with the given name was
  29582. // cleared in this mutation.
  29583. func (m *TokenMutation) FieldCleared(name string) bool {
  29584. _, ok := m.clearedFields[name]
  29585. return ok
  29586. }
  29587. // ClearField clears the value of the field with the given name. It returns an
  29588. // error if the field is not defined in the schema.
  29589. func (m *TokenMutation) ClearField(name string) error {
  29590. switch name {
  29591. case token.FieldDeletedAt:
  29592. m.ClearDeletedAt()
  29593. return nil
  29594. case token.FieldExpireAt:
  29595. m.ClearExpireAt()
  29596. return nil
  29597. case token.FieldToken:
  29598. m.ClearToken()
  29599. return nil
  29600. case token.FieldMAC:
  29601. m.ClearMAC()
  29602. return nil
  29603. case token.FieldCustomAgentBase:
  29604. m.ClearCustomAgentBase()
  29605. return nil
  29606. case token.FieldCustomAgentKey:
  29607. m.ClearCustomAgentKey()
  29608. return nil
  29609. case token.FieldOpenaiBase:
  29610. m.ClearOpenaiBase()
  29611. return nil
  29612. case token.FieldOpenaiKey:
  29613. m.ClearOpenaiKey()
  29614. return nil
  29615. }
  29616. return fmt.Errorf("unknown Token nullable field %s", name)
  29617. }
  29618. // ResetField resets all changes in the mutation for the field with the given name.
  29619. // It returns an error if the field is not defined in the schema.
  29620. func (m *TokenMutation) ResetField(name string) error {
  29621. switch name {
  29622. case token.FieldCreatedAt:
  29623. m.ResetCreatedAt()
  29624. return nil
  29625. case token.FieldUpdatedAt:
  29626. m.ResetUpdatedAt()
  29627. return nil
  29628. case token.FieldDeletedAt:
  29629. m.ResetDeletedAt()
  29630. return nil
  29631. case token.FieldExpireAt:
  29632. m.ResetExpireAt()
  29633. return nil
  29634. case token.FieldToken:
  29635. m.ResetToken()
  29636. return nil
  29637. case token.FieldMAC:
  29638. m.ResetMAC()
  29639. return nil
  29640. case token.FieldOrganizationID:
  29641. m.ResetOrganizationID()
  29642. return nil
  29643. case token.FieldAgentID:
  29644. m.ResetAgentID()
  29645. return nil
  29646. case token.FieldCustomAgentBase:
  29647. m.ResetCustomAgentBase()
  29648. return nil
  29649. case token.FieldCustomAgentKey:
  29650. m.ResetCustomAgentKey()
  29651. return nil
  29652. case token.FieldOpenaiBase:
  29653. m.ResetOpenaiBase()
  29654. return nil
  29655. case token.FieldOpenaiKey:
  29656. m.ResetOpenaiKey()
  29657. return nil
  29658. }
  29659. return fmt.Errorf("unknown Token field %s", name)
  29660. }
  29661. // AddedEdges returns all edge names that were set/added in this mutation.
  29662. func (m *TokenMutation) AddedEdges() []string {
  29663. edges := make([]string, 0, 1)
  29664. if m.agent != nil {
  29665. edges = append(edges, token.EdgeAgent)
  29666. }
  29667. return edges
  29668. }
  29669. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29670. // name in this mutation.
  29671. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  29672. switch name {
  29673. case token.EdgeAgent:
  29674. if id := m.agent; id != nil {
  29675. return []ent.Value{*id}
  29676. }
  29677. }
  29678. return nil
  29679. }
  29680. // RemovedEdges returns all edge names that were removed in this mutation.
  29681. func (m *TokenMutation) RemovedEdges() []string {
  29682. edges := make([]string, 0, 1)
  29683. return edges
  29684. }
  29685. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29686. // the given name in this mutation.
  29687. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  29688. return nil
  29689. }
  29690. // ClearedEdges returns all edge names that were cleared in this mutation.
  29691. func (m *TokenMutation) ClearedEdges() []string {
  29692. edges := make([]string, 0, 1)
  29693. if m.clearedagent {
  29694. edges = append(edges, token.EdgeAgent)
  29695. }
  29696. return edges
  29697. }
  29698. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29699. // was cleared in this mutation.
  29700. func (m *TokenMutation) EdgeCleared(name string) bool {
  29701. switch name {
  29702. case token.EdgeAgent:
  29703. return m.clearedagent
  29704. }
  29705. return false
  29706. }
  29707. // ClearEdge clears the value of the edge with the given name. It returns an error
  29708. // if that edge is not defined in the schema.
  29709. func (m *TokenMutation) ClearEdge(name string) error {
  29710. switch name {
  29711. case token.EdgeAgent:
  29712. m.ClearAgent()
  29713. return nil
  29714. }
  29715. return fmt.Errorf("unknown Token unique edge %s", name)
  29716. }
  29717. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29718. // It returns an error if the edge is not defined in the schema.
  29719. func (m *TokenMutation) ResetEdge(name string) error {
  29720. switch name {
  29721. case token.EdgeAgent:
  29722. m.ResetAgent()
  29723. return nil
  29724. }
  29725. return fmt.Errorf("unknown Token edge %s", name)
  29726. }
  29727. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  29728. type TutorialMutation struct {
  29729. config
  29730. op Op
  29731. typ string
  29732. id *uint64
  29733. created_at *time.Time
  29734. updated_at *time.Time
  29735. deleted_at *time.Time
  29736. index *int
  29737. addindex *int
  29738. title *string
  29739. content *string
  29740. organization_id *uint64
  29741. addorganization_id *int64
  29742. clearedFields map[string]struct{}
  29743. employee *uint64
  29744. clearedemployee bool
  29745. done bool
  29746. oldValue func(context.Context) (*Tutorial, error)
  29747. predicates []predicate.Tutorial
  29748. }
  29749. var _ ent.Mutation = (*TutorialMutation)(nil)
  29750. // tutorialOption allows management of the mutation configuration using functional options.
  29751. type tutorialOption func(*TutorialMutation)
  29752. // newTutorialMutation creates new mutation for the Tutorial entity.
  29753. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  29754. m := &TutorialMutation{
  29755. config: c,
  29756. op: op,
  29757. typ: TypeTutorial,
  29758. clearedFields: make(map[string]struct{}),
  29759. }
  29760. for _, opt := range opts {
  29761. opt(m)
  29762. }
  29763. return m
  29764. }
  29765. // withTutorialID sets the ID field of the mutation.
  29766. func withTutorialID(id uint64) tutorialOption {
  29767. return func(m *TutorialMutation) {
  29768. var (
  29769. err error
  29770. once sync.Once
  29771. value *Tutorial
  29772. )
  29773. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  29774. once.Do(func() {
  29775. if m.done {
  29776. err = errors.New("querying old values post mutation is not allowed")
  29777. } else {
  29778. value, err = m.Client().Tutorial.Get(ctx, id)
  29779. }
  29780. })
  29781. return value, err
  29782. }
  29783. m.id = &id
  29784. }
  29785. }
  29786. // withTutorial sets the old Tutorial of the mutation.
  29787. func withTutorial(node *Tutorial) tutorialOption {
  29788. return func(m *TutorialMutation) {
  29789. m.oldValue = func(context.Context) (*Tutorial, error) {
  29790. return node, nil
  29791. }
  29792. m.id = &node.ID
  29793. }
  29794. }
  29795. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29796. // executed in a transaction (ent.Tx), a transactional client is returned.
  29797. func (m TutorialMutation) Client() *Client {
  29798. client := &Client{config: m.config}
  29799. client.init()
  29800. return client
  29801. }
  29802. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29803. // it returns an error otherwise.
  29804. func (m TutorialMutation) Tx() (*Tx, error) {
  29805. if _, ok := m.driver.(*txDriver); !ok {
  29806. return nil, errors.New("ent: mutation is not running in a transaction")
  29807. }
  29808. tx := &Tx{config: m.config}
  29809. tx.init()
  29810. return tx, nil
  29811. }
  29812. // SetID sets the value of the id field. Note that this
  29813. // operation is only accepted on creation of Tutorial entities.
  29814. func (m *TutorialMutation) SetID(id uint64) {
  29815. m.id = &id
  29816. }
  29817. // ID returns the ID value in the mutation. Note that the ID is only available
  29818. // if it was provided to the builder or after it was returned from the database.
  29819. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  29820. if m.id == nil {
  29821. return
  29822. }
  29823. return *m.id, true
  29824. }
  29825. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29826. // That means, if the mutation is applied within a transaction with an isolation level such
  29827. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29828. // or updated by the mutation.
  29829. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  29830. switch {
  29831. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29832. id, exists := m.ID()
  29833. if exists {
  29834. return []uint64{id}, nil
  29835. }
  29836. fallthrough
  29837. case m.op.Is(OpUpdate | OpDelete):
  29838. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  29839. default:
  29840. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29841. }
  29842. }
  29843. // SetCreatedAt sets the "created_at" field.
  29844. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  29845. m.created_at = &t
  29846. }
  29847. // CreatedAt returns the value of the "created_at" field in the mutation.
  29848. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  29849. v := m.created_at
  29850. if v == nil {
  29851. return
  29852. }
  29853. return *v, true
  29854. }
  29855. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  29856. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29858. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29859. if !m.op.Is(OpUpdateOne) {
  29860. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29861. }
  29862. if m.id == nil || m.oldValue == nil {
  29863. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29864. }
  29865. oldValue, err := m.oldValue(ctx)
  29866. if err != nil {
  29867. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29868. }
  29869. return oldValue.CreatedAt, nil
  29870. }
  29871. // ResetCreatedAt resets all changes to the "created_at" field.
  29872. func (m *TutorialMutation) ResetCreatedAt() {
  29873. m.created_at = nil
  29874. }
  29875. // SetUpdatedAt sets the "updated_at" field.
  29876. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  29877. m.updated_at = &t
  29878. }
  29879. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29880. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  29881. v := m.updated_at
  29882. if v == nil {
  29883. return
  29884. }
  29885. return *v, true
  29886. }
  29887. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  29888. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29890. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29891. if !m.op.Is(OpUpdateOne) {
  29892. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29893. }
  29894. if m.id == nil || m.oldValue == nil {
  29895. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29896. }
  29897. oldValue, err := m.oldValue(ctx)
  29898. if err != nil {
  29899. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29900. }
  29901. return oldValue.UpdatedAt, nil
  29902. }
  29903. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29904. func (m *TutorialMutation) ResetUpdatedAt() {
  29905. m.updated_at = nil
  29906. }
  29907. // SetDeletedAt sets the "deleted_at" field.
  29908. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  29909. m.deleted_at = &t
  29910. }
  29911. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29912. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  29913. v := m.deleted_at
  29914. if v == nil {
  29915. return
  29916. }
  29917. return *v, true
  29918. }
  29919. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  29920. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29922. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29923. if !m.op.Is(OpUpdateOne) {
  29924. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29925. }
  29926. if m.id == nil || m.oldValue == nil {
  29927. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29928. }
  29929. oldValue, err := m.oldValue(ctx)
  29930. if err != nil {
  29931. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29932. }
  29933. return oldValue.DeletedAt, nil
  29934. }
  29935. // ClearDeletedAt clears the value of the "deleted_at" field.
  29936. func (m *TutorialMutation) ClearDeletedAt() {
  29937. m.deleted_at = nil
  29938. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  29939. }
  29940. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29941. func (m *TutorialMutation) DeletedAtCleared() bool {
  29942. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  29943. return ok
  29944. }
  29945. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29946. func (m *TutorialMutation) ResetDeletedAt() {
  29947. m.deleted_at = nil
  29948. delete(m.clearedFields, tutorial.FieldDeletedAt)
  29949. }
  29950. // SetEmployeeID sets the "employee_id" field.
  29951. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  29952. m.employee = &u
  29953. }
  29954. // EmployeeID returns the value of the "employee_id" field in the mutation.
  29955. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  29956. v := m.employee
  29957. if v == nil {
  29958. return
  29959. }
  29960. return *v, true
  29961. }
  29962. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  29963. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29965. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  29966. if !m.op.Is(OpUpdateOne) {
  29967. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  29968. }
  29969. if m.id == nil || m.oldValue == nil {
  29970. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  29971. }
  29972. oldValue, err := m.oldValue(ctx)
  29973. if err != nil {
  29974. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  29975. }
  29976. return oldValue.EmployeeID, nil
  29977. }
  29978. // ResetEmployeeID resets all changes to the "employee_id" field.
  29979. func (m *TutorialMutation) ResetEmployeeID() {
  29980. m.employee = nil
  29981. }
  29982. // SetIndex sets the "index" field.
  29983. func (m *TutorialMutation) SetIndex(i int) {
  29984. m.index = &i
  29985. m.addindex = nil
  29986. }
  29987. // Index returns the value of the "index" field in the mutation.
  29988. func (m *TutorialMutation) Index() (r int, exists bool) {
  29989. v := m.index
  29990. if v == nil {
  29991. return
  29992. }
  29993. return *v, true
  29994. }
  29995. // OldIndex returns the old "index" field's value of the Tutorial entity.
  29996. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29998. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  29999. if !m.op.Is(OpUpdateOne) {
  30000. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  30001. }
  30002. if m.id == nil || m.oldValue == nil {
  30003. return v, errors.New("OldIndex requires an ID field in the mutation")
  30004. }
  30005. oldValue, err := m.oldValue(ctx)
  30006. if err != nil {
  30007. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  30008. }
  30009. return oldValue.Index, nil
  30010. }
  30011. // AddIndex adds i to the "index" field.
  30012. func (m *TutorialMutation) AddIndex(i int) {
  30013. if m.addindex != nil {
  30014. *m.addindex += i
  30015. } else {
  30016. m.addindex = &i
  30017. }
  30018. }
  30019. // AddedIndex returns the value that was added to the "index" field in this mutation.
  30020. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  30021. v := m.addindex
  30022. if v == nil {
  30023. return
  30024. }
  30025. return *v, true
  30026. }
  30027. // ResetIndex resets all changes to the "index" field.
  30028. func (m *TutorialMutation) ResetIndex() {
  30029. m.index = nil
  30030. m.addindex = nil
  30031. }
  30032. // SetTitle sets the "title" field.
  30033. func (m *TutorialMutation) SetTitle(s string) {
  30034. m.title = &s
  30035. }
  30036. // Title returns the value of the "title" field in the mutation.
  30037. func (m *TutorialMutation) Title() (r string, exists bool) {
  30038. v := m.title
  30039. if v == nil {
  30040. return
  30041. }
  30042. return *v, true
  30043. }
  30044. // OldTitle returns the old "title" field's value of the Tutorial entity.
  30045. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30047. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  30048. if !m.op.Is(OpUpdateOne) {
  30049. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  30050. }
  30051. if m.id == nil || m.oldValue == nil {
  30052. return v, errors.New("OldTitle requires an ID field in the mutation")
  30053. }
  30054. oldValue, err := m.oldValue(ctx)
  30055. if err != nil {
  30056. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  30057. }
  30058. return oldValue.Title, nil
  30059. }
  30060. // ResetTitle resets all changes to the "title" field.
  30061. func (m *TutorialMutation) ResetTitle() {
  30062. m.title = nil
  30063. }
  30064. // SetContent sets the "content" field.
  30065. func (m *TutorialMutation) SetContent(s string) {
  30066. m.content = &s
  30067. }
  30068. // Content returns the value of the "content" field in the mutation.
  30069. func (m *TutorialMutation) Content() (r string, exists bool) {
  30070. v := m.content
  30071. if v == nil {
  30072. return
  30073. }
  30074. return *v, true
  30075. }
  30076. // OldContent returns the old "content" field's value of the Tutorial entity.
  30077. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30079. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  30080. if !m.op.Is(OpUpdateOne) {
  30081. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  30082. }
  30083. if m.id == nil || m.oldValue == nil {
  30084. return v, errors.New("OldContent requires an ID field in the mutation")
  30085. }
  30086. oldValue, err := m.oldValue(ctx)
  30087. if err != nil {
  30088. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  30089. }
  30090. return oldValue.Content, nil
  30091. }
  30092. // ResetContent resets all changes to the "content" field.
  30093. func (m *TutorialMutation) ResetContent() {
  30094. m.content = nil
  30095. }
  30096. // SetOrganizationID sets the "organization_id" field.
  30097. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  30098. m.organization_id = &u
  30099. m.addorganization_id = nil
  30100. }
  30101. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30102. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  30103. v := m.organization_id
  30104. if v == nil {
  30105. return
  30106. }
  30107. return *v, true
  30108. }
  30109. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  30110. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30112. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30113. if !m.op.Is(OpUpdateOne) {
  30114. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30115. }
  30116. if m.id == nil || m.oldValue == nil {
  30117. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30118. }
  30119. oldValue, err := m.oldValue(ctx)
  30120. if err != nil {
  30121. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30122. }
  30123. return oldValue.OrganizationID, nil
  30124. }
  30125. // AddOrganizationID adds u to the "organization_id" field.
  30126. func (m *TutorialMutation) AddOrganizationID(u int64) {
  30127. if m.addorganization_id != nil {
  30128. *m.addorganization_id += u
  30129. } else {
  30130. m.addorganization_id = &u
  30131. }
  30132. }
  30133. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30134. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  30135. v := m.addorganization_id
  30136. if v == nil {
  30137. return
  30138. }
  30139. return *v, true
  30140. }
  30141. // ResetOrganizationID resets all changes to the "organization_id" field.
  30142. func (m *TutorialMutation) ResetOrganizationID() {
  30143. m.organization_id = nil
  30144. m.addorganization_id = nil
  30145. }
  30146. // ClearEmployee clears the "employee" edge to the Employee entity.
  30147. func (m *TutorialMutation) ClearEmployee() {
  30148. m.clearedemployee = true
  30149. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  30150. }
  30151. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  30152. func (m *TutorialMutation) EmployeeCleared() bool {
  30153. return m.clearedemployee
  30154. }
  30155. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  30156. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30157. // EmployeeID instead. It exists only for internal usage by the builders.
  30158. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  30159. if id := m.employee; id != nil {
  30160. ids = append(ids, *id)
  30161. }
  30162. return
  30163. }
  30164. // ResetEmployee resets all changes to the "employee" edge.
  30165. func (m *TutorialMutation) ResetEmployee() {
  30166. m.employee = nil
  30167. m.clearedemployee = false
  30168. }
  30169. // Where appends a list predicates to the TutorialMutation builder.
  30170. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  30171. m.predicates = append(m.predicates, ps...)
  30172. }
  30173. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  30174. // users can use type-assertion to append predicates that do not depend on any generated package.
  30175. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  30176. p := make([]predicate.Tutorial, len(ps))
  30177. for i := range ps {
  30178. p[i] = ps[i]
  30179. }
  30180. m.Where(p...)
  30181. }
  30182. // Op returns the operation name.
  30183. func (m *TutorialMutation) Op() Op {
  30184. return m.op
  30185. }
  30186. // SetOp allows setting the mutation operation.
  30187. func (m *TutorialMutation) SetOp(op Op) {
  30188. m.op = op
  30189. }
  30190. // Type returns the node type of this mutation (Tutorial).
  30191. func (m *TutorialMutation) Type() string {
  30192. return m.typ
  30193. }
  30194. // Fields returns all fields that were changed during this mutation. Note that in
  30195. // order to get all numeric fields that were incremented/decremented, call
  30196. // AddedFields().
  30197. func (m *TutorialMutation) Fields() []string {
  30198. fields := make([]string, 0, 8)
  30199. if m.created_at != nil {
  30200. fields = append(fields, tutorial.FieldCreatedAt)
  30201. }
  30202. if m.updated_at != nil {
  30203. fields = append(fields, tutorial.FieldUpdatedAt)
  30204. }
  30205. if m.deleted_at != nil {
  30206. fields = append(fields, tutorial.FieldDeletedAt)
  30207. }
  30208. if m.employee != nil {
  30209. fields = append(fields, tutorial.FieldEmployeeID)
  30210. }
  30211. if m.index != nil {
  30212. fields = append(fields, tutorial.FieldIndex)
  30213. }
  30214. if m.title != nil {
  30215. fields = append(fields, tutorial.FieldTitle)
  30216. }
  30217. if m.content != nil {
  30218. fields = append(fields, tutorial.FieldContent)
  30219. }
  30220. if m.organization_id != nil {
  30221. fields = append(fields, tutorial.FieldOrganizationID)
  30222. }
  30223. return fields
  30224. }
  30225. // Field returns the value of a field with the given name. The second boolean
  30226. // return value indicates that this field was not set, or was not defined in the
  30227. // schema.
  30228. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  30229. switch name {
  30230. case tutorial.FieldCreatedAt:
  30231. return m.CreatedAt()
  30232. case tutorial.FieldUpdatedAt:
  30233. return m.UpdatedAt()
  30234. case tutorial.FieldDeletedAt:
  30235. return m.DeletedAt()
  30236. case tutorial.FieldEmployeeID:
  30237. return m.EmployeeID()
  30238. case tutorial.FieldIndex:
  30239. return m.Index()
  30240. case tutorial.FieldTitle:
  30241. return m.Title()
  30242. case tutorial.FieldContent:
  30243. return m.Content()
  30244. case tutorial.FieldOrganizationID:
  30245. return m.OrganizationID()
  30246. }
  30247. return nil, false
  30248. }
  30249. // OldField returns the old value of the field from the database. An error is
  30250. // returned if the mutation operation is not UpdateOne, or the query to the
  30251. // database failed.
  30252. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30253. switch name {
  30254. case tutorial.FieldCreatedAt:
  30255. return m.OldCreatedAt(ctx)
  30256. case tutorial.FieldUpdatedAt:
  30257. return m.OldUpdatedAt(ctx)
  30258. case tutorial.FieldDeletedAt:
  30259. return m.OldDeletedAt(ctx)
  30260. case tutorial.FieldEmployeeID:
  30261. return m.OldEmployeeID(ctx)
  30262. case tutorial.FieldIndex:
  30263. return m.OldIndex(ctx)
  30264. case tutorial.FieldTitle:
  30265. return m.OldTitle(ctx)
  30266. case tutorial.FieldContent:
  30267. return m.OldContent(ctx)
  30268. case tutorial.FieldOrganizationID:
  30269. return m.OldOrganizationID(ctx)
  30270. }
  30271. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  30272. }
  30273. // SetField sets the value of a field with the given name. It returns an error if
  30274. // the field is not defined in the schema, or if the type mismatched the field
  30275. // type.
  30276. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  30277. switch name {
  30278. case tutorial.FieldCreatedAt:
  30279. v, ok := value.(time.Time)
  30280. if !ok {
  30281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30282. }
  30283. m.SetCreatedAt(v)
  30284. return nil
  30285. case tutorial.FieldUpdatedAt:
  30286. v, ok := value.(time.Time)
  30287. if !ok {
  30288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30289. }
  30290. m.SetUpdatedAt(v)
  30291. return nil
  30292. case tutorial.FieldDeletedAt:
  30293. v, ok := value.(time.Time)
  30294. if !ok {
  30295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30296. }
  30297. m.SetDeletedAt(v)
  30298. return nil
  30299. case tutorial.FieldEmployeeID:
  30300. v, ok := value.(uint64)
  30301. if !ok {
  30302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30303. }
  30304. m.SetEmployeeID(v)
  30305. return nil
  30306. case tutorial.FieldIndex:
  30307. v, ok := value.(int)
  30308. if !ok {
  30309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30310. }
  30311. m.SetIndex(v)
  30312. return nil
  30313. case tutorial.FieldTitle:
  30314. v, ok := value.(string)
  30315. if !ok {
  30316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30317. }
  30318. m.SetTitle(v)
  30319. return nil
  30320. case tutorial.FieldContent:
  30321. v, ok := value.(string)
  30322. if !ok {
  30323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30324. }
  30325. m.SetContent(v)
  30326. return nil
  30327. case tutorial.FieldOrganizationID:
  30328. v, ok := value.(uint64)
  30329. if !ok {
  30330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30331. }
  30332. m.SetOrganizationID(v)
  30333. return nil
  30334. }
  30335. return fmt.Errorf("unknown Tutorial field %s", name)
  30336. }
  30337. // AddedFields returns all numeric fields that were incremented/decremented during
  30338. // this mutation.
  30339. func (m *TutorialMutation) AddedFields() []string {
  30340. var fields []string
  30341. if m.addindex != nil {
  30342. fields = append(fields, tutorial.FieldIndex)
  30343. }
  30344. if m.addorganization_id != nil {
  30345. fields = append(fields, tutorial.FieldOrganizationID)
  30346. }
  30347. return fields
  30348. }
  30349. // AddedField returns the numeric value that was incremented/decremented on a field
  30350. // with the given name. The second boolean return value indicates that this field
  30351. // was not set, or was not defined in the schema.
  30352. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  30353. switch name {
  30354. case tutorial.FieldIndex:
  30355. return m.AddedIndex()
  30356. case tutorial.FieldOrganizationID:
  30357. return m.AddedOrganizationID()
  30358. }
  30359. return nil, false
  30360. }
  30361. // AddField adds the value to the field with the given name. It returns an error if
  30362. // the field is not defined in the schema, or if the type mismatched the field
  30363. // type.
  30364. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  30365. switch name {
  30366. case tutorial.FieldIndex:
  30367. v, ok := value.(int)
  30368. if !ok {
  30369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30370. }
  30371. m.AddIndex(v)
  30372. return nil
  30373. case tutorial.FieldOrganizationID:
  30374. v, ok := value.(int64)
  30375. if !ok {
  30376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30377. }
  30378. m.AddOrganizationID(v)
  30379. return nil
  30380. }
  30381. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  30382. }
  30383. // ClearedFields returns all nullable fields that were cleared during this
  30384. // mutation.
  30385. func (m *TutorialMutation) ClearedFields() []string {
  30386. var fields []string
  30387. if m.FieldCleared(tutorial.FieldDeletedAt) {
  30388. fields = append(fields, tutorial.FieldDeletedAt)
  30389. }
  30390. return fields
  30391. }
  30392. // FieldCleared returns a boolean indicating if a field with the given name was
  30393. // cleared in this mutation.
  30394. func (m *TutorialMutation) FieldCleared(name string) bool {
  30395. _, ok := m.clearedFields[name]
  30396. return ok
  30397. }
  30398. // ClearField clears the value of the field with the given name. It returns an
  30399. // error if the field is not defined in the schema.
  30400. func (m *TutorialMutation) ClearField(name string) error {
  30401. switch name {
  30402. case tutorial.FieldDeletedAt:
  30403. m.ClearDeletedAt()
  30404. return nil
  30405. }
  30406. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  30407. }
  30408. // ResetField resets all changes in the mutation for the field with the given name.
  30409. // It returns an error if the field is not defined in the schema.
  30410. func (m *TutorialMutation) ResetField(name string) error {
  30411. switch name {
  30412. case tutorial.FieldCreatedAt:
  30413. m.ResetCreatedAt()
  30414. return nil
  30415. case tutorial.FieldUpdatedAt:
  30416. m.ResetUpdatedAt()
  30417. return nil
  30418. case tutorial.FieldDeletedAt:
  30419. m.ResetDeletedAt()
  30420. return nil
  30421. case tutorial.FieldEmployeeID:
  30422. m.ResetEmployeeID()
  30423. return nil
  30424. case tutorial.FieldIndex:
  30425. m.ResetIndex()
  30426. return nil
  30427. case tutorial.FieldTitle:
  30428. m.ResetTitle()
  30429. return nil
  30430. case tutorial.FieldContent:
  30431. m.ResetContent()
  30432. return nil
  30433. case tutorial.FieldOrganizationID:
  30434. m.ResetOrganizationID()
  30435. return nil
  30436. }
  30437. return fmt.Errorf("unknown Tutorial field %s", name)
  30438. }
  30439. // AddedEdges returns all edge names that were set/added in this mutation.
  30440. func (m *TutorialMutation) AddedEdges() []string {
  30441. edges := make([]string, 0, 1)
  30442. if m.employee != nil {
  30443. edges = append(edges, tutorial.EdgeEmployee)
  30444. }
  30445. return edges
  30446. }
  30447. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30448. // name in this mutation.
  30449. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  30450. switch name {
  30451. case tutorial.EdgeEmployee:
  30452. if id := m.employee; id != nil {
  30453. return []ent.Value{*id}
  30454. }
  30455. }
  30456. return nil
  30457. }
  30458. // RemovedEdges returns all edge names that were removed in this mutation.
  30459. func (m *TutorialMutation) RemovedEdges() []string {
  30460. edges := make([]string, 0, 1)
  30461. return edges
  30462. }
  30463. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30464. // the given name in this mutation.
  30465. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  30466. return nil
  30467. }
  30468. // ClearedEdges returns all edge names that were cleared in this mutation.
  30469. func (m *TutorialMutation) ClearedEdges() []string {
  30470. edges := make([]string, 0, 1)
  30471. if m.clearedemployee {
  30472. edges = append(edges, tutorial.EdgeEmployee)
  30473. }
  30474. return edges
  30475. }
  30476. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30477. // was cleared in this mutation.
  30478. func (m *TutorialMutation) EdgeCleared(name string) bool {
  30479. switch name {
  30480. case tutorial.EdgeEmployee:
  30481. return m.clearedemployee
  30482. }
  30483. return false
  30484. }
  30485. // ClearEdge clears the value of the edge with the given name. It returns an error
  30486. // if that edge is not defined in the schema.
  30487. func (m *TutorialMutation) ClearEdge(name string) error {
  30488. switch name {
  30489. case tutorial.EdgeEmployee:
  30490. m.ClearEmployee()
  30491. return nil
  30492. }
  30493. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  30494. }
  30495. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30496. // It returns an error if the edge is not defined in the schema.
  30497. func (m *TutorialMutation) ResetEdge(name string) error {
  30498. switch name {
  30499. case tutorial.EdgeEmployee:
  30500. m.ResetEmployee()
  30501. return nil
  30502. }
  30503. return fmt.Errorf("unknown Tutorial edge %s", name)
  30504. }
  30505. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  30506. type UsageDetailMutation struct {
  30507. config
  30508. op Op
  30509. typ string
  30510. id *uint64
  30511. created_at *time.Time
  30512. updated_at *time.Time
  30513. status *uint8
  30514. addstatus *int8
  30515. _type *int
  30516. add_type *int
  30517. bot_id *string
  30518. receiver_id *string
  30519. app *int
  30520. addapp *int
  30521. session_id *uint64
  30522. addsession_id *int64
  30523. request *string
  30524. response *string
  30525. original_data *custom_types.OriginalData
  30526. total_tokens *uint64
  30527. addtotal_tokens *int64
  30528. prompt_tokens *uint64
  30529. addprompt_tokens *int64
  30530. completion_tokens *uint64
  30531. addcompletion_tokens *int64
  30532. organization_id *uint64
  30533. addorganization_id *int64
  30534. clearedFields map[string]struct{}
  30535. done bool
  30536. oldValue func(context.Context) (*UsageDetail, error)
  30537. predicates []predicate.UsageDetail
  30538. }
  30539. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  30540. // usagedetailOption allows management of the mutation configuration using functional options.
  30541. type usagedetailOption func(*UsageDetailMutation)
  30542. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  30543. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  30544. m := &UsageDetailMutation{
  30545. config: c,
  30546. op: op,
  30547. typ: TypeUsageDetail,
  30548. clearedFields: make(map[string]struct{}),
  30549. }
  30550. for _, opt := range opts {
  30551. opt(m)
  30552. }
  30553. return m
  30554. }
  30555. // withUsageDetailID sets the ID field of the mutation.
  30556. func withUsageDetailID(id uint64) usagedetailOption {
  30557. return func(m *UsageDetailMutation) {
  30558. var (
  30559. err error
  30560. once sync.Once
  30561. value *UsageDetail
  30562. )
  30563. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  30564. once.Do(func() {
  30565. if m.done {
  30566. err = errors.New("querying old values post mutation is not allowed")
  30567. } else {
  30568. value, err = m.Client().UsageDetail.Get(ctx, id)
  30569. }
  30570. })
  30571. return value, err
  30572. }
  30573. m.id = &id
  30574. }
  30575. }
  30576. // withUsageDetail sets the old UsageDetail of the mutation.
  30577. func withUsageDetail(node *UsageDetail) usagedetailOption {
  30578. return func(m *UsageDetailMutation) {
  30579. m.oldValue = func(context.Context) (*UsageDetail, error) {
  30580. return node, nil
  30581. }
  30582. m.id = &node.ID
  30583. }
  30584. }
  30585. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30586. // executed in a transaction (ent.Tx), a transactional client is returned.
  30587. func (m UsageDetailMutation) Client() *Client {
  30588. client := &Client{config: m.config}
  30589. client.init()
  30590. return client
  30591. }
  30592. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30593. // it returns an error otherwise.
  30594. func (m UsageDetailMutation) Tx() (*Tx, error) {
  30595. if _, ok := m.driver.(*txDriver); !ok {
  30596. return nil, errors.New("ent: mutation is not running in a transaction")
  30597. }
  30598. tx := &Tx{config: m.config}
  30599. tx.init()
  30600. return tx, nil
  30601. }
  30602. // SetID sets the value of the id field. Note that this
  30603. // operation is only accepted on creation of UsageDetail entities.
  30604. func (m *UsageDetailMutation) SetID(id uint64) {
  30605. m.id = &id
  30606. }
  30607. // ID returns the ID value in the mutation. Note that the ID is only available
  30608. // if it was provided to the builder or after it was returned from the database.
  30609. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  30610. if m.id == nil {
  30611. return
  30612. }
  30613. return *m.id, true
  30614. }
  30615. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30616. // That means, if the mutation is applied within a transaction with an isolation level such
  30617. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30618. // or updated by the mutation.
  30619. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  30620. switch {
  30621. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30622. id, exists := m.ID()
  30623. if exists {
  30624. return []uint64{id}, nil
  30625. }
  30626. fallthrough
  30627. case m.op.Is(OpUpdate | OpDelete):
  30628. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  30629. default:
  30630. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30631. }
  30632. }
  30633. // SetCreatedAt sets the "created_at" field.
  30634. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  30635. m.created_at = &t
  30636. }
  30637. // CreatedAt returns the value of the "created_at" field in the mutation.
  30638. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  30639. v := m.created_at
  30640. if v == nil {
  30641. return
  30642. }
  30643. return *v, true
  30644. }
  30645. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  30646. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30648. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30649. if !m.op.Is(OpUpdateOne) {
  30650. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30651. }
  30652. if m.id == nil || m.oldValue == nil {
  30653. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30654. }
  30655. oldValue, err := m.oldValue(ctx)
  30656. if err != nil {
  30657. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30658. }
  30659. return oldValue.CreatedAt, nil
  30660. }
  30661. // ResetCreatedAt resets all changes to the "created_at" field.
  30662. func (m *UsageDetailMutation) ResetCreatedAt() {
  30663. m.created_at = nil
  30664. }
  30665. // SetUpdatedAt sets the "updated_at" field.
  30666. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  30667. m.updated_at = &t
  30668. }
  30669. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30670. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  30671. v := m.updated_at
  30672. if v == nil {
  30673. return
  30674. }
  30675. return *v, true
  30676. }
  30677. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  30678. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30680. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30681. if !m.op.Is(OpUpdateOne) {
  30682. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30683. }
  30684. if m.id == nil || m.oldValue == nil {
  30685. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30686. }
  30687. oldValue, err := m.oldValue(ctx)
  30688. if err != nil {
  30689. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30690. }
  30691. return oldValue.UpdatedAt, nil
  30692. }
  30693. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30694. func (m *UsageDetailMutation) ResetUpdatedAt() {
  30695. m.updated_at = nil
  30696. }
  30697. // SetStatus sets the "status" field.
  30698. func (m *UsageDetailMutation) SetStatus(u uint8) {
  30699. m.status = &u
  30700. m.addstatus = nil
  30701. }
  30702. // Status returns the value of the "status" field in the mutation.
  30703. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  30704. v := m.status
  30705. if v == nil {
  30706. return
  30707. }
  30708. return *v, true
  30709. }
  30710. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  30711. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30713. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30714. if !m.op.Is(OpUpdateOne) {
  30715. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30716. }
  30717. if m.id == nil || m.oldValue == nil {
  30718. return v, errors.New("OldStatus requires an ID field in the mutation")
  30719. }
  30720. oldValue, err := m.oldValue(ctx)
  30721. if err != nil {
  30722. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30723. }
  30724. return oldValue.Status, nil
  30725. }
  30726. // AddStatus adds u to the "status" field.
  30727. func (m *UsageDetailMutation) AddStatus(u int8) {
  30728. if m.addstatus != nil {
  30729. *m.addstatus += u
  30730. } else {
  30731. m.addstatus = &u
  30732. }
  30733. }
  30734. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30735. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  30736. v := m.addstatus
  30737. if v == nil {
  30738. return
  30739. }
  30740. return *v, true
  30741. }
  30742. // ClearStatus clears the value of the "status" field.
  30743. func (m *UsageDetailMutation) ClearStatus() {
  30744. m.status = nil
  30745. m.addstatus = nil
  30746. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  30747. }
  30748. // StatusCleared returns if the "status" field was cleared in this mutation.
  30749. func (m *UsageDetailMutation) StatusCleared() bool {
  30750. _, ok := m.clearedFields[usagedetail.FieldStatus]
  30751. return ok
  30752. }
  30753. // ResetStatus resets all changes to the "status" field.
  30754. func (m *UsageDetailMutation) ResetStatus() {
  30755. m.status = nil
  30756. m.addstatus = nil
  30757. delete(m.clearedFields, usagedetail.FieldStatus)
  30758. }
  30759. // SetType sets the "type" field.
  30760. func (m *UsageDetailMutation) SetType(i int) {
  30761. m._type = &i
  30762. m.add_type = nil
  30763. }
  30764. // GetType returns the value of the "type" field in the mutation.
  30765. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  30766. v := m._type
  30767. if v == nil {
  30768. return
  30769. }
  30770. return *v, true
  30771. }
  30772. // OldType returns the old "type" field's value of the UsageDetail entity.
  30773. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30775. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  30776. if !m.op.Is(OpUpdateOne) {
  30777. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30778. }
  30779. if m.id == nil || m.oldValue == nil {
  30780. return v, errors.New("OldType requires an ID field in the mutation")
  30781. }
  30782. oldValue, err := m.oldValue(ctx)
  30783. if err != nil {
  30784. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30785. }
  30786. return oldValue.Type, nil
  30787. }
  30788. // AddType adds i to the "type" field.
  30789. func (m *UsageDetailMutation) AddType(i int) {
  30790. if m.add_type != nil {
  30791. *m.add_type += i
  30792. } else {
  30793. m.add_type = &i
  30794. }
  30795. }
  30796. // AddedType returns the value that was added to the "type" field in this mutation.
  30797. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  30798. v := m.add_type
  30799. if v == nil {
  30800. return
  30801. }
  30802. return *v, true
  30803. }
  30804. // ClearType clears the value of the "type" field.
  30805. func (m *UsageDetailMutation) ClearType() {
  30806. m._type = nil
  30807. m.add_type = nil
  30808. m.clearedFields[usagedetail.FieldType] = struct{}{}
  30809. }
  30810. // TypeCleared returns if the "type" field was cleared in this mutation.
  30811. func (m *UsageDetailMutation) TypeCleared() bool {
  30812. _, ok := m.clearedFields[usagedetail.FieldType]
  30813. return ok
  30814. }
  30815. // ResetType resets all changes to the "type" field.
  30816. func (m *UsageDetailMutation) ResetType() {
  30817. m._type = nil
  30818. m.add_type = nil
  30819. delete(m.clearedFields, usagedetail.FieldType)
  30820. }
  30821. // SetBotID sets the "bot_id" field.
  30822. func (m *UsageDetailMutation) SetBotID(s string) {
  30823. m.bot_id = &s
  30824. }
  30825. // BotID returns the value of the "bot_id" field in the mutation.
  30826. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  30827. v := m.bot_id
  30828. if v == nil {
  30829. return
  30830. }
  30831. return *v, true
  30832. }
  30833. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  30834. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30836. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  30837. if !m.op.Is(OpUpdateOne) {
  30838. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30839. }
  30840. if m.id == nil || m.oldValue == nil {
  30841. return v, errors.New("OldBotID requires an ID field in the mutation")
  30842. }
  30843. oldValue, err := m.oldValue(ctx)
  30844. if err != nil {
  30845. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30846. }
  30847. return oldValue.BotID, nil
  30848. }
  30849. // ResetBotID resets all changes to the "bot_id" field.
  30850. func (m *UsageDetailMutation) ResetBotID() {
  30851. m.bot_id = nil
  30852. }
  30853. // SetReceiverID sets the "receiver_id" field.
  30854. func (m *UsageDetailMutation) SetReceiverID(s string) {
  30855. m.receiver_id = &s
  30856. }
  30857. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  30858. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  30859. v := m.receiver_id
  30860. if v == nil {
  30861. return
  30862. }
  30863. return *v, true
  30864. }
  30865. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  30866. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30868. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  30869. if !m.op.Is(OpUpdateOne) {
  30870. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  30871. }
  30872. if m.id == nil || m.oldValue == nil {
  30873. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  30874. }
  30875. oldValue, err := m.oldValue(ctx)
  30876. if err != nil {
  30877. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  30878. }
  30879. return oldValue.ReceiverID, nil
  30880. }
  30881. // ResetReceiverID resets all changes to the "receiver_id" field.
  30882. func (m *UsageDetailMutation) ResetReceiverID() {
  30883. m.receiver_id = nil
  30884. }
  30885. // SetApp sets the "app" field.
  30886. func (m *UsageDetailMutation) SetApp(i int) {
  30887. m.app = &i
  30888. m.addapp = nil
  30889. }
  30890. // App returns the value of the "app" field in the mutation.
  30891. func (m *UsageDetailMutation) App() (r int, exists bool) {
  30892. v := m.app
  30893. if v == nil {
  30894. return
  30895. }
  30896. return *v, true
  30897. }
  30898. // OldApp returns the old "app" field's value of the UsageDetail entity.
  30899. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30901. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  30902. if !m.op.Is(OpUpdateOne) {
  30903. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  30904. }
  30905. if m.id == nil || m.oldValue == nil {
  30906. return v, errors.New("OldApp requires an ID field in the mutation")
  30907. }
  30908. oldValue, err := m.oldValue(ctx)
  30909. if err != nil {
  30910. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  30911. }
  30912. return oldValue.App, nil
  30913. }
  30914. // AddApp adds i to the "app" field.
  30915. func (m *UsageDetailMutation) AddApp(i int) {
  30916. if m.addapp != nil {
  30917. *m.addapp += i
  30918. } else {
  30919. m.addapp = &i
  30920. }
  30921. }
  30922. // AddedApp returns the value that was added to the "app" field in this mutation.
  30923. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  30924. v := m.addapp
  30925. if v == nil {
  30926. return
  30927. }
  30928. return *v, true
  30929. }
  30930. // ClearApp clears the value of the "app" field.
  30931. func (m *UsageDetailMutation) ClearApp() {
  30932. m.app = nil
  30933. m.addapp = nil
  30934. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  30935. }
  30936. // AppCleared returns if the "app" field was cleared in this mutation.
  30937. func (m *UsageDetailMutation) AppCleared() bool {
  30938. _, ok := m.clearedFields[usagedetail.FieldApp]
  30939. return ok
  30940. }
  30941. // ResetApp resets all changes to the "app" field.
  30942. func (m *UsageDetailMutation) ResetApp() {
  30943. m.app = nil
  30944. m.addapp = nil
  30945. delete(m.clearedFields, usagedetail.FieldApp)
  30946. }
  30947. // SetSessionID sets the "session_id" field.
  30948. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  30949. m.session_id = &u
  30950. m.addsession_id = nil
  30951. }
  30952. // SessionID returns the value of the "session_id" field in the mutation.
  30953. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  30954. v := m.session_id
  30955. if v == nil {
  30956. return
  30957. }
  30958. return *v, true
  30959. }
  30960. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  30961. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30963. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  30964. if !m.op.Is(OpUpdateOne) {
  30965. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  30966. }
  30967. if m.id == nil || m.oldValue == nil {
  30968. return v, errors.New("OldSessionID requires an ID field in the mutation")
  30969. }
  30970. oldValue, err := m.oldValue(ctx)
  30971. if err != nil {
  30972. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  30973. }
  30974. return oldValue.SessionID, nil
  30975. }
  30976. // AddSessionID adds u to the "session_id" field.
  30977. func (m *UsageDetailMutation) AddSessionID(u int64) {
  30978. if m.addsession_id != nil {
  30979. *m.addsession_id += u
  30980. } else {
  30981. m.addsession_id = &u
  30982. }
  30983. }
  30984. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  30985. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  30986. v := m.addsession_id
  30987. if v == nil {
  30988. return
  30989. }
  30990. return *v, true
  30991. }
  30992. // ClearSessionID clears the value of the "session_id" field.
  30993. func (m *UsageDetailMutation) ClearSessionID() {
  30994. m.session_id = nil
  30995. m.addsession_id = nil
  30996. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  30997. }
  30998. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  30999. func (m *UsageDetailMutation) SessionIDCleared() bool {
  31000. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  31001. return ok
  31002. }
  31003. // ResetSessionID resets all changes to the "session_id" field.
  31004. func (m *UsageDetailMutation) ResetSessionID() {
  31005. m.session_id = nil
  31006. m.addsession_id = nil
  31007. delete(m.clearedFields, usagedetail.FieldSessionID)
  31008. }
  31009. // SetRequest sets the "request" field.
  31010. func (m *UsageDetailMutation) SetRequest(s string) {
  31011. m.request = &s
  31012. }
  31013. // Request returns the value of the "request" field in the mutation.
  31014. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  31015. v := m.request
  31016. if v == nil {
  31017. return
  31018. }
  31019. return *v, true
  31020. }
  31021. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  31022. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31024. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  31025. if !m.op.Is(OpUpdateOne) {
  31026. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  31027. }
  31028. if m.id == nil || m.oldValue == nil {
  31029. return v, errors.New("OldRequest requires an ID field in the mutation")
  31030. }
  31031. oldValue, err := m.oldValue(ctx)
  31032. if err != nil {
  31033. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  31034. }
  31035. return oldValue.Request, nil
  31036. }
  31037. // ResetRequest resets all changes to the "request" field.
  31038. func (m *UsageDetailMutation) ResetRequest() {
  31039. m.request = nil
  31040. }
  31041. // SetResponse sets the "response" field.
  31042. func (m *UsageDetailMutation) SetResponse(s string) {
  31043. m.response = &s
  31044. }
  31045. // Response returns the value of the "response" field in the mutation.
  31046. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  31047. v := m.response
  31048. if v == nil {
  31049. return
  31050. }
  31051. return *v, true
  31052. }
  31053. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  31054. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31056. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  31057. if !m.op.Is(OpUpdateOne) {
  31058. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  31059. }
  31060. if m.id == nil || m.oldValue == nil {
  31061. return v, errors.New("OldResponse requires an ID field in the mutation")
  31062. }
  31063. oldValue, err := m.oldValue(ctx)
  31064. if err != nil {
  31065. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  31066. }
  31067. return oldValue.Response, nil
  31068. }
  31069. // ResetResponse resets all changes to the "response" field.
  31070. func (m *UsageDetailMutation) ResetResponse() {
  31071. m.response = nil
  31072. }
  31073. // SetOriginalData sets the "original_data" field.
  31074. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  31075. m.original_data = &ctd
  31076. }
  31077. // OriginalData returns the value of the "original_data" field in the mutation.
  31078. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  31079. v := m.original_data
  31080. if v == nil {
  31081. return
  31082. }
  31083. return *v, true
  31084. }
  31085. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  31086. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31088. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  31089. if !m.op.Is(OpUpdateOne) {
  31090. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  31091. }
  31092. if m.id == nil || m.oldValue == nil {
  31093. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  31094. }
  31095. oldValue, err := m.oldValue(ctx)
  31096. if err != nil {
  31097. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  31098. }
  31099. return oldValue.OriginalData, nil
  31100. }
  31101. // ResetOriginalData resets all changes to the "original_data" field.
  31102. func (m *UsageDetailMutation) ResetOriginalData() {
  31103. m.original_data = nil
  31104. }
  31105. // SetTotalTokens sets the "total_tokens" field.
  31106. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  31107. m.total_tokens = &u
  31108. m.addtotal_tokens = nil
  31109. }
  31110. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  31111. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  31112. v := m.total_tokens
  31113. if v == nil {
  31114. return
  31115. }
  31116. return *v, true
  31117. }
  31118. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  31119. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31121. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  31122. if !m.op.Is(OpUpdateOne) {
  31123. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  31124. }
  31125. if m.id == nil || m.oldValue == nil {
  31126. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  31127. }
  31128. oldValue, err := m.oldValue(ctx)
  31129. if err != nil {
  31130. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  31131. }
  31132. return oldValue.TotalTokens, nil
  31133. }
  31134. // AddTotalTokens adds u to the "total_tokens" field.
  31135. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  31136. if m.addtotal_tokens != nil {
  31137. *m.addtotal_tokens += u
  31138. } else {
  31139. m.addtotal_tokens = &u
  31140. }
  31141. }
  31142. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  31143. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  31144. v := m.addtotal_tokens
  31145. if v == nil {
  31146. return
  31147. }
  31148. return *v, true
  31149. }
  31150. // ClearTotalTokens clears the value of the "total_tokens" field.
  31151. func (m *UsageDetailMutation) ClearTotalTokens() {
  31152. m.total_tokens = nil
  31153. m.addtotal_tokens = nil
  31154. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  31155. }
  31156. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  31157. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  31158. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  31159. return ok
  31160. }
  31161. // ResetTotalTokens resets all changes to the "total_tokens" field.
  31162. func (m *UsageDetailMutation) ResetTotalTokens() {
  31163. m.total_tokens = nil
  31164. m.addtotal_tokens = nil
  31165. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  31166. }
  31167. // SetPromptTokens sets the "prompt_tokens" field.
  31168. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  31169. m.prompt_tokens = &u
  31170. m.addprompt_tokens = nil
  31171. }
  31172. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  31173. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  31174. v := m.prompt_tokens
  31175. if v == nil {
  31176. return
  31177. }
  31178. return *v, true
  31179. }
  31180. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  31181. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31183. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  31184. if !m.op.Is(OpUpdateOne) {
  31185. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  31186. }
  31187. if m.id == nil || m.oldValue == nil {
  31188. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  31189. }
  31190. oldValue, err := m.oldValue(ctx)
  31191. if err != nil {
  31192. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  31193. }
  31194. return oldValue.PromptTokens, nil
  31195. }
  31196. // AddPromptTokens adds u to the "prompt_tokens" field.
  31197. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  31198. if m.addprompt_tokens != nil {
  31199. *m.addprompt_tokens += u
  31200. } else {
  31201. m.addprompt_tokens = &u
  31202. }
  31203. }
  31204. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  31205. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  31206. v := m.addprompt_tokens
  31207. if v == nil {
  31208. return
  31209. }
  31210. return *v, true
  31211. }
  31212. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  31213. func (m *UsageDetailMutation) ClearPromptTokens() {
  31214. m.prompt_tokens = nil
  31215. m.addprompt_tokens = nil
  31216. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  31217. }
  31218. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  31219. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  31220. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  31221. return ok
  31222. }
  31223. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  31224. func (m *UsageDetailMutation) ResetPromptTokens() {
  31225. m.prompt_tokens = nil
  31226. m.addprompt_tokens = nil
  31227. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  31228. }
  31229. // SetCompletionTokens sets the "completion_tokens" field.
  31230. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  31231. m.completion_tokens = &u
  31232. m.addcompletion_tokens = nil
  31233. }
  31234. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  31235. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  31236. v := m.completion_tokens
  31237. if v == nil {
  31238. return
  31239. }
  31240. return *v, true
  31241. }
  31242. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  31243. // If the UsageDetail 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 *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  31246. if !m.op.Is(OpUpdateOne) {
  31247. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  31248. }
  31249. if m.id == nil || m.oldValue == nil {
  31250. return v, errors.New("OldCompletionTokens 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 OldCompletionTokens: %w", err)
  31255. }
  31256. return oldValue.CompletionTokens, nil
  31257. }
  31258. // AddCompletionTokens adds u to the "completion_tokens" field.
  31259. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  31260. if m.addcompletion_tokens != nil {
  31261. *m.addcompletion_tokens += u
  31262. } else {
  31263. m.addcompletion_tokens = &u
  31264. }
  31265. }
  31266. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  31267. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  31268. v := m.addcompletion_tokens
  31269. if v == nil {
  31270. return
  31271. }
  31272. return *v, true
  31273. }
  31274. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  31275. func (m *UsageDetailMutation) ClearCompletionTokens() {
  31276. m.completion_tokens = nil
  31277. m.addcompletion_tokens = nil
  31278. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  31279. }
  31280. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  31281. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  31282. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  31283. return ok
  31284. }
  31285. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  31286. func (m *UsageDetailMutation) ResetCompletionTokens() {
  31287. m.completion_tokens = nil
  31288. m.addcompletion_tokens = nil
  31289. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  31290. }
  31291. // SetOrganizationID sets the "organization_id" field.
  31292. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  31293. m.organization_id = &u
  31294. m.addorganization_id = nil
  31295. }
  31296. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31297. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  31298. v := m.organization_id
  31299. if v == nil {
  31300. return
  31301. }
  31302. return *v, true
  31303. }
  31304. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  31305. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31307. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31308. if !m.op.Is(OpUpdateOne) {
  31309. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31310. }
  31311. if m.id == nil || m.oldValue == nil {
  31312. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31313. }
  31314. oldValue, err := m.oldValue(ctx)
  31315. if err != nil {
  31316. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31317. }
  31318. return oldValue.OrganizationID, nil
  31319. }
  31320. // AddOrganizationID adds u to the "organization_id" field.
  31321. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  31322. if m.addorganization_id != nil {
  31323. *m.addorganization_id += u
  31324. } else {
  31325. m.addorganization_id = &u
  31326. }
  31327. }
  31328. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31329. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  31330. v := m.addorganization_id
  31331. if v == nil {
  31332. return
  31333. }
  31334. return *v, true
  31335. }
  31336. // ClearOrganizationID clears the value of the "organization_id" field.
  31337. func (m *UsageDetailMutation) ClearOrganizationID() {
  31338. m.organization_id = nil
  31339. m.addorganization_id = nil
  31340. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  31341. }
  31342. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31343. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  31344. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  31345. return ok
  31346. }
  31347. // ResetOrganizationID resets all changes to the "organization_id" field.
  31348. func (m *UsageDetailMutation) ResetOrganizationID() {
  31349. m.organization_id = nil
  31350. m.addorganization_id = nil
  31351. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  31352. }
  31353. // Where appends a list predicates to the UsageDetailMutation builder.
  31354. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  31355. m.predicates = append(m.predicates, ps...)
  31356. }
  31357. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  31358. // users can use type-assertion to append predicates that do not depend on any generated package.
  31359. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  31360. p := make([]predicate.UsageDetail, len(ps))
  31361. for i := range ps {
  31362. p[i] = ps[i]
  31363. }
  31364. m.Where(p...)
  31365. }
  31366. // Op returns the operation name.
  31367. func (m *UsageDetailMutation) Op() Op {
  31368. return m.op
  31369. }
  31370. // SetOp allows setting the mutation operation.
  31371. func (m *UsageDetailMutation) SetOp(op Op) {
  31372. m.op = op
  31373. }
  31374. // Type returns the node type of this mutation (UsageDetail).
  31375. func (m *UsageDetailMutation) Type() string {
  31376. return m.typ
  31377. }
  31378. // Fields returns all fields that were changed during this mutation. Note that in
  31379. // order to get all numeric fields that were incremented/decremented, call
  31380. // AddedFields().
  31381. func (m *UsageDetailMutation) Fields() []string {
  31382. fields := make([]string, 0, 15)
  31383. if m.created_at != nil {
  31384. fields = append(fields, usagedetail.FieldCreatedAt)
  31385. }
  31386. if m.updated_at != nil {
  31387. fields = append(fields, usagedetail.FieldUpdatedAt)
  31388. }
  31389. if m.status != nil {
  31390. fields = append(fields, usagedetail.FieldStatus)
  31391. }
  31392. if m._type != nil {
  31393. fields = append(fields, usagedetail.FieldType)
  31394. }
  31395. if m.bot_id != nil {
  31396. fields = append(fields, usagedetail.FieldBotID)
  31397. }
  31398. if m.receiver_id != nil {
  31399. fields = append(fields, usagedetail.FieldReceiverID)
  31400. }
  31401. if m.app != nil {
  31402. fields = append(fields, usagedetail.FieldApp)
  31403. }
  31404. if m.session_id != nil {
  31405. fields = append(fields, usagedetail.FieldSessionID)
  31406. }
  31407. if m.request != nil {
  31408. fields = append(fields, usagedetail.FieldRequest)
  31409. }
  31410. if m.response != nil {
  31411. fields = append(fields, usagedetail.FieldResponse)
  31412. }
  31413. if m.original_data != nil {
  31414. fields = append(fields, usagedetail.FieldOriginalData)
  31415. }
  31416. if m.total_tokens != nil {
  31417. fields = append(fields, usagedetail.FieldTotalTokens)
  31418. }
  31419. if m.prompt_tokens != nil {
  31420. fields = append(fields, usagedetail.FieldPromptTokens)
  31421. }
  31422. if m.completion_tokens != nil {
  31423. fields = append(fields, usagedetail.FieldCompletionTokens)
  31424. }
  31425. if m.organization_id != nil {
  31426. fields = append(fields, usagedetail.FieldOrganizationID)
  31427. }
  31428. return fields
  31429. }
  31430. // Field returns the value of a field with the given name. The second boolean
  31431. // return value indicates that this field was not set, or was not defined in the
  31432. // schema.
  31433. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  31434. switch name {
  31435. case usagedetail.FieldCreatedAt:
  31436. return m.CreatedAt()
  31437. case usagedetail.FieldUpdatedAt:
  31438. return m.UpdatedAt()
  31439. case usagedetail.FieldStatus:
  31440. return m.Status()
  31441. case usagedetail.FieldType:
  31442. return m.GetType()
  31443. case usagedetail.FieldBotID:
  31444. return m.BotID()
  31445. case usagedetail.FieldReceiverID:
  31446. return m.ReceiverID()
  31447. case usagedetail.FieldApp:
  31448. return m.App()
  31449. case usagedetail.FieldSessionID:
  31450. return m.SessionID()
  31451. case usagedetail.FieldRequest:
  31452. return m.Request()
  31453. case usagedetail.FieldResponse:
  31454. return m.Response()
  31455. case usagedetail.FieldOriginalData:
  31456. return m.OriginalData()
  31457. case usagedetail.FieldTotalTokens:
  31458. return m.TotalTokens()
  31459. case usagedetail.FieldPromptTokens:
  31460. return m.PromptTokens()
  31461. case usagedetail.FieldCompletionTokens:
  31462. return m.CompletionTokens()
  31463. case usagedetail.FieldOrganizationID:
  31464. return m.OrganizationID()
  31465. }
  31466. return nil, false
  31467. }
  31468. // OldField returns the old value of the field from the database. An error is
  31469. // returned if the mutation operation is not UpdateOne, or the query to the
  31470. // database failed.
  31471. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31472. switch name {
  31473. case usagedetail.FieldCreatedAt:
  31474. return m.OldCreatedAt(ctx)
  31475. case usagedetail.FieldUpdatedAt:
  31476. return m.OldUpdatedAt(ctx)
  31477. case usagedetail.FieldStatus:
  31478. return m.OldStatus(ctx)
  31479. case usagedetail.FieldType:
  31480. return m.OldType(ctx)
  31481. case usagedetail.FieldBotID:
  31482. return m.OldBotID(ctx)
  31483. case usagedetail.FieldReceiverID:
  31484. return m.OldReceiverID(ctx)
  31485. case usagedetail.FieldApp:
  31486. return m.OldApp(ctx)
  31487. case usagedetail.FieldSessionID:
  31488. return m.OldSessionID(ctx)
  31489. case usagedetail.FieldRequest:
  31490. return m.OldRequest(ctx)
  31491. case usagedetail.FieldResponse:
  31492. return m.OldResponse(ctx)
  31493. case usagedetail.FieldOriginalData:
  31494. return m.OldOriginalData(ctx)
  31495. case usagedetail.FieldTotalTokens:
  31496. return m.OldTotalTokens(ctx)
  31497. case usagedetail.FieldPromptTokens:
  31498. return m.OldPromptTokens(ctx)
  31499. case usagedetail.FieldCompletionTokens:
  31500. return m.OldCompletionTokens(ctx)
  31501. case usagedetail.FieldOrganizationID:
  31502. return m.OldOrganizationID(ctx)
  31503. }
  31504. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  31505. }
  31506. // SetField sets the value of a field with the given name. It returns an error if
  31507. // the field is not defined in the schema, or if the type mismatched the field
  31508. // type.
  31509. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  31510. switch name {
  31511. case usagedetail.FieldCreatedAt:
  31512. v, ok := value.(time.Time)
  31513. if !ok {
  31514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31515. }
  31516. m.SetCreatedAt(v)
  31517. return nil
  31518. case usagedetail.FieldUpdatedAt:
  31519. v, ok := value.(time.Time)
  31520. if !ok {
  31521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31522. }
  31523. m.SetUpdatedAt(v)
  31524. return nil
  31525. case usagedetail.FieldStatus:
  31526. v, ok := value.(uint8)
  31527. if !ok {
  31528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31529. }
  31530. m.SetStatus(v)
  31531. return nil
  31532. case usagedetail.FieldType:
  31533. v, ok := value.(int)
  31534. if !ok {
  31535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31536. }
  31537. m.SetType(v)
  31538. return nil
  31539. case usagedetail.FieldBotID:
  31540. v, ok := value.(string)
  31541. if !ok {
  31542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31543. }
  31544. m.SetBotID(v)
  31545. return nil
  31546. case usagedetail.FieldReceiverID:
  31547. v, ok := value.(string)
  31548. if !ok {
  31549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31550. }
  31551. m.SetReceiverID(v)
  31552. return nil
  31553. case usagedetail.FieldApp:
  31554. v, ok := value.(int)
  31555. if !ok {
  31556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31557. }
  31558. m.SetApp(v)
  31559. return nil
  31560. case usagedetail.FieldSessionID:
  31561. v, ok := value.(uint64)
  31562. if !ok {
  31563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31564. }
  31565. m.SetSessionID(v)
  31566. return nil
  31567. case usagedetail.FieldRequest:
  31568. v, ok := value.(string)
  31569. if !ok {
  31570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31571. }
  31572. m.SetRequest(v)
  31573. return nil
  31574. case usagedetail.FieldResponse:
  31575. v, ok := value.(string)
  31576. if !ok {
  31577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31578. }
  31579. m.SetResponse(v)
  31580. return nil
  31581. case usagedetail.FieldOriginalData:
  31582. v, ok := value.(custom_types.OriginalData)
  31583. if !ok {
  31584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31585. }
  31586. m.SetOriginalData(v)
  31587. return nil
  31588. case usagedetail.FieldTotalTokens:
  31589. v, ok := value.(uint64)
  31590. if !ok {
  31591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31592. }
  31593. m.SetTotalTokens(v)
  31594. return nil
  31595. case usagedetail.FieldPromptTokens:
  31596. v, ok := value.(uint64)
  31597. if !ok {
  31598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31599. }
  31600. m.SetPromptTokens(v)
  31601. return nil
  31602. case usagedetail.FieldCompletionTokens:
  31603. v, ok := value.(uint64)
  31604. if !ok {
  31605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31606. }
  31607. m.SetCompletionTokens(v)
  31608. return nil
  31609. case usagedetail.FieldOrganizationID:
  31610. v, ok := value.(uint64)
  31611. if !ok {
  31612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31613. }
  31614. m.SetOrganizationID(v)
  31615. return nil
  31616. }
  31617. return fmt.Errorf("unknown UsageDetail field %s", name)
  31618. }
  31619. // AddedFields returns all numeric fields that were incremented/decremented during
  31620. // this mutation.
  31621. func (m *UsageDetailMutation) AddedFields() []string {
  31622. var fields []string
  31623. if m.addstatus != nil {
  31624. fields = append(fields, usagedetail.FieldStatus)
  31625. }
  31626. if m.add_type != nil {
  31627. fields = append(fields, usagedetail.FieldType)
  31628. }
  31629. if m.addapp != nil {
  31630. fields = append(fields, usagedetail.FieldApp)
  31631. }
  31632. if m.addsession_id != nil {
  31633. fields = append(fields, usagedetail.FieldSessionID)
  31634. }
  31635. if m.addtotal_tokens != nil {
  31636. fields = append(fields, usagedetail.FieldTotalTokens)
  31637. }
  31638. if m.addprompt_tokens != nil {
  31639. fields = append(fields, usagedetail.FieldPromptTokens)
  31640. }
  31641. if m.addcompletion_tokens != nil {
  31642. fields = append(fields, usagedetail.FieldCompletionTokens)
  31643. }
  31644. if m.addorganization_id != nil {
  31645. fields = append(fields, usagedetail.FieldOrganizationID)
  31646. }
  31647. return fields
  31648. }
  31649. // AddedField returns the numeric value that was incremented/decremented on a field
  31650. // with the given name. The second boolean return value indicates that this field
  31651. // was not set, or was not defined in the schema.
  31652. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  31653. switch name {
  31654. case usagedetail.FieldStatus:
  31655. return m.AddedStatus()
  31656. case usagedetail.FieldType:
  31657. return m.AddedType()
  31658. case usagedetail.FieldApp:
  31659. return m.AddedApp()
  31660. case usagedetail.FieldSessionID:
  31661. return m.AddedSessionID()
  31662. case usagedetail.FieldTotalTokens:
  31663. return m.AddedTotalTokens()
  31664. case usagedetail.FieldPromptTokens:
  31665. return m.AddedPromptTokens()
  31666. case usagedetail.FieldCompletionTokens:
  31667. return m.AddedCompletionTokens()
  31668. case usagedetail.FieldOrganizationID:
  31669. return m.AddedOrganizationID()
  31670. }
  31671. return nil, false
  31672. }
  31673. // AddField adds the value to the field with the given name. It returns an error if
  31674. // the field is not defined in the schema, or if the type mismatched the field
  31675. // type.
  31676. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  31677. switch name {
  31678. case usagedetail.FieldStatus:
  31679. v, ok := value.(int8)
  31680. if !ok {
  31681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31682. }
  31683. m.AddStatus(v)
  31684. return nil
  31685. case usagedetail.FieldType:
  31686. v, ok := value.(int)
  31687. if !ok {
  31688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31689. }
  31690. m.AddType(v)
  31691. return nil
  31692. case usagedetail.FieldApp:
  31693. v, ok := value.(int)
  31694. if !ok {
  31695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31696. }
  31697. m.AddApp(v)
  31698. return nil
  31699. case usagedetail.FieldSessionID:
  31700. v, ok := value.(int64)
  31701. if !ok {
  31702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31703. }
  31704. m.AddSessionID(v)
  31705. return nil
  31706. case usagedetail.FieldTotalTokens:
  31707. v, ok := value.(int64)
  31708. if !ok {
  31709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31710. }
  31711. m.AddTotalTokens(v)
  31712. return nil
  31713. case usagedetail.FieldPromptTokens:
  31714. v, ok := value.(int64)
  31715. if !ok {
  31716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31717. }
  31718. m.AddPromptTokens(v)
  31719. return nil
  31720. case usagedetail.FieldCompletionTokens:
  31721. v, ok := value.(int64)
  31722. if !ok {
  31723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31724. }
  31725. m.AddCompletionTokens(v)
  31726. return nil
  31727. case usagedetail.FieldOrganizationID:
  31728. v, ok := value.(int64)
  31729. if !ok {
  31730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31731. }
  31732. m.AddOrganizationID(v)
  31733. return nil
  31734. }
  31735. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  31736. }
  31737. // ClearedFields returns all nullable fields that were cleared during this
  31738. // mutation.
  31739. func (m *UsageDetailMutation) ClearedFields() []string {
  31740. var fields []string
  31741. if m.FieldCleared(usagedetail.FieldStatus) {
  31742. fields = append(fields, usagedetail.FieldStatus)
  31743. }
  31744. if m.FieldCleared(usagedetail.FieldType) {
  31745. fields = append(fields, usagedetail.FieldType)
  31746. }
  31747. if m.FieldCleared(usagedetail.FieldApp) {
  31748. fields = append(fields, usagedetail.FieldApp)
  31749. }
  31750. if m.FieldCleared(usagedetail.FieldSessionID) {
  31751. fields = append(fields, usagedetail.FieldSessionID)
  31752. }
  31753. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  31754. fields = append(fields, usagedetail.FieldTotalTokens)
  31755. }
  31756. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  31757. fields = append(fields, usagedetail.FieldPromptTokens)
  31758. }
  31759. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  31760. fields = append(fields, usagedetail.FieldCompletionTokens)
  31761. }
  31762. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  31763. fields = append(fields, usagedetail.FieldOrganizationID)
  31764. }
  31765. return fields
  31766. }
  31767. // FieldCleared returns a boolean indicating if a field with the given name was
  31768. // cleared in this mutation.
  31769. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  31770. _, ok := m.clearedFields[name]
  31771. return ok
  31772. }
  31773. // ClearField clears the value of the field with the given name. It returns an
  31774. // error if the field is not defined in the schema.
  31775. func (m *UsageDetailMutation) ClearField(name string) error {
  31776. switch name {
  31777. case usagedetail.FieldStatus:
  31778. m.ClearStatus()
  31779. return nil
  31780. case usagedetail.FieldType:
  31781. m.ClearType()
  31782. return nil
  31783. case usagedetail.FieldApp:
  31784. m.ClearApp()
  31785. return nil
  31786. case usagedetail.FieldSessionID:
  31787. m.ClearSessionID()
  31788. return nil
  31789. case usagedetail.FieldTotalTokens:
  31790. m.ClearTotalTokens()
  31791. return nil
  31792. case usagedetail.FieldPromptTokens:
  31793. m.ClearPromptTokens()
  31794. return nil
  31795. case usagedetail.FieldCompletionTokens:
  31796. m.ClearCompletionTokens()
  31797. return nil
  31798. case usagedetail.FieldOrganizationID:
  31799. m.ClearOrganizationID()
  31800. return nil
  31801. }
  31802. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  31803. }
  31804. // ResetField resets all changes in the mutation for the field with the given name.
  31805. // It returns an error if the field is not defined in the schema.
  31806. func (m *UsageDetailMutation) ResetField(name string) error {
  31807. switch name {
  31808. case usagedetail.FieldCreatedAt:
  31809. m.ResetCreatedAt()
  31810. return nil
  31811. case usagedetail.FieldUpdatedAt:
  31812. m.ResetUpdatedAt()
  31813. return nil
  31814. case usagedetail.FieldStatus:
  31815. m.ResetStatus()
  31816. return nil
  31817. case usagedetail.FieldType:
  31818. m.ResetType()
  31819. return nil
  31820. case usagedetail.FieldBotID:
  31821. m.ResetBotID()
  31822. return nil
  31823. case usagedetail.FieldReceiverID:
  31824. m.ResetReceiverID()
  31825. return nil
  31826. case usagedetail.FieldApp:
  31827. m.ResetApp()
  31828. return nil
  31829. case usagedetail.FieldSessionID:
  31830. m.ResetSessionID()
  31831. return nil
  31832. case usagedetail.FieldRequest:
  31833. m.ResetRequest()
  31834. return nil
  31835. case usagedetail.FieldResponse:
  31836. m.ResetResponse()
  31837. return nil
  31838. case usagedetail.FieldOriginalData:
  31839. m.ResetOriginalData()
  31840. return nil
  31841. case usagedetail.FieldTotalTokens:
  31842. m.ResetTotalTokens()
  31843. return nil
  31844. case usagedetail.FieldPromptTokens:
  31845. m.ResetPromptTokens()
  31846. return nil
  31847. case usagedetail.FieldCompletionTokens:
  31848. m.ResetCompletionTokens()
  31849. return nil
  31850. case usagedetail.FieldOrganizationID:
  31851. m.ResetOrganizationID()
  31852. return nil
  31853. }
  31854. return fmt.Errorf("unknown UsageDetail field %s", name)
  31855. }
  31856. // AddedEdges returns all edge names that were set/added in this mutation.
  31857. func (m *UsageDetailMutation) AddedEdges() []string {
  31858. edges := make([]string, 0, 0)
  31859. return edges
  31860. }
  31861. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31862. // name in this mutation.
  31863. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  31864. return nil
  31865. }
  31866. // RemovedEdges returns all edge names that were removed in this mutation.
  31867. func (m *UsageDetailMutation) RemovedEdges() []string {
  31868. edges := make([]string, 0, 0)
  31869. return edges
  31870. }
  31871. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31872. // the given name in this mutation.
  31873. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  31874. return nil
  31875. }
  31876. // ClearedEdges returns all edge names that were cleared in this mutation.
  31877. func (m *UsageDetailMutation) ClearedEdges() []string {
  31878. edges := make([]string, 0, 0)
  31879. return edges
  31880. }
  31881. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31882. // was cleared in this mutation.
  31883. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  31884. return false
  31885. }
  31886. // ClearEdge clears the value of the edge with the given name. It returns an error
  31887. // if that edge is not defined in the schema.
  31888. func (m *UsageDetailMutation) ClearEdge(name string) error {
  31889. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  31890. }
  31891. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31892. // It returns an error if the edge is not defined in the schema.
  31893. func (m *UsageDetailMutation) ResetEdge(name string) error {
  31894. return fmt.Errorf("unknown UsageDetail edge %s", name)
  31895. }
  31896. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  31897. type UsageStatisticDayMutation struct {
  31898. config
  31899. op Op
  31900. typ string
  31901. id *uint64
  31902. created_at *time.Time
  31903. updated_at *time.Time
  31904. status *uint8
  31905. addstatus *int8
  31906. deleted_at *time.Time
  31907. addtime *uint64
  31908. addaddtime *int64
  31909. _type *int
  31910. add_type *int
  31911. bot_id *string
  31912. organization_id *uint64
  31913. addorganization_id *int64
  31914. ai_response *uint64
  31915. addai_response *int64
  31916. sop_run *uint64
  31917. addsop_run *int64
  31918. total_friend *uint64
  31919. addtotal_friend *int64
  31920. total_group *uint64
  31921. addtotal_group *int64
  31922. account_balance *uint64
  31923. addaccount_balance *int64
  31924. consume_token *uint64
  31925. addconsume_token *int64
  31926. active_user *uint64
  31927. addactive_user *int64
  31928. new_user *int64
  31929. addnew_user *int64
  31930. label_dist *[]custom_types.LabelDist
  31931. appendlabel_dist []custom_types.LabelDist
  31932. clearedFields map[string]struct{}
  31933. done bool
  31934. oldValue func(context.Context) (*UsageStatisticDay, error)
  31935. predicates []predicate.UsageStatisticDay
  31936. }
  31937. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  31938. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  31939. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  31940. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  31941. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  31942. m := &UsageStatisticDayMutation{
  31943. config: c,
  31944. op: op,
  31945. typ: TypeUsageStatisticDay,
  31946. clearedFields: make(map[string]struct{}),
  31947. }
  31948. for _, opt := range opts {
  31949. opt(m)
  31950. }
  31951. return m
  31952. }
  31953. // withUsageStatisticDayID sets the ID field of the mutation.
  31954. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  31955. return func(m *UsageStatisticDayMutation) {
  31956. var (
  31957. err error
  31958. once sync.Once
  31959. value *UsageStatisticDay
  31960. )
  31961. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  31962. once.Do(func() {
  31963. if m.done {
  31964. err = errors.New("querying old values post mutation is not allowed")
  31965. } else {
  31966. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  31967. }
  31968. })
  31969. return value, err
  31970. }
  31971. m.id = &id
  31972. }
  31973. }
  31974. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  31975. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  31976. return func(m *UsageStatisticDayMutation) {
  31977. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  31978. return node, nil
  31979. }
  31980. m.id = &node.ID
  31981. }
  31982. }
  31983. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31984. // executed in a transaction (ent.Tx), a transactional client is returned.
  31985. func (m UsageStatisticDayMutation) Client() *Client {
  31986. client := &Client{config: m.config}
  31987. client.init()
  31988. return client
  31989. }
  31990. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31991. // it returns an error otherwise.
  31992. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  31993. if _, ok := m.driver.(*txDriver); !ok {
  31994. return nil, errors.New("ent: mutation is not running in a transaction")
  31995. }
  31996. tx := &Tx{config: m.config}
  31997. tx.init()
  31998. return tx, nil
  31999. }
  32000. // SetID sets the value of the id field. Note that this
  32001. // operation is only accepted on creation of UsageStatisticDay entities.
  32002. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  32003. m.id = &id
  32004. }
  32005. // ID returns the ID value in the mutation. Note that the ID is only available
  32006. // if it was provided to the builder or after it was returned from the database.
  32007. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  32008. if m.id == nil {
  32009. return
  32010. }
  32011. return *m.id, true
  32012. }
  32013. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32014. // That means, if the mutation is applied within a transaction with an isolation level such
  32015. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32016. // or updated by the mutation.
  32017. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  32018. switch {
  32019. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32020. id, exists := m.ID()
  32021. if exists {
  32022. return []uint64{id}, nil
  32023. }
  32024. fallthrough
  32025. case m.op.Is(OpUpdate | OpDelete):
  32026. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  32027. default:
  32028. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32029. }
  32030. }
  32031. // SetCreatedAt sets the "created_at" field.
  32032. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  32033. m.created_at = &t
  32034. }
  32035. // CreatedAt returns the value of the "created_at" field in the mutation.
  32036. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  32037. v := m.created_at
  32038. if v == nil {
  32039. return
  32040. }
  32041. return *v, true
  32042. }
  32043. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  32044. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32046. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32047. if !m.op.Is(OpUpdateOne) {
  32048. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32049. }
  32050. if m.id == nil || m.oldValue == nil {
  32051. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32052. }
  32053. oldValue, err := m.oldValue(ctx)
  32054. if err != nil {
  32055. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32056. }
  32057. return oldValue.CreatedAt, nil
  32058. }
  32059. // ResetCreatedAt resets all changes to the "created_at" field.
  32060. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  32061. m.created_at = nil
  32062. }
  32063. // SetUpdatedAt sets the "updated_at" field.
  32064. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  32065. m.updated_at = &t
  32066. }
  32067. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32068. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  32069. v := m.updated_at
  32070. if v == nil {
  32071. return
  32072. }
  32073. return *v, true
  32074. }
  32075. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  32076. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32078. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32079. if !m.op.Is(OpUpdateOne) {
  32080. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32081. }
  32082. if m.id == nil || m.oldValue == nil {
  32083. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32084. }
  32085. oldValue, err := m.oldValue(ctx)
  32086. if err != nil {
  32087. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32088. }
  32089. return oldValue.UpdatedAt, nil
  32090. }
  32091. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32092. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  32093. m.updated_at = nil
  32094. }
  32095. // SetStatus sets the "status" field.
  32096. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  32097. m.status = &u
  32098. m.addstatus = nil
  32099. }
  32100. // Status returns the value of the "status" field in the mutation.
  32101. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  32102. v := m.status
  32103. if v == nil {
  32104. return
  32105. }
  32106. return *v, true
  32107. }
  32108. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  32109. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32111. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32112. if !m.op.Is(OpUpdateOne) {
  32113. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32114. }
  32115. if m.id == nil || m.oldValue == nil {
  32116. return v, errors.New("OldStatus requires an ID field in the mutation")
  32117. }
  32118. oldValue, err := m.oldValue(ctx)
  32119. if err != nil {
  32120. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32121. }
  32122. return oldValue.Status, nil
  32123. }
  32124. // AddStatus adds u to the "status" field.
  32125. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  32126. if m.addstatus != nil {
  32127. *m.addstatus += u
  32128. } else {
  32129. m.addstatus = &u
  32130. }
  32131. }
  32132. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32133. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  32134. v := m.addstatus
  32135. if v == nil {
  32136. return
  32137. }
  32138. return *v, true
  32139. }
  32140. // ClearStatus clears the value of the "status" field.
  32141. func (m *UsageStatisticDayMutation) ClearStatus() {
  32142. m.status = nil
  32143. m.addstatus = nil
  32144. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  32145. }
  32146. // StatusCleared returns if the "status" field was cleared in this mutation.
  32147. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  32148. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  32149. return ok
  32150. }
  32151. // ResetStatus resets all changes to the "status" field.
  32152. func (m *UsageStatisticDayMutation) ResetStatus() {
  32153. m.status = nil
  32154. m.addstatus = nil
  32155. delete(m.clearedFields, usagestatisticday.FieldStatus)
  32156. }
  32157. // SetDeletedAt sets the "deleted_at" field.
  32158. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  32159. m.deleted_at = &t
  32160. }
  32161. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32162. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  32163. v := m.deleted_at
  32164. if v == nil {
  32165. return
  32166. }
  32167. return *v, true
  32168. }
  32169. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  32170. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32172. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32173. if !m.op.Is(OpUpdateOne) {
  32174. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32175. }
  32176. if m.id == nil || m.oldValue == nil {
  32177. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32178. }
  32179. oldValue, err := m.oldValue(ctx)
  32180. if err != nil {
  32181. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32182. }
  32183. return oldValue.DeletedAt, nil
  32184. }
  32185. // ClearDeletedAt clears the value of the "deleted_at" field.
  32186. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  32187. m.deleted_at = nil
  32188. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  32189. }
  32190. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32191. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  32192. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  32193. return ok
  32194. }
  32195. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32196. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  32197. m.deleted_at = nil
  32198. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  32199. }
  32200. // SetAddtime sets the "addtime" field.
  32201. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  32202. m.addtime = &u
  32203. m.addaddtime = nil
  32204. }
  32205. // Addtime returns the value of the "addtime" field in the mutation.
  32206. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  32207. v := m.addtime
  32208. if v == nil {
  32209. return
  32210. }
  32211. return *v, true
  32212. }
  32213. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  32214. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32216. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32217. if !m.op.Is(OpUpdateOne) {
  32218. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32219. }
  32220. if m.id == nil || m.oldValue == nil {
  32221. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32222. }
  32223. oldValue, err := m.oldValue(ctx)
  32224. if err != nil {
  32225. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32226. }
  32227. return oldValue.Addtime, nil
  32228. }
  32229. // AddAddtime adds u to the "addtime" field.
  32230. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  32231. if m.addaddtime != nil {
  32232. *m.addaddtime += u
  32233. } else {
  32234. m.addaddtime = &u
  32235. }
  32236. }
  32237. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32238. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  32239. v := m.addaddtime
  32240. if v == nil {
  32241. return
  32242. }
  32243. return *v, true
  32244. }
  32245. // ResetAddtime resets all changes to the "addtime" field.
  32246. func (m *UsageStatisticDayMutation) ResetAddtime() {
  32247. m.addtime = nil
  32248. m.addaddtime = nil
  32249. }
  32250. // SetType sets the "type" field.
  32251. func (m *UsageStatisticDayMutation) SetType(i int) {
  32252. m._type = &i
  32253. m.add_type = nil
  32254. }
  32255. // GetType returns the value of the "type" field in the mutation.
  32256. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  32257. v := m._type
  32258. if v == nil {
  32259. return
  32260. }
  32261. return *v, true
  32262. }
  32263. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  32264. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32266. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  32267. if !m.op.Is(OpUpdateOne) {
  32268. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32269. }
  32270. if m.id == nil || m.oldValue == nil {
  32271. return v, errors.New("OldType requires an ID field in the mutation")
  32272. }
  32273. oldValue, err := m.oldValue(ctx)
  32274. if err != nil {
  32275. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32276. }
  32277. return oldValue.Type, nil
  32278. }
  32279. // AddType adds i to the "type" field.
  32280. func (m *UsageStatisticDayMutation) AddType(i int) {
  32281. if m.add_type != nil {
  32282. *m.add_type += i
  32283. } else {
  32284. m.add_type = &i
  32285. }
  32286. }
  32287. // AddedType returns the value that was added to the "type" field in this mutation.
  32288. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  32289. v := m.add_type
  32290. if v == nil {
  32291. return
  32292. }
  32293. return *v, true
  32294. }
  32295. // ResetType resets all changes to the "type" field.
  32296. func (m *UsageStatisticDayMutation) ResetType() {
  32297. m._type = nil
  32298. m.add_type = nil
  32299. }
  32300. // SetBotID sets the "bot_id" field.
  32301. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  32302. m.bot_id = &s
  32303. }
  32304. // BotID returns the value of the "bot_id" field in the mutation.
  32305. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  32306. v := m.bot_id
  32307. if v == nil {
  32308. return
  32309. }
  32310. return *v, true
  32311. }
  32312. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  32313. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32315. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  32316. if !m.op.Is(OpUpdateOne) {
  32317. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32318. }
  32319. if m.id == nil || m.oldValue == nil {
  32320. return v, errors.New("OldBotID requires an ID field in the mutation")
  32321. }
  32322. oldValue, err := m.oldValue(ctx)
  32323. if err != nil {
  32324. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32325. }
  32326. return oldValue.BotID, nil
  32327. }
  32328. // ClearBotID clears the value of the "bot_id" field.
  32329. func (m *UsageStatisticDayMutation) ClearBotID() {
  32330. m.bot_id = nil
  32331. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  32332. }
  32333. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32334. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  32335. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  32336. return ok
  32337. }
  32338. // ResetBotID resets all changes to the "bot_id" field.
  32339. func (m *UsageStatisticDayMutation) ResetBotID() {
  32340. m.bot_id = nil
  32341. delete(m.clearedFields, usagestatisticday.FieldBotID)
  32342. }
  32343. // SetOrganizationID sets the "organization_id" field.
  32344. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  32345. m.organization_id = &u
  32346. m.addorganization_id = nil
  32347. }
  32348. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32349. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  32350. v := m.organization_id
  32351. if v == nil {
  32352. return
  32353. }
  32354. return *v, true
  32355. }
  32356. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  32357. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32359. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32360. if !m.op.Is(OpUpdateOne) {
  32361. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32362. }
  32363. if m.id == nil || m.oldValue == nil {
  32364. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32365. }
  32366. oldValue, err := m.oldValue(ctx)
  32367. if err != nil {
  32368. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32369. }
  32370. return oldValue.OrganizationID, nil
  32371. }
  32372. // AddOrganizationID adds u to the "organization_id" field.
  32373. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  32374. if m.addorganization_id != nil {
  32375. *m.addorganization_id += u
  32376. } else {
  32377. m.addorganization_id = &u
  32378. }
  32379. }
  32380. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32381. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  32382. v := m.addorganization_id
  32383. if v == nil {
  32384. return
  32385. }
  32386. return *v, true
  32387. }
  32388. // ClearOrganizationID clears the value of the "organization_id" field.
  32389. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  32390. m.organization_id = nil
  32391. m.addorganization_id = nil
  32392. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  32393. }
  32394. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32395. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  32396. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  32397. return ok
  32398. }
  32399. // ResetOrganizationID resets all changes to the "organization_id" field.
  32400. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  32401. m.organization_id = nil
  32402. m.addorganization_id = nil
  32403. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  32404. }
  32405. // SetAiResponse sets the "ai_response" field.
  32406. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  32407. m.ai_response = &u
  32408. m.addai_response = nil
  32409. }
  32410. // AiResponse returns the value of the "ai_response" field in the mutation.
  32411. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  32412. v := m.ai_response
  32413. if v == nil {
  32414. return
  32415. }
  32416. return *v, true
  32417. }
  32418. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  32419. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32421. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32422. if !m.op.Is(OpUpdateOne) {
  32423. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32424. }
  32425. if m.id == nil || m.oldValue == nil {
  32426. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32427. }
  32428. oldValue, err := m.oldValue(ctx)
  32429. if err != nil {
  32430. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32431. }
  32432. return oldValue.AiResponse, nil
  32433. }
  32434. // AddAiResponse adds u to the "ai_response" field.
  32435. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  32436. if m.addai_response != nil {
  32437. *m.addai_response += u
  32438. } else {
  32439. m.addai_response = &u
  32440. }
  32441. }
  32442. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32443. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  32444. v := m.addai_response
  32445. if v == nil {
  32446. return
  32447. }
  32448. return *v, true
  32449. }
  32450. // ResetAiResponse resets all changes to the "ai_response" field.
  32451. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  32452. m.ai_response = nil
  32453. m.addai_response = nil
  32454. }
  32455. // SetSopRun sets the "sop_run" field.
  32456. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  32457. m.sop_run = &u
  32458. m.addsop_run = nil
  32459. }
  32460. // SopRun returns the value of the "sop_run" field in the mutation.
  32461. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  32462. v := m.sop_run
  32463. if v == nil {
  32464. return
  32465. }
  32466. return *v, true
  32467. }
  32468. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  32469. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32471. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32472. if !m.op.Is(OpUpdateOne) {
  32473. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32474. }
  32475. if m.id == nil || m.oldValue == nil {
  32476. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32477. }
  32478. oldValue, err := m.oldValue(ctx)
  32479. if err != nil {
  32480. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32481. }
  32482. return oldValue.SopRun, nil
  32483. }
  32484. // AddSopRun adds u to the "sop_run" field.
  32485. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  32486. if m.addsop_run != nil {
  32487. *m.addsop_run += u
  32488. } else {
  32489. m.addsop_run = &u
  32490. }
  32491. }
  32492. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32493. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  32494. v := m.addsop_run
  32495. if v == nil {
  32496. return
  32497. }
  32498. return *v, true
  32499. }
  32500. // ResetSopRun resets all changes to the "sop_run" field.
  32501. func (m *UsageStatisticDayMutation) ResetSopRun() {
  32502. m.sop_run = nil
  32503. m.addsop_run = nil
  32504. }
  32505. // SetTotalFriend sets the "total_friend" field.
  32506. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  32507. m.total_friend = &u
  32508. m.addtotal_friend = nil
  32509. }
  32510. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32511. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  32512. v := m.total_friend
  32513. if v == nil {
  32514. return
  32515. }
  32516. return *v, true
  32517. }
  32518. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  32519. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32521. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32522. if !m.op.Is(OpUpdateOne) {
  32523. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32524. }
  32525. if m.id == nil || m.oldValue == nil {
  32526. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32527. }
  32528. oldValue, err := m.oldValue(ctx)
  32529. if err != nil {
  32530. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32531. }
  32532. return oldValue.TotalFriend, nil
  32533. }
  32534. // AddTotalFriend adds u to the "total_friend" field.
  32535. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  32536. if m.addtotal_friend != nil {
  32537. *m.addtotal_friend += u
  32538. } else {
  32539. m.addtotal_friend = &u
  32540. }
  32541. }
  32542. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32543. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  32544. v := m.addtotal_friend
  32545. if v == nil {
  32546. return
  32547. }
  32548. return *v, true
  32549. }
  32550. // ResetTotalFriend resets all changes to the "total_friend" field.
  32551. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  32552. m.total_friend = nil
  32553. m.addtotal_friend = nil
  32554. }
  32555. // SetTotalGroup sets the "total_group" field.
  32556. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  32557. m.total_group = &u
  32558. m.addtotal_group = nil
  32559. }
  32560. // TotalGroup returns the value of the "total_group" field in the mutation.
  32561. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  32562. v := m.total_group
  32563. if v == nil {
  32564. return
  32565. }
  32566. return *v, true
  32567. }
  32568. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  32569. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32571. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32572. if !m.op.Is(OpUpdateOne) {
  32573. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32574. }
  32575. if m.id == nil || m.oldValue == nil {
  32576. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32577. }
  32578. oldValue, err := m.oldValue(ctx)
  32579. if err != nil {
  32580. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32581. }
  32582. return oldValue.TotalGroup, nil
  32583. }
  32584. // AddTotalGroup adds u to the "total_group" field.
  32585. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  32586. if m.addtotal_group != nil {
  32587. *m.addtotal_group += u
  32588. } else {
  32589. m.addtotal_group = &u
  32590. }
  32591. }
  32592. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32593. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  32594. v := m.addtotal_group
  32595. if v == nil {
  32596. return
  32597. }
  32598. return *v, true
  32599. }
  32600. // ResetTotalGroup resets all changes to the "total_group" field.
  32601. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  32602. m.total_group = nil
  32603. m.addtotal_group = nil
  32604. }
  32605. // SetAccountBalance sets the "account_balance" field.
  32606. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  32607. m.account_balance = &u
  32608. m.addaccount_balance = nil
  32609. }
  32610. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32611. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  32612. v := m.account_balance
  32613. if v == nil {
  32614. return
  32615. }
  32616. return *v, true
  32617. }
  32618. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  32619. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32621. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32622. if !m.op.Is(OpUpdateOne) {
  32623. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32624. }
  32625. if m.id == nil || m.oldValue == nil {
  32626. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32627. }
  32628. oldValue, err := m.oldValue(ctx)
  32629. if err != nil {
  32630. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32631. }
  32632. return oldValue.AccountBalance, nil
  32633. }
  32634. // AddAccountBalance adds u to the "account_balance" field.
  32635. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  32636. if m.addaccount_balance != nil {
  32637. *m.addaccount_balance += u
  32638. } else {
  32639. m.addaccount_balance = &u
  32640. }
  32641. }
  32642. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32643. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  32644. v := m.addaccount_balance
  32645. if v == nil {
  32646. return
  32647. }
  32648. return *v, true
  32649. }
  32650. // ResetAccountBalance resets all changes to the "account_balance" field.
  32651. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  32652. m.account_balance = nil
  32653. m.addaccount_balance = nil
  32654. }
  32655. // SetConsumeToken sets the "consume_token" field.
  32656. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  32657. m.consume_token = &u
  32658. m.addconsume_token = nil
  32659. }
  32660. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32661. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  32662. v := m.consume_token
  32663. if v == nil {
  32664. return
  32665. }
  32666. return *v, true
  32667. }
  32668. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  32669. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32671. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32672. if !m.op.Is(OpUpdateOne) {
  32673. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32674. }
  32675. if m.id == nil || m.oldValue == nil {
  32676. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32677. }
  32678. oldValue, err := m.oldValue(ctx)
  32679. if err != nil {
  32680. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32681. }
  32682. return oldValue.ConsumeToken, nil
  32683. }
  32684. // AddConsumeToken adds u to the "consume_token" field.
  32685. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  32686. if m.addconsume_token != nil {
  32687. *m.addconsume_token += u
  32688. } else {
  32689. m.addconsume_token = &u
  32690. }
  32691. }
  32692. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32693. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  32694. v := m.addconsume_token
  32695. if v == nil {
  32696. return
  32697. }
  32698. return *v, true
  32699. }
  32700. // ResetConsumeToken resets all changes to the "consume_token" field.
  32701. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  32702. m.consume_token = nil
  32703. m.addconsume_token = nil
  32704. }
  32705. // SetActiveUser sets the "active_user" field.
  32706. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  32707. m.active_user = &u
  32708. m.addactive_user = nil
  32709. }
  32710. // ActiveUser returns the value of the "active_user" field in the mutation.
  32711. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  32712. v := m.active_user
  32713. if v == nil {
  32714. return
  32715. }
  32716. return *v, true
  32717. }
  32718. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  32719. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32721. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32722. if !m.op.Is(OpUpdateOne) {
  32723. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32724. }
  32725. if m.id == nil || m.oldValue == nil {
  32726. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32727. }
  32728. oldValue, err := m.oldValue(ctx)
  32729. if err != nil {
  32730. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32731. }
  32732. return oldValue.ActiveUser, nil
  32733. }
  32734. // AddActiveUser adds u to the "active_user" field.
  32735. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  32736. if m.addactive_user != nil {
  32737. *m.addactive_user += u
  32738. } else {
  32739. m.addactive_user = &u
  32740. }
  32741. }
  32742. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32743. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  32744. v := m.addactive_user
  32745. if v == nil {
  32746. return
  32747. }
  32748. return *v, true
  32749. }
  32750. // ResetActiveUser resets all changes to the "active_user" field.
  32751. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  32752. m.active_user = nil
  32753. m.addactive_user = nil
  32754. }
  32755. // SetNewUser sets the "new_user" field.
  32756. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  32757. m.new_user = &i
  32758. m.addnew_user = nil
  32759. }
  32760. // NewUser returns the value of the "new_user" field in the mutation.
  32761. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  32762. v := m.new_user
  32763. if v == nil {
  32764. return
  32765. }
  32766. return *v, true
  32767. }
  32768. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  32769. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32771. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32772. if !m.op.Is(OpUpdateOne) {
  32773. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32774. }
  32775. if m.id == nil || m.oldValue == nil {
  32776. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32777. }
  32778. oldValue, err := m.oldValue(ctx)
  32779. if err != nil {
  32780. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32781. }
  32782. return oldValue.NewUser, nil
  32783. }
  32784. // AddNewUser adds i to the "new_user" field.
  32785. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  32786. if m.addnew_user != nil {
  32787. *m.addnew_user += i
  32788. } else {
  32789. m.addnew_user = &i
  32790. }
  32791. }
  32792. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32793. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  32794. v := m.addnew_user
  32795. if v == nil {
  32796. return
  32797. }
  32798. return *v, true
  32799. }
  32800. // ResetNewUser resets all changes to the "new_user" field.
  32801. func (m *UsageStatisticDayMutation) ResetNewUser() {
  32802. m.new_user = nil
  32803. m.addnew_user = nil
  32804. }
  32805. // SetLabelDist sets the "label_dist" field.
  32806. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32807. m.label_dist = &ctd
  32808. m.appendlabel_dist = nil
  32809. }
  32810. // LabelDist returns the value of the "label_dist" field in the mutation.
  32811. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32812. v := m.label_dist
  32813. if v == nil {
  32814. return
  32815. }
  32816. return *v, true
  32817. }
  32818. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  32819. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32821. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32822. if !m.op.Is(OpUpdateOne) {
  32823. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32824. }
  32825. if m.id == nil || m.oldValue == nil {
  32826. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32827. }
  32828. oldValue, err := m.oldValue(ctx)
  32829. if err != nil {
  32830. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32831. }
  32832. return oldValue.LabelDist, nil
  32833. }
  32834. // AppendLabelDist adds ctd to the "label_dist" field.
  32835. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32836. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32837. }
  32838. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32839. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32840. if len(m.appendlabel_dist) == 0 {
  32841. return nil, false
  32842. }
  32843. return m.appendlabel_dist, true
  32844. }
  32845. // ResetLabelDist resets all changes to the "label_dist" field.
  32846. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  32847. m.label_dist = nil
  32848. m.appendlabel_dist = nil
  32849. }
  32850. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  32851. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  32852. m.predicates = append(m.predicates, ps...)
  32853. }
  32854. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  32855. // users can use type-assertion to append predicates that do not depend on any generated package.
  32856. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  32857. p := make([]predicate.UsageStatisticDay, len(ps))
  32858. for i := range ps {
  32859. p[i] = ps[i]
  32860. }
  32861. m.Where(p...)
  32862. }
  32863. // Op returns the operation name.
  32864. func (m *UsageStatisticDayMutation) Op() Op {
  32865. return m.op
  32866. }
  32867. // SetOp allows setting the mutation operation.
  32868. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  32869. m.op = op
  32870. }
  32871. // Type returns the node type of this mutation (UsageStatisticDay).
  32872. func (m *UsageStatisticDayMutation) Type() string {
  32873. return m.typ
  32874. }
  32875. // Fields returns all fields that were changed during this mutation. Note that in
  32876. // order to get all numeric fields that were incremented/decremented, call
  32877. // AddedFields().
  32878. func (m *UsageStatisticDayMutation) Fields() []string {
  32879. fields := make([]string, 0, 17)
  32880. if m.created_at != nil {
  32881. fields = append(fields, usagestatisticday.FieldCreatedAt)
  32882. }
  32883. if m.updated_at != nil {
  32884. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  32885. }
  32886. if m.status != nil {
  32887. fields = append(fields, usagestatisticday.FieldStatus)
  32888. }
  32889. if m.deleted_at != nil {
  32890. fields = append(fields, usagestatisticday.FieldDeletedAt)
  32891. }
  32892. if m.addtime != nil {
  32893. fields = append(fields, usagestatisticday.FieldAddtime)
  32894. }
  32895. if m._type != nil {
  32896. fields = append(fields, usagestatisticday.FieldType)
  32897. }
  32898. if m.bot_id != nil {
  32899. fields = append(fields, usagestatisticday.FieldBotID)
  32900. }
  32901. if m.organization_id != nil {
  32902. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32903. }
  32904. if m.ai_response != nil {
  32905. fields = append(fields, usagestatisticday.FieldAiResponse)
  32906. }
  32907. if m.sop_run != nil {
  32908. fields = append(fields, usagestatisticday.FieldSopRun)
  32909. }
  32910. if m.total_friend != nil {
  32911. fields = append(fields, usagestatisticday.FieldTotalFriend)
  32912. }
  32913. if m.total_group != nil {
  32914. fields = append(fields, usagestatisticday.FieldTotalGroup)
  32915. }
  32916. if m.account_balance != nil {
  32917. fields = append(fields, usagestatisticday.FieldAccountBalance)
  32918. }
  32919. if m.consume_token != nil {
  32920. fields = append(fields, usagestatisticday.FieldConsumeToken)
  32921. }
  32922. if m.active_user != nil {
  32923. fields = append(fields, usagestatisticday.FieldActiveUser)
  32924. }
  32925. if m.new_user != nil {
  32926. fields = append(fields, usagestatisticday.FieldNewUser)
  32927. }
  32928. if m.label_dist != nil {
  32929. fields = append(fields, usagestatisticday.FieldLabelDist)
  32930. }
  32931. return fields
  32932. }
  32933. // Field returns the value of a field with the given name. The second boolean
  32934. // return value indicates that this field was not set, or was not defined in the
  32935. // schema.
  32936. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  32937. switch name {
  32938. case usagestatisticday.FieldCreatedAt:
  32939. return m.CreatedAt()
  32940. case usagestatisticday.FieldUpdatedAt:
  32941. return m.UpdatedAt()
  32942. case usagestatisticday.FieldStatus:
  32943. return m.Status()
  32944. case usagestatisticday.FieldDeletedAt:
  32945. return m.DeletedAt()
  32946. case usagestatisticday.FieldAddtime:
  32947. return m.Addtime()
  32948. case usagestatisticday.FieldType:
  32949. return m.GetType()
  32950. case usagestatisticday.FieldBotID:
  32951. return m.BotID()
  32952. case usagestatisticday.FieldOrganizationID:
  32953. return m.OrganizationID()
  32954. case usagestatisticday.FieldAiResponse:
  32955. return m.AiResponse()
  32956. case usagestatisticday.FieldSopRun:
  32957. return m.SopRun()
  32958. case usagestatisticday.FieldTotalFriend:
  32959. return m.TotalFriend()
  32960. case usagestatisticday.FieldTotalGroup:
  32961. return m.TotalGroup()
  32962. case usagestatisticday.FieldAccountBalance:
  32963. return m.AccountBalance()
  32964. case usagestatisticday.FieldConsumeToken:
  32965. return m.ConsumeToken()
  32966. case usagestatisticday.FieldActiveUser:
  32967. return m.ActiveUser()
  32968. case usagestatisticday.FieldNewUser:
  32969. return m.NewUser()
  32970. case usagestatisticday.FieldLabelDist:
  32971. return m.LabelDist()
  32972. }
  32973. return nil, false
  32974. }
  32975. // OldField returns the old value of the field from the database. An error is
  32976. // returned if the mutation operation is not UpdateOne, or the query to the
  32977. // database failed.
  32978. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32979. switch name {
  32980. case usagestatisticday.FieldCreatedAt:
  32981. return m.OldCreatedAt(ctx)
  32982. case usagestatisticday.FieldUpdatedAt:
  32983. return m.OldUpdatedAt(ctx)
  32984. case usagestatisticday.FieldStatus:
  32985. return m.OldStatus(ctx)
  32986. case usagestatisticday.FieldDeletedAt:
  32987. return m.OldDeletedAt(ctx)
  32988. case usagestatisticday.FieldAddtime:
  32989. return m.OldAddtime(ctx)
  32990. case usagestatisticday.FieldType:
  32991. return m.OldType(ctx)
  32992. case usagestatisticday.FieldBotID:
  32993. return m.OldBotID(ctx)
  32994. case usagestatisticday.FieldOrganizationID:
  32995. return m.OldOrganizationID(ctx)
  32996. case usagestatisticday.FieldAiResponse:
  32997. return m.OldAiResponse(ctx)
  32998. case usagestatisticday.FieldSopRun:
  32999. return m.OldSopRun(ctx)
  33000. case usagestatisticday.FieldTotalFriend:
  33001. return m.OldTotalFriend(ctx)
  33002. case usagestatisticday.FieldTotalGroup:
  33003. return m.OldTotalGroup(ctx)
  33004. case usagestatisticday.FieldAccountBalance:
  33005. return m.OldAccountBalance(ctx)
  33006. case usagestatisticday.FieldConsumeToken:
  33007. return m.OldConsumeToken(ctx)
  33008. case usagestatisticday.FieldActiveUser:
  33009. return m.OldActiveUser(ctx)
  33010. case usagestatisticday.FieldNewUser:
  33011. return m.OldNewUser(ctx)
  33012. case usagestatisticday.FieldLabelDist:
  33013. return m.OldLabelDist(ctx)
  33014. }
  33015. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33016. }
  33017. // SetField sets the value of a field with the given name. It returns an error if
  33018. // the field is not defined in the schema, or if the type mismatched the field
  33019. // type.
  33020. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  33021. switch name {
  33022. case usagestatisticday.FieldCreatedAt:
  33023. v, ok := value.(time.Time)
  33024. if !ok {
  33025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33026. }
  33027. m.SetCreatedAt(v)
  33028. return nil
  33029. case usagestatisticday.FieldUpdatedAt:
  33030. v, ok := value.(time.Time)
  33031. if !ok {
  33032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33033. }
  33034. m.SetUpdatedAt(v)
  33035. return nil
  33036. case usagestatisticday.FieldStatus:
  33037. v, ok := value.(uint8)
  33038. if !ok {
  33039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33040. }
  33041. m.SetStatus(v)
  33042. return nil
  33043. case usagestatisticday.FieldDeletedAt:
  33044. v, ok := value.(time.Time)
  33045. if !ok {
  33046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33047. }
  33048. m.SetDeletedAt(v)
  33049. return nil
  33050. case usagestatisticday.FieldAddtime:
  33051. v, ok := value.(uint64)
  33052. if !ok {
  33053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33054. }
  33055. m.SetAddtime(v)
  33056. return nil
  33057. case usagestatisticday.FieldType:
  33058. v, ok := value.(int)
  33059. if !ok {
  33060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33061. }
  33062. m.SetType(v)
  33063. return nil
  33064. case usagestatisticday.FieldBotID:
  33065. v, ok := value.(string)
  33066. if !ok {
  33067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33068. }
  33069. m.SetBotID(v)
  33070. return nil
  33071. case usagestatisticday.FieldOrganizationID:
  33072. v, ok := value.(uint64)
  33073. if !ok {
  33074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33075. }
  33076. m.SetOrganizationID(v)
  33077. return nil
  33078. case usagestatisticday.FieldAiResponse:
  33079. v, ok := value.(uint64)
  33080. if !ok {
  33081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33082. }
  33083. m.SetAiResponse(v)
  33084. return nil
  33085. case usagestatisticday.FieldSopRun:
  33086. v, ok := value.(uint64)
  33087. if !ok {
  33088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33089. }
  33090. m.SetSopRun(v)
  33091. return nil
  33092. case usagestatisticday.FieldTotalFriend:
  33093. v, ok := value.(uint64)
  33094. if !ok {
  33095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33096. }
  33097. m.SetTotalFriend(v)
  33098. return nil
  33099. case usagestatisticday.FieldTotalGroup:
  33100. v, ok := value.(uint64)
  33101. if !ok {
  33102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33103. }
  33104. m.SetTotalGroup(v)
  33105. return nil
  33106. case usagestatisticday.FieldAccountBalance:
  33107. v, ok := value.(uint64)
  33108. if !ok {
  33109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33110. }
  33111. m.SetAccountBalance(v)
  33112. return nil
  33113. case usagestatisticday.FieldConsumeToken:
  33114. v, ok := value.(uint64)
  33115. if !ok {
  33116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33117. }
  33118. m.SetConsumeToken(v)
  33119. return nil
  33120. case usagestatisticday.FieldActiveUser:
  33121. v, ok := value.(uint64)
  33122. if !ok {
  33123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33124. }
  33125. m.SetActiveUser(v)
  33126. return nil
  33127. case usagestatisticday.FieldNewUser:
  33128. v, ok := value.(int64)
  33129. if !ok {
  33130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33131. }
  33132. m.SetNewUser(v)
  33133. return nil
  33134. case usagestatisticday.FieldLabelDist:
  33135. v, ok := value.([]custom_types.LabelDist)
  33136. if !ok {
  33137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33138. }
  33139. m.SetLabelDist(v)
  33140. return nil
  33141. }
  33142. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33143. }
  33144. // AddedFields returns all numeric fields that were incremented/decremented during
  33145. // this mutation.
  33146. func (m *UsageStatisticDayMutation) AddedFields() []string {
  33147. var fields []string
  33148. if m.addstatus != nil {
  33149. fields = append(fields, usagestatisticday.FieldStatus)
  33150. }
  33151. if m.addaddtime != nil {
  33152. fields = append(fields, usagestatisticday.FieldAddtime)
  33153. }
  33154. if m.add_type != nil {
  33155. fields = append(fields, usagestatisticday.FieldType)
  33156. }
  33157. if m.addorganization_id != nil {
  33158. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33159. }
  33160. if m.addai_response != nil {
  33161. fields = append(fields, usagestatisticday.FieldAiResponse)
  33162. }
  33163. if m.addsop_run != nil {
  33164. fields = append(fields, usagestatisticday.FieldSopRun)
  33165. }
  33166. if m.addtotal_friend != nil {
  33167. fields = append(fields, usagestatisticday.FieldTotalFriend)
  33168. }
  33169. if m.addtotal_group != nil {
  33170. fields = append(fields, usagestatisticday.FieldTotalGroup)
  33171. }
  33172. if m.addaccount_balance != nil {
  33173. fields = append(fields, usagestatisticday.FieldAccountBalance)
  33174. }
  33175. if m.addconsume_token != nil {
  33176. fields = append(fields, usagestatisticday.FieldConsumeToken)
  33177. }
  33178. if m.addactive_user != nil {
  33179. fields = append(fields, usagestatisticday.FieldActiveUser)
  33180. }
  33181. if m.addnew_user != nil {
  33182. fields = append(fields, usagestatisticday.FieldNewUser)
  33183. }
  33184. return fields
  33185. }
  33186. // AddedField returns the numeric value that was incremented/decremented on a field
  33187. // with the given name. The second boolean return value indicates that this field
  33188. // was not set, or was not defined in the schema.
  33189. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  33190. switch name {
  33191. case usagestatisticday.FieldStatus:
  33192. return m.AddedStatus()
  33193. case usagestatisticday.FieldAddtime:
  33194. return m.AddedAddtime()
  33195. case usagestatisticday.FieldType:
  33196. return m.AddedType()
  33197. case usagestatisticday.FieldOrganizationID:
  33198. return m.AddedOrganizationID()
  33199. case usagestatisticday.FieldAiResponse:
  33200. return m.AddedAiResponse()
  33201. case usagestatisticday.FieldSopRun:
  33202. return m.AddedSopRun()
  33203. case usagestatisticday.FieldTotalFriend:
  33204. return m.AddedTotalFriend()
  33205. case usagestatisticday.FieldTotalGroup:
  33206. return m.AddedTotalGroup()
  33207. case usagestatisticday.FieldAccountBalance:
  33208. return m.AddedAccountBalance()
  33209. case usagestatisticday.FieldConsumeToken:
  33210. return m.AddedConsumeToken()
  33211. case usagestatisticday.FieldActiveUser:
  33212. return m.AddedActiveUser()
  33213. case usagestatisticday.FieldNewUser:
  33214. return m.AddedNewUser()
  33215. }
  33216. return nil, false
  33217. }
  33218. // AddField adds the value to the field with the given name. It returns an error if
  33219. // the field is not defined in the schema, or if the type mismatched the field
  33220. // type.
  33221. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  33222. switch name {
  33223. case usagestatisticday.FieldStatus:
  33224. v, ok := value.(int8)
  33225. if !ok {
  33226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33227. }
  33228. m.AddStatus(v)
  33229. return nil
  33230. case usagestatisticday.FieldAddtime:
  33231. v, ok := value.(int64)
  33232. if !ok {
  33233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33234. }
  33235. m.AddAddtime(v)
  33236. return nil
  33237. case usagestatisticday.FieldType:
  33238. v, ok := value.(int)
  33239. if !ok {
  33240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33241. }
  33242. m.AddType(v)
  33243. return nil
  33244. case usagestatisticday.FieldOrganizationID:
  33245. v, ok := value.(int64)
  33246. if !ok {
  33247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33248. }
  33249. m.AddOrganizationID(v)
  33250. return nil
  33251. case usagestatisticday.FieldAiResponse:
  33252. v, ok := value.(int64)
  33253. if !ok {
  33254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33255. }
  33256. m.AddAiResponse(v)
  33257. return nil
  33258. case usagestatisticday.FieldSopRun:
  33259. v, ok := value.(int64)
  33260. if !ok {
  33261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33262. }
  33263. m.AddSopRun(v)
  33264. return nil
  33265. case usagestatisticday.FieldTotalFriend:
  33266. v, ok := value.(int64)
  33267. if !ok {
  33268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33269. }
  33270. m.AddTotalFriend(v)
  33271. return nil
  33272. case usagestatisticday.FieldTotalGroup:
  33273. v, ok := value.(int64)
  33274. if !ok {
  33275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33276. }
  33277. m.AddTotalGroup(v)
  33278. return nil
  33279. case usagestatisticday.FieldAccountBalance:
  33280. v, ok := value.(int64)
  33281. if !ok {
  33282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33283. }
  33284. m.AddAccountBalance(v)
  33285. return nil
  33286. case usagestatisticday.FieldConsumeToken:
  33287. v, ok := value.(int64)
  33288. if !ok {
  33289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33290. }
  33291. m.AddConsumeToken(v)
  33292. return nil
  33293. case usagestatisticday.FieldActiveUser:
  33294. v, ok := value.(int64)
  33295. if !ok {
  33296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33297. }
  33298. m.AddActiveUser(v)
  33299. return nil
  33300. case usagestatisticday.FieldNewUser:
  33301. v, ok := value.(int64)
  33302. if !ok {
  33303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33304. }
  33305. m.AddNewUser(v)
  33306. return nil
  33307. }
  33308. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  33309. }
  33310. // ClearedFields returns all nullable fields that were cleared during this
  33311. // mutation.
  33312. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  33313. var fields []string
  33314. if m.FieldCleared(usagestatisticday.FieldStatus) {
  33315. fields = append(fields, usagestatisticday.FieldStatus)
  33316. }
  33317. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  33318. fields = append(fields, usagestatisticday.FieldDeletedAt)
  33319. }
  33320. if m.FieldCleared(usagestatisticday.FieldBotID) {
  33321. fields = append(fields, usagestatisticday.FieldBotID)
  33322. }
  33323. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  33324. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33325. }
  33326. return fields
  33327. }
  33328. // FieldCleared returns a boolean indicating if a field with the given name was
  33329. // cleared in this mutation.
  33330. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  33331. _, ok := m.clearedFields[name]
  33332. return ok
  33333. }
  33334. // ClearField clears the value of the field with the given name. It returns an
  33335. // error if the field is not defined in the schema.
  33336. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  33337. switch name {
  33338. case usagestatisticday.FieldStatus:
  33339. m.ClearStatus()
  33340. return nil
  33341. case usagestatisticday.FieldDeletedAt:
  33342. m.ClearDeletedAt()
  33343. return nil
  33344. case usagestatisticday.FieldBotID:
  33345. m.ClearBotID()
  33346. return nil
  33347. case usagestatisticday.FieldOrganizationID:
  33348. m.ClearOrganizationID()
  33349. return nil
  33350. }
  33351. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  33352. }
  33353. // ResetField resets all changes in the mutation for the field with the given name.
  33354. // It returns an error if the field is not defined in the schema.
  33355. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  33356. switch name {
  33357. case usagestatisticday.FieldCreatedAt:
  33358. m.ResetCreatedAt()
  33359. return nil
  33360. case usagestatisticday.FieldUpdatedAt:
  33361. m.ResetUpdatedAt()
  33362. return nil
  33363. case usagestatisticday.FieldStatus:
  33364. m.ResetStatus()
  33365. return nil
  33366. case usagestatisticday.FieldDeletedAt:
  33367. m.ResetDeletedAt()
  33368. return nil
  33369. case usagestatisticday.FieldAddtime:
  33370. m.ResetAddtime()
  33371. return nil
  33372. case usagestatisticday.FieldType:
  33373. m.ResetType()
  33374. return nil
  33375. case usagestatisticday.FieldBotID:
  33376. m.ResetBotID()
  33377. return nil
  33378. case usagestatisticday.FieldOrganizationID:
  33379. m.ResetOrganizationID()
  33380. return nil
  33381. case usagestatisticday.FieldAiResponse:
  33382. m.ResetAiResponse()
  33383. return nil
  33384. case usagestatisticday.FieldSopRun:
  33385. m.ResetSopRun()
  33386. return nil
  33387. case usagestatisticday.FieldTotalFriend:
  33388. m.ResetTotalFriend()
  33389. return nil
  33390. case usagestatisticday.FieldTotalGroup:
  33391. m.ResetTotalGroup()
  33392. return nil
  33393. case usagestatisticday.FieldAccountBalance:
  33394. m.ResetAccountBalance()
  33395. return nil
  33396. case usagestatisticday.FieldConsumeToken:
  33397. m.ResetConsumeToken()
  33398. return nil
  33399. case usagestatisticday.FieldActiveUser:
  33400. m.ResetActiveUser()
  33401. return nil
  33402. case usagestatisticday.FieldNewUser:
  33403. m.ResetNewUser()
  33404. return nil
  33405. case usagestatisticday.FieldLabelDist:
  33406. m.ResetLabelDist()
  33407. return nil
  33408. }
  33409. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33410. }
  33411. // AddedEdges returns all edge names that were set/added in this mutation.
  33412. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  33413. edges := make([]string, 0, 0)
  33414. return edges
  33415. }
  33416. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33417. // name in this mutation.
  33418. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  33419. return nil
  33420. }
  33421. // RemovedEdges returns all edge names that were removed in this mutation.
  33422. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  33423. edges := make([]string, 0, 0)
  33424. return edges
  33425. }
  33426. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33427. // the given name in this mutation.
  33428. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  33429. return nil
  33430. }
  33431. // ClearedEdges returns all edge names that were cleared in this mutation.
  33432. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  33433. edges := make([]string, 0, 0)
  33434. return edges
  33435. }
  33436. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33437. // was cleared in this mutation.
  33438. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  33439. return false
  33440. }
  33441. // ClearEdge clears the value of the edge with the given name. It returns an error
  33442. // if that edge is not defined in the schema.
  33443. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  33444. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  33445. }
  33446. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33447. // It returns an error if the edge is not defined in the schema.
  33448. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  33449. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  33450. }
  33451. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  33452. type UsageStatisticHourMutation struct {
  33453. config
  33454. op Op
  33455. typ string
  33456. id *uint64
  33457. created_at *time.Time
  33458. updated_at *time.Time
  33459. status *uint8
  33460. addstatus *int8
  33461. deleted_at *time.Time
  33462. addtime *uint64
  33463. addaddtime *int64
  33464. _type *int
  33465. add_type *int
  33466. bot_id *string
  33467. organization_id *uint64
  33468. addorganization_id *int64
  33469. ai_response *uint64
  33470. addai_response *int64
  33471. sop_run *uint64
  33472. addsop_run *int64
  33473. total_friend *uint64
  33474. addtotal_friend *int64
  33475. total_group *uint64
  33476. addtotal_group *int64
  33477. account_balance *uint64
  33478. addaccount_balance *int64
  33479. consume_token *uint64
  33480. addconsume_token *int64
  33481. active_user *uint64
  33482. addactive_user *int64
  33483. new_user *int64
  33484. addnew_user *int64
  33485. label_dist *[]custom_types.LabelDist
  33486. appendlabel_dist []custom_types.LabelDist
  33487. clearedFields map[string]struct{}
  33488. done bool
  33489. oldValue func(context.Context) (*UsageStatisticHour, error)
  33490. predicates []predicate.UsageStatisticHour
  33491. }
  33492. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  33493. // usagestatistichourOption allows management of the mutation configuration using functional options.
  33494. type usagestatistichourOption func(*UsageStatisticHourMutation)
  33495. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  33496. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  33497. m := &UsageStatisticHourMutation{
  33498. config: c,
  33499. op: op,
  33500. typ: TypeUsageStatisticHour,
  33501. clearedFields: make(map[string]struct{}),
  33502. }
  33503. for _, opt := range opts {
  33504. opt(m)
  33505. }
  33506. return m
  33507. }
  33508. // withUsageStatisticHourID sets the ID field of the mutation.
  33509. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  33510. return func(m *UsageStatisticHourMutation) {
  33511. var (
  33512. err error
  33513. once sync.Once
  33514. value *UsageStatisticHour
  33515. )
  33516. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  33517. once.Do(func() {
  33518. if m.done {
  33519. err = errors.New("querying old values post mutation is not allowed")
  33520. } else {
  33521. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  33522. }
  33523. })
  33524. return value, err
  33525. }
  33526. m.id = &id
  33527. }
  33528. }
  33529. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  33530. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  33531. return func(m *UsageStatisticHourMutation) {
  33532. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  33533. return node, nil
  33534. }
  33535. m.id = &node.ID
  33536. }
  33537. }
  33538. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33539. // executed in a transaction (ent.Tx), a transactional client is returned.
  33540. func (m UsageStatisticHourMutation) Client() *Client {
  33541. client := &Client{config: m.config}
  33542. client.init()
  33543. return client
  33544. }
  33545. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33546. // it returns an error otherwise.
  33547. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  33548. if _, ok := m.driver.(*txDriver); !ok {
  33549. return nil, errors.New("ent: mutation is not running in a transaction")
  33550. }
  33551. tx := &Tx{config: m.config}
  33552. tx.init()
  33553. return tx, nil
  33554. }
  33555. // SetID sets the value of the id field. Note that this
  33556. // operation is only accepted on creation of UsageStatisticHour entities.
  33557. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  33558. m.id = &id
  33559. }
  33560. // ID returns the ID value in the mutation. Note that the ID is only available
  33561. // if it was provided to the builder or after it was returned from the database.
  33562. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  33563. if m.id == nil {
  33564. return
  33565. }
  33566. return *m.id, true
  33567. }
  33568. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33569. // That means, if the mutation is applied within a transaction with an isolation level such
  33570. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33571. // or updated by the mutation.
  33572. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  33573. switch {
  33574. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33575. id, exists := m.ID()
  33576. if exists {
  33577. return []uint64{id}, nil
  33578. }
  33579. fallthrough
  33580. case m.op.Is(OpUpdate | OpDelete):
  33581. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  33582. default:
  33583. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33584. }
  33585. }
  33586. // SetCreatedAt sets the "created_at" field.
  33587. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  33588. m.created_at = &t
  33589. }
  33590. // CreatedAt returns the value of the "created_at" field in the mutation.
  33591. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  33592. v := m.created_at
  33593. if v == nil {
  33594. return
  33595. }
  33596. return *v, true
  33597. }
  33598. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  33599. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33601. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33602. if !m.op.Is(OpUpdateOne) {
  33603. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33604. }
  33605. if m.id == nil || m.oldValue == nil {
  33606. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33607. }
  33608. oldValue, err := m.oldValue(ctx)
  33609. if err != nil {
  33610. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33611. }
  33612. return oldValue.CreatedAt, nil
  33613. }
  33614. // ResetCreatedAt resets all changes to the "created_at" field.
  33615. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  33616. m.created_at = nil
  33617. }
  33618. // SetUpdatedAt sets the "updated_at" field.
  33619. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  33620. m.updated_at = &t
  33621. }
  33622. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33623. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  33624. v := m.updated_at
  33625. if v == nil {
  33626. return
  33627. }
  33628. return *v, true
  33629. }
  33630. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  33631. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33633. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33634. if !m.op.Is(OpUpdateOne) {
  33635. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33636. }
  33637. if m.id == nil || m.oldValue == nil {
  33638. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33639. }
  33640. oldValue, err := m.oldValue(ctx)
  33641. if err != nil {
  33642. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33643. }
  33644. return oldValue.UpdatedAt, nil
  33645. }
  33646. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33647. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  33648. m.updated_at = nil
  33649. }
  33650. // SetStatus sets the "status" field.
  33651. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  33652. m.status = &u
  33653. m.addstatus = nil
  33654. }
  33655. // Status returns the value of the "status" field in the mutation.
  33656. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  33657. v := m.status
  33658. if v == nil {
  33659. return
  33660. }
  33661. return *v, true
  33662. }
  33663. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  33664. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33666. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33667. if !m.op.Is(OpUpdateOne) {
  33668. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33669. }
  33670. if m.id == nil || m.oldValue == nil {
  33671. return v, errors.New("OldStatus requires an ID field in the mutation")
  33672. }
  33673. oldValue, err := m.oldValue(ctx)
  33674. if err != nil {
  33675. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33676. }
  33677. return oldValue.Status, nil
  33678. }
  33679. // AddStatus adds u to the "status" field.
  33680. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  33681. if m.addstatus != nil {
  33682. *m.addstatus += u
  33683. } else {
  33684. m.addstatus = &u
  33685. }
  33686. }
  33687. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33688. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  33689. v := m.addstatus
  33690. if v == nil {
  33691. return
  33692. }
  33693. return *v, true
  33694. }
  33695. // ClearStatus clears the value of the "status" field.
  33696. func (m *UsageStatisticHourMutation) ClearStatus() {
  33697. m.status = nil
  33698. m.addstatus = nil
  33699. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  33700. }
  33701. // StatusCleared returns if the "status" field was cleared in this mutation.
  33702. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  33703. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  33704. return ok
  33705. }
  33706. // ResetStatus resets all changes to the "status" field.
  33707. func (m *UsageStatisticHourMutation) ResetStatus() {
  33708. m.status = nil
  33709. m.addstatus = nil
  33710. delete(m.clearedFields, usagestatistichour.FieldStatus)
  33711. }
  33712. // SetDeletedAt sets the "deleted_at" field.
  33713. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  33714. m.deleted_at = &t
  33715. }
  33716. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33717. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  33718. v := m.deleted_at
  33719. if v == nil {
  33720. return
  33721. }
  33722. return *v, true
  33723. }
  33724. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  33725. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33727. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33728. if !m.op.Is(OpUpdateOne) {
  33729. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33730. }
  33731. if m.id == nil || m.oldValue == nil {
  33732. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33733. }
  33734. oldValue, err := m.oldValue(ctx)
  33735. if err != nil {
  33736. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33737. }
  33738. return oldValue.DeletedAt, nil
  33739. }
  33740. // ClearDeletedAt clears the value of the "deleted_at" field.
  33741. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  33742. m.deleted_at = nil
  33743. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  33744. }
  33745. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33746. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  33747. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  33748. return ok
  33749. }
  33750. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33751. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  33752. m.deleted_at = nil
  33753. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  33754. }
  33755. // SetAddtime sets the "addtime" field.
  33756. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  33757. m.addtime = &u
  33758. m.addaddtime = nil
  33759. }
  33760. // Addtime returns the value of the "addtime" field in the mutation.
  33761. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  33762. v := m.addtime
  33763. if v == nil {
  33764. return
  33765. }
  33766. return *v, true
  33767. }
  33768. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  33769. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33771. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33772. if !m.op.Is(OpUpdateOne) {
  33773. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33774. }
  33775. if m.id == nil || m.oldValue == nil {
  33776. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33777. }
  33778. oldValue, err := m.oldValue(ctx)
  33779. if err != nil {
  33780. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33781. }
  33782. return oldValue.Addtime, nil
  33783. }
  33784. // AddAddtime adds u to the "addtime" field.
  33785. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  33786. if m.addaddtime != nil {
  33787. *m.addaddtime += u
  33788. } else {
  33789. m.addaddtime = &u
  33790. }
  33791. }
  33792. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33793. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  33794. v := m.addaddtime
  33795. if v == nil {
  33796. return
  33797. }
  33798. return *v, true
  33799. }
  33800. // ResetAddtime resets all changes to the "addtime" field.
  33801. func (m *UsageStatisticHourMutation) ResetAddtime() {
  33802. m.addtime = nil
  33803. m.addaddtime = nil
  33804. }
  33805. // SetType sets the "type" field.
  33806. func (m *UsageStatisticHourMutation) SetType(i int) {
  33807. m._type = &i
  33808. m.add_type = nil
  33809. }
  33810. // GetType returns the value of the "type" field in the mutation.
  33811. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  33812. v := m._type
  33813. if v == nil {
  33814. return
  33815. }
  33816. return *v, true
  33817. }
  33818. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  33819. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33821. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  33822. if !m.op.Is(OpUpdateOne) {
  33823. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33824. }
  33825. if m.id == nil || m.oldValue == nil {
  33826. return v, errors.New("OldType requires an ID field in the mutation")
  33827. }
  33828. oldValue, err := m.oldValue(ctx)
  33829. if err != nil {
  33830. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33831. }
  33832. return oldValue.Type, nil
  33833. }
  33834. // AddType adds i to the "type" field.
  33835. func (m *UsageStatisticHourMutation) AddType(i int) {
  33836. if m.add_type != nil {
  33837. *m.add_type += i
  33838. } else {
  33839. m.add_type = &i
  33840. }
  33841. }
  33842. // AddedType returns the value that was added to the "type" field in this mutation.
  33843. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  33844. v := m.add_type
  33845. if v == nil {
  33846. return
  33847. }
  33848. return *v, true
  33849. }
  33850. // ResetType resets all changes to the "type" field.
  33851. func (m *UsageStatisticHourMutation) ResetType() {
  33852. m._type = nil
  33853. m.add_type = nil
  33854. }
  33855. // SetBotID sets the "bot_id" field.
  33856. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  33857. m.bot_id = &s
  33858. }
  33859. // BotID returns the value of the "bot_id" field in the mutation.
  33860. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  33861. v := m.bot_id
  33862. if v == nil {
  33863. return
  33864. }
  33865. return *v, true
  33866. }
  33867. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  33868. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33870. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  33871. if !m.op.Is(OpUpdateOne) {
  33872. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33873. }
  33874. if m.id == nil || m.oldValue == nil {
  33875. return v, errors.New("OldBotID requires an ID field in the mutation")
  33876. }
  33877. oldValue, err := m.oldValue(ctx)
  33878. if err != nil {
  33879. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33880. }
  33881. return oldValue.BotID, nil
  33882. }
  33883. // ClearBotID clears the value of the "bot_id" field.
  33884. func (m *UsageStatisticHourMutation) ClearBotID() {
  33885. m.bot_id = nil
  33886. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  33887. }
  33888. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33889. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  33890. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  33891. return ok
  33892. }
  33893. // ResetBotID resets all changes to the "bot_id" field.
  33894. func (m *UsageStatisticHourMutation) ResetBotID() {
  33895. m.bot_id = nil
  33896. delete(m.clearedFields, usagestatistichour.FieldBotID)
  33897. }
  33898. // SetOrganizationID sets the "organization_id" field.
  33899. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  33900. m.organization_id = &u
  33901. m.addorganization_id = nil
  33902. }
  33903. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33904. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  33905. v := m.organization_id
  33906. if v == nil {
  33907. return
  33908. }
  33909. return *v, true
  33910. }
  33911. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  33912. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33914. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33915. if !m.op.Is(OpUpdateOne) {
  33916. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33917. }
  33918. if m.id == nil || m.oldValue == nil {
  33919. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33920. }
  33921. oldValue, err := m.oldValue(ctx)
  33922. if err != nil {
  33923. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33924. }
  33925. return oldValue.OrganizationID, nil
  33926. }
  33927. // AddOrganizationID adds u to the "organization_id" field.
  33928. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  33929. if m.addorganization_id != nil {
  33930. *m.addorganization_id += u
  33931. } else {
  33932. m.addorganization_id = &u
  33933. }
  33934. }
  33935. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33936. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  33937. v := m.addorganization_id
  33938. if v == nil {
  33939. return
  33940. }
  33941. return *v, true
  33942. }
  33943. // ClearOrganizationID clears the value of the "organization_id" field.
  33944. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  33945. m.organization_id = nil
  33946. m.addorganization_id = nil
  33947. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  33948. }
  33949. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33950. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  33951. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  33952. return ok
  33953. }
  33954. // ResetOrganizationID resets all changes to the "organization_id" field.
  33955. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  33956. m.organization_id = nil
  33957. m.addorganization_id = nil
  33958. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  33959. }
  33960. // SetAiResponse sets the "ai_response" field.
  33961. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  33962. m.ai_response = &u
  33963. m.addai_response = nil
  33964. }
  33965. // AiResponse returns the value of the "ai_response" field in the mutation.
  33966. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  33967. v := m.ai_response
  33968. if v == nil {
  33969. return
  33970. }
  33971. return *v, true
  33972. }
  33973. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  33974. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33976. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33977. if !m.op.Is(OpUpdateOne) {
  33978. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33979. }
  33980. if m.id == nil || m.oldValue == nil {
  33981. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33982. }
  33983. oldValue, err := m.oldValue(ctx)
  33984. if err != nil {
  33985. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33986. }
  33987. return oldValue.AiResponse, nil
  33988. }
  33989. // AddAiResponse adds u to the "ai_response" field.
  33990. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  33991. if m.addai_response != nil {
  33992. *m.addai_response += u
  33993. } else {
  33994. m.addai_response = &u
  33995. }
  33996. }
  33997. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33998. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  33999. v := m.addai_response
  34000. if v == nil {
  34001. return
  34002. }
  34003. return *v, true
  34004. }
  34005. // ResetAiResponse resets all changes to the "ai_response" field.
  34006. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  34007. m.ai_response = nil
  34008. m.addai_response = nil
  34009. }
  34010. // SetSopRun sets the "sop_run" field.
  34011. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  34012. m.sop_run = &u
  34013. m.addsop_run = nil
  34014. }
  34015. // SopRun returns the value of the "sop_run" field in the mutation.
  34016. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  34017. v := m.sop_run
  34018. if v == nil {
  34019. return
  34020. }
  34021. return *v, true
  34022. }
  34023. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  34024. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34026. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34027. if !m.op.Is(OpUpdateOne) {
  34028. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34029. }
  34030. if m.id == nil || m.oldValue == nil {
  34031. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34032. }
  34033. oldValue, err := m.oldValue(ctx)
  34034. if err != nil {
  34035. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34036. }
  34037. return oldValue.SopRun, nil
  34038. }
  34039. // AddSopRun adds u to the "sop_run" field.
  34040. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  34041. if m.addsop_run != nil {
  34042. *m.addsop_run += u
  34043. } else {
  34044. m.addsop_run = &u
  34045. }
  34046. }
  34047. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34048. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  34049. v := m.addsop_run
  34050. if v == nil {
  34051. return
  34052. }
  34053. return *v, true
  34054. }
  34055. // ResetSopRun resets all changes to the "sop_run" field.
  34056. func (m *UsageStatisticHourMutation) ResetSopRun() {
  34057. m.sop_run = nil
  34058. m.addsop_run = nil
  34059. }
  34060. // SetTotalFriend sets the "total_friend" field.
  34061. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  34062. m.total_friend = &u
  34063. m.addtotal_friend = nil
  34064. }
  34065. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34066. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  34067. v := m.total_friend
  34068. if v == nil {
  34069. return
  34070. }
  34071. return *v, true
  34072. }
  34073. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  34074. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34076. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34077. if !m.op.Is(OpUpdateOne) {
  34078. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34079. }
  34080. if m.id == nil || m.oldValue == nil {
  34081. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34082. }
  34083. oldValue, err := m.oldValue(ctx)
  34084. if err != nil {
  34085. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34086. }
  34087. return oldValue.TotalFriend, nil
  34088. }
  34089. // AddTotalFriend adds u to the "total_friend" field.
  34090. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  34091. if m.addtotal_friend != nil {
  34092. *m.addtotal_friend += u
  34093. } else {
  34094. m.addtotal_friend = &u
  34095. }
  34096. }
  34097. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34098. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  34099. v := m.addtotal_friend
  34100. if v == nil {
  34101. return
  34102. }
  34103. return *v, true
  34104. }
  34105. // ResetTotalFriend resets all changes to the "total_friend" field.
  34106. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  34107. m.total_friend = nil
  34108. m.addtotal_friend = nil
  34109. }
  34110. // SetTotalGroup sets the "total_group" field.
  34111. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  34112. m.total_group = &u
  34113. m.addtotal_group = nil
  34114. }
  34115. // TotalGroup returns the value of the "total_group" field in the mutation.
  34116. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  34117. v := m.total_group
  34118. if v == nil {
  34119. return
  34120. }
  34121. return *v, true
  34122. }
  34123. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  34124. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34126. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34127. if !m.op.Is(OpUpdateOne) {
  34128. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34129. }
  34130. if m.id == nil || m.oldValue == nil {
  34131. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34132. }
  34133. oldValue, err := m.oldValue(ctx)
  34134. if err != nil {
  34135. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34136. }
  34137. return oldValue.TotalGroup, nil
  34138. }
  34139. // AddTotalGroup adds u to the "total_group" field.
  34140. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  34141. if m.addtotal_group != nil {
  34142. *m.addtotal_group += u
  34143. } else {
  34144. m.addtotal_group = &u
  34145. }
  34146. }
  34147. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34148. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  34149. v := m.addtotal_group
  34150. if v == nil {
  34151. return
  34152. }
  34153. return *v, true
  34154. }
  34155. // ResetTotalGroup resets all changes to the "total_group" field.
  34156. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  34157. m.total_group = nil
  34158. m.addtotal_group = nil
  34159. }
  34160. // SetAccountBalance sets the "account_balance" field.
  34161. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  34162. m.account_balance = &u
  34163. m.addaccount_balance = nil
  34164. }
  34165. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34166. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  34167. v := m.account_balance
  34168. if v == nil {
  34169. return
  34170. }
  34171. return *v, true
  34172. }
  34173. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  34174. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34176. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34177. if !m.op.Is(OpUpdateOne) {
  34178. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34179. }
  34180. if m.id == nil || m.oldValue == nil {
  34181. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34182. }
  34183. oldValue, err := m.oldValue(ctx)
  34184. if err != nil {
  34185. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34186. }
  34187. return oldValue.AccountBalance, nil
  34188. }
  34189. // AddAccountBalance adds u to the "account_balance" field.
  34190. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  34191. if m.addaccount_balance != nil {
  34192. *m.addaccount_balance += u
  34193. } else {
  34194. m.addaccount_balance = &u
  34195. }
  34196. }
  34197. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34198. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  34199. v := m.addaccount_balance
  34200. if v == nil {
  34201. return
  34202. }
  34203. return *v, true
  34204. }
  34205. // ResetAccountBalance resets all changes to the "account_balance" field.
  34206. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  34207. m.account_balance = nil
  34208. m.addaccount_balance = nil
  34209. }
  34210. // SetConsumeToken sets the "consume_token" field.
  34211. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  34212. m.consume_token = &u
  34213. m.addconsume_token = nil
  34214. }
  34215. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34216. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  34217. v := m.consume_token
  34218. if v == nil {
  34219. return
  34220. }
  34221. return *v, true
  34222. }
  34223. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  34224. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34226. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34227. if !m.op.Is(OpUpdateOne) {
  34228. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34229. }
  34230. if m.id == nil || m.oldValue == nil {
  34231. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34232. }
  34233. oldValue, err := m.oldValue(ctx)
  34234. if err != nil {
  34235. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34236. }
  34237. return oldValue.ConsumeToken, nil
  34238. }
  34239. // AddConsumeToken adds u to the "consume_token" field.
  34240. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  34241. if m.addconsume_token != nil {
  34242. *m.addconsume_token += u
  34243. } else {
  34244. m.addconsume_token = &u
  34245. }
  34246. }
  34247. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34248. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  34249. v := m.addconsume_token
  34250. if v == nil {
  34251. return
  34252. }
  34253. return *v, true
  34254. }
  34255. // ResetConsumeToken resets all changes to the "consume_token" field.
  34256. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  34257. m.consume_token = nil
  34258. m.addconsume_token = nil
  34259. }
  34260. // SetActiveUser sets the "active_user" field.
  34261. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  34262. m.active_user = &u
  34263. m.addactive_user = nil
  34264. }
  34265. // ActiveUser returns the value of the "active_user" field in the mutation.
  34266. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  34267. v := m.active_user
  34268. if v == nil {
  34269. return
  34270. }
  34271. return *v, true
  34272. }
  34273. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  34274. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34276. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34277. if !m.op.Is(OpUpdateOne) {
  34278. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34279. }
  34280. if m.id == nil || m.oldValue == nil {
  34281. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34282. }
  34283. oldValue, err := m.oldValue(ctx)
  34284. if err != nil {
  34285. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34286. }
  34287. return oldValue.ActiveUser, nil
  34288. }
  34289. // AddActiveUser adds u to the "active_user" field.
  34290. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  34291. if m.addactive_user != nil {
  34292. *m.addactive_user += u
  34293. } else {
  34294. m.addactive_user = &u
  34295. }
  34296. }
  34297. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34298. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  34299. v := m.addactive_user
  34300. if v == nil {
  34301. return
  34302. }
  34303. return *v, true
  34304. }
  34305. // ResetActiveUser resets all changes to the "active_user" field.
  34306. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  34307. m.active_user = nil
  34308. m.addactive_user = nil
  34309. }
  34310. // SetNewUser sets the "new_user" field.
  34311. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  34312. m.new_user = &i
  34313. m.addnew_user = nil
  34314. }
  34315. // NewUser returns the value of the "new_user" field in the mutation.
  34316. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  34317. v := m.new_user
  34318. if v == nil {
  34319. return
  34320. }
  34321. return *v, true
  34322. }
  34323. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  34324. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34326. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34327. if !m.op.Is(OpUpdateOne) {
  34328. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34329. }
  34330. if m.id == nil || m.oldValue == nil {
  34331. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34332. }
  34333. oldValue, err := m.oldValue(ctx)
  34334. if err != nil {
  34335. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34336. }
  34337. return oldValue.NewUser, nil
  34338. }
  34339. // AddNewUser adds i to the "new_user" field.
  34340. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  34341. if m.addnew_user != nil {
  34342. *m.addnew_user += i
  34343. } else {
  34344. m.addnew_user = &i
  34345. }
  34346. }
  34347. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34348. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  34349. v := m.addnew_user
  34350. if v == nil {
  34351. return
  34352. }
  34353. return *v, true
  34354. }
  34355. // ResetNewUser resets all changes to the "new_user" field.
  34356. func (m *UsageStatisticHourMutation) ResetNewUser() {
  34357. m.new_user = nil
  34358. m.addnew_user = nil
  34359. }
  34360. // SetLabelDist sets the "label_dist" field.
  34361. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34362. m.label_dist = &ctd
  34363. m.appendlabel_dist = nil
  34364. }
  34365. // LabelDist returns the value of the "label_dist" field in the mutation.
  34366. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34367. v := m.label_dist
  34368. if v == nil {
  34369. return
  34370. }
  34371. return *v, true
  34372. }
  34373. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  34374. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34376. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34377. if !m.op.Is(OpUpdateOne) {
  34378. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34379. }
  34380. if m.id == nil || m.oldValue == nil {
  34381. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34382. }
  34383. oldValue, err := m.oldValue(ctx)
  34384. if err != nil {
  34385. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34386. }
  34387. return oldValue.LabelDist, nil
  34388. }
  34389. // AppendLabelDist adds ctd to the "label_dist" field.
  34390. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34391. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34392. }
  34393. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34394. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34395. if len(m.appendlabel_dist) == 0 {
  34396. return nil, false
  34397. }
  34398. return m.appendlabel_dist, true
  34399. }
  34400. // ResetLabelDist resets all changes to the "label_dist" field.
  34401. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  34402. m.label_dist = nil
  34403. m.appendlabel_dist = nil
  34404. }
  34405. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  34406. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  34407. m.predicates = append(m.predicates, ps...)
  34408. }
  34409. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  34410. // users can use type-assertion to append predicates that do not depend on any generated package.
  34411. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  34412. p := make([]predicate.UsageStatisticHour, len(ps))
  34413. for i := range ps {
  34414. p[i] = ps[i]
  34415. }
  34416. m.Where(p...)
  34417. }
  34418. // Op returns the operation name.
  34419. func (m *UsageStatisticHourMutation) Op() Op {
  34420. return m.op
  34421. }
  34422. // SetOp allows setting the mutation operation.
  34423. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  34424. m.op = op
  34425. }
  34426. // Type returns the node type of this mutation (UsageStatisticHour).
  34427. func (m *UsageStatisticHourMutation) Type() string {
  34428. return m.typ
  34429. }
  34430. // Fields returns all fields that were changed during this mutation. Note that in
  34431. // order to get all numeric fields that were incremented/decremented, call
  34432. // AddedFields().
  34433. func (m *UsageStatisticHourMutation) Fields() []string {
  34434. fields := make([]string, 0, 17)
  34435. if m.created_at != nil {
  34436. fields = append(fields, usagestatistichour.FieldCreatedAt)
  34437. }
  34438. if m.updated_at != nil {
  34439. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  34440. }
  34441. if m.status != nil {
  34442. fields = append(fields, usagestatistichour.FieldStatus)
  34443. }
  34444. if m.deleted_at != nil {
  34445. fields = append(fields, usagestatistichour.FieldDeletedAt)
  34446. }
  34447. if m.addtime != nil {
  34448. fields = append(fields, usagestatistichour.FieldAddtime)
  34449. }
  34450. if m._type != nil {
  34451. fields = append(fields, usagestatistichour.FieldType)
  34452. }
  34453. if m.bot_id != nil {
  34454. fields = append(fields, usagestatistichour.FieldBotID)
  34455. }
  34456. if m.organization_id != nil {
  34457. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34458. }
  34459. if m.ai_response != nil {
  34460. fields = append(fields, usagestatistichour.FieldAiResponse)
  34461. }
  34462. if m.sop_run != nil {
  34463. fields = append(fields, usagestatistichour.FieldSopRun)
  34464. }
  34465. if m.total_friend != nil {
  34466. fields = append(fields, usagestatistichour.FieldTotalFriend)
  34467. }
  34468. if m.total_group != nil {
  34469. fields = append(fields, usagestatistichour.FieldTotalGroup)
  34470. }
  34471. if m.account_balance != nil {
  34472. fields = append(fields, usagestatistichour.FieldAccountBalance)
  34473. }
  34474. if m.consume_token != nil {
  34475. fields = append(fields, usagestatistichour.FieldConsumeToken)
  34476. }
  34477. if m.active_user != nil {
  34478. fields = append(fields, usagestatistichour.FieldActiveUser)
  34479. }
  34480. if m.new_user != nil {
  34481. fields = append(fields, usagestatistichour.FieldNewUser)
  34482. }
  34483. if m.label_dist != nil {
  34484. fields = append(fields, usagestatistichour.FieldLabelDist)
  34485. }
  34486. return fields
  34487. }
  34488. // Field returns the value of a field with the given name. The second boolean
  34489. // return value indicates that this field was not set, or was not defined in the
  34490. // schema.
  34491. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  34492. switch name {
  34493. case usagestatistichour.FieldCreatedAt:
  34494. return m.CreatedAt()
  34495. case usagestatistichour.FieldUpdatedAt:
  34496. return m.UpdatedAt()
  34497. case usagestatistichour.FieldStatus:
  34498. return m.Status()
  34499. case usagestatistichour.FieldDeletedAt:
  34500. return m.DeletedAt()
  34501. case usagestatistichour.FieldAddtime:
  34502. return m.Addtime()
  34503. case usagestatistichour.FieldType:
  34504. return m.GetType()
  34505. case usagestatistichour.FieldBotID:
  34506. return m.BotID()
  34507. case usagestatistichour.FieldOrganizationID:
  34508. return m.OrganizationID()
  34509. case usagestatistichour.FieldAiResponse:
  34510. return m.AiResponse()
  34511. case usagestatistichour.FieldSopRun:
  34512. return m.SopRun()
  34513. case usagestatistichour.FieldTotalFriend:
  34514. return m.TotalFriend()
  34515. case usagestatistichour.FieldTotalGroup:
  34516. return m.TotalGroup()
  34517. case usagestatistichour.FieldAccountBalance:
  34518. return m.AccountBalance()
  34519. case usagestatistichour.FieldConsumeToken:
  34520. return m.ConsumeToken()
  34521. case usagestatistichour.FieldActiveUser:
  34522. return m.ActiveUser()
  34523. case usagestatistichour.FieldNewUser:
  34524. return m.NewUser()
  34525. case usagestatistichour.FieldLabelDist:
  34526. return m.LabelDist()
  34527. }
  34528. return nil, false
  34529. }
  34530. // OldField returns the old value of the field from the database. An error is
  34531. // returned if the mutation operation is not UpdateOne, or the query to the
  34532. // database failed.
  34533. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34534. switch name {
  34535. case usagestatistichour.FieldCreatedAt:
  34536. return m.OldCreatedAt(ctx)
  34537. case usagestatistichour.FieldUpdatedAt:
  34538. return m.OldUpdatedAt(ctx)
  34539. case usagestatistichour.FieldStatus:
  34540. return m.OldStatus(ctx)
  34541. case usagestatistichour.FieldDeletedAt:
  34542. return m.OldDeletedAt(ctx)
  34543. case usagestatistichour.FieldAddtime:
  34544. return m.OldAddtime(ctx)
  34545. case usagestatistichour.FieldType:
  34546. return m.OldType(ctx)
  34547. case usagestatistichour.FieldBotID:
  34548. return m.OldBotID(ctx)
  34549. case usagestatistichour.FieldOrganizationID:
  34550. return m.OldOrganizationID(ctx)
  34551. case usagestatistichour.FieldAiResponse:
  34552. return m.OldAiResponse(ctx)
  34553. case usagestatistichour.FieldSopRun:
  34554. return m.OldSopRun(ctx)
  34555. case usagestatistichour.FieldTotalFriend:
  34556. return m.OldTotalFriend(ctx)
  34557. case usagestatistichour.FieldTotalGroup:
  34558. return m.OldTotalGroup(ctx)
  34559. case usagestatistichour.FieldAccountBalance:
  34560. return m.OldAccountBalance(ctx)
  34561. case usagestatistichour.FieldConsumeToken:
  34562. return m.OldConsumeToken(ctx)
  34563. case usagestatistichour.FieldActiveUser:
  34564. return m.OldActiveUser(ctx)
  34565. case usagestatistichour.FieldNewUser:
  34566. return m.OldNewUser(ctx)
  34567. case usagestatistichour.FieldLabelDist:
  34568. return m.OldLabelDist(ctx)
  34569. }
  34570. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34571. }
  34572. // SetField sets the value of a field with the given name. It returns an error if
  34573. // the field is not defined in the schema, or if the type mismatched the field
  34574. // type.
  34575. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  34576. switch name {
  34577. case usagestatistichour.FieldCreatedAt:
  34578. v, ok := value.(time.Time)
  34579. if !ok {
  34580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34581. }
  34582. m.SetCreatedAt(v)
  34583. return nil
  34584. case usagestatistichour.FieldUpdatedAt:
  34585. v, ok := value.(time.Time)
  34586. if !ok {
  34587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34588. }
  34589. m.SetUpdatedAt(v)
  34590. return nil
  34591. case usagestatistichour.FieldStatus:
  34592. v, ok := value.(uint8)
  34593. if !ok {
  34594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34595. }
  34596. m.SetStatus(v)
  34597. return nil
  34598. case usagestatistichour.FieldDeletedAt:
  34599. v, ok := value.(time.Time)
  34600. if !ok {
  34601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34602. }
  34603. m.SetDeletedAt(v)
  34604. return nil
  34605. case usagestatistichour.FieldAddtime:
  34606. v, ok := value.(uint64)
  34607. if !ok {
  34608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34609. }
  34610. m.SetAddtime(v)
  34611. return nil
  34612. case usagestatistichour.FieldType:
  34613. v, ok := value.(int)
  34614. if !ok {
  34615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34616. }
  34617. m.SetType(v)
  34618. return nil
  34619. case usagestatistichour.FieldBotID:
  34620. v, ok := value.(string)
  34621. if !ok {
  34622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34623. }
  34624. m.SetBotID(v)
  34625. return nil
  34626. case usagestatistichour.FieldOrganizationID:
  34627. v, ok := value.(uint64)
  34628. if !ok {
  34629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34630. }
  34631. m.SetOrganizationID(v)
  34632. return nil
  34633. case usagestatistichour.FieldAiResponse:
  34634. v, ok := value.(uint64)
  34635. if !ok {
  34636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34637. }
  34638. m.SetAiResponse(v)
  34639. return nil
  34640. case usagestatistichour.FieldSopRun:
  34641. v, ok := value.(uint64)
  34642. if !ok {
  34643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34644. }
  34645. m.SetSopRun(v)
  34646. return nil
  34647. case usagestatistichour.FieldTotalFriend:
  34648. v, ok := value.(uint64)
  34649. if !ok {
  34650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34651. }
  34652. m.SetTotalFriend(v)
  34653. return nil
  34654. case usagestatistichour.FieldTotalGroup:
  34655. v, ok := value.(uint64)
  34656. if !ok {
  34657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34658. }
  34659. m.SetTotalGroup(v)
  34660. return nil
  34661. case usagestatistichour.FieldAccountBalance:
  34662. v, ok := value.(uint64)
  34663. if !ok {
  34664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34665. }
  34666. m.SetAccountBalance(v)
  34667. return nil
  34668. case usagestatistichour.FieldConsumeToken:
  34669. v, ok := value.(uint64)
  34670. if !ok {
  34671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34672. }
  34673. m.SetConsumeToken(v)
  34674. return nil
  34675. case usagestatistichour.FieldActiveUser:
  34676. v, ok := value.(uint64)
  34677. if !ok {
  34678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34679. }
  34680. m.SetActiveUser(v)
  34681. return nil
  34682. case usagestatistichour.FieldNewUser:
  34683. v, ok := value.(int64)
  34684. if !ok {
  34685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34686. }
  34687. m.SetNewUser(v)
  34688. return nil
  34689. case usagestatistichour.FieldLabelDist:
  34690. v, ok := value.([]custom_types.LabelDist)
  34691. if !ok {
  34692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34693. }
  34694. m.SetLabelDist(v)
  34695. return nil
  34696. }
  34697. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34698. }
  34699. // AddedFields returns all numeric fields that were incremented/decremented during
  34700. // this mutation.
  34701. func (m *UsageStatisticHourMutation) AddedFields() []string {
  34702. var fields []string
  34703. if m.addstatus != nil {
  34704. fields = append(fields, usagestatistichour.FieldStatus)
  34705. }
  34706. if m.addaddtime != nil {
  34707. fields = append(fields, usagestatistichour.FieldAddtime)
  34708. }
  34709. if m.add_type != nil {
  34710. fields = append(fields, usagestatistichour.FieldType)
  34711. }
  34712. if m.addorganization_id != nil {
  34713. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34714. }
  34715. if m.addai_response != nil {
  34716. fields = append(fields, usagestatistichour.FieldAiResponse)
  34717. }
  34718. if m.addsop_run != nil {
  34719. fields = append(fields, usagestatistichour.FieldSopRun)
  34720. }
  34721. if m.addtotal_friend != nil {
  34722. fields = append(fields, usagestatistichour.FieldTotalFriend)
  34723. }
  34724. if m.addtotal_group != nil {
  34725. fields = append(fields, usagestatistichour.FieldTotalGroup)
  34726. }
  34727. if m.addaccount_balance != nil {
  34728. fields = append(fields, usagestatistichour.FieldAccountBalance)
  34729. }
  34730. if m.addconsume_token != nil {
  34731. fields = append(fields, usagestatistichour.FieldConsumeToken)
  34732. }
  34733. if m.addactive_user != nil {
  34734. fields = append(fields, usagestatistichour.FieldActiveUser)
  34735. }
  34736. if m.addnew_user != nil {
  34737. fields = append(fields, usagestatistichour.FieldNewUser)
  34738. }
  34739. return fields
  34740. }
  34741. // AddedField returns the numeric value that was incremented/decremented on a field
  34742. // with the given name. The second boolean return value indicates that this field
  34743. // was not set, or was not defined in the schema.
  34744. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  34745. switch name {
  34746. case usagestatistichour.FieldStatus:
  34747. return m.AddedStatus()
  34748. case usagestatistichour.FieldAddtime:
  34749. return m.AddedAddtime()
  34750. case usagestatistichour.FieldType:
  34751. return m.AddedType()
  34752. case usagestatistichour.FieldOrganizationID:
  34753. return m.AddedOrganizationID()
  34754. case usagestatistichour.FieldAiResponse:
  34755. return m.AddedAiResponse()
  34756. case usagestatistichour.FieldSopRun:
  34757. return m.AddedSopRun()
  34758. case usagestatistichour.FieldTotalFriend:
  34759. return m.AddedTotalFriend()
  34760. case usagestatistichour.FieldTotalGroup:
  34761. return m.AddedTotalGroup()
  34762. case usagestatistichour.FieldAccountBalance:
  34763. return m.AddedAccountBalance()
  34764. case usagestatistichour.FieldConsumeToken:
  34765. return m.AddedConsumeToken()
  34766. case usagestatistichour.FieldActiveUser:
  34767. return m.AddedActiveUser()
  34768. case usagestatistichour.FieldNewUser:
  34769. return m.AddedNewUser()
  34770. }
  34771. return nil, false
  34772. }
  34773. // AddField adds the value to the field with the given name. It returns an error if
  34774. // the field is not defined in the schema, or if the type mismatched the field
  34775. // type.
  34776. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  34777. switch name {
  34778. case usagestatistichour.FieldStatus:
  34779. v, ok := value.(int8)
  34780. if !ok {
  34781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34782. }
  34783. m.AddStatus(v)
  34784. return nil
  34785. case usagestatistichour.FieldAddtime:
  34786. v, ok := value.(int64)
  34787. if !ok {
  34788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34789. }
  34790. m.AddAddtime(v)
  34791. return nil
  34792. case usagestatistichour.FieldType:
  34793. v, ok := value.(int)
  34794. if !ok {
  34795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34796. }
  34797. m.AddType(v)
  34798. return nil
  34799. case usagestatistichour.FieldOrganizationID:
  34800. v, ok := value.(int64)
  34801. if !ok {
  34802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34803. }
  34804. m.AddOrganizationID(v)
  34805. return nil
  34806. case usagestatistichour.FieldAiResponse:
  34807. v, ok := value.(int64)
  34808. if !ok {
  34809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34810. }
  34811. m.AddAiResponse(v)
  34812. return nil
  34813. case usagestatistichour.FieldSopRun:
  34814. v, ok := value.(int64)
  34815. if !ok {
  34816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34817. }
  34818. m.AddSopRun(v)
  34819. return nil
  34820. case usagestatistichour.FieldTotalFriend:
  34821. v, ok := value.(int64)
  34822. if !ok {
  34823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34824. }
  34825. m.AddTotalFriend(v)
  34826. return nil
  34827. case usagestatistichour.FieldTotalGroup:
  34828. v, ok := value.(int64)
  34829. if !ok {
  34830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34831. }
  34832. m.AddTotalGroup(v)
  34833. return nil
  34834. case usagestatistichour.FieldAccountBalance:
  34835. v, ok := value.(int64)
  34836. if !ok {
  34837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34838. }
  34839. m.AddAccountBalance(v)
  34840. return nil
  34841. case usagestatistichour.FieldConsumeToken:
  34842. v, ok := value.(int64)
  34843. if !ok {
  34844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34845. }
  34846. m.AddConsumeToken(v)
  34847. return nil
  34848. case usagestatistichour.FieldActiveUser:
  34849. v, ok := value.(int64)
  34850. if !ok {
  34851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34852. }
  34853. m.AddActiveUser(v)
  34854. return nil
  34855. case usagestatistichour.FieldNewUser:
  34856. v, ok := value.(int64)
  34857. if !ok {
  34858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34859. }
  34860. m.AddNewUser(v)
  34861. return nil
  34862. }
  34863. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  34864. }
  34865. // ClearedFields returns all nullable fields that were cleared during this
  34866. // mutation.
  34867. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  34868. var fields []string
  34869. if m.FieldCleared(usagestatistichour.FieldStatus) {
  34870. fields = append(fields, usagestatistichour.FieldStatus)
  34871. }
  34872. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  34873. fields = append(fields, usagestatistichour.FieldDeletedAt)
  34874. }
  34875. if m.FieldCleared(usagestatistichour.FieldBotID) {
  34876. fields = append(fields, usagestatistichour.FieldBotID)
  34877. }
  34878. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  34879. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34880. }
  34881. return fields
  34882. }
  34883. // FieldCleared returns a boolean indicating if a field with the given name was
  34884. // cleared in this mutation.
  34885. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  34886. _, ok := m.clearedFields[name]
  34887. return ok
  34888. }
  34889. // ClearField clears the value of the field with the given name. It returns an
  34890. // error if the field is not defined in the schema.
  34891. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  34892. switch name {
  34893. case usagestatistichour.FieldStatus:
  34894. m.ClearStatus()
  34895. return nil
  34896. case usagestatistichour.FieldDeletedAt:
  34897. m.ClearDeletedAt()
  34898. return nil
  34899. case usagestatistichour.FieldBotID:
  34900. m.ClearBotID()
  34901. return nil
  34902. case usagestatistichour.FieldOrganizationID:
  34903. m.ClearOrganizationID()
  34904. return nil
  34905. }
  34906. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  34907. }
  34908. // ResetField resets all changes in the mutation for the field with the given name.
  34909. // It returns an error if the field is not defined in the schema.
  34910. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  34911. switch name {
  34912. case usagestatistichour.FieldCreatedAt:
  34913. m.ResetCreatedAt()
  34914. return nil
  34915. case usagestatistichour.FieldUpdatedAt:
  34916. m.ResetUpdatedAt()
  34917. return nil
  34918. case usagestatistichour.FieldStatus:
  34919. m.ResetStatus()
  34920. return nil
  34921. case usagestatistichour.FieldDeletedAt:
  34922. m.ResetDeletedAt()
  34923. return nil
  34924. case usagestatistichour.FieldAddtime:
  34925. m.ResetAddtime()
  34926. return nil
  34927. case usagestatistichour.FieldType:
  34928. m.ResetType()
  34929. return nil
  34930. case usagestatistichour.FieldBotID:
  34931. m.ResetBotID()
  34932. return nil
  34933. case usagestatistichour.FieldOrganizationID:
  34934. m.ResetOrganizationID()
  34935. return nil
  34936. case usagestatistichour.FieldAiResponse:
  34937. m.ResetAiResponse()
  34938. return nil
  34939. case usagestatistichour.FieldSopRun:
  34940. m.ResetSopRun()
  34941. return nil
  34942. case usagestatistichour.FieldTotalFriend:
  34943. m.ResetTotalFriend()
  34944. return nil
  34945. case usagestatistichour.FieldTotalGroup:
  34946. m.ResetTotalGroup()
  34947. return nil
  34948. case usagestatistichour.FieldAccountBalance:
  34949. m.ResetAccountBalance()
  34950. return nil
  34951. case usagestatistichour.FieldConsumeToken:
  34952. m.ResetConsumeToken()
  34953. return nil
  34954. case usagestatistichour.FieldActiveUser:
  34955. m.ResetActiveUser()
  34956. return nil
  34957. case usagestatistichour.FieldNewUser:
  34958. m.ResetNewUser()
  34959. return nil
  34960. case usagestatistichour.FieldLabelDist:
  34961. m.ResetLabelDist()
  34962. return nil
  34963. }
  34964. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34965. }
  34966. // AddedEdges returns all edge names that were set/added in this mutation.
  34967. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  34968. edges := make([]string, 0, 0)
  34969. return edges
  34970. }
  34971. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34972. // name in this mutation.
  34973. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  34974. return nil
  34975. }
  34976. // RemovedEdges returns all edge names that were removed in this mutation.
  34977. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  34978. edges := make([]string, 0, 0)
  34979. return edges
  34980. }
  34981. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34982. // the given name in this mutation.
  34983. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  34984. return nil
  34985. }
  34986. // ClearedEdges returns all edge names that were cleared in this mutation.
  34987. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  34988. edges := make([]string, 0, 0)
  34989. return edges
  34990. }
  34991. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34992. // was cleared in this mutation.
  34993. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  34994. return false
  34995. }
  34996. // ClearEdge clears the value of the edge with the given name. It returns an error
  34997. // if that edge is not defined in the schema.
  34998. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  34999. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  35000. }
  35001. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35002. // It returns an error if the edge is not defined in the schema.
  35003. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  35004. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  35005. }
  35006. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  35007. type UsageStatisticMonthMutation struct {
  35008. config
  35009. op Op
  35010. typ string
  35011. id *uint64
  35012. created_at *time.Time
  35013. updated_at *time.Time
  35014. status *uint8
  35015. addstatus *int8
  35016. deleted_at *time.Time
  35017. addtime *uint64
  35018. addaddtime *int64
  35019. _type *int
  35020. add_type *int
  35021. bot_id *string
  35022. organization_id *uint64
  35023. addorganization_id *int64
  35024. ai_response *uint64
  35025. addai_response *int64
  35026. sop_run *uint64
  35027. addsop_run *int64
  35028. total_friend *uint64
  35029. addtotal_friend *int64
  35030. total_group *uint64
  35031. addtotal_group *int64
  35032. account_balance *uint64
  35033. addaccount_balance *int64
  35034. consume_token *uint64
  35035. addconsume_token *int64
  35036. active_user *uint64
  35037. addactive_user *int64
  35038. new_user *int64
  35039. addnew_user *int64
  35040. label_dist *[]custom_types.LabelDist
  35041. appendlabel_dist []custom_types.LabelDist
  35042. clearedFields map[string]struct{}
  35043. done bool
  35044. oldValue func(context.Context) (*UsageStatisticMonth, error)
  35045. predicates []predicate.UsageStatisticMonth
  35046. }
  35047. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  35048. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  35049. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  35050. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  35051. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  35052. m := &UsageStatisticMonthMutation{
  35053. config: c,
  35054. op: op,
  35055. typ: TypeUsageStatisticMonth,
  35056. clearedFields: make(map[string]struct{}),
  35057. }
  35058. for _, opt := range opts {
  35059. opt(m)
  35060. }
  35061. return m
  35062. }
  35063. // withUsageStatisticMonthID sets the ID field of the mutation.
  35064. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  35065. return func(m *UsageStatisticMonthMutation) {
  35066. var (
  35067. err error
  35068. once sync.Once
  35069. value *UsageStatisticMonth
  35070. )
  35071. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  35072. once.Do(func() {
  35073. if m.done {
  35074. err = errors.New("querying old values post mutation is not allowed")
  35075. } else {
  35076. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  35077. }
  35078. })
  35079. return value, err
  35080. }
  35081. m.id = &id
  35082. }
  35083. }
  35084. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  35085. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  35086. return func(m *UsageStatisticMonthMutation) {
  35087. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  35088. return node, nil
  35089. }
  35090. m.id = &node.ID
  35091. }
  35092. }
  35093. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35094. // executed in a transaction (ent.Tx), a transactional client is returned.
  35095. func (m UsageStatisticMonthMutation) Client() *Client {
  35096. client := &Client{config: m.config}
  35097. client.init()
  35098. return client
  35099. }
  35100. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35101. // it returns an error otherwise.
  35102. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  35103. if _, ok := m.driver.(*txDriver); !ok {
  35104. return nil, errors.New("ent: mutation is not running in a transaction")
  35105. }
  35106. tx := &Tx{config: m.config}
  35107. tx.init()
  35108. return tx, nil
  35109. }
  35110. // SetID sets the value of the id field. Note that this
  35111. // operation is only accepted on creation of UsageStatisticMonth entities.
  35112. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  35113. m.id = &id
  35114. }
  35115. // ID returns the ID value in the mutation. Note that the ID is only available
  35116. // if it was provided to the builder or after it was returned from the database.
  35117. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  35118. if m.id == nil {
  35119. return
  35120. }
  35121. return *m.id, true
  35122. }
  35123. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35124. // That means, if the mutation is applied within a transaction with an isolation level such
  35125. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35126. // or updated by the mutation.
  35127. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  35128. switch {
  35129. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35130. id, exists := m.ID()
  35131. if exists {
  35132. return []uint64{id}, nil
  35133. }
  35134. fallthrough
  35135. case m.op.Is(OpUpdate | OpDelete):
  35136. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  35137. default:
  35138. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35139. }
  35140. }
  35141. // SetCreatedAt sets the "created_at" field.
  35142. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  35143. m.created_at = &t
  35144. }
  35145. // CreatedAt returns the value of the "created_at" field in the mutation.
  35146. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  35147. v := m.created_at
  35148. if v == nil {
  35149. return
  35150. }
  35151. return *v, true
  35152. }
  35153. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  35154. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35156. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35157. if !m.op.Is(OpUpdateOne) {
  35158. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35159. }
  35160. if m.id == nil || m.oldValue == nil {
  35161. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35162. }
  35163. oldValue, err := m.oldValue(ctx)
  35164. if err != nil {
  35165. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35166. }
  35167. return oldValue.CreatedAt, nil
  35168. }
  35169. // ResetCreatedAt resets all changes to the "created_at" field.
  35170. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  35171. m.created_at = nil
  35172. }
  35173. // SetUpdatedAt sets the "updated_at" field.
  35174. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  35175. m.updated_at = &t
  35176. }
  35177. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35178. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  35179. v := m.updated_at
  35180. if v == nil {
  35181. return
  35182. }
  35183. return *v, true
  35184. }
  35185. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  35186. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35188. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35189. if !m.op.Is(OpUpdateOne) {
  35190. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35191. }
  35192. if m.id == nil || m.oldValue == nil {
  35193. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35194. }
  35195. oldValue, err := m.oldValue(ctx)
  35196. if err != nil {
  35197. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35198. }
  35199. return oldValue.UpdatedAt, nil
  35200. }
  35201. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35202. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  35203. m.updated_at = nil
  35204. }
  35205. // SetStatus sets the "status" field.
  35206. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  35207. m.status = &u
  35208. m.addstatus = nil
  35209. }
  35210. // Status returns the value of the "status" field in the mutation.
  35211. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  35212. v := m.status
  35213. if v == nil {
  35214. return
  35215. }
  35216. return *v, true
  35217. }
  35218. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  35219. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35221. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35222. if !m.op.Is(OpUpdateOne) {
  35223. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35224. }
  35225. if m.id == nil || m.oldValue == nil {
  35226. return v, errors.New("OldStatus requires an ID field in the mutation")
  35227. }
  35228. oldValue, err := m.oldValue(ctx)
  35229. if err != nil {
  35230. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35231. }
  35232. return oldValue.Status, nil
  35233. }
  35234. // AddStatus adds u to the "status" field.
  35235. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  35236. if m.addstatus != nil {
  35237. *m.addstatus += u
  35238. } else {
  35239. m.addstatus = &u
  35240. }
  35241. }
  35242. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35243. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  35244. v := m.addstatus
  35245. if v == nil {
  35246. return
  35247. }
  35248. return *v, true
  35249. }
  35250. // ClearStatus clears the value of the "status" field.
  35251. func (m *UsageStatisticMonthMutation) ClearStatus() {
  35252. m.status = nil
  35253. m.addstatus = nil
  35254. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  35255. }
  35256. // StatusCleared returns if the "status" field was cleared in this mutation.
  35257. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  35258. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  35259. return ok
  35260. }
  35261. // ResetStatus resets all changes to the "status" field.
  35262. func (m *UsageStatisticMonthMutation) ResetStatus() {
  35263. m.status = nil
  35264. m.addstatus = nil
  35265. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  35266. }
  35267. // SetDeletedAt sets the "deleted_at" field.
  35268. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  35269. m.deleted_at = &t
  35270. }
  35271. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35272. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  35273. v := m.deleted_at
  35274. if v == nil {
  35275. return
  35276. }
  35277. return *v, true
  35278. }
  35279. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  35280. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35282. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35283. if !m.op.Is(OpUpdateOne) {
  35284. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35285. }
  35286. if m.id == nil || m.oldValue == nil {
  35287. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35288. }
  35289. oldValue, err := m.oldValue(ctx)
  35290. if err != nil {
  35291. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35292. }
  35293. return oldValue.DeletedAt, nil
  35294. }
  35295. // ClearDeletedAt clears the value of the "deleted_at" field.
  35296. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  35297. m.deleted_at = nil
  35298. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  35299. }
  35300. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35301. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  35302. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  35303. return ok
  35304. }
  35305. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35306. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  35307. m.deleted_at = nil
  35308. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  35309. }
  35310. // SetAddtime sets the "addtime" field.
  35311. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  35312. m.addtime = &u
  35313. m.addaddtime = nil
  35314. }
  35315. // Addtime returns the value of the "addtime" field in the mutation.
  35316. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  35317. v := m.addtime
  35318. if v == nil {
  35319. return
  35320. }
  35321. return *v, true
  35322. }
  35323. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  35324. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35326. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35327. if !m.op.Is(OpUpdateOne) {
  35328. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35329. }
  35330. if m.id == nil || m.oldValue == nil {
  35331. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35332. }
  35333. oldValue, err := m.oldValue(ctx)
  35334. if err != nil {
  35335. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35336. }
  35337. return oldValue.Addtime, nil
  35338. }
  35339. // AddAddtime adds u to the "addtime" field.
  35340. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  35341. if m.addaddtime != nil {
  35342. *m.addaddtime += u
  35343. } else {
  35344. m.addaddtime = &u
  35345. }
  35346. }
  35347. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35348. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  35349. v := m.addaddtime
  35350. if v == nil {
  35351. return
  35352. }
  35353. return *v, true
  35354. }
  35355. // ResetAddtime resets all changes to the "addtime" field.
  35356. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  35357. m.addtime = nil
  35358. m.addaddtime = nil
  35359. }
  35360. // SetType sets the "type" field.
  35361. func (m *UsageStatisticMonthMutation) SetType(i int) {
  35362. m._type = &i
  35363. m.add_type = nil
  35364. }
  35365. // GetType returns the value of the "type" field in the mutation.
  35366. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  35367. v := m._type
  35368. if v == nil {
  35369. return
  35370. }
  35371. return *v, true
  35372. }
  35373. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  35374. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35376. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  35377. if !m.op.Is(OpUpdateOne) {
  35378. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35379. }
  35380. if m.id == nil || m.oldValue == nil {
  35381. return v, errors.New("OldType requires an ID field in the mutation")
  35382. }
  35383. oldValue, err := m.oldValue(ctx)
  35384. if err != nil {
  35385. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35386. }
  35387. return oldValue.Type, nil
  35388. }
  35389. // AddType adds i to the "type" field.
  35390. func (m *UsageStatisticMonthMutation) AddType(i int) {
  35391. if m.add_type != nil {
  35392. *m.add_type += i
  35393. } else {
  35394. m.add_type = &i
  35395. }
  35396. }
  35397. // AddedType returns the value that was added to the "type" field in this mutation.
  35398. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  35399. v := m.add_type
  35400. if v == nil {
  35401. return
  35402. }
  35403. return *v, true
  35404. }
  35405. // ResetType resets all changes to the "type" field.
  35406. func (m *UsageStatisticMonthMutation) ResetType() {
  35407. m._type = nil
  35408. m.add_type = nil
  35409. }
  35410. // SetBotID sets the "bot_id" field.
  35411. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  35412. m.bot_id = &s
  35413. }
  35414. // BotID returns the value of the "bot_id" field in the mutation.
  35415. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  35416. v := m.bot_id
  35417. if v == nil {
  35418. return
  35419. }
  35420. return *v, true
  35421. }
  35422. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  35423. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35425. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  35426. if !m.op.Is(OpUpdateOne) {
  35427. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35428. }
  35429. if m.id == nil || m.oldValue == nil {
  35430. return v, errors.New("OldBotID requires an ID field in the mutation")
  35431. }
  35432. oldValue, err := m.oldValue(ctx)
  35433. if err != nil {
  35434. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35435. }
  35436. return oldValue.BotID, nil
  35437. }
  35438. // ClearBotID clears the value of the "bot_id" field.
  35439. func (m *UsageStatisticMonthMutation) ClearBotID() {
  35440. m.bot_id = nil
  35441. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  35442. }
  35443. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  35444. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  35445. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  35446. return ok
  35447. }
  35448. // ResetBotID resets all changes to the "bot_id" field.
  35449. func (m *UsageStatisticMonthMutation) ResetBotID() {
  35450. m.bot_id = nil
  35451. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  35452. }
  35453. // SetOrganizationID sets the "organization_id" field.
  35454. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  35455. m.organization_id = &u
  35456. m.addorganization_id = nil
  35457. }
  35458. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35459. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  35460. v := m.organization_id
  35461. if v == nil {
  35462. return
  35463. }
  35464. return *v, true
  35465. }
  35466. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  35467. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35469. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35470. if !m.op.Is(OpUpdateOne) {
  35471. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35472. }
  35473. if m.id == nil || m.oldValue == nil {
  35474. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35475. }
  35476. oldValue, err := m.oldValue(ctx)
  35477. if err != nil {
  35478. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35479. }
  35480. return oldValue.OrganizationID, nil
  35481. }
  35482. // AddOrganizationID adds u to the "organization_id" field.
  35483. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  35484. if m.addorganization_id != nil {
  35485. *m.addorganization_id += u
  35486. } else {
  35487. m.addorganization_id = &u
  35488. }
  35489. }
  35490. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35491. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  35492. v := m.addorganization_id
  35493. if v == nil {
  35494. return
  35495. }
  35496. return *v, true
  35497. }
  35498. // ClearOrganizationID clears the value of the "organization_id" field.
  35499. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  35500. m.organization_id = nil
  35501. m.addorganization_id = nil
  35502. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  35503. }
  35504. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35505. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  35506. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  35507. return ok
  35508. }
  35509. // ResetOrganizationID resets all changes to the "organization_id" field.
  35510. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  35511. m.organization_id = nil
  35512. m.addorganization_id = nil
  35513. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  35514. }
  35515. // SetAiResponse sets the "ai_response" field.
  35516. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  35517. m.ai_response = &u
  35518. m.addai_response = nil
  35519. }
  35520. // AiResponse returns the value of the "ai_response" field in the mutation.
  35521. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  35522. v := m.ai_response
  35523. if v == nil {
  35524. return
  35525. }
  35526. return *v, true
  35527. }
  35528. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  35529. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35531. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  35532. if !m.op.Is(OpUpdateOne) {
  35533. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  35534. }
  35535. if m.id == nil || m.oldValue == nil {
  35536. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  35537. }
  35538. oldValue, err := m.oldValue(ctx)
  35539. if err != nil {
  35540. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  35541. }
  35542. return oldValue.AiResponse, nil
  35543. }
  35544. // AddAiResponse adds u to the "ai_response" field.
  35545. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  35546. if m.addai_response != nil {
  35547. *m.addai_response += u
  35548. } else {
  35549. m.addai_response = &u
  35550. }
  35551. }
  35552. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  35553. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  35554. v := m.addai_response
  35555. if v == nil {
  35556. return
  35557. }
  35558. return *v, true
  35559. }
  35560. // ResetAiResponse resets all changes to the "ai_response" field.
  35561. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  35562. m.ai_response = nil
  35563. m.addai_response = nil
  35564. }
  35565. // SetSopRun sets the "sop_run" field.
  35566. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  35567. m.sop_run = &u
  35568. m.addsop_run = nil
  35569. }
  35570. // SopRun returns the value of the "sop_run" field in the mutation.
  35571. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  35572. v := m.sop_run
  35573. if v == nil {
  35574. return
  35575. }
  35576. return *v, true
  35577. }
  35578. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  35579. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35581. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  35582. if !m.op.Is(OpUpdateOne) {
  35583. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  35584. }
  35585. if m.id == nil || m.oldValue == nil {
  35586. return v, errors.New("OldSopRun requires an ID field in the mutation")
  35587. }
  35588. oldValue, err := m.oldValue(ctx)
  35589. if err != nil {
  35590. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  35591. }
  35592. return oldValue.SopRun, nil
  35593. }
  35594. // AddSopRun adds u to the "sop_run" field.
  35595. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  35596. if m.addsop_run != nil {
  35597. *m.addsop_run += u
  35598. } else {
  35599. m.addsop_run = &u
  35600. }
  35601. }
  35602. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  35603. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  35604. v := m.addsop_run
  35605. if v == nil {
  35606. return
  35607. }
  35608. return *v, true
  35609. }
  35610. // ResetSopRun resets all changes to the "sop_run" field.
  35611. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  35612. m.sop_run = nil
  35613. m.addsop_run = nil
  35614. }
  35615. // SetTotalFriend sets the "total_friend" field.
  35616. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  35617. m.total_friend = &u
  35618. m.addtotal_friend = nil
  35619. }
  35620. // TotalFriend returns the value of the "total_friend" field in the mutation.
  35621. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  35622. v := m.total_friend
  35623. if v == nil {
  35624. return
  35625. }
  35626. return *v, true
  35627. }
  35628. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  35629. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35631. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  35632. if !m.op.Is(OpUpdateOne) {
  35633. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  35634. }
  35635. if m.id == nil || m.oldValue == nil {
  35636. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  35637. }
  35638. oldValue, err := m.oldValue(ctx)
  35639. if err != nil {
  35640. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  35641. }
  35642. return oldValue.TotalFriend, nil
  35643. }
  35644. // AddTotalFriend adds u to the "total_friend" field.
  35645. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  35646. if m.addtotal_friend != nil {
  35647. *m.addtotal_friend += u
  35648. } else {
  35649. m.addtotal_friend = &u
  35650. }
  35651. }
  35652. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  35653. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  35654. v := m.addtotal_friend
  35655. if v == nil {
  35656. return
  35657. }
  35658. return *v, true
  35659. }
  35660. // ResetTotalFriend resets all changes to the "total_friend" field.
  35661. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  35662. m.total_friend = nil
  35663. m.addtotal_friend = nil
  35664. }
  35665. // SetTotalGroup sets the "total_group" field.
  35666. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  35667. m.total_group = &u
  35668. m.addtotal_group = nil
  35669. }
  35670. // TotalGroup returns the value of the "total_group" field in the mutation.
  35671. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  35672. v := m.total_group
  35673. if v == nil {
  35674. return
  35675. }
  35676. return *v, true
  35677. }
  35678. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  35679. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35681. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  35682. if !m.op.Is(OpUpdateOne) {
  35683. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  35684. }
  35685. if m.id == nil || m.oldValue == nil {
  35686. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  35687. }
  35688. oldValue, err := m.oldValue(ctx)
  35689. if err != nil {
  35690. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  35691. }
  35692. return oldValue.TotalGroup, nil
  35693. }
  35694. // AddTotalGroup adds u to the "total_group" field.
  35695. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  35696. if m.addtotal_group != nil {
  35697. *m.addtotal_group += u
  35698. } else {
  35699. m.addtotal_group = &u
  35700. }
  35701. }
  35702. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  35703. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  35704. v := m.addtotal_group
  35705. if v == nil {
  35706. return
  35707. }
  35708. return *v, true
  35709. }
  35710. // ResetTotalGroup resets all changes to the "total_group" field.
  35711. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  35712. m.total_group = nil
  35713. m.addtotal_group = nil
  35714. }
  35715. // SetAccountBalance sets the "account_balance" field.
  35716. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  35717. m.account_balance = &u
  35718. m.addaccount_balance = nil
  35719. }
  35720. // AccountBalance returns the value of the "account_balance" field in the mutation.
  35721. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  35722. v := m.account_balance
  35723. if v == nil {
  35724. return
  35725. }
  35726. return *v, true
  35727. }
  35728. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  35729. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35731. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  35732. if !m.op.Is(OpUpdateOne) {
  35733. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  35734. }
  35735. if m.id == nil || m.oldValue == nil {
  35736. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  35737. }
  35738. oldValue, err := m.oldValue(ctx)
  35739. if err != nil {
  35740. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  35741. }
  35742. return oldValue.AccountBalance, nil
  35743. }
  35744. // AddAccountBalance adds u to the "account_balance" field.
  35745. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  35746. if m.addaccount_balance != nil {
  35747. *m.addaccount_balance += u
  35748. } else {
  35749. m.addaccount_balance = &u
  35750. }
  35751. }
  35752. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  35753. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  35754. v := m.addaccount_balance
  35755. if v == nil {
  35756. return
  35757. }
  35758. return *v, true
  35759. }
  35760. // ResetAccountBalance resets all changes to the "account_balance" field.
  35761. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  35762. m.account_balance = nil
  35763. m.addaccount_balance = nil
  35764. }
  35765. // SetConsumeToken sets the "consume_token" field.
  35766. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  35767. m.consume_token = &u
  35768. m.addconsume_token = nil
  35769. }
  35770. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  35771. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  35772. v := m.consume_token
  35773. if v == nil {
  35774. return
  35775. }
  35776. return *v, true
  35777. }
  35778. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  35779. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35781. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  35782. if !m.op.Is(OpUpdateOne) {
  35783. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  35784. }
  35785. if m.id == nil || m.oldValue == nil {
  35786. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  35787. }
  35788. oldValue, err := m.oldValue(ctx)
  35789. if err != nil {
  35790. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  35791. }
  35792. return oldValue.ConsumeToken, nil
  35793. }
  35794. // AddConsumeToken adds u to the "consume_token" field.
  35795. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  35796. if m.addconsume_token != nil {
  35797. *m.addconsume_token += u
  35798. } else {
  35799. m.addconsume_token = &u
  35800. }
  35801. }
  35802. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  35803. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  35804. v := m.addconsume_token
  35805. if v == nil {
  35806. return
  35807. }
  35808. return *v, true
  35809. }
  35810. // ResetConsumeToken resets all changes to the "consume_token" field.
  35811. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  35812. m.consume_token = nil
  35813. m.addconsume_token = nil
  35814. }
  35815. // SetActiveUser sets the "active_user" field.
  35816. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  35817. m.active_user = &u
  35818. m.addactive_user = nil
  35819. }
  35820. // ActiveUser returns the value of the "active_user" field in the mutation.
  35821. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  35822. v := m.active_user
  35823. if v == nil {
  35824. return
  35825. }
  35826. return *v, true
  35827. }
  35828. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  35829. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35831. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  35832. if !m.op.Is(OpUpdateOne) {
  35833. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  35834. }
  35835. if m.id == nil || m.oldValue == nil {
  35836. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  35837. }
  35838. oldValue, err := m.oldValue(ctx)
  35839. if err != nil {
  35840. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  35841. }
  35842. return oldValue.ActiveUser, nil
  35843. }
  35844. // AddActiveUser adds u to the "active_user" field.
  35845. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  35846. if m.addactive_user != nil {
  35847. *m.addactive_user += u
  35848. } else {
  35849. m.addactive_user = &u
  35850. }
  35851. }
  35852. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  35853. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  35854. v := m.addactive_user
  35855. if v == nil {
  35856. return
  35857. }
  35858. return *v, true
  35859. }
  35860. // ResetActiveUser resets all changes to the "active_user" field.
  35861. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  35862. m.active_user = nil
  35863. m.addactive_user = nil
  35864. }
  35865. // SetNewUser sets the "new_user" field.
  35866. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  35867. m.new_user = &i
  35868. m.addnew_user = nil
  35869. }
  35870. // NewUser returns the value of the "new_user" field in the mutation.
  35871. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  35872. v := m.new_user
  35873. if v == nil {
  35874. return
  35875. }
  35876. return *v, true
  35877. }
  35878. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  35879. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35881. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  35882. if !m.op.Is(OpUpdateOne) {
  35883. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  35884. }
  35885. if m.id == nil || m.oldValue == nil {
  35886. return v, errors.New("OldNewUser requires an ID field in the mutation")
  35887. }
  35888. oldValue, err := m.oldValue(ctx)
  35889. if err != nil {
  35890. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  35891. }
  35892. return oldValue.NewUser, nil
  35893. }
  35894. // AddNewUser adds i to the "new_user" field.
  35895. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  35896. if m.addnew_user != nil {
  35897. *m.addnew_user += i
  35898. } else {
  35899. m.addnew_user = &i
  35900. }
  35901. }
  35902. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  35903. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  35904. v := m.addnew_user
  35905. if v == nil {
  35906. return
  35907. }
  35908. return *v, true
  35909. }
  35910. // ResetNewUser resets all changes to the "new_user" field.
  35911. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  35912. m.new_user = nil
  35913. m.addnew_user = nil
  35914. }
  35915. // SetLabelDist sets the "label_dist" field.
  35916. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  35917. m.label_dist = &ctd
  35918. m.appendlabel_dist = nil
  35919. }
  35920. // LabelDist returns the value of the "label_dist" field in the mutation.
  35921. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  35922. v := m.label_dist
  35923. if v == nil {
  35924. return
  35925. }
  35926. return *v, true
  35927. }
  35928. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  35929. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35931. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  35932. if !m.op.Is(OpUpdateOne) {
  35933. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  35934. }
  35935. if m.id == nil || m.oldValue == nil {
  35936. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  35937. }
  35938. oldValue, err := m.oldValue(ctx)
  35939. if err != nil {
  35940. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  35941. }
  35942. return oldValue.LabelDist, nil
  35943. }
  35944. // AppendLabelDist adds ctd to the "label_dist" field.
  35945. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  35946. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  35947. }
  35948. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  35949. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  35950. if len(m.appendlabel_dist) == 0 {
  35951. return nil, false
  35952. }
  35953. return m.appendlabel_dist, true
  35954. }
  35955. // ResetLabelDist resets all changes to the "label_dist" field.
  35956. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  35957. m.label_dist = nil
  35958. m.appendlabel_dist = nil
  35959. }
  35960. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  35961. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  35962. m.predicates = append(m.predicates, ps...)
  35963. }
  35964. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  35965. // users can use type-assertion to append predicates that do not depend on any generated package.
  35966. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  35967. p := make([]predicate.UsageStatisticMonth, len(ps))
  35968. for i := range ps {
  35969. p[i] = ps[i]
  35970. }
  35971. m.Where(p...)
  35972. }
  35973. // Op returns the operation name.
  35974. func (m *UsageStatisticMonthMutation) Op() Op {
  35975. return m.op
  35976. }
  35977. // SetOp allows setting the mutation operation.
  35978. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  35979. m.op = op
  35980. }
  35981. // Type returns the node type of this mutation (UsageStatisticMonth).
  35982. func (m *UsageStatisticMonthMutation) Type() string {
  35983. return m.typ
  35984. }
  35985. // Fields returns all fields that were changed during this mutation. Note that in
  35986. // order to get all numeric fields that were incremented/decremented, call
  35987. // AddedFields().
  35988. func (m *UsageStatisticMonthMutation) Fields() []string {
  35989. fields := make([]string, 0, 17)
  35990. if m.created_at != nil {
  35991. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  35992. }
  35993. if m.updated_at != nil {
  35994. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  35995. }
  35996. if m.status != nil {
  35997. fields = append(fields, usagestatisticmonth.FieldStatus)
  35998. }
  35999. if m.deleted_at != nil {
  36000. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  36001. }
  36002. if m.addtime != nil {
  36003. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36004. }
  36005. if m._type != nil {
  36006. fields = append(fields, usagestatisticmonth.FieldType)
  36007. }
  36008. if m.bot_id != nil {
  36009. fields = append(fields, usagestatisticmonth.FieldBotID)
  36010. }
  36011. if m.organization_id != nil {
  36012. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36013. }
  36014. if m.ai_response != nil {
  36015. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36016. }
  36017. if m.sop_run != nil {
  36018. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36019. }
  36020. if m.total_friend != nil {
  36021. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36022. }
  36023. if m.total_group != nil {
  36024. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36025. }
  36026. if m.account_balance != nil {
  36027. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36028. }
  36029. if m.consume_token != nil {
  36030. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36031. }
  36032. if m.active_user != nil {
  36033. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36034. }
  36035. if m.new_user != nil {
  36036. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36037. }
  36038. if m.label_dist != nil {
  36039. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  36040. }
  36041. return fields
  36042. }
  36043. // Field returns the value of a field with the given name. The second boolean
  36044. // return value indicates that this field was not set, or was not defined in the
  36045. // schema.
  36046. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  36047. switch name {
  36048. case usagestatisticmonth.FieldCreatedAt:
  36049. return m.CreatedAt()
  36050. case usagestatisticmonth.FieldUpdatedAt:
  36051. return m.UpdatedAt()
  36052. case usagestatisticmonth.FieldStatus:
  36053. return m.Status()
  36054. case usagestatisticmonth.FieldDeletedAt:
  36055. return m.DeletedAt()
  36056. case usagestatisticmonth.FieldAddtime:
  36057. return m.Addtime()
  36058. case usagestatisticmonth.FieldType:
  36059. return m.GetType()
  36060. case usagestatisticmonth.FieldBotID:
  36061. return m.BotID()
  36062. case usagestatisticmonth.FieldOrganizationID:
  36063. return m.OrganizationID()
  36064. case usagestatisticmonth.FieldAiResponse:
  36065. return m.AiResponse()
  36066. case usagestatisticmonth.FieldSopRun:
  36067. return m.SopRun()
  36068. case usagestatisticmonth.FieldTotalFriend:
  36069. return m.TotalFriend()
  36070. case usagestatisticmonth.FieldTotalGroup:
  36071. return m.TotalGroup()
  36072. case usagestatisticmonth.FieldAccountBalance:
  36073. return m.AccountBalance()
  36074. case usagestatisticmonth.FieldConsumeToken:
  36075. return m.ConsumeToken()
  36076. case usagestatisticmonth.FieldActiveUser:
  36077. return m.ActiveUser()
  36078. case usagestatisticmonth.FieldNewUser:
  36079. return m.NewUser()
  36080. case usagestatisticmonth.FieldLabelDist:
  36081. return m.LabelDist()
  36082. }
  36083. return nil, false
  36084. }
  36085. // OldField returns the old value of the field from the database. An error is
  36086. // returned if the mutation operation is not UpdateOne, or the query to the
  36087. // database failed.
  36088. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36089. switch name {
  36090. case usagestatisticmonth.FieldCreatedAt:
  36091. return m.OldCreatedAt(ctx)
  36092. case usagestatisticmonth.FieldUpdatedAt:
  36093. return m.OldUpdatedAt(ctx)
  36094. case usagestatisticmonth.FieldStatus:
  36095. return m.OldStatus(ctx)
  36096. case usagestatisticmonth.FieldDeletedAt:
  36097. return m.OldDeletedAt(ctx)
  36098. case usagestatisticmonth.FieldAddtime:
  36099. return m.OldAddtime(ctx)
  36100. case usagestatisticmonth.FieldType:
  36101. return m.OldType(ctx)
  36102. case usagestatisticmonth.FieldBotID:
  36103. return m.OldBotID(ctx)
  36104. case usagestatisticmonth.FieldOrganizationID:
  36105. return m.OldOrganizationID(ctx)
  36106. case usagestatisticmonth.FieldAiResponse:
  36107. return m.OldAiResponse(ctx)
  36108. case usagestatisticmonth.FieldSopRun:
  36109. return m.OldSopRun(ctx)
  36110. case usagestatisticmonth.FieldTotalFriend:
  36111. return m.OldTotalFriend(ctx)
  36112. case usagestatisticmonth.FieldTotalGroup:
  36113. return m.OldTotalGroup(ctx)
  36114. case usagestatisticmonth.FieldAccountBalance:
  36115. return m.OldAccountBalance(ctx)
  36116. case usagestatisticmonth.FieldConsumeToken:
  36117. return m.OldConsumeToken(ctx)
  36118. case usagestatisticmonth.FieldActiveUser:
  36119. return m.OldActiveUser(ctx)
  36120. case usagestatisticmonth.FieldNewUser:
  36121. return m.OldNewUser(ctx)
  36122. case usagestatisticmonth.FieldLabelDist:
  36123. return m.OldLabelDist(ctx)
  36124. }
  36125. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36126. }
  36127. // SetField sets the value of a field with the given name. It returns an error if
  36128. // the field is not defined in the schema, or if the type mismatched the field
  36129. // type.
  36130. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  36131. switch name {
  36132. case usagestatisticmonth.FieldCreatedAt:
  36133. v, ok := value.(time.Time)
  36134. if !ok {
  36135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36136. }
  36137. m.SetCreatedAt(v)
  36138. return nil
  36139. case usagestatisticmonth.FieldUpdatedAt:
  36140. v, ok := value.(time.Time)
  36141. if !ok {
  36142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36143. }
  36144. m.SetUpdatedAt(v)
  36145. return nil
  36146. case usagestatisticmonth.FieldStatus:
  36147. v, ok := value.(uint8)
  36148. if !ok {
  36149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36150. }
  36151. m.SetStatus(v)
  36152. return nil
  36153. case usagestatisticmonth.FieldDeletedAt:
  36154. v, ok := value.(time.Time)
  36155. if !ok {
  36156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36157. }
  36158. m.SetDeletedAt(v)
  36159. return nil
  36160. case usagestatisticmonth.FieldAddtime:
  36161. v, ok := value.(uint64)
  36162. if !ok {
  36163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36164. }
  36165. m.SetAddtime(v)
  36166. return nil
  36167. case usagestatisticmonth.FieldType:
  36168. v, ok := value.(int)
  36169. if !ok {
  36170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36171. }
  36172. m.SetType(v)
  36173. return nil
  36174. case usagestatisticmonth.FieldBotID:
  36175. v, ok := value.(string)
  36176. if !ok {
  36177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36178. }
  36179. m.SetBotID(v)
  36180. return nil
  36181. case usagestatisticmonth.FieldOrganizationID:
  36182. v, ok := value.(uint64)
  36183. if !ok {
  36184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36185. }
  36186. m.SetOrganizationID(v)
  36187. return nil
  36188. case usagestatisticmonth.FieldAiResponse:
  36189. v, ok := value.(uint64)
  36190. if !ok {
  36191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36192. }
  36193. m.SetAiResponse(v)
  36194. return nil
  36195. case usagestatisticmonth.FieldSopRun:
  36196. v, ok := value.(uint64)
  36197. if !ok {
  36198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36199. }
  36200. m.SetSopRun(v)
  36201. return nil
  36202. case usagestatisticmonth.FieldTotalFriend:
  36203. v, ok := value.(uint64)
  36204. if !ok {
  36205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36206. }
  36207. m.SetTotalFriend(v)
  36208. return nil
  36209. case usagestatisticmonth.FieldTotalGroup:
  36210. v, ok := value.(uint64)
  36211. if !ok {
  36212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36213. }
  36214. m.SetTotalGroup(v)
  36215. return nil
  36216. case usagestatisticmonth.FieldAccountBalance:
  36217. v, ok := value.(uint64)
  36218. if !ok {
  36219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36220. }
  36221. m.SetAccountBalance(v)
  36222. return nil
  36223. case usagestatisticmonth.FieldConsumeToken:
  36224. v, ok := value.(uint64)
  36225. if !ok {
  36226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36227. }
  36228. m.SetConsumeToken(v)
  36229. return nil
  36230. case usagestatisticmonth.FieldActiveUser:
  36231. v, ok := value.(uint64)
  36232. if !ok {
  36233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36234. }
  36235. m.SetActiveUser(v)
  36236. return nil
  36237. case usagestatisticmonth.FieldNewUser:
  36238. v, ok := value.(int64)
  36239. if !ok {
  36240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36241. }
  36242. m.SetNewUser(v)
  36243. return nil
  36244. case usagestatisticmonth.FieldLabelDist:
  36245. v, ok := value.([]custom_types.LabelDist)
  36246. if !ok {
  36247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36248. }
  36249. m.SetLabelDist(v)
  36250. return nil
  36251. }
  36252. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36253. }
  36254. // AddedFields returns all numeric fields that were incremented/decremented during
  36255. // this mutation.
  36256. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  36257. var fields []string
  36258. if m.addstatus != nil {
  36259. fields = append(fields, usagestatisticmonth.FieldStatus)
  36260. }
  36261. if m.addaddtime != nil {
  36262. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36263. }
  36264. if m.add_type != nil {
  36265. fields = append(fields, usagestatisticmonth.FieldType)
  36266. }
  36267. if m.addorganization_id != nil {
  36268. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36269. }
  36270. if m.addai_response != nil {
  36271. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36272. }
  36273. if m.addsop_run != nil {
  36274. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36275. }
  36276. if m.addtotal_friend != nil {
  36277. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36278. }
  36279. if m.addtotal_group != nil {
  36280. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36281. }
  36282. if m.addaccount_balance != nil {
  36283. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36284. }
  36285. if m.addconsume_token != nil {
  36286. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36287. }
  36288. if m.addactive_user != nil {
  36289. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36290. }
  36291. if m.addnew_user != nil {
  36292. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36293. }
  36294. return fields
  36295. }
  36296. // AddedField returns the numeric value that was incremented/decremented on a field
  36297. // with the given name. The second boolean return value indicates that this field
  36298. // was not set, or was not defined in the schema.
  36299. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  36300. switch name {
  36301. case usagestatisticmonth.FieldStatus:
  36302. return m.AddedStatus()
  36303. case usagestatisticmonth.FieldAddtime:
  36304. return m.AddedAddtime()
  36305. case usagestatisticmonth.FieldType:
  36306. return m.AddedType()
  36307. case usagestatisticmonth.FieldOrganizationID:
  36308. return m.AddedOrganizationID()
  36309. case usagestatisticmonth.FieldAiResponse:
  36310. return m.AddedAiResponse()
  36311. case usagestatisticmonth.FieldSopRun:
  36312. return m.AddedSopRun()
  36313. case usagestatisticmonth.FieldTotalFriend:
  36314. return m.AddedTotalFriend()
  36315. case usagestatisticmonth.FieldTotalGroup:
  36316. return m.AddedTotalGroup()
  36317. case usagestatisticmonth.FieldAccountBalance:
  36318. return m.AddedAccountBalance()
  36319. case usagestatisticmonth.FieldConsumeToken:
  36320. return m.AddedConsumeToken()
  36321. case usagestatisticmonth.FieldActiveUser:
  36322. return m.AddedActiveUser()
  36323. case usagestatisticmonth.FieldNewUser:
  36324. return m.AddedNewUser()
  36325. }
  36326. return nil, false
  36327. }
  36328. // AddField adds the value to the field with the given name. It returns an error if
  36329. // the field is not defined in the schema, or if the type mismatched the field
  36330. // type.
  36331. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  36332. switch name {
  36333. case usagestatisticmonth.FieldStatus:
  36334. v, ok := value.(int8)
  36335. if !ok {
  36336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36337. }
  36338. m.AddStatus(v)
  36339. return nil
  36340. case usagestatisticmonth.FieldAddtime:
  36341. v, ok := value.(int64)
  36342. if !ok {
  36343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36344. }
  36345. m.AddAddtime(v)
  36346. return nil
  36347. case usagestatisticmonth.FieldType:
  36348. v, ok := value.(int)
  36349. if !ok {
  36350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36351. }
  36352. m.AddType(v)
  36353. return nil
  36354. case usagestatisticmonth.FieldOrganizationID:
  36355. v, ok := value.(int64)
  36356. if !ok {
  36357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36358. }
  36359. m.AddOrganizationID(v)
  36360. return nil
  36361. case usagestatisticmonth.FieldAiResponse:
  36362. v, ok := value.(int64)
  36363. if !ok {
  36364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36365. }
  36366. m.AddAiResponse(v)
  36367. return nil
  36368. case usagestatisticmonth.FieldSopRun:
  36369. v, ok := value.(int64)
  36370. if !ok {
  36371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36372. }
  36373. m.AddSopRun(v)
  36374. return nil
  36375. case usagestatisticmonth.FieldTotalFriend:
  36376. v, ok := value.(int64)
  36377. if !ok {
  36378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36379. }
  36380. m.AddTotalFriend(v)
  36381. return nil
  36382. case usagestatisticmonth.FieldTotalGroup:
  36383. v, ok := value.(int64)
  36384. if !ok {
  36385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36386. }
  36387. m.AddTotalGroup(v)
  36388. return nil
  36389. case usagestatisticmonth.FieldAccountBalance:
  36390. v, ok := value.(int64)
  36391. if !ok {
  36392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36393. }
  36394. m.AddAccountBalance(v)
  36395. return nil
  36396. case usagestatisticmonth.FieldConsumeToken:
  36397. v, ok := value.(int64)
  36398. if !ok {
  36399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36400. }
  36401. m.AddConsumeToken(v)
  36402. return nil
  36403. case usagestatisticmonth.FieldActiveUser:
  36404. v, ok := value.(int64)
  36405. if !ok {
  36406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36407. }
  36408. m.AddActiveUser(v)
  36409. return nil
  36410. case usagestatisticmonth.FieldNewUser:
  36411. v, ok := value.(int64)
  36412. if !ok {
  36413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36414. }
  36415. m.AddNewUser(v)
  36416. return nil
  36417. }
  36418. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  36419. }
  36420. // ClearedFields returns all nullable fields that were cleared during this
  36421. // mutation.
  36422. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  36423. var fields []string
  36424. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  36425. fields = append(fields, usagestatisticmonth.FieldStatus)
  36426. }
  36427. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  36428. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  36429. }
  36430. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  36431. fields = append(fields, usagestatisticmonth.FieldBotID)
  36432. }
  36433. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  36434. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36435. }
  36436. return fields
  36437. }
  36438. // FieldCleared returns a boolean indicating if a field with the given name was
  36439. // cleared in this mutation.
  36440. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  36441. _, ok := m.clearedFields[name]
  36442. return ok
  36443. }
  36444. // ClearField clears the value of the field with the given name. It returns an
  36445. // error if the field is not defined in the schema.
  36446. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  36447. switch name {
  36448. case usagestatisticmonth.FieldStatus:
  36449. m.ClearStatus()
  36450. return nil
  36451. case usagestatisticmonth.FieldDeletedAt:
  36452. m.ClearDeletedAt()
  36453. return nil
  36454. case usagestatisticmonth.FieldBotID:
  36455. m.ClearBotID()
  36456. return nil
  36457. case usagestatisticmonth.FieldOrganizationID:
  36458. m.ClearOrganizationID()
  36459. return nil
  36460. }
  36461. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  36462. }
  36463. // ResetField resets all changes in the mutation for the field with the given name.
  36464. // It returns an error if the field is not defined in the schema.
  36465. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  36466. switch name {
  36467. case usagestatisticmonth.FieldCreatedAt:
  36468. m.ResetCreatedAt()
  36469. return nil
  36470. case usagestatisticmonth.FieldUpdatedAt:
  36471. m.ResetUpdatedAt()
  36472. return nil
  36473. case usagestatisticmonth.FieldStatus:
  36474. m.ResetStatus()
  36475. return nil
  36476. case usagestatisticmonth.FieldDeletedAt:
  36477. m.ResetDeletedAt()
  36478. return nil
  36479. case usagestatisticmonth.FieldAddtime:
  36480. m.ResetAddtime()
  36481. return nil
  36482. case usagestatisticmonth.FieldType:
  36483. m.ResetType()
  36484. return nil
  36485. case usagestatisticmonth.FieldBotID:
  36486. m.ResetBotID()
  36487. return nil
  36488. case usagestatisticmonth.FieldOrganizationID:
  36489. m.ResetOrganizationID()
  36490. return nil
  36491. case usagestatisticmonth.FieldAiResponse:
  36492. m.ResetAiResponse()
  36493. return nil
  36494. case usagestatisticmonth.FieldSopRun:
  36495. m.ResetSopRun()
  36496. return nil
  36497. case usagestatisticmonth.FieldTotalFriend:
  36498. m.ResetTotalFriend()
  36499. return nil
  36500. case usagestatisticmonth.FieldTotalGroup:
  36501. m.ResetTotalGroup()
  36502. return nil
  36503. case usagestatisticmonth.FieldAccountBalance:
  36504. m.ResetAccountBalance()
  36505. return nil
  36506. case usagestatisticmonth.FieldConsumeToken:
  36507. m.ResetConsumeToken()
  36508. return nil
  36509. case usagestatisticmonth.FieldActiveUser:
  36510. m.ResetActiveUser()
  36511. return nil
  36512. case usagestatisticmonth.FieldNewUser:
  36513. m.ResetNewUser()
  36514. return nil
  36515. case usagestatisticmonth.FieldLabelDist:
  36516. m.ResetLabelDist()
  36517. return nil
  36518. }
  36519. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36520. }
  36521. // AddedEdges returns all edge names that were set/added in this mutation.
  36522. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  36523. edges := make([]string, 0, 0)
  36524. return edges
  36525. }
  36526. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36527. // name in this mutation.
  36528. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  36529. return nil
  36530. }
  36531. // RemovedEdges returns all edge names that were removed in this mutation.
  36532. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  36533. edges := make([]string, 0, 0)
  36534. return edges
  36535. }
  36536. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36537. // the given name in this mutation.
  36538. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  36539. return nil
  36540. }
  36541. // ClearedEdges returns all edge names that were cleared in this mutation.
  36542. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  36543. edges := make([]string, 0, 0)
  36544. return edges
  36545. }
  36546. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36547. // was cleared in this mutation.
  36548. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  36549. return false
  36550. }
  36551. // ClearEdge clears the value of the edge with the given name. It returns an error
  36552. // if that edge is not defined in the schema.
  36553. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  36554. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  36555. }
  36556. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36557. // It returns an error if the edge is not defined in the schema.
  36558. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  36559. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  36560. }
  36561. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  36562. type UsageTotalMutation struct {
  36563. config
  36564. op Op
  36565. typ string
  36566. id *uint64
  36567. created_at *time.Time
  36568. updated_at *time.Time
  36569. status *uint8
  36570. addstatus *int8
  36571. _type *int
  36572. add_type *int
  36573. bot_id *string
  36574. total_tokens *uint64
  36575. addtotal_tokens *int64
  36576. start_index *uint64
  36577. addstart_index *int64
  36578. end_index *uint64
  36579. addend_index *int64
  36580. organization_id *uint64
  36581. addorganization_id *int64
  36582. clearedFields map[string]struct{}
  36583. done bool
  36584. oldValue func(context.Context) (*UsageTotal, error)
  36585. predicates []predicate.UsageTotal
  36586. }
  36587. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  36588. // usagetotalOption allows management of the mutation configuration using functional options.
  36589. type usagetotalOption func(*UsageTotalMutation)
  36590. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  36591. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  36592. m := &UsageTotalMutation{
  36593. config: c,
  36594. op: op,
  36595. typ: TypeUsageTotal,
  36596. clearedFields: make(map[string]struct{}),
  36597. }
  36598. for _, opt := range opts {
  36599. opt(m)
  36600. }
  36601. return m
  36602. }
  36603. // withUsageTotalID sets the ID field of the mutation.
  36604. func withUsageTotalID(id uint64) usagetotalOption {
  36605. return func(m *UsageTotalMutation) {
  36606. var (
  36607. err error
  36608. once sync.Once
  36609. value *UsageTotal
  36610. )
  36611. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  36612. once.Do(func() {
  36613. if m.done {
  36614. err = errors.New("querying old values post mutation is not allowed")
  36615. } else {
  36616. value, err = m.Client().UsageTotal.Get(ctx, id)
  36617. }
  36618. })
  36619. return value, err
  36620. }
  36621. m.id = &id
  36622. }
  36623. }
  36624. // withUsageTotal sets the old UsageTotal of the mutation.
  36625. func withUsageTotal(node *UsageTotal) usagetotalOption {
  36626. return func(m *UsageTotalMutation) {
  36627. m.oldValue = func(context.Context) (*UsageTotal, error) {
  36628. return node, nil
  36629. }
  36630. m.id = &node.ID
  36631. }
  36632. }
  36633. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36634. // executed in a transaction (ent.Tx), a transactional client is returned.
  36635. func (m UsageTotalMutation) Client() *Client {
  36636. client := &Client{config: m.config}
  36637. client.init()
  36638. return client
  36639. }
  36640. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36641. // it returns an error otherwise.
  36642. func (m UsageTotalMutation) Tx() (*Tx, error) {
  36643. if _, ok := m.driver.(*txDriver); !ok {
  36644. return nil, errors.New("ent: mutation is not running in a transaction")
  36645. }
  36646. tx := &Tx{config: m.config}
  36647. tx.init()
  36648. return tx, nil
  36649. }
  36650. // SetID sets the value of the id field. Note that this
  36651. // operation is only accepted on creation of UsageTotal entities.
  36652. func (m *UsageTotalMutation) SetID(id uint64) {
  36653. m.id = &id
  36654. }
  36655. // ID returns the ID value in the mutation. Note that the ID is only available
  36656. // if it was provided to the builder or after it was returned from the database.
  36657. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  36658. if m.id == nil {
  36659. return
  36660. }
  36661. return *m.id, true
  36662. }
  36663. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36664. // That means, if the mutation is applied within a transaction with an isolation level such
  36665. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36666. // or updated by the mutation.
  36667. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  36668. switch {
  36669. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36670. id, exists := m.ID()
  36671. if exists {
  36672. return []uint64{id}, nil
  36673. }
  36674. fallthrough
  36675. case m.op.Is(OpUpdate | OpDelete):
  36676. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  36677. default:
  36678. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36679. }
  36680. }
  36681. // SetCreatedAt sets the "created_at" field.
  36682. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  36683. m.created_at = &t
  36684. }
  36685. // CreatedAt returns the value of the "created_at" field in the mutation.
  36686. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  36687. v := m.created_at
  36688. if v == nil {
  36689. return
  36690. }
  36691. return *v, true
  36692. }
  36693. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  36694. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36696. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36697. if !m.op.Is(OpUpdateOne) {
  36698. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36699. }
  36700. if m.id == nil || m.oldValue == nil {
  36701. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36702. }
  36703. oldValue, err := m.oldValue(ctx)
  36704. if err != nil {
  36705. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36706. }
  36707. return oldValue.CreatedAt, nil
  36708. }
  36709. // ResetCreatedAt resets all changes to the "created_at" field.
  36710. func (m *UsageTotalMutation) ResetCreatedAt() {
  36711. m.created_at = nil
  36712. }
  36713. // SetUpdatedAt sets the "updated_at" field.
  36714. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  36715. m.updated_at = &t
  36716. }
  36717. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36718. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  36719. v := m.updated_at
  36720. if v == nil {
  36721. return
  36722. }
  36723. return *v, true
  36724. }
  36725. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  36726. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36728. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36729. if !m.op.Is(OpUpdateOne) {
  36730. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36731. }
  36732. if m.id == nil || m.oldValue == nil {
  36733. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36734. }
  36735. oldValue, err := m.oldValue(ctx)
  36736. if err != nil {
  36737. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36738. }
  36739. return oldValue.UpdatedAt, nil
  36740. }
  36741. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36742. func (m *UsageTotalMutation) ResetUpdatedAt() {
  36743. m.updated_at = nil
  36744. }
  36745. // SetStatus sets the "status" field.
  36746. func (m *UsageTotalMutation) SetStatus(u uint8) {
  36747. m.status = &u
  36748. m.addstatus = nil
  36749. }
  36750. // Status returns the value of the "status" field in the mutation.
  36751. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  36752. v := m.status
  36753. if v == nil {
  36754. return
  36755. }
  36756. return *v, true
  36757. }
  36758. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  36759. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36761. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36762. if !m.op.Is(OpUpdateOne) {
  36763. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36764. }
  36765. if m.id == nil || m.oldValue == nil {
  36766. return v, errors.New("OldStatus requires an ID field in the mutation")
  36767. }
  36768. oldValue, err := m.oldValue(ctx)
  36769. if err != nil {
  36770. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36771. }
  36772. return oldValue.Status, nil
  36773. }
  36774. // AddStatus adds u to the "status" field.
  36775. func (m *UsageTotalMutation) AddStatus(u int8) {
  36776. if m.addstatus != nil {
  36777. *m.addstatus += u
  36778. } else {
  36779. m.addstatus = &u
  36780. }
  36781. }
  36782. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36783. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  36784. v := m.addstatus
  36785. if v == nil {
  36786. return
  36787. }
  36788. return *v, true
  36789. }
  36790. // ClearStatus clears the value of the "status" field.
  36791. func (m *UsageTotalMutation) ClearStatus() {
  36792. m.status = nil
  36793. m.addstatus = nil
  36794. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  36795. }
  36796. // StatusCleared returns if the "status" field was cleared in this mutation.
  36797. func (m *UsageTotalMutation) StatusCleared() bool {
  36798. _, ok := m.clearedFields[usagetotal.FieldStatus]
  36799. return ok
  36800. }
  36801. // ResetStatus resets all changes to the "status" field.
  36802. func (m *UsageTotalMutation) ResetStatus() {
  36803. m.status = nil
  36804. m.addstatus = nil
  36805. delete(m.clearedFields, usagetotal.FieldStatus)
  36806. }
  36807. // SetType sets the "type" field.
  36808. func (m *UsageTotalMutation) SetType(i int) {
  36809. m._type = &i
  36810. m.add_type = nil
  36811. }
  36812. // GetType returns the value of the "type" field in the mutation.
  36813. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  36814. v := m._type
  36815. if v == nil {
  36816. return
  36817. }
  36818. return *v, true
  36819. }
  36820. // OldType returns the old "type" field's value of the UsageTotal entity.
  36821. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36823. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  36824. if !m.op.Is(OpUpdateOne) {
  36825. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36826. }
  36827. if m.id == nil || m.oldValue == nil {
  36828. return v, errors.New("OldType requires an ID field in the mutation")
  36829. }
  36830. oldValue, err := m.oldValue(ctx)
  36831. if err != nil {
  36832. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36833. }
  36834. return oldValue.Type, nil
  36835. }
  36836. // AddType adds i to the "type" field.
  36837. func (m *UsageTotalMutation) AddType(i int) {
  36838. if m.add_type != nil {
  36839. *m.add_type += i
  36840. } else {
  36841. m.add_type = &i
  36842. }
  36843. }
  36844. // AddedType returns the value that was added to the "type" field in this mutation.
  36845. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  36846. v := m.add_type
  36847. if v == nil {
  36848. return
  36849. }
  36850. return *v, true
  36851. }
  36852. // ClearType clears the value of the "type" field.
  36853. func (m *UsageTotalMutation) ClearType() {
  36854. m._type = nil
  36855. m.add_type = nil
  36856. m.clearedFields[usagetotal.FieldType] = struct{}{}
  36857. }
  36858. // TypeCleared returns if the "type" field was cleared in this mutation.
  36859. func (m *UsageTotalMutation) TypeCleared() bool {
  36860. _, ok := m.clearedFields[usagetotal.FieldType]
  36861. return ok
  36862. }
  36863. // ResetType resets all changes to the "type" field.
  36864. func (m *UsageTotalMutation) ResetType() {
  36865. m._type = nil
  36866. m.add_type = nil
  36867. delete(m.clearedFields, usagetotal.FieldType)
  36868. }
  36869. // SetBotID sets the "bot_id" field.
  36870. func (m *UsageTotalMutation) SetBotID(s string) {
  36871. m.bot_id = &s
  36872. }
  36873. // BotID returns the value of the "bot_id" field in the mutation.
  36874. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  36875. v := m.bot_id
  36876. if v == nil {
  36877. return
  36878. }
  36879. return *v, true
  36880. }
  36881. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  36882. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36884. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  36885. if !m.op.Is(OpUpdateOne) {
  36886. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36887. }
  36888. if m.id == nil || m.oldValue == nil {
  36889. return v, errors.New("OldBotID requires an ID field in the mutation")
  36890. }
  36891. oldValue, err := m.oldValue(ctx)
  36892. if err != nil {
  36893. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36894. }
  36895. return oldValue.BotID, nil
  36896. }
  36897. // ResetBotID resets all changes to the "bot_id" field.
  36898. func (m *UsageTotalMutation) ResetBotID() {
  36899. m.bot_id = nil
  36900. }
  36901. // SetTotalTokens sets the "total_tokens" field.
  36902. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  36903. m.total_tokens = &u
  36904. m.addtotal_tokens = nil
  36905. }
  36906. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  36907. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  36908. v := m.total_tokens
  36909. if v == nil {
  36910. return
  36911. }
  36912. return *v, true
  36913. }
  36914. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  36915. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36917. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  36918. if !m.op.Is(OpUpdateOne) {
  36919. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  36920. }
  36921. if m.id == nil || m.oldValue == nil {
  36922. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  36923. }
  36924. oldValue, err := m.oldValue(ctx)
  36925. if err != nil {
  36926. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  36927. }
  36928. return oldValue.TotalTokens, nil
  36929. }
  36930. // AddTotalTokens adds u to the "total_tokens" field.
  36931. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  36932. if m.addtotal_tokens != nil {
  36933. *m.addtotal_tokens += u
  36934. } else {
  36935. m.addtotal_tokens = &u
  36936. }
  36937. }
  36938. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  36939. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  36940. v := m.addtotal_tokens
  36941. if v == nil {
  36942. return
  36943. }
  36944. return *v, true
  36945. }
  36946. // ClearTotalTokens clears the value of the "total_tokens" field.
  36947. func (m *UsageTotalMutation) ClearTotalTokens() {
  36948. m.total_tokens = nil
  36949. m.addtotal_tokens = nil
  36950. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  36951. }
  36952. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  36953. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  36954. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  36955. return ok
  36956. }
  36957. // ResetTotalTokens resets all changes to the "total_tokens" field.
  36958. func (m *UsageTotalMutation) ResetTotalTokens() {
  36959. m.total_tokens = nil
  36960. m.addtotal_tokens = nil
  36961. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  36962. }
  36963. // SetStartIndex sets the "start_index" field.
  36964. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  36965. m.start_index = &u
  36966. m.addstart_index = nil
  36967. }
  36968. // StartIndex returns the value of the "start_index" field in the mutation.
  36969. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  36970. v := m.start_index
  36971. if v == nil {
  36972. return
  36973. }
  36974. return *v, true
  36975. }
  36976. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  36977. // If the UsageTotal 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 *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  36980. if !m.op.Is(OpUpdateOne) {
  36981. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  36982. }
  36983. if m.id == nil || m.oldValue == nil {
  36984. return v, errors.New("OldStartIndex 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 OldStartIndex: %w", err)
  36989. }
  36990. return oldValue.StartIndex, nil
  36991. }
  36992. // AddStartIndex adds u to the "start_index" field.
  36993. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  36994. if m.addstart_index != nil {
  36995. *m.addstart_index += u
  36996. } else {
  36997. m.addstart_index = &u
  36998. }
  36999. }
  37000. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  37001. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  37002. v := m.addstart_index
  37003. if v == nil {
  37004. return
  37005. }
  37006. return *v, true
  37007. }
  37008. // ClearStartIndex clears the value of the "start_index" field.
  37009. func (m *UsageTotalMutation) ClearStartIndex() {
  37010. m.start_index = nil
  37011. m.addstart_index = nil
  37012. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  37013. }
  37014. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  37015. func (m *UsageTotalMutation) StartIndexCleared() bool {
  37016. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  37017. return ok
  37018. }
  37019. // ResetStartIndex resets all changes to the "start_index" field.
  37020. func (m *UsageTotalMutation) ResetStartIndex() {
  37021. m.start_index = nil
  37022. m.addstart_index = nil
  37023. delete(m.clearedFields, usagetotal.FieldStartIndex)
  37024. }
  37025. // SetEndIndex sets the "end_index" field.
  37026. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  37027. m.end_index = &u
  37028. m.addend_index = nil
  37029. }
  37030. // EndIndex returns the value of the "end_index" field in the mutation.
  37031. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  37032. v := m.end_index
  37033. if v == nil {
  37034. return
  37035. }
  37036. return *v, true
  37037. }
  37038. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  37039. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37041. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  37042. if !m.op.Is(OpUpdateOne) {
  37043. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  37044. }
  37045. if m.id == nil || m.oldValue == nil {
  37046. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  37047. }
  37048. oldValue, err := m.oldValue(ctx)
  37049. if err != nil {
  37050. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  37051. }
  37052. return oldValue.EndIndex, nil
  37053. }
  37054. // AddEndIndex adds u to the "end_index" field.
  37055. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  37056. if m.addend_index != nil {
  37057. *m.addend_index += u
  37058. } else {
  37059. m.addend_index = &u
  37060. }
  37061. }
  37062. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  37063. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  37064. v := m.addend_index
  37065. if v == nil {
  37066. return
  37067. }
  37068. return *v, true
  37069. }
  37070. // ClearEndIndex clears the value of the "end_index" field.
  37071. func (m *UsageTotalMutation) ClearEndIndex() {
  37072. m.end_index = nil
  37073. m.addend_index = nil
  37074. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  37075. }
  37076. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  37077. func (m *UsageTotalMutation) EndIndexCleared() bool {
  37078. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  37079. return ok
  37080. }
  37081. // ResetEndIndex resets all changes to the "end_index" field.
  37082. func (m *UsageTotalMutation) ResetEndIndex() {
  37083. m.end_index = nil
  37084. m.addend_index = nil
  37085. delete(m.clearedFields, usagetotal.FieldEndIndex)
  37086. }
  37087. // SetOrganizationID sets the "organization_id" field.
  37088. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  37089. m.organization_id = &u
  37090. m.addorganization_id = nil
  37091. }
  37092. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37093. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  37094. v := m.organization_id
  37095. if v == nil {
  37096. return
  37097. }
  37098. return *v, true
  37099. }
  37100. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  37101. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37103. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37104. if !m.op.Is(OpUpdateOne) {
  37105. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37106. }
  37107. if m.id == nil || m.oldValue == nil {
  37108. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37109. }
  37110. oldValue, err := m.oldValue(ctx)
  37111. if err != nil {
  37112. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37113. }
  37114. return oldValue.OrganizationID, nil
  37115. }
  37116. // AddOrganizationID adds u to the "organization_id" field.
  37117. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  37118. if m.addorganization_id != nil {
  37119. *m.addorganization_id += u
  37120. } else {
  37121. m.addorganization_id = &u
  37122. }
  37123. }
  37124. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37125. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  37126. v := m.addorganization_id
  37127. if v == nil {
  37128. return
  37129. }
  37130. return *v, true
  37131. }
  37132. // ClearOrganizationID clears the value of the "organization_id" field.
  37133. func (m *UsageTotalMutation) ClearOrganizationID() {
  37134. m.organization_id = nil
  37135. m.addorganization_id = nil
  37136. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  37137. }
  37138. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37139. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  37140. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  37141. return ok
  37142. }
  37143. // ResetOrganizationID resets all changes to the "organization_id" field.
  37144. func (m *UsageTotalMutation) ResetOrganizationID() {
  37145. m.organization_id = nil
  37146. m.addorganization_id = nil
  37147. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  37148. }
  37149. // Where appends a list predicates to the UsageTotalMutation builder.
  37150. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  37151. m.predicates = append(m.predicates, ps...)
  37152. }
  37153. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  37154. // users can use type-assertion to append predicates that do not depend on any generated package.
  37155. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  37156. p := make([]predicate.UsageTotal, len(ps))
  37157. for i := range ps {
  37158. p[i] = ps[i]
  37159. }
  37160. m.Where(p...)
  37161. }
  37162. // Op returns the operation name.
  37163. func (m *UsageTotalMutation) Op() Op {
  37164. return m.op
  37165. }
  37166. // SetOp allows setting the mutation operation.
  37167. func (m *UsageTotalMutation) SetOp(op Op) {
  37168. m.op = op
  37169. }
  37170. // Type returns the node type of this mutation (UsageTotal).
  37171. func (m *UsageTotalMutation) Type() string {
  37172. return m.typ
  37173. }
  37174. // Fields returns all fields that were changed during this mutation. Note that in
  37175. // order to get all numeric fields that were incremented/decremented, call
  37176. // AddedFields().
  37177. func (m *UsageTotalMutation) Fields() []string {
  37178. fields := make([]string, 0, 9)
  37179. if m.created_at != nil {
  37180. fields = append(fields, usagetotal.FieldCreatedAt)
  37181. }
  37182. if m.updated_at != nil {
  37183. fields = append(fields, usagetotal.FieldUpdatedAt)
  37184. }
  37185. if m.status != nil {
  37186. fields = append(fields, usagetotal.FieldStatus)
  37187. }
  37188. if m._type != nil {
  37189. fields = append(fields, usagetotal.FieldType)
  37190. }
  37191. if m.bot_id != nil {
  37192. fields = append(fields, usagetotal.FieldBotID)
  37193. }
  37194. if m.total_tokens != nil {
  37195. fields = append(fields, usagetotal.FieldTotalTokens)
  37196. }
  37197. if m.start_index != nil {
  37198. fields = append(fields, usagetotal.FieldStartIndex)
  37199. }
  37200. if m.end_index != nil {
  37201. fields = append(fields, usagetotal.FieldEndIndex)
  37202. }
  37203. if m.organization_id != nil {
  37204. fields = append(fields, usagetotal.FieldOrganizationID)
  37205. }
  37206. return fields
  37207. }
  37208. // Field returns the value of a field with the given name. The second boolean
  37209. // return value indicates that this field was not set, or was not defined in the
  37210. // schema.
  37211. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  37212. switch name {
  37213. case usagetotal.FieldCreatedAt:
  37214. return m.CreatedAt()
  37215. case usagetotal.FieldUpdatedAt:
  37216. return m.UpdatedAt()
  37217. case usagetotal.FieldStatus:
  37218. return m.Status()
  37219. case usagetotal.FieldType:
  37220. return m.GetType()
  37221. case usagetotal.FieldBotID:
  37222. return m.BotID()
  37223. case usagetotal.FieldTotalTokens:
  37224. return m.TotalTokens()
  37225. case usagetotal.FieldStartIndex:
  37226. return m.StartIndex()
  37227. case usagetotal.FieldEndIndex:
  37228. return m.EndIndex()
  37229. case usagetotal.FieldOrganizationID:
  37230. return m.OrganizationID()
  37231. }
  37232. return nil, false
  37233. }
  37234. // OldField returns the old value of the field from the database. An error is
  37235. // returned if the mutation operation is not UpdateOne, or the query to the
  37236. // database failed.
  37237. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37238. switch name {
  37239. case usagetotal.FieldCreatedAt:
  37240. return m.OldCreatedAt(ctx)
  37241. case usagetotal.FieldUpdatedAt:
  37242. return m.OldUpdatedAt(ctx)
  37243. case usagetotal.FieldStatus:
  37244. return m.OldStatus(ctx)
  37245. case usagetotal.FieldType:
  37246. return m.OldType(ctx)
  37247. case usagetotal.FieldBotID:
  37248. return m.OldBotID(ctx)
  37249. case usagetotal.FieldTotalTokens:
  37250. return m.OldTotalTokens(ctx)
  37251. case usagetotal.FieldStartIndex:
  37252. return m.OldStartIndex(ctx)
  37253. case usagetotal.FieldEndIndex:
  37254. return m.OldEndIndex(ctx)
  37255. case usagetotal.FieldOrganizationID:
  37256. return m.OldOrganizationID(ctx)
  37257. }
  37258. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  37259. }
  37260. // SetField sets the value of a field with the given name. It returns an error if
  37261. // the field is not defined in the schema, or if the type mismatched the field
  37262. // type.
  37263. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  37264. switch name {
  37265. case usagetotal.FieldCreatedAt:
  37266. v, ok := value.(time.Time)
  37267. if !ok {
  37268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37269. }
  37270. m.SetCreatedAt(v)
  37271. return nil
  37272. case usagetotal.FieldUpdatedAt:
  37273. v, ok := value.(time.Time)
  37274. if !ok {
  37275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37276. }
  37277. m.SetUpdatedAt(v)
  37278. return nil
  37279. case usagetotal.FieldStatus:
  37280. v, ok := value.(uint8)
  37281. if !ok {
  37282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37283. }
  37284. m.SetStatus(v)
  37285. return nil
  37286. case usagetotal.FieldType:
  37287. v, ok := value.(int)
  37288. if !ok {
  37289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37290. }
  37291. m.SetType(v)
  37292. return nil
  37293. case usagetotal.FieldBotID:
  37294. v, ok := value.(string)
  37295. if !ok {
  37296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37297. }
  37298. m.SetBotID(v)
  37299. return nil
  37300. case usagetotal.FieldTotalTokens:
  37301. v, ok := value.(uint64)
  37302. if !ok {
  37303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37304. }
  37305. m.SetTotalTokens(v)
  37306. return nil
  37307. case usagetotal.FieldStartIndex:
  37308. v, ok := value.(uint64)
  37309. if !ok {
  37310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37311. }
  37312. m.SetStartIndex(v)
  37313. return nil
  37314. case usagetotal.FieldEndIndex:
  37315. v, ok := value.(uint64)
  37316. if !ok {
  37317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37318. }
  37319. m.SetEndIndex(v)
  37320. return nil
  37321. case usagetotal.FieldOrganizationID:
  37322. v, ok := value.(uint64)
  37323. if !ok {
  37324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37325. }
  37326. m.SetOrganizationID(v)
  37327. return nil
  37328. }
  37329. return fmt.Errorf("unknown UsageTotal field %s", name)
  37330. }
  37331. // AddedFields returns all numeric fields that were incremented/decremented during
  37332. // this mutation.
  37333. func (m *UsageTotalMutation) AddedFields() []string {
  37334. var fields []string
  37335. if m.addstatus != nil {
  37336. fields = append(fields, usagetotal.FieldStatus)
  37337. }
  37338. if m.add_type != nil {
  37339. fields = append(fields, usagetotal.FieldType)
  37340. }
  37341. if m.addtotal_tokens != nil {
  37342. fields = append(fields, usagetotal.FieldTotalTokens)
  37343. }
  37344. if m.addstart_index != nil {
  37345. fields = append(fields, usagetotal.FieldStartIndex)
  37346. }
  37347. if m.addend_index != nil {
  37348. fields = append(fields, usagetotal.FieldEndIndex)
  37349. }
  37350. if m.addorganization_id != nil {
  37351. fields = append(fields, usagetotal.FieldOrganizationID)
  37352. }
  37353. return fields
  37354. }
  37355. // AddedField returns the numeric value that was incremented/decremented on a field
  37356. // with the given name. The second boolean return value indicates that this field
  37357. // was not set, or was not defined in the schema.
  37358. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  37359. switch name {
  37360. case usagetotal.FieldStatus:
  37361. return m.AddedStatus()
  37362. case usagetotal.FieldType:
  37363. return m.AddedType()
  37364. case usagetotal.FieldTotalTokens:
  37365. return m.AddedTotalTokens()
  37366. case usagetotal.FieldStartIndex:
  37367. return m.AddedStartIndex()
  37368. case usagetotal.FieldEndIndex:
  37369. return m.AddedEndIndex()
  37370. case usagetotal.FieldOrganizationID:
  37371. return m.AddedOrganizationID()
  37372. }
  37373. return nil, false
  37374. }
  37375. // AddField adds the value to the field with the given name. It returns an error if
  37376. // the field is not defined in the schema, or if the type mismatched the field
  37377. // type.
  37378. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  37379. switch name {
  37380. case usagetotal.FieldStatus:
  37381. v, ok := value.(int8)
  37382. if !ok {
  37383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37384. }
  37385. m.AddStatus(v)
  37386. return nil
  37387. case usagetotal.FieldType:
  37388. v, ok := value.(int)
  37389. if !ok {
  37390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37391. }
  37392. m.AddType(v)
  37393. return nil
  37394. case usagetotal.FieldTotalTokens:
  37395. v, ok := value.(int64)
  37396. if !ok {
  37397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37398. }
  37399. m.AddTotalTokens(v)
  37400. return nil
  37401. case usagetotal.FieldStartIndex:
  37402. v, ok := value.(int64)
  37403. if !ok {
  37404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37405. }
  37406. m.AddStartIndex(v)
  37407. return nil
  37408. case usagetotal.FieldEndIndex:
  37409. v, ok := value.(int64)
  37410. if !ok {
  37411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37412. }
  37413. m.AddEndIndex(v)
  37414. return nil
  37415. case usagetotal.FieldOrganizationID:
  37416. v, ok := value.(int64)
  37417. if !ok {
  37418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37419. }
  37420. m.AddOrganizationID(v)
  37421. return nil
  37422. }
  37423. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  37424. }
  37425. // ClearedFields returns all nullable fields that were cleared during this
  37426. // mutation.
  37427. func (m *UsageTotalMutation) ClearedFields() []string {
  37428. var fields []string
  37429. if m.FieldCleared(usagetotal.FieldStatus) {
  37430. fields = append(fields, usagetotal.FieldStatus)
  37431. }
  37432. if m.FieldCleared(usagetotal.FieldType) {
  37433. fields = append(fields, usagetotal.FieldType)
  37434. }
  37435. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  37436. fields = append(fields, usagetotal.FieldTotalTokens)
  37437. }
  37438. if m.FieldCleared(usagetotal.FieldStartIndex) {
  37439. fields = append(fields, usagetotal.FieldStartIndex)
  37440. }
  37441. if m.FieldCleared(usagetotal.FieldEndIndex) {
  37442. fields = append(fields, usagetotal.FieldEndIndex)
  37443. }
  37444. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  37445. fields = append(fields, usagetotal.FieldOrganizationID)
  37446. }
  37447. return fields
  37448. }
  37449. // FieldCleared returns a boolean indicating if a field with the given name was
  37450. // cleared in this mutation.
  37451. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  37452. _, ok := m.clearedFields[name]
  37453. return ok
  37454. }
  37455. // ClearField clears the value of the field with the given name. It returns an
  37456. // error if the field is not defined in the schema.
  37457. func (m *UsageTotalMutation) ClearField(name string) error {
  37458. switch name {
  37459. case usagetotal.FieldStatus:
  37460. m.ClearStatus()
  37461. return nil
  37462. case usagetotal.FieldType:
  37463. m.ClearType()
  37464. return nil
  37465. case usagetotal.FieldTotalTokens:
  37466. m.ClearTotalTokens()
  37467. return nil
  37468. case usagetotal.FieldStartIndex:
  37469. m.ClearStartIndex()
  37470. return nil
  37471. case usagetotal.FieldEndIndex:
  37472. m.ClearEndIndex()
  37473. return nil
  37474. case usagetotal.FieldOrganizationID:
  37475. m.ClearOrganizationID()
  37476. return nil
  37477. }
  37478. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  37479. }
  37480. // ResetField resets all changes in the mutation for the field with the given name.
  37481. // It returns an error if the field is not defined in the schema.
  37482. func (m *UsageTotalMutation) ResetField(name string) error {
  37483. switch name {
  37484. case usagetotal.FieldCreatedAt:
  37485. m.ResetCreatedAt()
  37486. return nil
  37487. case usagetotal.FieldUpdatedAt:
  37488. m.ResetUpdatedAt()
  37489. return nil
  37490. case usagetotal.FieldStatus:
  37491. m.ResetStatus()
  37492. return nil
  37493. case usagetotal.FieldType:
  37494. m.ResetType()
  37495. return nil
  37496. case usagetotal.FieldBotID:
  37497. m.ResetBotID()
  37498. return nil
  37499. case usagetotal.FieldTotalTokens:
  37500. m.ResetTotalTokens()
  37501. return nil
  37502. case usagetotal.FieldStartIndex:
  37503. m.ResetStartIndex()
  37504. return nil
  37505. case usagetotal.FieldEndIndex:
  37506. m.ResetEndIndex()
  37507. return nil
  37508. case usagetotal.FieldOrganizationID:
  37509. m.ResetOrganizationID()
  37510. return nil
  37511. }
  37512. return fmt.Errorf("unknown UsageTotal field %s", name)
  37513. }
  37514. // AddedEdges returns all edge names that were set/added in this mutation.
  37515. func (m *UsageTotalMutation) AddedEdges() []string {
  37516. edges := make([]string, 0, 0)
  37517. return edges
  37518. }
  37519. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37520. // name in this mutation.
  37521. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  37522. return nil
  37523. }
  37524. // RemovedEdges returns all edge names that were removed in this mutation.
  37525. func (m *UsageTotalMutation) RemovedEdges() []string {
  37526. edges := make([]string, 0, 0)
  37527. return edges
  37528. }
  37529. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37530. // the given name in this mutation.
  37531. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  37532. return nil
  37533. }
  37534. // ClearedEdges returns all edge names that were cleared in this mutation.
  37535. func (m *UsageTotalMutation) ClearedEdges() []string {
  37536. edges := make([]string, 0, 0)
  37537. return edges
  37538. }
  37539. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37540. // was cleared in this mutation.
  37541. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  37542. return false
  37543. }
  37544. // ClearEdge clears the value of the edge with the given name. It returns an error
  37545. // if that edge is not defined in the schema.
  37546. func (m *UsageTotalMutation) ClearEdge(name string) error {
  37547. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  37548. }
  37549. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37550. // It returns an error if the edge is not defined in the schema.
  37551. func (m *UsageTotalMutation) ResetEdge(name string) error {
  37552. return fmt.Errorf("unknown UsageTotal edge %s", name)
  37553. }
  37554. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  37555. type WhatsappMutation struct {
  37556. config
  37557. op Op
  37558. typ string
  37559. id *uint64
  37560. created_at *time.Time
  37561. updated_at *time.Time
  37562. status *uint8
  37563. addstatus *int8
  37564. deleted_at *time.Time
  37565. wa_id *string
  37566. wa_name *string
  37567. callback *string
  37568. account *string
  37569. cc *string
  37570. phone *string
  37571. cc_phone *string
  37572. phone_name *string
  37573. phone_status *int8
  37574. addphone_status *int8
  37575. organization_id *uint64
  37576. addorganization_id *int64
  37577. api_base *string
  37578. api_key *string
  37579. allow_list *[]string
  37580. appendallow_list []string
  37581. group_allow_list *[]string
  37582. appendgroup_allow_list []string
  37583. block_list *[]string
  37584. appendblock_list []string
  37585. group_block_list *[]string
  37586. appendgroup_block_list []string
  37587. clearedFields map[string]struct{}
  37588. agent *uint64
  37589. clearedagent bool
  37590. done bool
  37591. oldValue func(context.Context) (*Whatsapp, error)
  37592. predicates []predicate.Whatsapp
  37593. }
  37594. var _ ent.Mutation = (*WhatsappMutation)(nil)
  37595. // whatsappOption allows management of the mutation configuration using functional options.
  37596. type whatsappOption func(*WhatsappMutation)
  37597. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  37598. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  37599. m := &WhatsappMutation{
  37600. config: c,
  37601. op: op,
  37602. typ: TypeWhatsapp,
  37603. clearedFields: make(map[string]struct{}),
  37604. }
  37605. for _, opt := range opts {
  37606. opt(m)
  37607. }
  37608. return m
  37609. }
  37610. // withWhatsappID sets the ID field of the mutation.
  37611. func withWhatsappID(id uint64) whatsappOption {
  37612. return func(m *WhatsappMutation) {
  37613. var (
  37614. err error
  37615. once sync.Once
  37616. value *Whatsapp
  37617. )
  37618. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  37619. once.Do(func() {
  37620. if m.done {
  37621. err = errors.New("querying old values post mutation is not allowed")
  37622. } else {
  37623. value, err = m.Client().Whatsapp.Get(ctx, id)
  37624. }
  37625. })
  37626. return value, err
  37627. }
  37628. m.id = &id
  37629. }
  37630. }
  37631. // withWhatsapp sets the old Whatsapp of the mutation.
  37632. func withWhatsapp(node *Whatsapp) whatsappOption {
  37633. return func(m *WhatsappMutation) {
  37634. m.oldValue = func(context.Context) (*Whatsapp, error) {
  37635. return node, nil
  37636. }
  37637. m.id = &node.ID
  37638. }
  37639. }
  37640. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37641. // executed in a transaction (ent.Tx), a transactional client is returned.
  37642. func (m WhatsappMutation) Client() *Client {
  37643. client := &Client{config: m.config}
  37644. client.init()
  37645. return client
  37646. }
  37647. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37648. // it returns an error otherwise.
  37649. func (m WhatsappMutation) Tx() (*Tx, error) {
  37650. if _, ok := m.driver.(*txDriver); !ok {
  37651. return nil, errors.New("ent: mutation is not running in a transaction")
  37652. }
  37653. tx := &Tx{config: m.config}
  37654. tx.init()
  37655. return tx, nil
  37656. }
  37657. // SetID sets the value of the id field. Note that this
  37658. // operation is only accepted on creation of Whatsapp entities.
  37659. func (m *WhatsappMutation) SetID(id uint64) {
  37660. m.id = &id
  37661. }
  37662. // ID returns the ID value in the mutation. Note that the ID is only available
  37663. // if it was provided to the builder or after it was returned from the database.
  37664. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  37665. if m.id == nil {
  37666. return
  37667. }
  37668. return *m.id, true
  37669. }
  37670. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37671. // That means, if the mutation is applied within a transaction with an isolation level such
  37672. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37673. // or updated by the mutation.
  37674. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  37675. switch {
  37676. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37677. id, exists := m.ID()
  37678. if exists {
  37679. return []uint64{id}, nil
  37680. }
  37681. fallthrough
  37682. case m.op.Is(OpUpdate | OpDelete):
  37683. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  37684. default:
  37685. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37686. }
  37687. }
  37688. // SetCreatedAt sets the "created_at" field.
  37689. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  37690. m.created_at = &t
  37691. }
  37692. // CreatedAt returns the value of the "created_at" field in the mutation.
  37693. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  37694. v := m.created_at
  37695. if v == nil {
  37696. return
  37697. }
  37698. return *v, true
  37699. }
  37700. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  37701. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37703. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37704. if !m.op.Is(OpUpdateOne) {
  37705. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37706. }
  37707. if m.id == nil || m.oldValue == nil {
  37708. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37709. }
  37710. oldValue, err := m.oldValue(ctx)
  37711. if err != nil {
  37712. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37713. }
  37714. return oldValue.CreatedAt, nil
  37715. }
  37716. // ResetCreatedAt resets all changes to the "created_at" field.
  37717. func (m *WhatsappMutation) ResetCreatedAt() {
  37718. m.created_at = nil
  37719. }
  37720. // SetUpdatedAt sets the "updated_at" field.
  37721. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  37722. m.updated_at = &t
  37723. }
  37724. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37725. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  37726. v := m.updated_at
  37727. if v == nil {
  37728. return
  37729. }
  37730. return *v, true
  37731. }
  37732. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  37733. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37735. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37736. if !m.op.Is(OpUpdateOne) {
  37737. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37738. }
  37739. if m.id == nil || m.oldValue == nil {
  37740. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37741. }
  37742. oldValue, err := m.oldValue(ctx)
  37743. if err != nil {
  37744. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37745. }
  37746. return oldValue.UpdatedAt, nil
  37747. }
  37748. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37749. func (m *WhatsappMutation) ResetUpdatedAt() {
  37750. m.updated_at = nil
  37751. }
  37752. // SetStatus sets the "status" field.
  37753. func (m *WhatsappMutation) SetStatus(u uint8) {
  37754. m.status = &u
  37755. m.addstatus = nil
  37756. }
  37757. // Status returns the value of the "status" field in the mutation.
  37758. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  37759. v := m.status
  37760. if v == nil {
  37761. return
  37762. }
  37763. return *v, true
  37764. }
  37765. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  37766. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37768. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37769. if !m.op.Is(OpUpdateOne) {
  37770. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37771. }
  37772. if m.id == nil || m.oldValue == nil {
  37773. return v, errors.New("OldStatus requires an ID field in the mutation")
  37774. }
  37775. oldValue, err := m.oldValue(ctx)
  37776. if err != nil {
  37777. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37778. }
  37779. return oldValue.Status, nil
  37780. }
  37781. // AddStatus adds u to the "status" field.
  37782. func (m *WhatsappMutation) AddStatus(u int8) {
  37783. if m.addstatus != nil {
  37784. *m.addstatus += u
  37785. } else {
  37786. m.addstatus = &u
  37787. }
  37788. }
  37789. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37790. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  37791. v := m.addstatus
  37792. if v == nil {
  37793. return
  37794. }
  37795. return *v, true
  37796. }
  37797. // ClearStatus clears the value of the "status" field.
  37798. func (m *WhatsappMutation) ClearStatus() {
  37799. m.status = nil
  37800. m.addstatus = nil
  37801. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  37802. }
  37803. // StatusCleared returns if the "status" field was cleared in this mutation.
  37804. func (m *WhatsappMutation) StatusCleared() bool {
  37805. _, ok := m.clearedFields[whatsapp.FieldStatus]
  37806. return ok
  37807. }
  37808. // ResetStatus resets all changes to the "status" field.
  37809. func (m *WhatsappMutation) ResetStatus() {
  37810. m.status = nil
  37811. m.addstatus = nil
  37812. delete(m.clearedFields, whatsapp.FieldStatus)
  37813. }
  37814. // SetDeletedAt sets the "deleted_at" field.
  37815. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  37816. m.deleted_at = &t
  37817. }
  37818. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37819. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  37820. v := m.deleted_at
  37821. if v == nil {
  37822. return
  37823. }
  37824. return *v, true
  37825. }
  37826. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  37827. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37829. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37830. if !m.op.Is(OpUpdateOne) {
  37831. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37832. }
  37833. if m.id == nil || m.oldValue == nil {
  37834. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37835. }
  37836. oldValue, err := m.oldValue(ctx)
  37837. if err != nil {
  37838. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37839. }
  37840. return oldValue.DeletedAt, nil
  37841. }
  37842. // ClearDeletedAt clears the value of the "deleted_at" field.
  37843. func (m *WhatsappMutation) ClearDeletedAt() {
  37844. m.deleted_at = nil
  37845. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  37846. }
  37847. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37848. func (m *WhatsappMutation) DeletedAtCleared() bool {
  37849. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  37850. return ok
  37851. }
  37852. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37853. func (m *WhatsappMutation) ResetDeletedAt() {
  37854. m.deleted_at = nil
  37855. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  37856. }
  37857. // SetWaID sets the "wa_id" field.
  37858. func (m *WhatsappMutation) SetWaID(s string) {
  37859. m.wa_id = &s
  37860. }
  37861. // WaID returns the value of the "wa_id" field in the mutation.
  37862. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  37863. v := m.wa_id
  37864. if v == nil {
  37865. return
  37866. }
  37867. return *v, true
  37868. }
  37869. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  37870. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37872. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  37873. if !m.op.Is(OpUpdateOne) {
  37874. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  37875. }
  37876. if m.id == nil || m.oldValue == nil {
  37877. return v, errors.New("OldWaID requires an ID field in the mutation")
  37878. }
  37879. oldValue, err := m.oldValue(ctx)
  37880. if err != nil {
  37881. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  37882. }
  37883. return oldValue.WaID, nil
  37884. }
  37885. // ClearWaID clears the value of the "wa_id" field.
  37886. func (m *WhatsappMutation) ClearWaID() {
  37887. m.wa_id = nil
  37888. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  37889. }
  37890. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  37891. func (m *WhatsappMutation) WaIDCleared() bool {
  37892. _, ok := m.clearedFields[whatsapp.FieldWaID]
  37893. return ok
  37894. }
  37895. // ResetWaID resets all changes to the "wa_id" field.
  37896. func (m *WhatsappMutation) ResetWaID() {
  37897. m.wa_id = nil
  37898. delete(m.clearedFields, whatsapp.FieldWaID)
  37899. }
  37900. // SetWaName sets the "wa_name" field.
  37901. func (m *WhatsappMutation) SetWaName(s string) {
  37902. m.wa_name = &s
  37903. }
  37904. // WaName returns the value of the "wa_name" field in the mutation.
  37905. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  37906. v := m.wa_name
  37907. if v == nil {
  37908. return
  37909. }
  37910. return *v, true
  37911. }
  37912. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  37913. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37915. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  37916. if !m.op.Is(OpUpdateOne) {
  37917. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  37918. }
  37919. if m.id == nil || m.oldValue == nil {
  37920. return v, errors.New("OldWaName requires an ID field in the mutation")
  37921. }
  37922. oldValue, err := m.oldValue(ctx)
  37923. if err != nil {
  37924. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  37925. }
  37926. return oldValue.WaName, nil
  37927. }
  37928. // ClearWaName clears the value of the "wa_name" field.
  37929. func (m *WhatsappMutation) ClearWaName() {
  37930. m.wa_name = nil
  37931. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  37932. }
  37933. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  37934. func (m *WhatsappMutation) WaNameCleared() bool {
  37935. _, ok := m.clearedFields[whatsapp.FieldWaName]
  37936. return ok
  37937. }
  37938. // ResetWaName resets all changes to the "wa_name" field.
  37939. func (m *WhatsappMutation) ResetWaName() {
  37940. m.wa_name = nil
  37941. delete(m.clearedFields, whatsapp.FieldWaName)
  37942. }
  37943. // SetCallback sets the "callback" field.
  37944. func (m *WhatsappMutation) SetCallback(s string) {
  37945. m.callback = &s
  37946. }
  37947. // Callback returns the value of the "callback" field in the mutation.
  37948. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  37949. v := m.callback
  37950. if v == nil {
  37951. return
  37952. }
  37953. return *v, true
  37954. }
  37955. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  37956. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37958. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  37959. if !m.op.Is(OpUpdateOne) {
  37960. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  37961. }
  37962. if m.id == nil || m.oldValue == nil {
  37963. return v, errors.New("OldCallback requires an ID field in the mutation")
  37964. }
  37965. oldValue, err := m.oldValue(ctx)
  37966. if err != nil {
  37967. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  37968. }
  37969. return oldValue.Callback, nil
  37970. }
  37971. // ClearCallback clears the value of the "callback" field.
  37972. func (m *WhatsappMutation) ClearCallback() {
  37973. m.callback = nil
  37974. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  37975. }
  37976. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  37977. func (m *WhatsappMutation) CallbackCleared() bool {
  37978. _, ok := m.clearedFields[whatsapp.FieldCallback]
  37979. return ok
  37980. }
  37981. // ResetCallback resets all changes to the "callback" field.
  37982. func (m *WhatsappMutation) ResetCallback() {
  37983. m.callback = nil
  37984. delete(m.clearedFields, whatsapp.FieldCallback)
  37985. }
  37986. // SetAgentID sets the "agent_id" field.
  37987. func (m *WhatsappMutation) SetAgentID(u uint64) {
  37988. m.agent = &u
  37989. }
  37990. // AgentID returns the value of the "agent_id" field in the mutation.
  37991. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  37992. v := m.agent
  37993. if v == nil {
  37994. return
  37995. }
  37996. return *v, true
  37997. }
  37998. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  37999. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38001. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  38002. if !m.op.Is(OpUpdateOne) {
  38003. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  38004. }
  38005. if m.id == nil || m.oldValue == nil {
  38006. return v, errors.New("OldAgentID requires an ID field in the mutation")
  38007. }
  38008. oldValue, err := m.oldValue(ctx)
  38009. if err != nil {
  38010. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  38011. }
  38012. return oldValue.AgentID, nil
  38013. }
  38014. // ResetAgentID resets all changes to the "agent_id" field.
  38015. func (m *WhatsappMutation) ResetAgentID() {
  38016. m.agent = nil
  38017. }
  38018. // SetAccount sets the "account" field.
  38019. func (m *WhatsappMutation) SetAccount(s string) {
  38020. m.account = &s
  38021. }
  38022. // Account returns the value of the "account" field in the mutation.
  38023. func (m *WhatsappMutation) Account() (r string, exists bool) {
  38024. v := m.account
  38025. if v == nil {
  38026. return
  38027. }
  38028. return *v, true
  38029. }
  38030. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  38031. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38033. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  38034. if !m.op.Is(OpUpdateOne) {
  38035. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  38036. }
  38037. if m.id == nil || m.oldValue == nil {
  38038. return v, errors.New("OldAccount requires an ID field in the mutation")
  38039. }
  38040. oldValue, err := m.oldValue(ctx)
  38041. if err != nil {
  38042. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  38043. }
  38044. return oldValue.Account, nil
  38045. }
  38046. // ClearAccount clears the value of the "account" field.
  38047. func (m *WhatsappMutation) ClearAccount() {
  38048. m.account = nil
  38049. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  38050. }
  38051. // AccountCleared returns if the "account" field was cleared in this mutation.
  38052. func (m *WhatsappMutation) AccountCleared() bool {
  38053. _, ok := m.clearedFields[whatsapp.FieldAccount]
  38054. return ok
  38055. }
  38056. // ResetAccount resets all changes to the "account" field.
  38057. func (m *WhatsappMutation) ResetAccount() {
  38058. m.account = nil
  38059. delete(m.clearedFields, whatsapp.FieldAccount)
  38060. }
  38061. // SetCc sets the "cc" field.
  38062. func (m *WhatsappMutation) SetCc(s string) {
  38063. m.cc = &s
  38064. }
  38065. // Cc returns the value of the "cc" field in the mutation.
  38066. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  38067. v := m.cc
  38068. if v == nil {
  38069. return
  38070. }
  38071. return *v, true
  38072. }
  38073. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  38074. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38076. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  38077. if !m.op.Is(OpUpdateOne) {
  38078. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  38079. }
  38080. if m.id == nil || m.oldValue == nil {
  38081. return v, errors.New("OldCc requires an ID field in the mutation")
  38082. }
  38083. oldValue, err := m.oldValue(ctx)
  38084. if err != nil {
  38085. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  38086. }
  38087. return oldValue.Cc, nil
  38088. }
  38089. // ResetCc resets all changes to the "cc" field.
  38090. func (m *WhatsappMutation) ResetCc() {
  38091. m.cc = nil
  38092. }
  38093. // SetPhone sets the "phone" field.
  38094. func (m *WhatsappMutation) SetPhone(s string) {
  38095. m.phone = &s
  38096. }
  38097. // Phone returns the value of the "phone" field in the mutation.
  38098. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  38099. v := m.phone
  38100. if v == nil {
  38101. return
  38102. }
  38103. return *v, true
  38104. }
  38105. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  38106. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38108. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  38109. if !m.op.Is(OpUpdateOne) {
  38110. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  38111. }
  38112. if m.id == nil || m.oldValue == nil {
  38113. return v, errors.New("OldPhone requires an ID field in the mutation")
  38114. }
  38115. oldValue, err := m.oldValue(ctx)
  38116. if err != nil {
  38117. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  38118. }
  38119. return oldValue.Phone, nil
  38120. }
  38121. // ResetPhone resets all changes to the "phone" field.
  38122. func (m *WhatsappMutation) ResetPhone() {
  38123. m.phone = nil
  38124. }
  38125. // SetCcPhone sets the "cc_phone" field.
  38126. func (m *WhatsappMutation) SetCcPhone(s string) {
  38127. m.cc_phone = &s
  38128. }
  38129. // CcPhone returns the value of the "cc_phone" field in the mutation.
  38130. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  38131. v := m.cc_phone
  38132. if v == nil {
  38133. return
  38134. }
  38135. return *v, true
  38136. }
  38137. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  38138. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38140. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  38141. if !m.op.Is(OpUpdateOne) {
  38142. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  38143. }
  38144. if m.id == nil || m.oldValue == nil {
  38145. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  38146. }
  38147. oldValue, err := m.oldValue(ctx)
  38148. if err != nil {
  38149. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  38150. }
  38151. return oldValue.CcPhone, nil
  38152. }
  38153. // ResetCcPhone resets all changes to the "cc_phone" field.
  38154. func (m *WhatsappMutation) ResetCcPhone() {
  38155. m.cc_phone = nil
  38156. }
  38157. // SetPhoneName sets the "phone_name" field.
  38158. func (m *WhatsappMutation) SetPhoneName(s string) {
  38159. m.phone_name = &s
  38160. }
  38161. // PhoneName returns the value of the "phone_name" field in the mutation.
  38162. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  38163. v := m.phone_name
  38164. if v == nil {
  38165. return
  38166. }
  38167. return *v, true
  38168. }
  38169. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  38170. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38172. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  38173. if !m.op.Is(OpUpdateOne) {
  38174. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  38175. }
  38176. if m.id == nil || m.oldValue == nil {
  38177. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  38178. }
  38179. oldValue, err := m.oldValue(ctx)
  38180. if err != nil {
  38181. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  38182. }
  38183. return oldValue.PhoneName, nil
  38184. }
  38185. // ResetPhoneName resets all changes to the "phone_name" field.
  38186. func (m *WhatsappMutation) ResetPhoneName() {
  38187. m.phone_name = nil
  38188. }
  38189. // SetPhoneStatus sets the "phone_status" field.
  38190. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  38191. m.phone_status = &i
  38192. m.addphone_status = nil
  38193. }
  38194. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  38195. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  38196. v := m.phone_status
  38197. if v == nil {
  38198. return
  38199. }
  38200. return *v, true
  38201. }
  38202. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  38203. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38205. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  38206. if !m.op.Is(OpUpdateOne) {
  38207. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  38208. }
  38209. if m.id == nil || m.oldValue == nil {
  38210. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  38211. }
  38212. oldValue, err := m.oldValue(ctx)
  38213. if err != nil {
  38214. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  38215. }
  38216. return oldValue.PhoneStatus, nil
  38217. }
  38218. // AddPhoneStatus adds i to the "phone_status" field.
  38219. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  38220. if m.addphone_status != nil {
  38221. *m.addphone_status += i
  38222. } else {
  38223. m.addphone_status = &i
  38224. }
  38225. }
  38226. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  38227. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  38228. v := m.addphone_status
  38229. if v == nil {
  38230. return
  38231. }
  38232. return *v, true
  38233. }
  38234. // ResetPhoneStatus resets all changes to the "phone_status" field.
  38235. func (m *WhatsappMutation) ResetPhoneStatus() {
  38236. m.phone_status = nil
  38237. m.addphone_status = nil
  38238. }
  38239. // SetOrganizationID sets the "organization_id" field.
  38240. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  38241. m.organization_id = &u
  38242. m.addorganization_id = nil
  38243. }
  38244. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38245. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  38246. v := m.organization_id
  38247. if v == nil {
  38248. return
  38249. }
  38250. return *v, true
  38251. }
  38252. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  38253. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38255. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38256. if !m.op.Is(OpUpdateOne) {
  38257. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38258. }
  38259. if m.id == nil || m.oldValue == nil {
  38260. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38261. }
  38262. oldValue, err := m.oldValue(ctx)
  38263. if err != nil {
  38264. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38265. }
  38266. return oldValue.OrganizationID, nil
  38267. }
  38268. // AddOrganizationID adds u to the "organization_id" field.
  38269. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  38270. if m.addorganization_id != nil {
  38271. *m.addorganization_id += u
  38272. } else {
  38273. m.addorganization_id = &u
  38274. }
  38275. }
  38276. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38277. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  38278. v := m.addorganization_id
  38279. if v == nil {
  38280. return
  38281. }
  38282. return *v, true
  38283. }
  38284. // ClearOrganizationID clears the value of the "organization_id" field.
  38285. func (m *WhatsappMutation) ClearOrganizationID() {
  38286. m.organization_id = nil
  38287. m.addorganization_id = nil
  38288. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  38289. }
  38290. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38291. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  38292. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  38293. return ok
  38294. }
  38295. // ResetOrganizationID resets all changes to the "organization_id" field.
  38296. func (m *WhatsappMutation) ResetOrganizationID() {
  38297. m.organization_id = nil
  38298. m.addorganization_id = nil
  38299. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  38300. }
  38301. // SetAPIBase sets the "api_base" field.
  38302. func (m *WhatsappMutation) SetAPIBase(s string) {
  38303. m.api_base = &s
  38304. }
  38305. // APIBase returns the value of the "api_base" field in the mutation.
  38306. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  38307. v := m.api_base
  38308. if v == nil {
  38309. return
  38310. }
  38311. return *v, true
  38312. }
  38313. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  38314. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38316. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38317. if !m.op.Is(OpUpdateOne) {
  38318. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38319. }
  38320. if m.id == nil || m.oldValue == nil {
  38321. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38322. }
  38323. oldValue, err := m.oldValue(ctx)
  38324. if err != nil {
  38325. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38326. }
  38327. return oldValue.APIBase, nil
  38328. }
  38329. // ClearAPIBase clears the value of the "api_base" field.
  38330. func (m *WhatsappMutation) ClearAPIBase() {
  38331. m.api_base = nil
  38332. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  38333. }
  38334. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38335. func (m *WhatsappMutation) APIBaseCleared() bool {
  38336. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  38337. return ok
  38338. }
  38339. // ResetAPIBase resets all changes to the "api_base" field.
  38340. func (m *WhatsappMutation) ResetAPIBase() {
  38341. m.api_base = nil
  38342. delete(m.clearedFields, whatsapp.FieldAPIBase)
  38343. }
  38344. // SetAPIKey sets the "api_key" field.
  38345. func (m *WhatsappMutation) SetAPIKey(s string) {
  38346. m.api_key = &s
  38347. }
  38348. // APIKey returns the value of the "api_key" field in the mutation.
  38349. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  38350. v := m.api_key
  38351. if v == nil {
  38352. return
  38353. }
  38354. return *v, true
  38355. }
  38356. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  38357. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38359. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38360. if !m.op.Is(OpUpdateOne) {
  38361. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38362. }
  38363. if m.id == nil || m.oldValue == nil {
  38364. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38365. }
  38366. oldValue, err := m.oldValue(ctx)
  38367. if err != nil {
  38368. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38369. }
  38370. return oldValue.APIKey, nil
  38371. }
  38372. // ClearAPIKey clears the value of the "api_key" field.
  38373. func (m *WhatsappMutation) ClearAPIKey() {
  38374. m.api_key = nil
  38375. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  38376. }
  38377. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38378. func (m *WhatsappMutation) APIKeyCleared() bool {
  38379. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  38380. return ok
  38381. }
  38382. // ResetAPIKey resets all changes to the "api_key" field.
  38383. func (m *WhatsappMutation) ResetAPIKey() {
  38384. m.api_key = nil
  38385. delete(m.clearedFields, whatsapp.FieldAPIKey)
  38386. }
  38387. // SetAllowList sets the "allow_list" field.
  38388. func (m *WhatsappMutation) SetAllowList(s []string) {
  38389. m.allow_list = &s
  38390. m.appendallow_list = nil
  38391. }
  38392. // AllowList returns the value of the "allow_list" field in the mutation.
  38393. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  38394. v := m.allow_list
  38395. if v == nil {
  38396. return
  38397. }
  38398. return *v, true
  38399. }
  38400. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  38401. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38403. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38404. if !m.op.Is(OpUpdateOne) {
  38405. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38406. }
  38407. if m.id == nil || m.oldValue == nil {
  38408. return v, errors.New("OldAllowList requires an ID field in the mutation")
  38409. }
  38410. oldValue, err := m.oldValue(ctx)
  38411. if err != nil {
  38412. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  38413. }
  38414. return oldValue.AllowList, nil
  38415. }
  38416. // AppendAllowList adds s to the "allow_list" field.
  38417. func (m *WhatsappMutation) AppendAllowList(s []string) {
  38418. m.appendallow_list = append(m.appendallow_list, s...)
  38419. }
  38420. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  38421. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  38422. if len(m.appendallow_list) == 0 {
  38423. return nil, false
  38424. }
  38425. return m.appendallow_list, true
  38426. }
  38427. // ClearAllowList clears the value of the "allow_list" field.
  38428. func (m *WhatsappMutation) ClearAllowList() {
  38429. m.allow_list = nil
  38430. m.appendallow_list = nil
  38431. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  38432. }
  38433. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  38434. func (m *WhatsappMutation) AllowListCleared() bool {
  38435. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  38436. return ok
  38437. }
  38438. // ResetAllowList resets all changes to the "allow_list" field.
  38439. func (m *WhatsappMutation) ResetAllowList() {
  38440. m.allow_list = nil
  38441. m.appendallow_list = nil
  38442. delete(m.clearedFields, whatsapp.FieldAllowList)
  38443. }
  38444. // SetGroupAllowList sets the "group_allow_list" field.
  38445. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  38446. m.group_allow_list = &s
  38447. m.appendgroup_allow_list = nil
  38448. }
  38449. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  38450. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  38451. v := m.group_allow_list
  38452. if v == nil {
  38453. return
  38454. }
  38455. return *v, true
  38456. }
  38457. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  38458. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38460. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  38461. if !m.op.Is(OpUpdateOne) {
  38462. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  38463. }
  38464. if m.id == nil || m.oldValue == nil {
  38465. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  38466. }
  38467. oldValue, err := m.oldValue(ctx)
  38468. if err != nil {
  38469. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  38470. }
  38471. return oldValue.GroupAllowList, nil
  38472. }
  38473. // AppendGroupAllowList adds s to the "group_allow_list" field.
  38474. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  38475. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  38476. }
  38477. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  38478. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  38479. if len(m.appendgroup_allow_list) == 0 {
  38480. return nil, false
  38481. }
  38482. return m.appendgroup_allow_list, true
  38483. }
  38484. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  38485. func (m *WhatsappMutation) ClearGroupAllowList() {
  38486. m.group_allow_list = nil
  38487. m.appendgroup_allow_list = nil
  38488. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  38489. }
  38490. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  38491. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  38492. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  38493. return ok
  38494. }
  38495. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  38496. func (m *WhatsappMutation) ResetGroupAllowList() {
  38497. m.group_allow_list = nil
  38498. m.appendgroup_allow_list = nil
  38499. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  38500. }
  38501. // SetBlockList sets the "block_list" field.
  38502. func (m *WhatsappMutation) SetBlockList(s []string) {
  38503. m.block_list = &s
  38504. m.appendblock_list = nil
  38505. }
  38506. // BlockList returns the value of the "block_list" field in the mutation.
  38507. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  38508. v := m.block_list
  38509. if v == nil {
  38510. return
  38511. }
  38512. return *v, true
  38513. }
  38514. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  38515. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38517. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38518. if !m.op.Is(OpUpdateOne) {
  38519. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38520. }
  38521. if m.id == nil || m.oldValue == nil {
  38522. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38523. }
  38524. oldValue, err := m.oldValue(ctx)
  38525. if err != nil {
  38526. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38527. }
  38528. return oldValue.BlockList, nil
  38529. }
  38530. // AppendBlockList adds s to the "block_list" field.
  38531. func (m *WhatsappMutation) AppendBlockList(s []string) {
  38532. m.appendblock_list = append(m.appendblock_list, s...)
  38533. }
  38534. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38535. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  38536. if len(m.appendblock_list) == 0 {
  38537. return nil, false
  38538. }
  38539. return m.appendblock_list, true
  38540. }
  38541. // ClearBlockList clears the value of the "block_list" field.
  38542. func (m *WhatsappMutation) ClearBlockList() {
  38543. m.block_list = nil
  38544. m.appendblock_list = nil
  38545. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  38546. }
  38547. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  38548. func (m *WhatsappMutation) BlockListCleared() bool {
  38549. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  38550. return ok
  38551. }
  38552. // ResetBlockList resets all changes to the "block_list" field.
  38553. func (m *WhatsappMutation) ResetBlockList() {
  38554. m.block_list = nil
  38555. m.appendblock_list = nil
  38556. delete(m.clearedFields, whatsapp.FieldBlockList)
  38557. }
  38558. // SetGroupBlockList sets the "group_block_list" field.
  38559. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  38560. m.group_block_list = &s
  38561. m.appendgroup_block_list = nil
  38562. }
  38563. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38564. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  38565. v := m.group_block_list
  38566. if v == nil {
  38567. return
  38568. }
  38569. return *v, true
  38570. }
  38571. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  38572. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38574. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38575. if !m.op.Is(OpUpdateOne) {
  38576. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38577. }
  38578. if m.id == nil || m.oldValue == nil {
  38579. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38580. }
  38581. oldValue, err := m.oldValue(ctx)
  38582. if err != nil {
  38583. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38584. }
  38585. return oldValue.GroupBlockList, nil
  38586. }
  38587. // AppendGroupBlockList adds s to the "group_block_list" field.
  38588. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  38589. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38590. }
  38591. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38592. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  38593. if len(m.appendgroup_block_list) == 0 {
  38594. return nil, false
  38595. }
  38596. return m.appendgroup_block_list, true
  38597. }
  38598. // ClearGroupBlockList clears the value of the "group_block_list" field.
  38599. func (m *WhatsappMutation) ClearGroupBlockList() {
  38600. m.group_block_list = nil
  38601. m.appendgroup_block_list = nil
  38602. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  38603. }
  38604. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  38605. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  38606. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  38607. return ok
  38608. }
  38609. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38610. func (m *WhatsappMutation) ResetGroupBlockList() {
  38611. m.group_block_list = nil
  38612. m.appendgroup_block_list = nil
  38613. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  38614. }
  38615. // ClearAgent clears the "agent" edge to the Agent entity.
  38616. func (m *WhatsappMutation) ClearAgent() {
  38617. m.clearedagent = true
  38618. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  38619. }
  38620. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38621. func (m *WhatsappMutation) AgentCleared() bool {
  38622. return m.clearedagent
  38623. }
  38624. // AgentIDs returns the "agent" edge IDs in the mutation.
  38625. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38626. // AgentID instead. It exists only for internal usage by the builders.
  38627. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  38628. if id := m.agent; id != nil {
  38629. ids = append(ids, *id)
  38630. }
  38631. return
  38632. }
  38633. // ResetAgent resets all changes to the "agent" edge.
  38634. func (m *WhatsappMutation) ResetAgent() {
  38635. m.agent = nil
  38636. m.clearedagent = false
  38637. }
  38638. // Where appends a list predicates to the WhatsappMutation builder.
  38639. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  38640. m.predicates = append(m.predicates, ps...)
  38641. }
  38642. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  38643. // users can use type-assertion to append predicates that do not depend on any generated package.
  38644. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  38645. p := make([]predicate.Whatsapp, len(ps))
  38646. for i := range ps {
  38647. p[i] = ps[i]
  38648. }
  38649. m.Where(p...)
  38650. }
  38651. // Op returns the operation name.
  38652. func (m *WhatsappMutation) Op() Op {
  38653. return m.op
  38654. }
  38655. // SetOp allows setting the mutation operation.
  38656. func (m *WhatsappMutation) SetOp(op Op) {
  38657. m.op = op
  38658. }
  38659. // Type returns the node type of this mutation (Whatsapp).
  38660. func (m *WhatsappMutation) Type() string {
  38661. return m.typ
  38662. }
  38663. // Fields returns all fields that were changed during this mutation. Note that in
  38664. // order to get all numeric fields that were incremented/decremented, call
  38665. // AddedFields().
  38666. func (m *WhatsappMutation) Fields() []string {
  38667. fields := make([]string, 0, 21)
  38668. if m.created_at != nil {
  38669. fields = append(fields, whatsapp.FieldCreatedAt)
  38670. }
  38671. if m.updated_at != nil {
  38672. fields = append(fields, whatsapp.FieldUpdatedAt)
  38673. }
  38674. if m.status != nil {
  38675. fields = append(fields, whatsapp.FieldStatus)
  38676. }
  38677. if m.deleted_at != nil {
  38678. fields = append(fields, whatsapp.FieldDeletedAt)
  38679. }
  38680. if m.wa_id != nil {
  38681. fields = append(fields, whatsapp.FieldWaID)
  38682. }
  38683. if m.wa_name != nil {
  38684. fields = append(fields, whatsapp.FieldWaName)
  38685. }
  38686. if m.callback != nil {
  38687. fields = append(fields, whatsapp.FieldCallback)
  38688. }
  38689. if m.agent != nil {
  38690. fields = append(fields, whatsapp.FieldAgentID)
  38691. }
  38692. if m.account != nil {
  38693. fields = append(fields, whatsapp.FieldAccount)
  38694. }
  38695. if m.cc != nil {
  38696. fields = append(fields, whatsapp.FieldCc)
  38697. }
  38698. if m.phone != nil {
  38699. fields = append(fields, whatsapp.FieldPhone)
  38700. }
  38701. if m.cc_phone != nil {
  38702. fields = append(fields, whatsapp.FieldCcPhone)
  38703. }
  38704. if m.phone_name != nil {
  38705. fields = append(fields, whatsapp.FieldPhoneName)
  38706. }
  38707. if m.phone_status != nil {
  38708. fields = append(fields, whatsapp.FieldPhoneStatus)
  38709. }
  38710. if m.organization_id != nil {
  38711. fields = append(fields, whatsapp.FieldOrganizationID)
  38712. }
  38713. if m.api_base != nil {
  38714. fields = append(fields, whatsapp.FieldAPIBase)
  38715. }
  38716. if m.api_key != nil {
  38717. fields = append(fields, whatsapp.FieldAPIKey)
  38718. }
  38719. if m.allow_list != nil {
  38720. fields = append(fields, whatsapp.FieldAllowList)
  38721. }
  38722. if m.group_allow_list != nil {
  38723. fields = append(fields, whatsapp.FieldGroupAllowList)
  38724. }
  38725. if m.block_list != nil {
  38726. fields = append(fields, whatsapp.FieldBlockList)
  38727. }
  38728. if m.group_block_list != nil {
  38729. fields = append(fields, whatsapp.FieldGroupBlockList)
  38730. }
  38731. return fields
  38732. }
  38733. // Field returns the value of a field with the given name. The second boolean
  38734. // return value indicates that this field was not set, or was not defined in the
  38735. // schema.
  38736. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  38737. switch name {
  38738. case whatsapp.FieldCreatedAt:
  38739. return m.CreatedAt()
  38740. case whatsapp.FieldUpdatedAt:
  38741. return m.UpdatedAt()
  38742. case whatsapp.FieldStatus:
  38743. return m.Status()
  38744. case whatsapp.FieldDeletedAt:
  38745. return m.DeletedAt()
  38746. case whatsapp.FieldWaID:
  38747. return m.WaID()
  38748. case whatsapp.FieldWaName:
  38749. return m.WaName()
  38750. case whatsapp.FieldCallback:
  38751. return m.Callback()
  38752. case whatsapp.FieldAgentID:
  38753. return m.AgentID()
  38754. case whatsapp.FieldAccount:
  38755. return m.Account()
  38756. case whatsapp.FieldCc:
  38757. return m.Cc()
  38758. case whatsapp.FieldPhone:
  38759. return m.Phone()
  38760. case whatsapp.FieldCcPhone:
  38761. return m.CcPhone()
  38762. case whatsapp.FieldPhoneName:
  38763. return m.PhoneName()
  38764. case whatsapp.FieldPhoneStatus:
  38765. return m.PhoneStatus()
  38766. case whatsapp.FieldOrganizationID:
  38767. return m.OrganizationID()
  38768. case whatsapp.FieldAPIBase:
  38769. return m.APIBase()
  38770. case whatsapp.FieldAPIKey:
  38771. return m.APIKey()
  38772. case whatsapp.FieldAllowList:
  38773. return m.AllowList()
  38774. case whatsapp.FieldGroupAllowList:
  38775. return m.GroupAllowList()
  38776. case whatsapp.FieldBlockList:
  38777. return m.BlockList()
  38778. case whatsapp.FieldGroupBlockList:
  38779. return m.GroupBlockList()
  38780. }
  38781. return nil, false
  38782. }
  38783. // OldField returns the old value of the field from the database. An error is
  38784. // returned if the mutation operation is not UpdateOne, or the query to the
  38785. // database failed.
  38786. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38787. switch name {
  38788. case whatsapp.FieldCreatedAt:
  38789. return m.OldCreatedAt(ctx)
  38790. case whatsapp.FieldUpdatedAt:
  38791. return m.OldUpdatedAt(ctx)
  38792. case whatsapp.FieldStatus:
  38793. return m.OldStatus(ctx)
  38794. case whatsapp.FieldDeletedAt:
  38795. return m.OldDeletedAt(ctx)
  38796. case whatsapp.FieldWaID:
  38797. return m.OldWaID(ctx)
  38798. case whatsapp.FieldWaName:
  38799. return m.OldWaName(ctx)
  38800. case whatsapp.FieldCallback:
  38801. return m.OldCallback(ctx)
  38802. case whatsapp.FieldAgentID:
  38803. return m.OldAgentID(ctx)
  38804. case whatsapp.FieldAccount:
  38805. return m.OldAccount(ctx)
  38806. case whatsapp.FieldCc:
  38807. return m.OldCc(ctx)
  38808. case whatsapp.FieldPhone:
  38809. return m.OldPhone(ctx)
  38810. case whatsapp.FieldCcPhone:
  38811. return m.OldCcPhone(ctx)
  38812. case whatsapp.FieldPhoneName:
  38813. return m.OldPhoneName(ctx)
  38814. case whatsapp.FieldPhoneStatus:
  38815. return m.OldPhoneStatus(ctx)
  38816. case whatsapp.FieldOrganizationID:
  38817. return m.OldOrganizationID(ctx)
  38818. case whatsapp.FieldAPIBase:
  38819. return m.OldAPIBase(ctx)
  38820. case whatsapp.FieldAPIKey:
  38821. return m.OldAPIKey(ctx)
  38822. case whatsapp.FieldAllowList:
  38823. return m.OldAllowList(ctx)
  38824. case whatsapp.FieldGroupAllowList:
  38825. return m.OldGroupAllowList(ctx)
  38826. case whatsapp.FieldBlockList:
  38827. return m.OldBlockList(ctx)
  38828. case whatsapp.FieldGroupBlockList:
  38829. return m.OldGroupBlockList(ctx)
  38830. }
  38831. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  38832. }
  38833. // SetField sets the value of a field with the given name. It returns an error if
  38834. // the field is not defined in the schema, or if the type mismatched the field
  38835. // type.
  38836. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  38837. switch name {
  38838. case whatsapp.FieldCreatedAt:
  38839. v, ok := value.(time.Time)
  38840. if !ok {
  38841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38842. }
  38843. m.SetCreatedAt(v)
  38844. return nil
  38845. case whatsapp.FieldUpdatedAt:
  38846. v, ok := value.(time.Time)
  38847. if !ok {
  38848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38849. }
  38850. m.SetUpdatedAt(v)
  38851. return nil
  38852. case whatsapp.FieldStatus:
  38853. v, ok := value.(uint8)
  38854. if !ok {
  38855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38856. }
  38857. m.SetStatus(v)
  38858. return nil
  38859. case whatsapp.FieldDeletedAt:
  38860. v, ok := value.(time.Time)
  38861. if !ok {
  38862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38863. }
  38864. m.SetDeletedAt(v)
  38865. return nil
  38866. case whatsapp.FieldWaID:
  38867. v, ok := value.(string)
  38868. if !ok {
  38869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38870. }
  38871. m.SetWaID(v)
  38872. return nil
  38873. case whatsapp.FieldWaName:
  38874. v, ok := value.(string)
  38875. if !ok {
  38876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38877. }
  38878. m.SetWaName(v)
  38879. return nil
  38880. case whatsapp.FieldCallback:
  38881. v, ok := value.(string)
  38882. if !ok {
  38883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38884. }
  38885. m.SetCallback(v)
  38886. return nil
  38887. case whatsapp.FieldAgentID:
  38888. v, ok := value.(uint64)
  38889. if !ok {
  38890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38891. }
  38892. m.SetAgentID(v)
  38893. return nil
  38894. case whatsapp.FieldAccount:
  38895. v, ok := value.(string)
  38896. if !ok {
  38897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38898. }
  38899. m.SetAccount(v)
  38900. return nil
  38901. case whatsapp.FieldCc:
  38902. v, ok := value.(string)
  38903. if !ok {
  38904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38905. }
  38906. m.SetCc(v)
  38907. return nil
  38908. case whatsapp.FieldPhone:
  38909. v, ok := value.(string)
  38910. if !ok {
  38911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38912. }
  38913. m.SetPhone(v)
  38914. return nil
  38915. case whatsapp.FieldCcPhone:
  38916. v, ok := value.(string)
  38917. if !ok {
  38918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38919. }
  38920. m.SetCcPhone(v)
  38921. return nil
  38922. case whatsapp.FieldPhoneName:
  38923. v, ok := value.(string)
  38924. if !ok {
  38925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38926. }
  38927. m.SetPhoneName(v)
  38928. return nil
  38929. case whatsapp.FieldPhoneStatus:
  38930. v, ok := value.(int8)
  38931. if !ok {
  38932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38933. }
  38934. m.SetPhoneStatus(v)
  38935. return nil
  38936. case whatsapp.FieldOrganizationID:
  38937. v, ok := value.(uint64)
  38938. if !ok {
  38939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38940. }
  38941. m.SetOrganizationID(v)
  38942. return nil
  38943. case whatsapp.FieldAPIBase:
  38944. v, ok := value.(string)
  38945. if !ok {
  38946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38947. }
  38948. m.SetAPIBase(v)
  38949. return nil
  38950. case whatsapp.FieldAPIKey:
  38951. v, ok := value.(string)
  38952. if !ok {
  38953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38954. }
  38955. m.SetAPIKey(v)
  38956. return nil
  38957. case whatsapp.FieldAllowList:
  38958. v, ok := value.([]string)
  38959. if !ok {
  38960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38961. }
  38962. m.SetAllowList(v)
  38963. return nil
  38964. case whatsapp.FieldGroupAllowList:
  38965. v, ok := value.([]string)
  38966. if !ok {
  38967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38968. }
  38969. m.SetGroupAllowList(v)
  38970. return nil
  38971. case whatsapp.FieldBlockList:
  38972. v, ok := value.([]string)
  38973. if !ok {
  38974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38975. }
  38976. m.SetBlockList(v)
  38977. return nil
  38978. case whatsapp.FieldGroupBlockList:
  38979. v, ok := value.([]string)
  38980. if !ok {
  38981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38982. }
  38983. m.SetGroupBlockList(v)
  38984. return nil
  38985. }
  38986. return fmt.Errorf("unknown Whatsapp field %s", name)
  38987. }
  38988. // AddedFields returns all numeric fields that were incremented/decremented during
  38989. // this mutation.
  38990. func (m *WhatsappMutation) AddedFields() []string {
  38991. var fields []string
  38992. if m.addstatus != nil {
  38993. fields = append(fields, whatsapp.FieldStatus)
  38994. }
  38995. if m.addphone_status != nil {
  38996. fields = append(fields, whatsapp.FieldPhoneStatus)
  38997. }
  38998. if m.addorganization_id != nil {
  38999. fields = append(fields, whatsapp.FieldOrganizationID)
  39000. }
  39001. return fields
  39002. }
  39003. // AddedField returns the numeric value that was incremented/decremented on a field
  39004. // with the given name. The second boolean return value indicates that this field
  39005. // was not set, or was not defined in the schema.
  39006. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  39007. switch name {
  39008. case whatsapp.FieldStatus:
  39009. return m.AddedStatus()
  39010. case whatsapp.FieldPhoneStatus:
  39011. return m.AddedPhoneStatus()
  39012. case whatsapp.FieldOrganizationID:
  39013. return m.AddedOrganizationID()
  39014. }
  39015. return nil, false
  39016. }
  39017. // AddField adds the value to the field with the given name. It returns an error if
  39018. // the field is not defined in the schema, or if the type mismatched the field
  39019. // type.
  39020. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  39021. switch name {
  39022. case whatsapp.FieldStatus:
  39023. v, ok := value.(int8)
  39024. if !ok {
  39025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39026. }
  39027. m.AddStatus(v)
  39028. return nil
  39029. case whatsapp.FieldPhoneStatus:
  39030. v, ok := value.(int8)
  39031. if !ok {
  39032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39033. }
  39034. m.AddPhoneStatus(v)
  39035. return nil
  39036. case whatsapp.FieldOrganizationID:
  39037. v, ok := value.(int64)
  39038. if !ok {
  39039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39040. }
  39041. m.AddOrganizationID(v)
  39042. return nil
  39043. }
  39044. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  39045. }
  39046. // ClearedFields returns all nullable fields that were cleared during this
  39047. // mutation.
  39048. func (m *WhatsappMutation) ClearedFields() []string {
  39049. var fields []string
  39050. if m.FieldCleared(whatsapp.FieldStatus) {
  39051. fields = append(fields, whatsapp.FieldStatus)
  39052. }
  39053. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  39054. fields = append(fields, whatsapp.FieldDeletedAt)
  39055. }
  39056. if m.FieldCleared(whatsapp.FieldWaID) {
  39057. fields = append(fields, whatsapp.FieldWaID)
  39058. }
  39059. if m.FieldCleared(whatsapp.FieldWaName) {
  39060. fields = append(fields, whatsapp.FieldWaName)
  39061. }
  39062. if m.FieldCleared(whatsapp.FieldCallback) {
  39063. fields = append(fields, whatsapp.FieldCallback)
  39064. }
  39065. if m.FieldCleared(whatsapp.FieldAccount) {
  39066. fields = append(fields, whatsapp.FieldAccount)
  39067. }
  39068. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  39069. fields = append(fields, whatsapp.FieldOrganizationID)
  39070. }
  39071. if m.FieldCleared(whatsapp.FieldAPIBase) {
  39072. fields = append(fields, whatsapp.FieldAPIBase)
  39073. }
  39074. if m.FieldCleared(whatsapp.FieldAPIKey) {
  39075. fields = append(fields, whatsapp.FieldAPIKey)
  39076. }
  39077. if m.FieldCleared(whatsapp.FieldAllowList) {
  39078. fields = append(fields, whatsapp.FieldAllowList)
  39079. }
  39080. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  39081. fields = append(fields, whatsapp.FieldGroupAllowList)
  39082. }
  39083. if m.FieldCleared(whatsapp.FieldBlockList) {
  39084. fields = append(fields, whatsapp.FieldBlockList)
  39085. }
  39086. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  39087. fields = append(fields, whatsapp.FieldGroupBlockList)
  39088. }
  39089. return fields
  39090. }
  39091. // FieldCleared returns a boolean indicating if a field with the given name was
  39092. // cleared in this mutation.
  39093. func (m *WhatsappMutation) FieldCleared(name string) bool {
  39094. _, ok := m.clearedFields[name]
  39095. return ok
  39096. }
  39097. // ClearField clears the value of the field with the given name. It returns an
  39098. // error if the field is not defined in the schema.
  39099. func (m *WhatsappMutation) ClearField(name string) error {
  39100. switch name {
  39101. case whatsapp.FieldStatus:
  39102. m.ClearStatus()
  39103. return nil
  39104. case whatsapp.FieldDeletedAt:
  39105. m.ClearDeletedAt()
  39106. return nil
  39107. case whatsapp.FieldWaID:
  39108. m.ClearWaID()
  39109. return nil
  39110. case whatsapp.FieldWaName:
  39111. m.ClearWaName()
  39112. return nil
  39113. case whatsapp.FieldCallback:
  39114. m.ClearCallback()
  39115. return nil
  39116. case whatsapp.FieldAccount:
  39117. m.ClearAccount()
  39118. return nil
  39119. case whatsapp.FieldOrganizationID:
  39120. m.ClearOrganizationID()
  39121. return nil
  39122. case whatsapp.FieldAPIBase:
  39123. m.ClearAPIBase()
  39124. return nil
  39125. case whatsapp.FieldAPIKey:
  39126. m.ClearAPIKey()
  39127. return nil
  39128. case whatsapp.FieldAllowList:
  39129. m.ClearAllowList()
  39130. return nil
  39131. case whatsapp.FieldGroupAllowList:
  39132. m.ClearGroupAllowList()
  39133. return nil
  39134. case whatsapp.FieldBlockList:
  39135. m.ClearBlockList()
  39136. return nil
  39137. case whatsapp.FieldGroupBlockList:
  39138. m.ClearGroupBlockList()
  39139. return nil
  39140. }
  39141. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  39142. }
  39143. // ResetField resets all changes in the mutation for the field with the given name.
  39144. // It returns an error if the field is not defined in the schema.
  39145. func (m *WhatsappMutation) ResetField(name string) error {
  39146. switch name {
  39147. case whatsapp.FieldCreatedAt:
  39148. m.ResetCreatedAt()
  39149. return nil
  39150. case whatsapp.FieldUpdatedAt:
  39151. m.ResetUpdatedAt()
  39152. return nil
  39153. case whatsapp.FieldStatus:
  39154. m.ResetStatus()
  39155. return nil
  39156. case whatsapp.FieldDeletedAt:
  39157. m.ResetDeletedAt()
  39158. return nil
  39159. case whatsapp.FieldWaID:
  39160. m.ResetWaID()
  39161. return nil
  39162. case whatsapp.FieldWaName:
  39163. m.ResetWaName()
  39164. return nil
  39165. case whatsapp.FieldCallback:
  39166. m.ResetCallback()
  39167. return nil
  39168. case whatsapp.FieldAgentID:
  39169. m.ResetAgentID()
  39170. return nil
  39171. case whatsapp.FieldAccount:
  39172. m.ResetAccount()
  39173. return nil
  39174. case whatsapp.FieldCc:
  39175. m.ResetCc()
  39176. return nil
  39177. case whatsapp.FieldPhone:
  39178. m.ResetPhone()
  39179. return nil
  39180. case whatsapp.FieldCcPhone:
  39181. m.ResetCcPhone()
  39182. return nil
  39183. case whatsapp.FieldPhoneName:
  39184. m.ResetPhoneName()
  39185. return nil
  39186. case whatsapp.FieldPhoneStatus:
  39187. m.ResetPhoneStatus()
  39188. return nil
  39189. case whatsapp.FieldOrganizationID:
  39190. m.ResetOrganizationID()
  39191. return nil
  39192. case whatsapp.FieldAPIBase:
  39193. m.ResetAPIBase()
  39194. return nil
  39195. case whatsapp.FieldAPIKey:
  39196. m.ResetAPIKey()
  39197. return nil
  39198. case whatsapp.FieldAllowList:
  39199. m.ResetAllowList()
  39200. return nil
  39201. case whatsapp.FieldGroupAllowList:
  39202. m.ResetGroupAllowList()
  39203. return nil
  39204. case whatsapp.FieldBlockList:
  39205. m.ResetBlockList()
  39206. return nil
  39207. case whatsapp.FieldGroupBlockList:
  39208. m.ResetGroupBlockList()
  39209. return nil
  39210. }
  39211. return fmt.Errorf("unknown Whatsapp field %s", name)
  39212. }
  39213. // AddedEdges returns all edge names that were set/added in this mutation.
  39214. func (m *WhatsappMutation) AddedEdges() []string {
  39215. edges := make([]string, 0, 1)
  39216. if m.agent != nil {
  39217. edges = append(edges, whatsapp.EdgeAgent)
  39218. }
  39219. return edges
  39220. }
  39221. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39222. // name in this mutation.
  39223. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  39224. switch name {
  39225. case whatsapp.EdgeAgent:
  39226. if id := m.agent; id != nil {
  39227. return []ent.Value{*id}
  39228. }
  39229. }
  39230. return nil
  39231. }
  39232. // RemovedEdges returns all edge names that were removed in this mutation.
  39233. func (m *WhatsappMutation) RemovedEdges() []string {
  39234. edges := make([]string, 0, 1)
  39235. return edges
  39236. }
  39237. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39238. // the given name in this mutation.
  39239. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  39240. return nil
  39241. }
  39242. // ClearedEdges returns all edge names that were cleared in this mutation.
  39243. func (m *WhatsappMutation) ClearedEdges() []string {
  39244. edges := make([]string, 0, 1)
  39245. if m.clearedagent {
  39246. edges = append(edges, whatsapp.EdgeAgent)
  39247. }
  39248. return edges
  39249. }
  39250. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39251. // was cleared in this mutation.
  39252. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  39253. switch name {
  39254. case whatsapp.EdgeAgent:
  39255. return m.clearedagent
  39256. }
  39257. return false
  39258. }
  39259. // ClearEdge clears the value of the edge with the given name. It returns an error
  39260. // if that edge is not defined in the schema.
  39261. func (m *WhatsappMutation) ClearEdge(name string) error {
  39262. switch name {
  39263. case whatsapp.EdgeAgent:
  39264. m.ClearAgent()
  39265. return nil
  39266. }
  39267. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  39268. }
  39269. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39270. // It returns an error if the edge is not defined in the schema.
  39271. func (m *WhatsappMutation) ResetEdge(name string) error {
  39272. switch name {
  39273. case whatsapp.EdgeAgent:
  39274. m.ResetAgent()
  39275. return nil
  39276. }
  39277. return fmt.Errorf("unknown Whatsapp edge %s", name)
  39278. }
  39279. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  39280. type WhatsappChannelMutation struct {
  39281. config
  39282. op Op
  39283. typ string
  39284. id *uint64
  39285. created_at *time.Time
  39286. updated_at *time.Time
  39287. status *uint8
  39288. addstatus *int8
  39289. deleted_at *time.Time
  39290. ak *string
  39291. sk *string
  39292. wa_id *string
  39293. wa_name *string
  39294. waba_id *uint64
  39295. addwaba_id *int64
  39296. business_id *uint64
  39297. addbusiness_id *int64
  39298. organization_id *uint64
  39299. addorganization_id *int64
  39300. verify_account *string
  39301. clearedFields map[string]struct{}
  39302. done bool
  39303. oldValue func(context.Context) (*WhatsappChannel, error)
  39304. predicates []predicate.WhatsappChannel
  39305. }
  39306. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  39307. // whatsappchannelOption allows management of the mutation configuration using functional options.
  39308. type whatsappchannelOption func(*WhatsappChannelMutation)
  39309. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  39310. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  39311. m := &WhatsappChannelMutation{
  39312. config: c,
  39313. op: op,
  39314. typ: TypeWhatsappChannel,
  39315. clearedFields: make(map[string]struct{}),
  39316. }
  39317. for _, opt := range opts {
  39318. opt(m)
  39319. }
  39320. return m
  39321. }
  39322. // withWhatsappChannelID sets the ID field of the mutation.
  39323. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  39324. return func(m *WhatsappChannelMutation) {
  39325. var (
  39326. err error
  39327. once sync.Once
  39328. value *WhatsappChannel
  39329. )
  39330. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  39331. once.Do(func() {
  39332. if m.done {
  39333. err = errors.New("querying old values post mutation is not allowed")
  39334. } else {
  39335. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  39336. }
  39337. })
  39338. return value, err
  39339. }
  39340. m.id = &id
  39341. }
  39342. }
  39343. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  39344. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  39345. return func(m *WhatsappChannelMutation) {
  39346. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  39347. return node, nil
  39348. }
  39349. m.id = &node.ID
  39350. }
  39351. }
  39352. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39353. // executed in a transaction (ent.Tx), a transactional client is returned.
  39354. func (m WhatsappChannelMutation) Client() *Client {
  39355. client := &Client{config: m.config}
  39356. client.init()
  39357. return client
  39358. }
  39359. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39360. // it returns an error otherwise.
  39361. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  39362. if _, ok := m.driver.(*txDriver); !ok {
  39363. return nil, errors.New("ent: mutation is not running in a transaction")
  39364. }
  39365. tx := &Tx{config: m.config}
  39366. tx.init()
  39367. return tx, nil
  39368. }
  39369. // SetID sets the value of the id field. Note that this
  39370. // operation is only accepted on creation of WhatsappChannel entities.
  39371. func (m *WhatsappChannelMutation) SetID(id uint64) {
  39372. m.id = &id
  39373. }
  39374. // ID returns the ID value in the mutation. Note that the ID is only available
  39375. // if it was provided to the builder or after it was returned from the database.
  39376. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  39377. if m.id == nil {
  39378. return
  39379. }
  39380. return *m.id, true
  39381. }
  39382. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39383. // That means, if the mutation is applied within a transaction with an isolation level such
  39384. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39385. // or updated by the mutation.
  39386. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  39387. switch {
  39388. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39389. id, exists := m.ID()
  39390. if exists {
  39391. return []uint64{id}, nil
  39392. }
  39393. fallthrough
  39394. case m.op.Is(OpUpdate | OpDelete):
  39395. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  39396. default:
  39397. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39398. }
  39399. }
  39400. // SetCreatedAt sets the "created_at" field.
  39401. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  39402. m.created_at = &t
  39403. }
  39404. // CreatedAt returns the value of the "created_at" field in the mutation.
  39405. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  39406. v := m.created_at
  39407. if v == nil {
  39408. return
  39409. }
  39410. return *v, true
  39411. }
  39412. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  39413. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39415. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39416. if !m.op.Is(OpUpdateOne) {
  39417. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39418. }
  39419. if m.id == nil || m.oldValue == nil {
  39420. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39421. }
  39422. oldValue, err := m.oldValue(ctx)
  39423. if err != nil {
  39424. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39425. }
  39426. return oldValue.CreatedAt, nil
  39427. }
  39428. // ResetCreatedAt resets all changes to the "created_at" field.
  39429. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  39430. m.created_at = nil
  39431. }
  39432. // SetUpdatedAt sets the "updated_at" field.
  39433. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  39434. m.updated_at = &t
  39435. }
  39436. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39437. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  39438. v := m.updated_at
  39439. if v == nil {
  39440. return
  39441. }
  39442. return *v, true
  39443. }
  39444. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  39445. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39447. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39448. if !m.op.Is(OpUpdateOne) {
  39449. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39450. }
  39451. if m.id == nil || m.oldValue == nil {
  39452. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39453. }
  39454. oldValue, err := m.oldValue(ctx)
  39455. if err != nil {
  39456. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39457. }
  39458. return oldValue.UpdatedAt, nil
  39459. }
  39460. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39461. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  39462. m.updated_at = nil
  39463. }
  39464. // SetStatus sets the "status" field.
  39465. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  39466. m.status = &u
  39467. m.addstatus = nil
  39468. }
  39469. // Status returns the value of the "status" field in the mutation.
  39470. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  39471. v := m.status
  39472. if v == nil {
  39473. return
  39474. }
  39475. return *v, true
  39476. }
  39477. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  39478. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39480. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39481. if !m.op.Is(OpUpdateOne) {
  39482. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39483. }
  39484. if m.id == nil || m.oldValue == nil {
  39485. return v, errors.New("OldStatus requires an ID field in the mutation")
  39486. }
  39487. oldValue, err := m.oldValue(ctx)
  39488. if err != nil {
  39489. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39490. }
  39491. return oldValue.Status, nil
  39492. }
  39493. // AddStatus adds u to the "status" field.
  39494. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  39495. if m.addstatus != nil {
  39496. *m.addstatus += u
  39497. } else {
  39498. m.addstatus = &u
  39499. }
  39500. }
  39501. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39502. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  39503. v := m.addstatus
  39504. if v == nil {
  39505. return
  39506. }
  39507. return *v, true
  39508. }
  39509. // ClearStatus clears the value of the "status" field.
  39510. func (m *WhatsappChannelMutation) ClearStatus() {
  39511. m.status = nil
  39512. m.addstatus = nil
  39513. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  39514. }
  39515. // StatusCleared returns if the "status" field was cleared in this mutation.
  39516. func (m *WhatsappChannelMutation) StatusCleared() bool {
  39517. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  39518. return ok
  39519. }
  39520. // ResetStatus resets all changes to the "status" field.
  39521. func (m *WhatsappChannelMutation) ResetStatus() {
  39522. m.status = nil
  39523. m.addstatus = nil
  39524. delete(m.clearedFields, whatsappchannel.FieldStatus)
  39525. }
  39526. // SetDeletedAt sets the "deleted_at" field.
  39527. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  39528. m.deleted_at = &t
  39529. }
  39530. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39531. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  39532. v := m.deleted_at
  39533. if v == nil {
  39534. return
  39535. }
  39536. return *v, true
  39537. }
  39538. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  39539. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39541. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39542. if !m.op.Is(OpUpdateOne) {
  39543. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39544. }
  39545. if m.id == nil || m.oldValue == nil {
  39546. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39547. }
  39548. oldValue, err := m.oldValue(ctx)
  39549. if err != nil {
  39550. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39551. }
  39552. return oldValue.DeletedAt, nil
  39553. }
  39554. // ClearDeletedAt clears the value of the "deleted_at" field.
  39555. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  39556. m.deleted_at = nil
  39557. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  39558. }
  39559. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39560. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  39561. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  39562. return ok
  39563. }
  39564. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39565. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  39566. m.deleted_at = nil
  39567. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  39568. }
  39569. // SetAk sets the "ak" field.
  39570. func (m *WhatsappChannelMutation) SetAk(s string) {
  39571. m.ak = &s
  39572. }
  39573. // Ak returns the value of the "ak" field in the mutation.
  39574. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  39575. v := m.ak
  39576. if v == nil {
  39577. return
  39578. }
  39579. return *v, true
  39580. }
  39581. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  39582. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39584. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  39585. if !m.op.Is(OpUpdateOne) {
  39586. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  39587. }
  39588. if m.id == nil || m.oldValue == nil {
  39589. return v, errors.New("OldAk requires an ID field in the mutation")
  39590. }
  39591. oldValue, err := m.oldValue(ctx)
  39592. if err != nil {
  39593. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  39594. }
  39595. return oldValue.Ak, nil
  39596. }
  39597. // ClearAk clears the value of the "ak" field.
  39598. func (m *WhatsappChannelMutation) ClearAk() {
  39599. m.ak = nil
  39600. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  39601. }
  39602. // AkCleared returns if the "ak" field was cleared in this mutation.
  39603. func (m *WhatsappChannelMutation) AkCleared() bool {
  39604. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  39605. return ok
  39606. }
  39607. // ResetAk resets all changes to the "ak" field.
  39608. func (m *WhatsappChannelMutation) ResetAk() {
  39609. m.ak = nil
  39610. delete(m.clearedFields, whatsappchannel.FieldAk)
  39611. }
  39612. // SetSk sets the "sk" field.
  39613. func (m *WhatsappChannelMutation) SetSk(s string) {
  39614. m.sk = &s
  39615. }
  39616. // Sk returns the value of the "sk" field in the mutation.
  39617. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  39618. v := m.sk
  39619. if v == nil {
  39620. return
  39621. }
  39622. return *v, true
  39623. }
  39624. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  39625. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39627. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  39628. if !m.op.Is(OpUpdateOne) {
  39629. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  39630. }
  39631. if m.id == nil || m.oldValue == nil {
  39632. return v, errors.New("OldSk requires an ID field in the mutation")
  39633. }
  39634. oldValue, err := m.oldValue(ctx)
  39635. if err != nil {
  39636. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  39637. }
  39638. return oldValue.Sk, nil
  39639. }
  39640. // ResetSk resets all changes to the "sk" field.
  39641. func (m *WhatsappChannelMutation) ResetSk() {
  39642. m.sk = nil
  39643. }
  39644. // SetWaID sets the "wa_id" field.
  39645. func (m *WhatsappChannelMutation) SetWaID(s string) {
  39646. m.wa_id = &s
  39647. }
  39648. // WaID returns the value of the "wa_id" field in the mutation.
  39649. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  39650. v := m.wa_id
  39651. if v == nil {
  39652. return
  39653. }
  39654. return *v, true
  39655. }
  39656. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  39657. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39659. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  39660. if !m.op.Is(OpUpdateOne) {
  39661. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  39662. }
  39663. if m.id == nil || m.oldValue == nil {
  39664. return v, errors.New("OldWaID requires an ID field in the mutation")
  39665. }
  39666. oldValue, err := m.oldValue(ctx)
  39667. if err != nil {
  39668. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  39669. }
  39670. return oldValue.WaID, nil
  39671. }
  39672. // ClearWaID clears the value of the "wa_id" field.
  39673. func (m *WhatsappChannelMutation) ClearWaID() {
  39674. m.wa_id = nil
  39675. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  39676. }
  39677. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  39678. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  39679. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  39680. return ok
  39681. }
  39682. // ResetWaID resets all changes to the "wa_id" field.
  39683. func (m *WhatsappChannelMutation) ResetWaID() {
  39684. m.wa_id = nil
  39685. delete(m.clearedFields, whatsappchannel.FieldWaID)
  39686. }
  39687. // SetWaName sets the "wa_name" field.
  39688. func (m *WhatsappChannelMutation) SetWaName(s string) {
  39689. m.wa_name = &s
  39690. }
  39691. // WaName returns the value of the "wa_name" field in the mutation.
  39692. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  39693. v := m.wa_name
  39694. if v == nil {
  39695. return
  39696. }
  39697. return *v, true
  39698. }
  39699. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  39700. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39702. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  39703. if !m.op.Is(OpUpdateOne) {
  39704. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  39705. }
  39706. if m.id == nil || m.oldValue == nil {
  39707. return v, errors.New("OldWaName requires an ID field in the mutation")
  39708. }
  39709. oldValue, err := m.oldValue(ctx)
  39710. if err != nil {
  39711. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  39712. }
  39713. return oldValue.WaName, nil
  39714. }
  39715. // ClearWaName clears the value of the "wa_name" field.
  39716. func (m *WhatsappChannelMutation) ClearWaName() {
  39717. m.wa_name = nil
  39718. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  39719. }
  39720. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  39721. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  39722. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  39723. return ok
  39724. }
  39725. // ResetWaName resets all changes to the "wa_name" field.
  39726. func (m *WhatsappChannelMutation) ResetWaName() {
  39727. m.wa_name = nil
  39728. delete(m.clearedFields, whatsappchannel.FieldWaName)
  39729. }
  39730. // SetWabaID sets the "waba_id" field.
  39731. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  39732. m.waba_id = &u
  39733. m.addwaba_id = nil
  39734. }
  39735. // WabaID returns the value of the "waba_id" field in the mutation.
  39736. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  39737. v := m.waba_id
  39738. if v == nil {
  39739. return
  39740. }
  39741. return *v, true
  39742. }
  39743. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  39744. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39746. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  39747. if !m.op.Is(OpUpdateOne) {
  39748. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  39749. }
  39750. if m.id == nil || m.oldValue == nil {
  39751. return v, errors.New("OldWabaID requires an ID field in the mutation")
  39752. }
  39753. oldValue, err := m.oldValue(ctx)
  39754. if err != nil {
  39755. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  39756. }
  39757. return oldValue.WabaID, nil
  39758. }
  39759. // AddWabaID adds u to the "waba_id" field.
  39760. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  39761. if m.addwaba_id != nil {
  39762. *m.addwaba_id += u
  39763. } else {
  39764. m.addwaba_id = &u
  39765. }
  39766. }
  39767. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  39768. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  39769. v := m.addwaba_id
  39770. if v == nil {
  39771. return
  39772. }
  39773. return *v, true
  39774. }
  39775. // ResetWabaID resets all changes to the "waba_id" field.
  39776. func (m *WhatsappChannelMutation) ResetWabaID() {
  39777. m.waba_id = nil
  39778. m.addwaba_id = nil
  39779. }
  39780. // SetBusinessID sets the "business_id" field.
  39781. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  39782. m.business_id = &u
  39783. m.addbusiness_id = nil
  39784. }
  39785. // BusinessID returns the value of the "business_id" field in the mutation.
  39786. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  39787. v := m.business_id
  39788. if v == nil {
  39789. return
  39790. }
  39791. return *v, true
  39792. }
  39793. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  39794. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39796. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  39797. if !m.op.Is(OpUpdateOne) {
  39798. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  39799. }
  39800. if m.id == nil || m.oldValue == nil {
  39801. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  39802. }
  39803. oldValue, err := m.oldValue(ctx)
  39804. if err != nil {
  39805. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  39806. }
  39807. return oldValue.BusinessID, nil
  39808. }
  39809. // AddBusinessID adds u to the "business_id" field.
  39810. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  39811. if m.addbusiness_id != nil {
  39812. *m.addbusiness_id += u
  39813. } else {
  39814. m.addbusiness_id = &u
  39815. }
  39816. }
  39817. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  39818. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  39819. v := m.addbusiness_id
  39820. if v == nil {
  39821. return
  39822. }
  39823. return *v, true
  39824. }
  39825. // ResetBusinessID resets all changes to the "business_id" field.
  39826. func (m *WhatsappChannelMutation) ResetBusinessID() {
  39827. m.business_id = nil
  39828. m.addbusiness_id = nil
  39829. }
  39830. // SetOrganizationID sets the "organization_id" field.
  39831. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  39832. m.organization_id = &u
  39833. m.addorganization_id = nil
  39834. }
  39835. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39836. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  39837. v := m.organization_id
  39838. if v == nil {
  39839. return
  39840. }
  39841. return *v, true
  39842. }
  39843. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  39844. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39846. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39847. if !m.op.Is(OpUpdateOne) {
  39848. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39849. }
  39850. if m.id == nil || m.oldValue == nil {
  39851. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39852. }
  39853. oldValue, err := m.oldValue(ctx)
  39854. if err != nil {
  39855. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39856. }
  39857. return oldValue.OrganizationID, nil
  39858. }
  39859. // AddOrganizationID adds u to the "organization_id" field.
  39860. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  39861. if m.addorganization_id != nil {
  39862. *m.addorganization_id += u
  39863. } else {
  39864. m.addorganization_id = &u
  39865. }
  39866. }
  39867. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39868. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  39869. v := m.addorganization_id
  39870. if v == nil {
  39871. return
  39872. }
  39873. return *v, true
  39874. }
  39875. // ClearOrganizationID clears the value of the "organization_id" field.
  39876. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  39877. m.organization_id = nil
  39878. m.addorganization_id = nil
  39879. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  39880. }
  39881. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39882. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  39883. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  39884. return ok
  39885. }
  39886. // ResetOrganizationID resets all changes to the "organization_id" field.
  39887. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  39888. m.organization_id = nil
  39889. m.addorganization_id = nil
  39890. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  39891. }
  39892. // SetVerifyAccount sets the "verify_account" field.
  39893. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  39894. m.verify_account = &s
  39895. }
  39896. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  39897. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  39898. v := m.verify_account
  39899. if v == nil {
  39900. return
  39901. }
  39902. return *v, true
  39903. }
  39904. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  39905. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39907. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  39908. if !m.op.Is(OpUpdateOne) {
  39909. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  39910. }
  39911. if m.id == nil || m.oldValue == nil {
  39912. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  39913. }
  39914. oldValue, err := m.oldValue(ctx)
  39915. if err != nil {
  39916. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  39917. }
  39918. return oldValue.VerifyAccount, nil
  39919. }
  39920. // ResetVerifyAccount resets all changes to the "verify_account" field.
  39921. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  39922. m.verify_account = nil
  39923. }
  39924. // Where appends a list predicates to the WhatsappChannelMutation builder.
  39925. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  39926. m.predicates = append(m.predicates, ps...)
  39927. }
  39928. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  39929. // users can use type-assertion to append predicates that do not depend on any generated package.
  39930. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  39931. p := make([]predicate.WhatsappChannel, len(ps))
  39932. for i := range ps {
  39933. p[i] = ps[i]
  39934. }
  39935. m.Where(p...)
  39936. }
  39937. // Op returns the operation name.
  39938. func (m *WhatsappChannelMutation) Op() Op {
  39939. return m.op
  39940. }
  39941. // SetOp allows setting the mutation operation.
  39942. func (m *WhatsappChannelMutation) SetOp(op Op) {
  39943. m.op = op
  39944. }
  39945. // Type returns the node type of this mutation (WhatsappChannel).
  39946. func (m *WhatsappChannelMutation) Type() string {
  39947. return m.typ
  39948. }
  39949. // Fields returns all fields that were changed during this mutation. Note that in
  39950. // order to get all numeric fields that were incremented/decremented, call
  39951. // AddedFields().
  39952. func (m *WhatsappChannelMutation) Fields() []string {
  39953. fields := make([]string, 0, 12)
  39954. if m.created_at != nil {
  39955. fields = append(fields, whatsappchannel.FieldCreatedAt)
  39956. }
  39957. if m.updated_at != nil {
  39958. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  39959. }
  39960. if m.status != nil {
  39961. fields = append(fields, whatsappchannel.FieldStatus)
  39962. }
  39963. if m.deleted_at != nil {
  39964. fields = append(fields, whatsappchannel.FieldDeletedAt)
  39965. }
  39966. if m.ak != nil {
  39967. fields = append(fields, whatsappchannel.FieldAk)
  39968. }
  39969. if m.sk != nil {
  39970. fields = append(fields, whatsappchannel.FieldSk)
  39971. }
  39972. if m.wa_id != nil {
  39973. fields = append(fields, whatsappchannel.FieldWaID)
  39974. }
  39975. if m.wa_name != nil {
  39976. fields = append(fields, whatsappchannel.FieldWaName)
  39977. }
  39978. if m.waba_id != nil {
  39979. fields = append(fields, whatsappchannel.FieldWabaID)
  39980. }
  39981. if m.business_id != nil {
  39982. fields = append(fields, whatsappchannel.FieldBusinessID)
  39983. }
  39984. if m.organization_id != nil {
  39985. fields = append(fields, whatsappchannel.FieldOrganizationID)
  39986. }
  39987. if m.verify_account != nil {
  39988. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  39989. }
  39990. return fields
  39991. }
  39992. // Field returns the value of a field with the given name. The second boolean
  39993. // return value indicates that this field was not set, or was not defined in the
  39994. // schema.
  39995. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  39996. switch name {
  39997. case whatsappchannel.FieldCreatedAt:
  39998. return m.CreatedAt()
  39999. case whatsappchannel.FieldUpdatedAt:
  40000. return m.UpdatedAt()
  40001. case whatsappchannel.FieldStatus:
  40002. return m.Status()
  40003. case whatsappchannel.FieldDeletedAt:
  40004. return m.DeletedAt()
  40005. case whatsappchannel.FieldAk:
  40006. return m.Ak()
  40007. case whatsappchannel.FieldSk:
  40008. return m.Sk()
  40009. case whatsappchannel.FieldWaID:
  40010. return m.WaID()
  40011. case whatsappchannel.FieldWaName:
  40012. return m.WaName()
  40013. case whatsappchannel.FieldWabaID:
  40014. return m.WabaID()
  40015. case whatsappchannel.FieldBusinessID:
  40016. return m.BusinessID()
  40017. case whatsappchannel.FieldOrganizationID:
  40018. return m.OrganizationID()
  40019. case whatsappchannel.FieldVerifyAccount:
  40020. return m.VerifyAccount()
  40021. }
  40022. return nil, false
  40023. }
  40024. // OldField returns the old value of the field from the database. An error is
  40025. // returned if the mutation operation is not UpdateOne, or the query to the
  40026. // database failed.
  40027. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40028. switch name {
  40029. case whatsappchannel.FieldCreatedAt:
  40030. return m.OldCreatedAt(ctx)
  40031. case whatsappchannel.FieldUpdatedAt:
  40032. return m.OldUpdatedAt(ctx)
  40033. case whatsappchannel.FieldStatus:
  40034. return m.OldStatus(ctx)
  40035. case whatsappchannel.FieldDeletedAt:
  40036. return m.OldDeletedAt(ctx)
  40037. case whatsappchannel.FieldAk:
  40038. return m.OldAk(ctx)
  40039. case whatsappchannel.FieldSk:
  40040. return m.OldSk(ctx)
  40041. case whatsappchannel.FieldWaID:
  40042. return m.OldWaID(ctx)
  40043. case whatsappchannel.FieldWaName:
  40044. return m.OldWaName(ctx)
  40045. case whatsappchannel.FieldWabaID:
  40046. return m.OldWabaID(ctx)
  40047. case whatsappchannel.FieldBusinessID:
  40048. return m.OldBusinessID(ctx)
  40049. case whatsappchannel.FieldOrganizationID:
  40050. return m.OldOrganizationID(ctx)
  40051. case whatsappchannel.FieldVerifyAccount:
  40052. return m.OldVerifyAccount(ctx)
  40053. }
  40054. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  40055. }
  40056. // SetField sets the value of a field with the given name. It returns an error if
  40057. // the field is not defined in the schema, or if the type mismatched the field
  40058. // type.
  40059. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  40060. switch name {
  40061. case whatsappchannel.FieldCreatedAt:
  40062. v, ok := value.(time.Time)
  40063. if !ok {
  40064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40065. }
  40066. m.SetCreatedAt(v)
  40067. return nil
  40068. case whatsappchannel.FieldUpdatedAt:
  40069. v, ok := value.(time.Time)
  40070. if !ok {
  40071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40072. }
  40073. m.SetUpdatedAt(v)
  40074. return nil
  40075. case whatsappchannel.FieldStatus:
  40076. v, ok := value.(uint8)
  40077. if !ok {
  40078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40079. }
  40080. m.SetStatus(v)
  40081. return nil
  40082. case whatsappchannel.FieldDeletedAt:
  40083. v, ok := value.(time.Time)
  40084. if !ok {
  40085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40086. }
  40087. m.SetDeletedAt(v)
  40088. return nil
  40089. case whatsappchannel.FieldAk:
  40090. v, ok := value.(string)
  40091. if !ok {
  40092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40093. }
  40094. m.SetAk(v)
  40095. return nil
  40096. case whatsappchannel.FieldSk:
  40097. v, ok := value.(string)
  40098. if !ok {
  40099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40100. }
  40101. m.SetSk(v)
  40102. return nil
  40103. case whatsappchannel.FieldWaID:
  40104. v, ok := value.(string)
  40105. if !ok {
  40106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40107. }
  40108. m.SetWaID(v)
  40109. return nil
  40110. case whatsappchannel.FieldWaName:
  40111. v, ok := value.(string)
  40112. if !ok {
  40113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40114. }
  40115. m.SetWaName(v)
  40116. return nil
  40117. case whatsappchannel.FieldWabaID:
  40118. v, ok := value.(uint64)
  40119. if !ok {
  40120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40121. }
  40122. m.SetWabaID(v)
  40123. return nil
  40124. case whatsappchannel.FieldBusinessID:
  40125. v, ok := value.(uint64)
  40126. if !ok {
  40127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40128. }
  40129. m.SetBusinessID(v)
  40130. return nil
  40131. case whatsappchannel.FieldOrganizationID:
  40132. v, ok := value.(uint64)
  40133. if !ok {
  40134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40135. }
  40136. m.SetOrganizationID(v)
  40137. return nil
  40138. case whatsappchannel.FieldVerifyAccount:
  40139. v, ok := value.(string)
  40140. if !ok {
  40141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40142. }
  40143. m.SetVerifyAccount(v)
  40144. return nil
  40145. }
  40146. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40147. }
  40148. // AddedFields returns all numeric fields that were incremented/decremented during
  40149. // this mutation.
  40150. func (m *WhatsappChannelMutation) AddedFields() []string {
  40151. var fields []string
  40152. if m.addstatus != nil {
  40153. fields = append(fields, whatsappchannel.FieldStatus)
  40154. }
  40155. if m.addwaba_id != nil {
  40156. fields = append(fields, whatsappchannel.FieldWabaID)
  40157. }
  40158. if m.addbusiness_id != nil {
  40159. fields = append(fields, whatsappchannel.FieldBusinessID)
  40160. }
  40161. if m.addorganization_id != nil {
  40162. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40163. }
  40164. return fields
  40165. }
  40166. // AddedField returns the numeric value that was incremented/decremented on a field
  40167. // with the given name. The second boolean return value indicates that this field
  40168. // was not set, or was not defined in the schema.
  40169. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  40170. switch name {
  40171. case whatsappchannel.FieldStatus:
  40172. return m.AddedStatus()
  40173. case whatsappchannel.FieldWabaID:
  40174. return m.AddedWabaID()
  40175. case whatsappchannel.FieldBusinessID:
  40176. return m.AddedBusinessID()
  40177. case whatsappchannel.FieldOrganizationID:
  40178. return m.AddedOrganizationID()
  40179. }
  40180. return nil, false
  40181. }
  40182. // AddField adds the value to the field with the given name. It returns an error if
  40183. // the field is not defined in the schema, or if the type mismatched the field
  40184. // type.
  40185. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  40186. switch name {
  40187. case whatsappchannel.FieldStatus:
  40188. v, ok := value.(int8)
  40189. if !ok {
  40190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40191. }
  40192. m.AddStatus(v)
  40193. return nil
  40194. case whatsappchannel.FieldWabaID:
  40195. v, ok := value.(int64)
  40196. if !ok {
  40197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40198. }
  40199. m.AddWabaID(v)
  40200. return nil
  40201. case whatsappchannel.FieldBusinessID:
  40202. v, ok := value.(int64)
  40203. if !ok {
  40204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40205. }
  40206. m.AddBusinessID(v)
  40207. return nil
  40208. case whatsappchannel.FieldOrganizationID:
  40209. v, ok := value.(int64)
  40210. if !ok {
  40211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40212. }
  40213. m.AddOrganizationID(v)
  40214. return nil
  40215. }
  40216. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  40217. }
  40218. // ClearedFields returns all nullable fields that were cleared during this
  40219. // mutation.
  40220. func (m *WhatsappChannelMutation) ClearedFields() []string {
  40221. var fields []string
  40222. if m.FieldCleared(whatsappchannel.FieldStatus) {
  40223. fields = append(fields, whatsappchannel.FieldStatus)
  40224. }
  40225. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  40226. fields = append(fields, whatsappchannel.FieldDeletedAt)
  40227. }
  40228. if m.FieldCleared(whatsappchannel.FieldAk) {
  40229. fields = append(fields, whatsappchannel.FieldAk)
  40230. }
  40231. if m.FieldCleared(whatsappchannel.FieldWaID) {
  40232. fields = append(fields, whatsappchannel.FieldWaID)
  40233. }
  40234. if m.FieldCleared(whatsappchannel.FieldWaName) {
  40235. fields = append(fields, whatsappchannel.FieldWaName)
  40236. }
  40237. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  40238. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40239. }
  40240. return fields
  40241. }
  40242. // FieldCleared returns a boolean indicating if a field with the given name was
  40243. // cleared in this mutation.
  40244. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  40245. _, ok := m.clearedFields[name]
  40246. return ok
  40247. }
  40248. // ClearField clears the value of the field with the given name. It returns an
  40249. // error if the field is not defined in the schema.
  40250. func (m *WhatsappChannelMutation) ClearField(name string) error {
  40251. switch name {
  40252. case whatsappchannel.FieldStatus:
  40253. m.ClearStatus()
  40254. return nil
  40255. case whatsappchannel.FieldDeletedAt:
  40256. m.ClearDeletedAt()
  40257. return nil
  40258. case whatsappchannel.FieldAk:
  40259. m.ClearAk()
  40260. return nil
  40261. case whatsappchannel.FieldWaID:
  40262. m.ClearWaID()
  40263. return nil
  40264. case whatsappchannel.FieldWaName:
  40265. m.ClearWaName()
  40266. return nil
  40267. case whatsappchannel.FieldOrganizationID:
  40268. m.ClearOrganizationID()
  40269. return nil
  40270. }
  40271. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  40272. }
  40273. // ResetField resets all changes in the mutation for the field with the given name.
  40274. // It returns an error if the field is not defined in the schema.
  40275. func (m *WhatsappChannelMutation) ResetField(name string) error {
  40276. switch name {
  40277. case whatsappchannel.FieldCreatedAt:
  40278. m.ResetCreatedAt()
  40279. return nil
  40280. case whatsappchannel.FieldUpdatedAt:
  40281. m.ResetUpdatedAt()
  40282. return nil
  40283. case whatsappchannel.FieldStatus:
  40284. m.ResetStatus()
  40285. return nil
  40286. case whatsappchannel.FieldDeletedAt:
  40287. m.ResetDeletedAt()
  40288. return nil
  40289. case whatsappchannel.FieldAk:
  40290. m.ResetAk()
  40291. return nil
  40292. case whatsappchannel.FieldSk:
  40293. m.ResetSk()
  40294. return nil
  40295. case whatsappchannel.FieldWaID:
  40296. m.ResetWaID()
  40297. return nil
  40298. case whatsappchannel.FieldWaName:
  40299. m.ResetWaName()
  40300. return nil
  40301. case whatsappchannel.FieldWabaID:
  40302. m.ResetWabaID()
  40303. return nil
  40304. case whatsappchannel.FieldBusinessID:
  40305. m.ResetBusinessID()
  40306. return nil
  40307. case whatsappchannel.FieldOrganizationID:
  40308. m.ResetOrganizationID()
  40309. return nil
  40310. case whatsappchannel.FieldVerifyAccount:
  40311. m.ResetVerifyAccount()
  40312. return nil
  40313. }
  40314. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40315. }
  40316. // AddedEdges returns all edge names that were set/added in this mutation.
  40317. func (m *WhatsappChannelMutation) AddedEdges() []string {
  40318. edges := make([]string, 0, 0)
  40319. return edges
  40320. }
  40321. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40322. // name in this mutation.
  40323. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  40324. return nil
  40325. }
  40326. // RemovedEdges returns all edge names that were removed in this mutation.
  40327. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  40328. edges := make([]string, 0, 0)
  40329. return edges
  40330. }
  40331. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40332. // the given name in this mutation.
  40333. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  40334. return nil
  40335. }
  40336. // ClearedEdges returns all edge names that were cleared in this mutation.
  40337. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  40338. edges := make([]string, 0, 0)
  40339. return edges
  40340. }
  40341. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40342. // was cleared in this mutation.
  40343. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  40344. return false
  40345. }
  40346. // ClearEdge clears the value of the edge with the given name. It returns an error
  40347. // if that edge is not defined in the schema.
  40348. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  40349. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  40350. }
  40351. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40352. // It returns an error if the edge is not defined in the schema.
  40353. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  40354. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  40355. }
  40356. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  40357. type WorkExperienceMutation struct {
  40358. config
  40359. op Op
  40360. typ string
  40361. id *uint64
  40362. created_at *time.Time
  40363. updated_at *time.Time
  40364. deleted_at *time.Time
  40365. start_date *time.Time
  40366. end_date *time.Time
  40367. company *string
  40368. experience *string
  40369. organization_id *uint64
  40370. addorganization_id *int64
  40371. clearedFields map[string]struct{}
  40372. employee *uint64
  40373. clearedemployee bool
  40374. done bool
  40375. oldValue func(context.Context) (*WorkExperience, error)
  40376. predicates []predicate.WorkExperience
  40377. }
  40378. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  40379. // workexperienceOption allows management of the mutation configuration using functional options.
  40380. type workexperienceOption func(*WorkExperienceMutation)
  40381. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  40382. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  40383. m := &WorkExperienceMutation{
  40384. config: c,
  40385. op: op,
  40386. typ: TypeWorkExperience,
  40387. clearedFields: make(map[string]struct{}),
  40388. }
  40389. for _, opt := range opts {
  40390. opt(m)
  40391. }
  40392. return m
  40393. }
  40394. // withWorkExperienceID sets the ID field of the mutation.
  40395. func withWorkExperienceID(id uint64) workexperienceOption {
  40396. return func(m *WorkExperienceMutation) {
  40397. var (
  40398. err error
  40399. once sync.Once
  40400. value *WorkExperience
  40401. )
  40402. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  40403. once.Do(func() {
  40404. if m.done {
  40405. err = errors.New("querying old values post mutation is not allowed")
  40406. } else {
  40407. value, err = m.Client().WorkExperience.Get(ctx, id)
  40408. }
  40409. })
  40410. return value, err
  40411. }
  40412. m.id = &id
  40413. }
  40414. }
  40415. // withWorkExperience sets the old WorkExperience of the mutation.
  40416. func withWorkExperience(node *WorkExperience) workexperienceOption {
  40417. return func(m *WorkExperienceMutation) {
  40418. m.oldValue = func(context.Context) (*WorkExperience, error) {
  40419. return node, nil
  40420. }
  40421. m.id = &node.ID
  40422. }
  40423. }
  40424. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40425. // executed in a transaction (ent.Tx), a transactional client is returned.
  40426. func (m WorkExperienceMutation) Client() *Client {
  40427. client := &Client{config: m.config}
  40428. client.init()
  40429. return client
  40430. }
  40431. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40432. // it returns an error otherwise.
  40433. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  40434. if _, ok := m.driver.(*txDriver); !ok {
  40435. return nil, errors.New("ent: mutation is not running in a transaction")
  40436. }
  40437. tx := &Tx{config: m.config}
  40438. tx.init()
  40439. return tx, nil
  40440. }
  40441. // SetID sets the value of the id field. Note that this
  40442. // operation is only accepted on creation of WorkExperience entities.
  40443. func (m *WorkExperienceMutation) SetID(id uint64) {
  40444. m.id = &id
  40445. }
  40446. // ID returns the ID value in the mutation. Note that the ID is only available
  40447. // if it was provided to the builder or after it was returned from the database.
  40448. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  40449. if m.id == nil {
  40450. return
  40451. }
  40452. return *m.id, true
  40453. }
  40454. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40455. // That means, if the mutation is applied within a transaction with an isolation level such
  40456. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40457. // or updated by the mutation.
  40458. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  40459. switch {
  40460. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40461. id, exists := m.ID()
  40462. if exists {
  40463. return []uint64{id}, nil
  40464. }
  40465. fallthrough
  40466. case m.op.Is(OpUpdate | OpDelete):
  40467. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  40468. default:
  40469. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40470. }
  40471. }
  40472. // SetCreatedAt sets the "created_at" field.
  40473. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  40474. m.created_at = &t
  40475. }
  40476. // CreatedAt returns the value of the "created_at" field in the mutation.
  40477. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  40478. v := m.created_at
  40479. if v == nil {
  40480. return
  40481. }
  40482. return *v, true
  40483. }
  40484. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  40485. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40487. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40488. if !m.op.Is(OpUpdateOne) {
  40489. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40490. }
  40491. if m.id == nil || m.oldValue == nil {
  40492. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40493. }
  40494. oldValue, err := m.oldValue(ctx)
  40495. if err != nil {
  40496. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40497. }
  40498. return oldValue.CreatedAt, nil
  40499. }
  40500. // ResetCreatedAt resets all changes to the "created_at" field.
  40501. func (m *WorkExperienceMutation) ResetCreatedAt() {
  40502. m.created_at = nil
  40503. }
  40504. // SetUpdatedAt sets the "updated_at" field.
  40505. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  40506. m.updated_at = &t
  40507. }
  40508. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40509. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  40510. v := m.updated_at
  40511. if v == nil {
  40512. return
  40513. }
  40514. return *v, true
  40515. }
  40516. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  40517. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40519. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40520. if !m.op.Is(OpUpdateOne) {
  40521. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40522. }
  40523. if m.id == nil || m.oldValue == nil {
  40524. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40525. }
  40526. oldValue, err := m.oldValue(ctx)
  40527. if err != nil {
  40528. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40529. }
  40530. return oldValue.UpdatedAt, nil
  40531. }
  40532. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40533. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  40534. m.updated_at = nil
  40535. }
  40536. // SetDeletedAt sets the "deleted_at" field.
  40537. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  40538. m.deleted_at = &t
  40539. }
  40540. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40541. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  40542. v := m.deleted_at
  40543. if v == nil {
  40544. return
  40545. }
  40546. return *v, true
  40547. }
  40548. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  40549. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40551. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40552. if !m.op.Is(OpUpdateOne) {
  40553. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40554. }
  40555. if m.id == nil || m.oldValue == nil {
  40556. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40557. }
  40558. oldValue, err := m.oldValue(ctx)
  40559. if err != nil {
  40560. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40561. }
  40562. return oldValue.DeletedAt, nil
  40563. }
  40564. // ClearDeletedAt clears the value of the "deleted_at" field.
  40565. func (m *WorkExperienceMutation) ClearDeletedAt() {
  40566. m.deleted_at = nil
  40567. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  40568. }
  40569. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40570. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  40571. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  40572. return ok
  40573. }
  40574. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40575. func (m *WorkExperienceMutation) ResetDeletedAt() {
  40576. m.deleted_at = nil
  40577. delete(m.clearedFields, workexperience.FieldDeletedAt)
  40578. }
  40579. // SetEmployeeID sets the "employee_id" field.
  40580. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  40581. m.employee = &u
  40582. }
  40583. // EmployeeID returns the value of the "employee_id" field in the mutation.
  40584. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  40585. v := m.employee
  40586. if v == nil {
  40587. return
  40588. }
  40589. return *v, true
  40590. }
  40591. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  40592. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40594. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  40595. if !m.op.Is(OpUpdateOne) {
  40596. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  40597. }
  40598. if m.id == nil || m.oldValue == nil {
  40599. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  40600. }
  40601. oldValue, err := m.oldValue(ctx)
  40602. if err != nil {
  40603. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  40604. }
  40605. return oldValue.EmployeeID, nil
  40606. }
  40607. // ResetEmployeeID resets all changes to the "employee_id" field.
  40608. func (m *WorkExperienceMutation) ResetEmployeeID() {
  40609. m.employee = nil
  40610. }
  40611. // SetStartDate sets the "start_date" field.
  40612. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  40613. m.start_date = &t
  40614. }
  40615. // StartDate returns the value of the "start_date" field in the mutation.
  40616. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  40617. v := m.start_date
  40618. if v == nil {
  40619. return
  40620. }
  40621. return *v, true
  40622. }
  40623. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  40624. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40626. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  40627. if !m.op.Is(OpUpdateOne) {
  40628. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  40629. }
  40630. if m.id == nil || m.oldValue == nil {
  40631. return v, errors.New("OldStartDate requires an ID field in the mutation")
  40632. }
  40633. oldValue, err := m.oldValue(ctx)
  40634. if err != nil {
  40635. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  40636. }
  40637. return oldValue.StartDate, nil
  40638. }
  40639. // ResetStartDate resets all changes to the "start_date" field.
  40640. func (m *WorkExperienceMutation) ResetStartDate() {
  40641. m.start_date = nil
  40642. }
  40643. // SetEndDate sets the "end_date" field.
  40644. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  40645. m.end_date = &t
  40646. }
  40647. // EndDate returns the value of the "end_date" field in the mutation.
  40648. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  40649. v := m.end_date
  40650. if v == nil {
  40651. return
  40652. }
  40653. return *v, true
  40654. }
  40655. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  40656. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40658. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  40659. if !m.op.Is(OpUpdateOne) {
  40660. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  40661. }
  40662. if m.id == nil || m.oldValue == nil {
  40663. return v, errors.New("OldEndDate requires an ID field in the mutation")
  40664. }
  40665. oldValue, err := m.oldValue(ctx)
  40666. if err != nil {
  40667. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  40668. }
  40669. return oldValue.EndDate, nil
  40670. }
  40671. // ResetEndDate resets all changes to the "end_date" field.
  40672. func (m *WorkExperienceMutation) ResetEndDate() {
  40673. m.end_date = nil
  40674. }
  40675. // SetCompany sets the "company" field.
  40676. func (m *WorkExperienceMutation) SetCompany(s string) {
  40677. m.company = &s
  40678. }
  40679. // Company returns the value of the "company" field in the mutation.
  40680. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  40681. v := m.company
  40682. if v == nil {
  40683. return
  40684. }
  40685. return *v, true
  40686. }
  40687. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  40688. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40690. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  40691. if !m.op.Is(OpUpdateOne) {
  40692. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  40693. }
  40694. if m.id == nil || m.oldValue == nil {
  40695. return v, errors.New("OldCompany requires an ID field in the mutation")
  40696. }
  40697. oldValue, err := m.oldValue(ctx)
  40698. if err != nil {
  40699. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  40700. }
  40701. return oldValue.Company, nil
  40702. }
  40703. // ResetCompany resets all changes to the "company" field.
  40704. func (m *WorkExperienceMutation) ResetCompany() {
  40705. m.company = nil
  40706. }
  40707. // SetExperience sets the "experience" field.
  40708. func (m *WorkExperienceMutation) SetExperience(s string) {
  40709. m.experience = &s
  40710. }
  40711. // Experience returns the value of the "experience" field in the mutation.
  40712. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  40713. v := m.experience
  40714. if v == nil {
  40715. return
  40716. }
  40717. return *v, true
  40718. }
  40719. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  40720. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40722. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  40723. if !m.op.Is(OpUpdateOne) {
  40724. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  40725. }
  40726. if m.id == nil || m.oldValue == nil {
  40727. return v, errors.New("OldExperience requires an ID field in the mutation")
  40728. }
  40729. oldValue, err := m.oldValue(ctx)
  40730. if err != nil {
  40731. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  40732. }
  40733. return oldValue.Experience, nil
  40734. }
  40735. // ResetExperience resets all changes to the "experience" field.
  40736. func (m *WorkExperienceMutation) ResetExperience() {
  40737. m.experience = nil
  40738. }
  40739. // SetOrganizationID sets the "organization_id" field.
  40740. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  40741. m.organization_id = &u
  40742. m.addorganization_id = nil
  40743. }
  40744. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40745. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  40746. v := m.organization_id
  40747. if v == nil {
  40748. return
  40749. }
  40750. return *v, true
  40751. }
  40752. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  40753. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40755. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40756. if !m.op.Is(OpUpdateOne) {
  40757. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40758. }
  40759. if m.id == nil || m.oldValue == nil {
  40760. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40761. }
  40762. oldValue, err := m.oldValue(ctx)
  40763. if err != nil {
  40764. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40765. }
  40766. return oldValue.OrganizationID, nil
  40767. }
  40768. // AddOrganizationID adds u to the "organization_id" field.
  40769. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  40770. if m.addorganization_id != nil {
  40771. *m.addorganization_id += u
  40772. } else {
  40773. m.addorganization_id = &u
  40774. }
  40775. }
  40776. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40777. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  40778. v := m.addorganization_id
  40779. if v == nil {
  40780. return
  40781. }
  40782. return *v, true
  40783. }
  40784. // ResetOrganizationID resets all changes to the "organization_id" field.
  40785. func (m *WorkExperienceMutation) ResetOrganizationID() {
  40786. m.organization_id = nil
  40787. m.addorganization_id = nil
  40788. }
  40789. // ClearEmployee clears the "employee" edge to the Employee entity.
  40790. func (m *WorkExperienceMutation) ClearEmployee() {
  40791. m.clearedemployee = true
  40792. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  40793. }
  40794. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  40795. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  40796. return m.clearedemployee
  40797. }
  40798. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  40799. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40800. // EmployeeID instead. It exists only for internal usage by the builders.
  40801. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  40802. if id := m.employee; id != nil {
  40803. ids = append(ids, *id)
  40804. }
  40805. return
  40806. }
  40807. // ResetEmployee resets all changes to the "employee" edge.
  40808. func (m *WorkExperienceMutation) ResetEmployee() {
  40809. m.employee = nil
  40810. m.clearedemployee = false
  40811. }
  40812. // Where appends a list predicates to the WorkExperienceMutation builder.
  40813. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  40814. m.predicates = append(m.predicates, ps...)
  40815. }
  40816. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  40817. // users can use type-assertion to append predicates that do not depend on any generated package.
  40818. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  40819. p := make([]predicate.WorkExperience, len(ps))
  40820. for i := range ps {
  40821. p[i] = ps[i]
  40822. }
  40823. m.Where(p...)
  40824. }
  40825. // Op returns the operation name.
  40826. func (m *WorkExperienceMutation) Op() Op {
  40827. return m.op
  40828. }
  40829. // SetOp allows setting the mutation operation.
  40830. func (m *WorkExperienceMutation) SetOp(op Op) {
  40831. m.op = op
  40832. }
  40833. // Type returns the node type of this mutation (WorkExperience).
  40834. func (m *WorkExperienceMutation) Type() string {
  40835. return m.typ
  40836. }
  40837. // Fields returns all fields that were changed during this mutation. Note that in
  40838. // order to get all numeric fields that were incremented/decremented, call
  40839. // AddedFields().
  40840. func (m *WorkExperienceMutation) Fields() []string {
  40841. fields := make([]string, 0, 9)
  40842. if m.created_at != nil {
  40843. fields = append(fields, workexperience.FieldCreatedAt)
  40844. }
  40845. if m.updated_at != nil {
  40846. fields = append(fields, workexperience.FieldUpdatedAt)
  40847. }
  40848. if m.deleted_at != nil {
  40849. fields = append(fields, workexperience.FieldDeletedAt)
  40850. }
  40851. if m.employee != nil {
  40852. fields = append(fields, workexperience.FieldEmployeeID)
  40853. }
  40854. if m.start_date != nil {
  40855. fields = append(fields, workexperience.FieldStartDate)
  40856. }
  40857. if m.end_date != nil {
  40858. fields = append(fields, workexperience.FieldEndDate)
  40859. }
  40860. if m.company != nil {
  40861. fields = append(fields, workexperience.FieldCompany)
  40862. }
  40863. if m.experience != nil {
  40864. fields = append(fields, workexperience.FieldExperience)
  40865. }
  40866. if m.organization_id != nil {
  40867. fields = append(fields, workexperience.FieldOrganizationID)
  40868. }
  40869. return fields
  40870. }
  40871. // Field returns the value of a field with the given name. The second boolean
  40872. // return value indicates that this field was not set, or was not defined in the
  40873. // schema.
  40874. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  40875. switch name {
  40876. case workexperience.FieldCreatedAt:
  40877. return m.CreatedAt()
  40878. case workexperience.FieldUpdatedAt:
  40879. return m.UpdatedAt()
  40880. case workexperience.FieldDeletedAt:
  40881. return m.DeletedAt()
  40882. case workexperience.FieldEmployeeID:
  40883. return m.EmployeeID()
  40884. case workexperience.FieldStartDate:
  40885. return m.StartDate()
  40886. case workexperience.FieldEndDate:
  40887. return m.EndDate()
  40888. case workexperience.FieldCompany:
  40889. return m.Company()
  40890. case workexperience.FieldExperience:
  40891. return m.Experience()
  40892. case workexperience.FieldOrganizationID:
  40893. return m.OrganizationID()
  40894. }
  40895. return nil, false
  40896. }
  40897. // OldField returns the old value of the field from the database. An error is
  40898. // returned if the mutation operation is not UpdateOne, or the query to the
  40899. // database failed.
  40900. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40901. switch name {
  40902. case workexperience.FieldCreatedAt:
  40903. return m.OldCreatedAt(ctx)
  40904. case workexperience.FieldUpdatedAt:
  40905. return m.OldUpdatedAt(ctx)
  40906. case workexperience.FieldDeletedAt:
  40907. return m.OldDeletedAt(ctx)
  40908. case workexperience.FieldEmployeeID:
  40909. return m.OldEmployeeID(ctx)
  40910. case workexperience.FieldStartDate:
  40911. return m.OldStartDate(ctx)
  40912. case workexperience.FieldEndDate:
  40913. return m.OldEndDate(ctx)
  40914. case workexperience.FieldCompany:
  40915. return m.OldCompany(ctx)
  40916. case workexperience.FieldExperience:
  40917. return m.OldExperience(ctx)
  40918. case workexperience.FieldOrganizationID:
  40919. return m.OldOrganizationID(ctx)
  40920. }
  40921. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  40922. }
  40923. // SetField sets the value of a field with the given name. It returns an error if
  40924. // the field is not defined in the schema, or if the type mismatched the field
  40925. // type.
  40926. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  40927. switch name {
  40928. case workexperience.FieldCreatedAt:
  40929. v, ok := value.(time.Time)
  40930. if !ok {
  40931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40932. }
  40933. m.SetCreatedAt(v)
  40934. return nil
  40935. case workexperience.FieldUpdatedAt:
  40936. v, ok := value.(time.Time)
  40937. if !ok {
  40938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40939. }
  40940. m.SetUpdatedAt(v)
  40941. return nil
  40942. case workexperience.FieldDeletedAt:
  40943. v, ok := value.(time.Time)
  40944. if !ok {
  40945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40946. }
  40947. m.SetDeletedAt(v)
  40948. return nil
  40949. case workexperience.FieldEmployeeID:
  40950. v, ok := value.(uint64)
  40951. if !ok {
  40952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40953. }
  40954. m.SetEmployeeID(v)
  40955. return nil
  40956. case workexperience.FieldStartDate:
  40957. v, ok := value.(time.Time)
  40958. if !ok {
  40959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40960. }
  40961. m.SetStartDate(v)
  40962. return nil
  40963. case workexperience.FieldEndDate:
  40964. v, ok := value.(time.Time)
  40965. if !ok {
  40966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40967. }
  40968. m.SetEndDate(v)
  40969. return nil
  40970. case workexperience.FieldCompany:
  40971. v, ok := value.(string)
  40972. if !ok {
  40973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40974. }
  40975. m.SetCompany(v)
  40976. return nil
  40977. case workexperience.FieldExperience:
  40978. v, ok := value.(string)
  40979. if !ok {
  40980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40981. }
  40982. m.SetExperience(v)
  40983. return nil
  40984. case workexperience.FieldOrganizationID:
  40985. v, ok := value.(uint64)
  40986. if !ok {
  40987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40988. }
  40989. m.SetOrganizationID(v)
  40990. return nil
  40991. }
  40992. return fmt.Errorf("unknown WorkExperience field %s", name)
  40993. }
  40994. // AddedFields returns all numeric fields that were incremented/decremented during
  40995. // this mutation.
  40996. func (m *WorkExperienceMutation) AddedFields() []string {
  40997. var fields []string
  40998. if m.addorganization_id != nil {
  40999. fields = append(fields, workexperience.FieldOrganizationID)
  41000. }
  41001. return fields
  41002. }
  41003. // AddedField returns the numeric value that was incremented/decremented on a field
  41004. // with the given name. The second boolean return value indicates that this field
  41005. // was not set, or was not defined in the schema.
  41006. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  41007. switch name {
  41008. case workexperience.FieldOrganizationID:
  41009. return m.AddedOrganizationID()
  41010. }
  41011. return nil, false
  41012. }
  41013. // AddField adds the value to the field with the given name. It returns an error if
  41014. // the field is not defined in the schema, or if the type mismatched the field
  41015. // type.
  41016. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  41017. switch name {
  41018. case workexperience.FieldOrganizationID:
  41019. v, ok := value.(int64)
  41020. if !ok {
  41021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41022. }
  41023. m.AddOrganizationID(v)
  41024. return nil
  41025. }
  41026. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  41027. }
  41028. // ClearedFields returns all nullable fields that were cleared during this
  41029. // mutation.
  41030. func (m *WorkExperienceMutation) ClearedFields() []string {
  41031. var fields []string
  41032. if m.FieldCleared(workexperience.FieldDeletedAt) {
  41033. fields = append(fields, workexperience.FieldDeletedAt)
  41034. }
  41035. return fields
  41036. }
  41037. // FieldCleared returns a boolean indicating if a field with the given name was
  41038. // cleared in this mutation.
  41039. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  41040. _, ok := m.clearedFields[name]
  41041. return ok
  41042. }
  41043. // ClearField clears the value of the field with the given name. It returns an
  41044. // error if the field is not defined in the schema.
  41045. func (m *WorkExperienceMutation) ClearField(name string) error {
  41046. switch name {
  41047. case workexperience.FieldDeletedAt:
  41048. m.ClearDeletedAt()
  41049. return nil
  41050. }
  41051. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  41052. }
  41053. // ResetField resets all changes in the mutation for the field with the given name.
  41054. // It returns an error if the field is not defined in the schema.
  41055. func (m *WorkExperienceMutation) ResetField(name string) error {
  41056. switch name {
  41057. case workexperience.FieldCreatedAt:
  41058. m.ResetCreatedAt()
  41059. return nil
  41060. case workexperience.FieldUpdatedAt:
  41061. m.ResetUpdatedAt()
  41062. return nil
  41063. case workexperience.FieldDeletedAt:
  41064. m.ResetDeletedAt()
  41065. return nil
  41066. case workexperience.FieldEmployeeID:
  41067. m.ResetEmployeeID()
  41068. return nil
  41069. case workexperience.FieldStartDate:
  41070. m.ResetStartDate()
  41071. return nil
  41072. case workexperience.FieldEndDate:
  41073. m.ResetEndDate()
  41074. return nil
  41075. case workexperience.FieldCompany:
  41076. m.ResetCompany()
  41077. return nil
  41078. case workexperience.FieldExperience:
  41079. m.ResetExperience()
  41080. return nil
  41081. case workexperience.FieldOrganizationID:
  41082. m.ResetOrganizationID()
  41083. return nil
  41084. }
  41085. return fmt.Errorf("unknown WorkExperience field %s", name)
  41086. }
  41087. // AddedEdges returns all edge names that were set/added in this mutation.
  41088. func (m *WorkExperienceMutation) AddedEdges() []string {
  41089. edges := make([]string, 0, 1)
  41090. if m.employee != nil {
  41091. edges = append(edges, workexperience.EdgeEmployee)
  41092. }
  41093. return edges
  41094. }
  41095. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41096. // name in this mutation.
  41097. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  41098. switch name {
  41099. case workexperience.EdgeEmployee:
  41100. if id := m.employee; id != nil {
  41101. return []ent.Value{*id}
  41102. }
  41103. }
  41104. return nil
  41105. }
  41106. // RemovedEdges returns all edge names that were removed in this mutation.
  41107. func (m *WorkExperienceMutation) RemovedEdges() []string {
  41108. edges := make([]string, 0, 1)
  41109. return edges
  41110. }
  41111. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41112. // the given name in this mutation.
  41113. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  41114. return nil
  41115. }
  41116. // ClearedEdges returns all edge names that were cleared in this mutation.
  41117. func (m *WorkExperienceMutation) ClearedEdges() []string {
  41118. edges := make([]string, 0, 1)
  41119. if m.clearedemployee {
  41120. edges = append(edges, workexperience.EdgeEmployee)
  41121. }
  41122. return edges
  41123. }
  41124. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41125. // was cleared in this mutation.
  41126. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  41127. switch name {
  41128. case workexperience.EdgeEmployee:
  41129. return m.clearedemployee
  41130. }
  41131. return false
  41132. }
  41133. // ClearEdge clears the value of the edge with the given name. It returns an error
  41134. // if that edge is not defined in the schema.
  41135. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  41136. switch name {
  41137. case workexperience.EdgeEmployee:
  41138. m.ClearEmployee()
  41139. return nil
  41140. }
  41141. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  41142. }
  41143. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41144. // It returns an error if the edge is not defined in the schema.
  41145. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  41146. switch name {
  41147. case workexperience.EdgeEmployee:
  41148. m.ResetEmployee()
  41149. return nil
  41150. }
  41151. return fmt.Errorf("unknown WorkExperience edge %s", name)
  41152. }
  41153. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  41154. type WpChatroomMutation struct {
  41155. config
  41156. op Op
  41157. typ string
  41158. id *uint64
  41159. created_at *time.Time
  41160. updated_at *time.Time
  41161. status *uint8
  41162. addstatus *int8
  41163. wx_wxid *string
  41164. chatroom_id *string
  41165. nickname *string
  41166. owner *string
  41167. avatar *string
  41168. member_list *[]string
  41169. appendmember_list []string
  41170. clearedFields map[string]struct{}
  41171. done bool
  41172. oldValue func(context.Context) (*WpChatroom, error)
  41173. predicates []predicate.WpChatroom
  41174. }
  41175. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  41176. // wpchatroomOption allows management of the mutation configuration using functional options.
  41177. type wpchatroomOption func(*WpChatroomMutation)
  41178. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  41179. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  41180. m := &WpChatroomMutation{
  41181. config: c,
  41182. op: op,
  41183. typ: TypeWpChatroom,
  41184. clearedFields: make(map[string]struct{}),
  41185. }
  41186. for _, opt := range opts {
  41187. opt(m)
  41188. }
  41189. return m
  41190. }
  41191. // withWpChatroomID sets the ID field of the mutation.
  41192. func withWpChatroomID(id uint64) wpchatroomOption {
  41193. return func(m *WpChatroomMutation) {
  41194. var (
  41195. err error
  41196. once sync.Once
  41197. value *WpChatroom
  41198. )
  41199. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  41200. once.Do(func() {
  41201. if m.done {
  41202. err = errors.New("querying old values post mutation is not allowed")
  41203. } else {
  41204. value, err = m.Client().WpChatroom.Get(ctx, id)
  41205. }
  41206. })
  41207. return value, err
  41208. }
  41209. m.id = &id
  41210. }
  41211. }
  41212. // withWpChatroom sets the old WpChatroom of the mutation.
  41213. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  41214. return func(m *WpChatroomMutation) {
  41215. m.oldValue = func(context.Context) (*WpChatroom, error) {
  41216. return node, nil
  41217. }
  41218. m.id = &node.ID
  41219. }
  41220. }
  41221. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41222. // executed in a transaction (ent.Tx), a transactional client is returned.
  41223. func (m WpChatroomMutation) Client() *Client {
  41224. client := &Client{config: m.config}
  41225. client.init()
  41226. return client
  41227. }
  41228. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41229. // it returns an error otherwise.
  41230. func (m WpChatroomMutation) Tx() (*Tx, error) {
  41231. if _, ok := m.driver.(*txDriver); !ok {
  41232. return nil, errors.New("ent: mutation is not running in a transaction")
  41233. }
  41234. tx := &Tx{config: m.config}
  41235. tx.init()
  41236. return tx, nil
  41237. }
  41238. // SetID sets the value of the id field. Note that this
  41239. // operation is only accepted on creation of WpChatroom entities.
  41240. func (m *WpChatroomMutation) SetID(id uint64) {
  41241. m.id = &id
  41242. }
  41243. // ID returns the ID value in the mutation. Note that the ID is only available
  41244. // if it was provided to the builder or after it was returned from the database.
  41245. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  41246. if m.id == nil {
  41247. return
  41248. }
  41249. return *m.id, true
  41250. }
  41251. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41252. // That means, if the mutation is applied within a transaction with an isolation level such
  41253. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41254. // or updated by the mutation.
  41255. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  41256. switch {
  41257. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41258. id, exists := m.ID()
  41259. if exists {
  41260. return []uint64{id}, nil
  41261. }
  41262. fallthrough
  41263. case m.op.Is(OpUpdate | OpDelete):
  41264. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  41265. default:
  41266. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41267. }
  41268. }
  41269. // SetCreatedAt sets the "created_at" field.
  41270. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  41271. m.created_at = &t
  41272. }
  41273. // CreatedAt returns the value of the "created_at" field in the mutation.
  41274. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  41275. v := m.created_at
  41276. if v == nil {
  41277. return
  41278. }
  41279. return *v, true
  41280. }
  41281. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  41282. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41284. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41285. if !m.op.Is(OpUpdateOne) {
  41286. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41287. }
  41288. if m.id == nil || m.oldValue == nil {
  41289. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41290. }
  41291. oldValue, err := m.oldValue(ctx)
  41292. if err != nil {
  41293. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41294. }
  41295. return oldValue.CreatedAt, nil
  41296. }
  41297. // ResetCreatedAt resets all changes to the "created_at" field.
  41298. func (m *WpChatroomMutation) ResetCreatedAt() {
  41299. m.created_at = nil
  41300. }
  41301. // SetUpdatedAt sets the "updated_at" field.
  41302. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  41303. m.updated_at = &t
  41304. }
  41305. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41306. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  41307. v := m.updated_at
  41308. if v == nil {
  41309. return
  41310. }
  41311. return *v, true
  41312. }
  41313. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  41314. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41316. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41317. if !m.op.Is(OpUpdateOne) {
  41318. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41319. }
  41320. if m.id == nil || m.oldValue == nil {
  41321. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41322. }
  41323. oldValue, err := m.oldValue(ctx)
  41324. if err != nil {
  41325. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41326. }
  41327. return oldValue.UpdatedAt, nil
  41328. }
  41329. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41330. func (m *WpChatroomMutation) ResetUpdatedAt() {
  41331. m.updated_at = nil
  41332. }
  41333. // SetStatus sets the "status" field.
  41334. func (m *WpChatroomMutation) SetStatus(u uint8) {
  41335. m.status = &u
  41336. m.addstatus = nil
  41337. }
  41338. // Status returns the value of the "status" field in the mutation.
  41339. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  41340. v := m.status
  41341. if v == nil {
  41342. return
  41343. }
  41344. return *v, true
  41345. }
  41346. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  41347. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41349. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41350. if !m.op.Is(OpUpdateOne) {
  41351. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41352. }
  41353. if m.id == nil || m.oldValue == nil {
  41354. return v, errors.New("OldStatus requires an ID field in the mutation")
  41355. }
  41356. oldValue, err := m.oldValue(ctx)
  41357. if err != nil {
  41358. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41359. }
  41360. return oldValue.Status, nil
  41361. }
  41362. // AddStatus adds u to the "status" field.
  41363. func (m *WpChatroomMutation) AddStatus(u int8) {
  41364. if m.addstatus != nil {
  41365. *m.addstatus += u
  41366. } else {
  41367. m.addstatus = &u
  41368. }
  41369. }
  41370. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41371. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  41372. v := m.addstatus
  41373. if v == nil {
  41374. return
  41375. }
  41376. return *v, true
  41377. }
  41378. // ClearStatus clears the value of the "status" field.
  41379. func (m *WpChatroomMutation) ClearStatus() {
  41380. m.status = nil
  41381. m.addstatus = nil
  41382. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  41383. }
  41384. // StatusCleared returns if the "status" field was cleared in this mutation.
  41385. func (m *WpChatroomMutation) StatusCleared() bool {
  41386. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  41387. return ok
  41388. }
  41389. // ResetStatus resets all changes to the "status" field.
  41390. func (m *WpChatroomMutation) ResetStatus() {
  41391. m.status = nil
  41392. m.addstatus = nil
  41393. delete(m.clearedFields, wpchatroom.FieldStatus)
  41394. }
  41395. // SetWxWxid sets the "wx_wxid" field.
  41396. func (m *WpChatroomMutation) SetWxWxid(s string) {
  41397. m.wx_wxid = &s
  41398. }
  41399. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  41400. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  41401. v := m.wx_wxid
  41402. if v == nil {
  41403. return
  41404. }
  41405. return *v, true
  41406. }
  41407. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  41408. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41410. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  41411. if !m.op.Is(OpUpdateOne) {
  41412. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  41413. }
  41414. if m.id == nil || m.oldValue == nil {
  41415. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  41416. }
  41417. oldValue, err := m.oldValue(ctx)
  41418. if err != nil {
  41419. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  41420. }
  41421. return oldValue.WxWxid, nil
  41422. }
  41423. // ResetWxWxid resets all changes to the "wx_wxid" field.
  41424. func (m *WpChatroomMutation) ResetWxWxid() {
  41425. m.wx_wxid = nil
  41426. }
  41427. // SetChatroomID sets the "chatroom_id" field.
  41428. func (m *WpChatroomMutation) SetChatroomID(s string) {
  41429. m.chatroom_id = &s
  41430. }
  41431. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  41432. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  41433. v := m.chatroom_id
  41434. if v == nil {
  41435. return
  41436. }
  41437. return *v, true
  41438. }
  41439. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  41440. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41442. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  41443. if !m.op.Is(OpUpdateOne) {
  41444. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  41445. }
  41446. if m.id == nil || m.oldValue == nil {
  41447. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  41448. }
  41449. oldValue, err := m.oldValue(ctx)
  41450. if err != nil {
  41451. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  41452. }
  41453. return oldValue.ChatroomID, nil
  41454. }
  41455. // ResetChatroomID resets all changes to the "chatroom_id" field.
  41456. func (m *WpChatroomMutation) ResetChatroomID() {
  41457. m.chatroom_id = nil
  41458. }
  41459. // SetNickname sets the "nickname" field.
  41460. func (m *WpChatroomMutation) SetNickname(s string) {
  41461. m.nickname = &s
  41462. }
  41463. // Nickname returns the value of the "nickname" field in the mutation.
  41464. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  41465. v := m.nickname
  41466. if v == nil {
  41467. return
  41468. }
  41469. return *v, true
  41470. }
  41471. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  41472. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41474. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  41475. if !m.op.Is(OpUpdateOne) {
  41476. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41477. }
  41478. if m.id == nil || m.oldValue == nil {
  41479. return v, errors.New("OldNickname requires an ID field in the mutation")
  41480. }
  41481. oldValue, err := m.oldValue(ctx)
  41482. if err != nil {
  41483. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41484. }
  41485. return oldValue.Nickname, nil
  41486. }
  41487. // ResetNickname resets all changes to the "nickname" field.
  41488. func (m *WpChatroomMutation) ResetNickname() {
  41489. m.nickname = nil
  41490. }
  41491. // SetOwner sets the "owner" field.
  41492. func (m *WpChatroomMutation) SetOwner(s string) {
  41493. m.owner = &s
  41494. }
  41495. // Owner returns the value of the "owner" field in the mutation.
  41496. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  41497. v := m.owner
  41498. if v == nil {
  41499. return
  41500. }
  41501. return *v, true
  41502. }
  41503. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  41504. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41506. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  41507. if !m.op.Is(OpUpdateOne) {
  41508. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  41509. }
  41510. if m.id == nil || m.oldValue == nil {
  41511. return v, errors.New("OldOwner requires an ID field in the mutation")
  41512. }
  41513. oldValue, err := m.oldValue(ctx)
  41514. if err != nil {
  41515. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  41516. }
  41517. return oldValue.Owner, nil
  41518. }
  41519. // ResetOwner resets all changes to the "owner" field.
  41520. func (m *WpChatroomMutation) ResetOwner() {
  41521. m.owner = nil
  41522. }
  41523. // SetAvatar sets the "avatar" field.
  41524. func (m *WpChatroomMutation) SetAvatar(s string) {
  41525. m.avatar = &s
  41526. }
  41527. // Avatar returns the value of the "avatar" field in the mutation.
  41528. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  41529. v := m.avatar
  41530. if v == nil {
  41531. return
  41532. }
  41533. return *v, true
  41534. }
  41535. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  41536. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41538. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41539. if !m.op.Is(OpUpdateOne) {
  41540. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41541. }
  41542. if m.id == nil || m.oldValue == nil {
  41543. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41544. }
  41545. oldValue, err := m.oldValue(ctx)
  41546. if err != nil {
  41547. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41548. }
  41549. return oldValue.Avatar, nil
  41550. }
  41551. // ResetAvatar resets all changes to the "avatar" field.
  41552. func (m *WpChatroomMutation) ResetAvatar() {
  41553. m.avatar = nil
  41554. }
  41555. // SetMemberList sets the "member_list" field.
  41556. func (m *WpChatroomMutation) SetMemberList(s []string) {
  41557. m.member_list = &s
  41558. m.appendmember_list = nil
  41559. }
  41560. // MemberList returns the value of the "member_list" field in the mutation.
  41561. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  41562. v := m.member_list
  41563. if v == nil {
  41564. return
  41565. }
  41566. return *v, true
  41567. }
  41568. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  41569. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41571. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  41572. if !m.op.Is(OpUpdateOne) {
  41573. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  41574. }
  41575. if m.id == nil || m.oldValue == nil {
  41576. return v, errors.New("OldMemberList requires an ID field in the mutation")
  41577. }
  41578. oldValue, err := m.oldValue(ctx)
  41579. if err != nil {
  41580. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  41581. }
  41582. return oldValue.MemberList, nil
  41583. }
  41584. // AppendMemberList adds s to the "member_list" field.
  41585. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  41586. m.appendmember_list = append(m.appendmember_list, s...)
  41587. }
  41588. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  41589. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  41590. if len(m.appendmember_list) == 0 {
  41591. return nil, false
  41592. }
  41593. return m.appendmember_list, true
  41594. }
  41595. // ResetMemberList resets all changes to the "member_list" field.
  41596. func (m *WpChatroomMutation) ResetMemberList() {
  41597. m.member_list = nil
  41598. m.appendmember_list = nil
  41599. }
  41600. // Where appends a list predicates to the WpChatroomMutation builder.
  41601. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  41602. m.predicates = append(m.predicates, ps...)
  41603. }
  41604. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  41605. // users can use type-assertion to append predicates that do not depend on any generated package.
  41606. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  41607. p := make([]predicate.WpChatroom, len(ps))
  41608. for i := range ps {
  41609. p[i] = ps[i]
  41610. }
  41611. m.Where(p...)
  41612. }
  41613. // Op returns the operation name.
  41614. func (m *WpChatroomMutation) Op() Op {
  41615. return m.op
  41616. }
  41617. // SetOp allows setting the mutation operation.
  41618. func (m *WpChatroomMutation) SetOp(op Op) {
  41619. m.op = op
  41620. }
  41621. // Type returns the node type of this mutation (WpChatroom).
  41622. func (m *WpChatroomMutation) Type() string {
  41623. return m.typ
  41624. }
  41625. // Fields returns all fields that were changed during this mutation. Note that in
  41626. // order to get all numeric fields that were incremented/decremented, call
  41627. // AddedFields().
  41628. func (m *WpChatroomMutation) Fields() []string {
  41629. fields := make([]string, 0, 9)
  41630. if m.created_at != nil {
  41631. fields = append(fields, wpchatroom.FieldCreatedAt)
  41632. }
  41633. if m.updated_at != nil {
  41634. fields = append(fields, wpchatroom.FieldUpdatedAt)
  41635. }
  41636. if m.status != nil {
  41637. fields = append(fields, wpchatroom.FieldStatus)
  41638. }
  41639. if m.wx_wxid != nil {
  41640. fields = append(fields, wpchatroom.FieldWxWxid)
  41641. }
  41642. if m.chatroom_id != nil {
  41643. fields = append(fields, wpchatroom.FieldChatroomID)
  41644. }
  41645. if m.nickname != nil {
  41646. fields = append(fields, wpchatroom.FieldNickname)
  41647. }
  41648. if m.owner != nil {
  41649. fields = append(fields, wpchatroom.FieldOwner)
  41650. }
  41651. if m.avatar != nil {
  41652. fields = append(fields, wpchatroom.FieldAvatar)
  41653. }
  41654. if m.member_list != nil {
  41655. fields = append(fields, wpchatroom.FieldMemberList)
  41656. }
  41657. return fields
  41658. }
  41659. // Field returns the value of a field with the given name. The second boolean
  41660. // return value indicates that this field was not set, or was not defined in the
  41661. // schema.
  41662. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  41663. switch name {
  41664. case wpchatroom.FieldCreatedAt:
  41665. return m.CreatedAt()
  41666. case wpchatroom.FieldUpdatedAt:
  41667. return m.UpdatedAt()
  41668. case wpchatroom.FieldStatus:
  41669. return m.Status()
  41670. case wpchatroom.FieldWxWxid:
  41671. return m.WxWxid()
  41672. case wpchatroom.FieldChatroomID:
  41673. return m.ChatroomID()
  41674. case wpchatroom.FieldNickname:
  41675. return m.Nickname()
  41676. case wpchatroom.FieldOwner:
  41677. return m.Owner()
  41678. case wpchatroom.FieldAvatar:
  41679. return m.Avatar()
  41680. case wpchatroom.FieldMemberList:
  41681. return m.MemberList()
  41682. }
  41683. return nil, false
  41684. }
  41685. // OldField returns the old value of the field from the database. An error is
  41686. // returned if the mutation operation is not UpdateOne, or the query to the
  41687. // database failed.
  41688. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41689. switch name {
  41690. case wpchatroom.FieldCreatedAt:
  41691. return m.OldCreatedAt(ctx)
  41692. case wpchatroom.FieldUpdatedAt:
  41693. return m.OldUpdatedAt(ctx)
  41694. case wpchatroom.FieldStatus:
  41695. return m.OldStatus(ctx)
  41696. case wpchatroom.FieldWxWxid:
  41697. return m.OldWxWxid(ctx)
  41698. case wpchatroom.FieldChatroomID:
  41699. return m.OldChatroomID(ctx)
  41700. case wpchatroom.FieldNickname:
  41701. return m.OldNickname(ctx)
  41702. case wpchatroom.FieldOwner:
  41703. return m.OldOwner(ctx)
  41704. case wpchatroom.FieldAvatar:
  41705. return m.OldAvatar(ctx)
  41706. case wpchatroom.FieldMemberList:
  41707. return m.OldMemberList(ctx)
  41708. }
  41709. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  41710. }
  41711. // SetField sets the value of a field with the given name. It returns an error if
  41712. // the field is not defined in the schema, or if the type mismatched the field
  41713. // type.
  41714. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  41715. switch name {
  41716. case wpchatroom.FieldCreatedAt:
  41717. v, ok := value.(time.Time)
  41718. if !ok {
  41719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41720. }
  41721. m.SetCreatedAt(v)
  41722. return nil
  41723. case wpchatroom.FieldUpdatedAt:
  41724. v, ok := value.(time.Time)
  41725. if !ok {
  41726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41727. }
  41728. m.SetUpdatedAt(v)
  41729. return nil
  41730. case wpchatroom.FieldStatus:
  41731. v, ok := value.(uint8)
  41732. if !ok {
  41733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41734. }
  41735. m.SetStatus(v)
  41736. return nil
  41737. case wpchatroom.FieldWxWxid:
  41738. v, ok := value.(string)
  41739. if !ok {
  41740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41741. }
  41742. m.SetWxWxid(v)
  41743. return nil
  41744. case wpchatroom.FieldChatroomID:
  41745. v, ok := value.(string)
  41746. if !ok {
  41747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41748. }
  41749. m.SetChatroomID(v)
  41750. return nil
  41751. case wpchatroom.FieldNickname:
  41752. v, ok := value.(string)
  41753. if !ok {
  41754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41755. }
  41756. m.SetNickname(v)
  41757. return nil
  41758. case wpchatroom.FieldOwner:
  41759. v, ok := value.(string)
  41760. if !ok {
  41761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41762. }
  41763. m.SetOwner(v)
  41764. return nil
  41765. case wpchatroom.FieldAvatar:
  41766. v, ok := value.(string)
  41767. if !ok {
  41768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41769. }
  41770. m.SetAvatar(v)
  41771. return nil
  41772. case wpchatroom.FieldMemberList:
  41773. v, ok := value.([]string)
  41774. if !ok {
  41775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41776. }
  41777. m.SetMemberList(v)
  41778. return nil
  41779. }
  41780. return fmt.Errorf("unknown WpChatroom field %s", name)
  41781. }
  41782. // AddedFields returns all numeric fields that were incremented/decremented during
  41783. // this mutation.
  41784. func (m *WpChatroomMutation) AddedFields() []string {
  41785. var fields []string
  41786. if m.addstatus != nil {
  41787. fields = append(fields, wpchatroom.FieldStatus)
  41788. }
  41789. return fields
  41790. }
  41791. // AddedField returns the numeric value that was incremented/decremented on a field
  41792. // with the given name. The second boolean return value indicates that this field
  41793. // was not set, or was not defined in the schema.
  41794. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  41795. switch name {
  41796. case wpchatroom.FieldStatus:
  41797. return m.AddedStatus()
  41798. }
  41799. return nil, false
  41800. }
  41801. // AddField adds the value to the field with the given name. It returns an error if
  41802. // the field is not defined in the schema, or if the type mismatched the field
  41803. // type.
  41804. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  41805. switch name {
  41806. case wpchatroom.FieldStatus:
  41807. v, ok := value.(int8)
  41808. if !ok {
  41809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41810. }
  41811. m.AddStatus(v)
  41812. return nil
  41813. }
  41814. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  41815. }
  41816. // ClearedFields returns all nullable fields that were cleared during this
  41817. // mutation.
  41818. func (m *WpChatroomMutation) ClearedFields() []string {
  41819. var fields []string
  41820. if m.FieldCleared(wpchatroom.FieldStatus) {
  41821. fields = append(fields, wpchatroom.FieldStatus)
  41822. }
  41823. return fields
  41824. }
  41825. // FieldCleared returns a boolean indicating if a field with the given name was
  41826. // cleared in this mutation.
  41827. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  41828. _, ok := m.clearedFields[name]
  41829. return ok
  41830. }
  41831. // ClearField clears the value of the field with the given name. It returns an
  41832. // error if the field is not defined in the schema.
  41833. func (m *WpChatroomMutation) ClearField(name string) error {
  41834. switch name {
  41835. case wpchatroom.FieldStatus:
  41836. m.ClearStatus()
  41837. return nil
  41838. }
  41839. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  41840. }
  41841. // ResetField resets all changes in the mutation for the field with the given name.
  41842. // It returns an error if the field is not defined in the schema.
  41843. func (m *WpChatroomMutation) ResetField(name string) error {
  41844. switch name {
  41845. case wpchatroom.FieldCreatedAt:
  41846. m.ResetCreatedAt()
  41847. return nil
  41848. case wpchatroom.FieldUpdatedAt:
  41849. m.ResetUpdatedAt()
  41850. return nil
  41851. case wpchatroom.FieldStatus:
  41852. m.ResetStatus()
  41853. return nil
  41854. case wpchatroom.FieldWxWxid:
  41855. m.ResetWxWxid()
  41856. return nil
  41857. case wpchatroom.FieldChatroomID:
  41858. m.ResetChatroomID()
  41859. return nil
  41860. case wpchatroom.FieldNickname:
  41861. m.ResetNickname()
  41862. return nil
  41863. case wpchatroom.FieldOwner:
  41864. m.ResetOwner()
  41865. return nil
  41866. case wpchatroom.FieldAvatar:
  41867. m.ResetAvatar()
  41868. return nil
  41869. case wpchatroom.FieldMemberList:
  41870. m.ResetMemberList()
  41871. return nil
  41872. }
  41873. return fmt.Errorf("unknown WpChatroom field %s", name)
  41874. }
  41875. // AddedEdges returns all edge names that were set/added in this mutation.
  41876. func (m *WpChatroomMutation) AddedEdges() []string {
  41877. edges := make([]string, 0, 0)
  41878. return edges
  41879. }
  41880. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41881. // name in this mutation.
  41882. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  41883. return nil
  41884. }
  41885. // RemovedEdges returns all edge names that were removed in this mutation.
  41886. func (m *WpChatroomMutation) RemovedEdges() []string {
  41887. edges := make([]string, 0, 0)
  41888. return edges
  41889. }
  41890. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41891. // the given name in this mutation.
  41892. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  41893. return nil
  41894. }
  41895. // ClearedEdges returns all edge names that were cleared in this mutation.
  41896. func (m *WpChatroomMutation) ClearedEdges() []string {
  41897. edges := make([]string, 0, 0)
  41898. return edges
  41899. }
  41900. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41901. // was cleared in this mutation.
  41902. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  41903. return false
  41904. }
  41905. // ClearEdge clears the value of the edge with the given name. It returns an error
  41906. // if that edge is not defined in the schema.
  41907. func (m *WpChatroomMutation) ClearEdge(name string) error {
  41908. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  41909. }
  41910. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41911. // It returns an error if the edge is not defined in the schema.
  41912. func (m *WpChatroomMutation) ResetEdge(name string) error {
  41913. return fmt.Errorf("unknown WpChatroom edge %s", name)
  41914. }
  41915. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  41916. type WpChatroomMemberMutation struct {
  41917. config
  41918. op Op
  41919. typ string
  41920. id *uint64
  41921. created_at *time.Time
  41922. updated_at *time.Time
  41923. status *uint8
  41924. addstatus *int8
  41925. wx_wxid *string
  41926. wxid *string
  41927. nickname *string
  41928. avatar *string
  41929. clearedFields map[string]struct{}
  41930. done bool
  41931. oldValue func(context.Context) (*WpChatroomMember, error)
  41932. predicates []predicate.WpChatroomMember
  41933. }
  41934. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  41935. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  41936. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  41937. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  41938. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  41939. m := &WpChatroomMemberMutation{
  41940. config: c,
  41941. op: op,
  41942. typ: TypeWpChatroomMember,
  41943. clearedFields: make(map[string]struct{}),
  41944. }
  41945. for _, opt := range opts {
  41946. opt(m)
  41947. }
  41948. return m
  41949. }
  41950. // withWpChatroomMemberID sets the ID field of the mutation.
  41951. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  41952. return func(m *WpChatroomMemberMutation) {
  41953. var (
  41954. err error
  41955. once sync.Once
  41956. value *WpChatroomMember
  41957. )
  41958. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  41959. once.Do(func() {
  41960. if m.done {
  41961. err = errors.New("querying old values post mutation is not allowed")
  41962. } else {
  41963. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  41964. }
  41965. })
  41966. return value, err
  41967. }
  41968. m.id = &id
  41969. }
  41970. }
  41971. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  41972. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  41973. return func(m *WpChatroomMemberMutation) {
  41974. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  41975. return node, nil
  41976. }
  41977. m.id = &node.ID
  41978. }
  41979. }
  41980. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41981. // executed in a transaction (ent.Tx), a transactional client is returned.
  41982. func (m WpChatroomMemberMutation) Client() *Client {
  41983. client := &Client{config: m.config}
  41984. client.init()
  41985. return client
  41986. }
  41987. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41988. // it returns an error otherwise.
  41989. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  41990. if _, ok := m.driver.(*txDriver); !ok {
  41991. return nil, errors.New("ent: mutation is not running in a transaction")
  41992. }
  41993. tx := &Tx{config: m.config}
  41994. tx.init()
  41995. return tx, nil
  41996. }
  41997. // SetID sets the value of the id field. Note that this
  41998. // operation is only accepted on creation of WpChatroomMember entities.
  41999. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  42000. m.id = &id
  42001. }
  42002. // ID returns the ID value in the mutation. Note that the ID is only available
  42003. // if it was provided to the builder or after it was returned from the database.
  42004. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  42005. if m.id == nil {
  42006. return
  42007. }
  42008. return *m.id, true
  42009. }
  42010. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42011. // That means, if the mutation is applied within a transaction with an isolation level such
  42012. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42013. // or updated by the mutation.
  42014. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  42015. switch {
  42016. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42017. id, exists := m.ID()
  42018. if exists {
  42019. return []uint64{id}, nil
  42020. }
  42021. fallthrough
  42022. case m.op.Is(OpUpdate | OpDelete):
  42023. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  42024. default:
  42025. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42026. }
  42027. }
  42028. // SetCreatedAt sets the "created_at" field.
  42029. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  42030. m.created_at = &t
  42031. }
  42032. // CreatedAt returns the value of the "created_at" field in the mutation.
  42033. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  42034. v := m.created_at
  42035. if v == nil {
  42036. return
  42037. }
  42038. return *v, true
  42039. }
  42040. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  42041. // If the WpChatroomMember 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 *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42044. if !m.op.Is(OpUpdateOne) {
  42045. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42046. }
  42047. if m.id == nil || m.oldValue == nil {
  42048. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  42053. }
  42054. return oldValue.CreatedAt, nil
  42055. }
  42056. // ResetCreatedAt resets all changes to the "created_at" field.
  42057. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  42058. m.created_at = nil
  42059. }
  42060. // SetUpdatedAt sets the "updated_at" field.
  42061. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  42062. m.updated_at = &t
  42063. }
  42064. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42065. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  42066. v := m.updated_at
  42067. if v == nil {
  42068. return
  42069. }
  42070. return *v, true
  42071. }
  42072. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  42073. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42075. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42076. if !m.op.Is(OpUpdateOne) {
  42077. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42078. }
  42079. if m.id == nil || m.oldValue == nil {
  42080. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42081. }
  42082. oldValue, err := m.oldValue(ctx)
  42083. if err != nil {
  42084. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42085. }
  42086. return oldValue.UpdatedAt, nil
  42087. }
  42088. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42089. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  42090. m.updated_at = nil
  42091. }
  42092. // SetStatus sets the "status" field.
  42093. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  42094. m.status = &u
  42095. m.addstatus = nil
  42096. }
  42097. // Status returns the value of the "status" field in the mutation.
  42098. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  42099. v := m.status
  42100. if v == nil {
  42101. return
  42102. }
  42103. return *v, true
  42104. }
  42105. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  42106. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42108. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42109. if !m.op.Is(OpUpdateOne) {
  42110. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42111. }
  42112. if m.id == nil || m.oldValue == nil {
  42113. return v, errors.New("OldStatus requires an ID field in the mutation")
  42114. }
  42115. oldValue, err := m.oldValue(ctx)
  42116. if err != nil {
  42117. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42118. }
  42119. return oldValue.Status, nil
  42120. }
  42121. // AddStatus adds u to the "status" field.
  42122. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  42123. if m.addstatus != nil {
  42124. *m.addstatus += u
  42125. } else {
  42126. m.addstatus = &u
  42127. }
  42128. }
  42129. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42130. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  42131. v := m.addstatus
  42132. if v == nil {
  42133. return
  42134. }
  42135. return *v, true
  42136. }
  42137. // ClearStatus clears the value of the "status" field.
  42138. func (m *WpChatroomMemberMutation) ClearStatus() {
  42139. m.status = nil
  42140. m.addstatus = nil
  42141. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  42142. }
  42143. // StatusCleared returns if the "status" field was cleared in this mutation.
  42144. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  42145. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  42146. return ok
  42147. }
  42148. // ResetStatus resets all changes to the "status" field.
  42149. func (m *WpChatroomMemberMutation) ResetStatus() {
  42150. m.status = nil
  42151. m.addstatus = nil
  42152. delete(m.clearedFields, wpchatroommember.FieldStatus)
  42153. }
  42154. // SetWxWxid sets the "wx_wxid" field.
  42155. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  42156. m.wx_wxid = &s
  42157. }
  42158. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  42159. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  42160. v := m.wx_wxid
  42161. if v == nil {
  42162. return
  42163. }
  42164. return *v, true
  42165. }
  42166. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  42167. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42169. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  42170. if !m.op.Is(OpUpdateOne) {
  42171. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  42172. }
  42173. if m.id == nil || m.oldValue == nil {
  42174. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  42175. }
  42176. oldValue, err := m.oldValue(ctx)
  42177. if err != nil {
  42178. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  42179. }
  42180. return oldValue.WxWxid, nil
  42181. }
  42182. // ResetWxWxid resets all changes to the "wx_wxid" field.
  42183. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  42184. m.wx_wxid = nil
  42185. }
  42186. // SetWxid sets the "wxid" field.
  42187. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  42188. m.wxid = &s
  42189. }
  42190. // Wxid returns the value of the "wxid" field in the mutation.
  42191. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  42192. v := m.wxid
  42193. if v == nil {
  42194. return
  42195. }
  42196. return *v, true
  42197. }
  42198. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  42199. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42201. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  42202. if !m.op.Is(OpUpdateOne) {
  42203. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  42204. }
  42205. if m.id == nil || m.oldValue == nil {
  42206. return v, errors.New("OldWxid requires an ID field in the mutation")
  42207. }
  42208. oldValue, err := m.oldValue(ctx)
  42209. if err != nil {
  42210. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  42211. }
  42212. return oldValue.Wxid, nil
  42213. }
  42214. // ResetWxid resets all changes to the "wxid" field.
  42215. func (m *WpChatroomMemberMutation) ResetWxid() {
  42216. m.wxid = nil
  42217. }
  42218. // SetNickname sets the "nickname" field.
  42219. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  42220. m.nickname = &s
  42221. }
  42222. // Nickname returns the value of the "nickname" field in the mutation.
  42223. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  42224. v := m.nickname
  42225. if v == nil {
  42226. return
  42227. }
  42228. return *v, true
  42229. }
  42230. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  42231. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42233. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  42234. if !m.op.Is(OpUpdateOne) {
  42235. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42236. }
  42237. if m.id == nil || m.oldValue == nil {
  42238. return v, errors.New("OldNickname requires an ID field in the mutation")
  42239. }
  42240. oldValue, err := m.oldValue(ctx)
  42241. if err != nil {
  42242. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42243. }
  42244. return oldValue.Nickname, nil
  42245. }
  42246. // ResetNickname resets all changes to the "nickname" field.
  42247. func (m *WpChatroomMemberMutation) ResetNickname() {
  42248. m.nickname = nil
  42249. }
  42250. // SetAvatar sets the "avatar" field.
  42251. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  42252. m.avatar = &s
  42253. }
  42254. // Avatar returns the value of the "avatar" field in the mutation.
  42255. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  42256. v := m.avatar
  42257. if v == nil {
  42258. return
  42259. }
  42260. return *v, true
  42261. }
  42262. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  42263. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42265. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42266. if !m.op.Is(OpUpdateOne) {
  42267. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42268. }
  42269. if m.id == nil || m.oldValue == nil {
  42270. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42271. }
  42272. oldValue, err := m.oldValue(ctx)
  42273. if err != nil {
  42274. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42275. }
  42276. return oldValue.Avatar, nil
  42277. }
  42278. // ResetAvatar resets all changes to the "avatar" field.
  42279. func (m *WpChatroomMemberMutation) ResetAvatar() {
  42280. m.avatar = nil
  42281. }
  42282. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  42283. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  42284. m.predicates = append(m.predicates, ps...)
  42285. }
  42286. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  42287. // users can use type-assertion to append predicates that do not depend on any generated package.
  42288. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  42289. p := make([]predicate.WpChatroomMember, len(ps))
  42290. for i := range ps {
  42291. p[i] = ps[i]
  42292. }
  42293. m.Where(p...)
  42294. }
  42295. // Op returns the operation name.
  42296. func (m *WpChatroomMemberMutation) Op() Op {
  42297. return m.op
  42298. }
  42299. // SetOp allows setting the mutation operation.
  42300. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  42301. m.op = op
  42302. }
  42303. // Type returns the node type of this mutation (WpChatroomMember).
  42304. func (m *WpChatroomMemberMutation) Type() string {
  42305. return m.typ
  42306. }
  42307. // Fields returns all fields that were changed during this mutation. Note that in
  42308. // order to get all numeric fields that were incremented/decremented, call
  42309. // AddedFields().
  42310. func (m *WpChatroomMemberMutation) Fields() []string {
  42311. fields := make([]string, 0, 7)
  42312. if m.created_at != nil {
  42313. fields = append(fields, wpchatroommember.FieldCreatedAt)
  42314. }
  42315. if m.updated_at != nil {
  42316. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  42317. }
  42318. if m.status != nil {
  42319. fields = append(fields, wpchatroommember.FieldStatus)
  42320. }
  42321. if m.wx_wxid != nil {
  42322. fields = append(fields, wpchatroommember.FieldWxWxid)
  42323. }
  42324. if m.wxid != nil {
  42325. fields = append(fields, wpchatroommember.FieldWxid)
  42326. }
  42327. if m.nickname != nil {
  42328. fields = append(fields, wpchatroommember.FieldNickname)
  42329. }
  42330. if m.avatar != nil {
  42331. fields = append(fields, wpchatroommember.FieldAvatar)
  42332. }
  42333. return fields
  42334. }
  42335. // Field returns the value of a field with the given name. The second boolean
  42336. // return value indicates that this field was not set, or was not defined in the
  42337. // schema.
  42338. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  42339. switch name {
  42340. case wpchatroommember.FieldCreatedAt:
  42341. return m.CreatedAt()
  42342. case wpchatroommember.FieldUpdatedAt:
  42343. return m.UpdatedAt()
  42344. case wpchatroommember.FieldStatus:
  42345. return m.Status()
  42346. case wpchatroommember.FieldWxWxid:
  42347. return m.WxWxid()
  42348. case wpchatroommember.FieldWxid:
  42349. return m.Wxid()
  42350. case wpchatroommember.FieldNickname:
  42351. return m.Nickname()
  42352. case wpchatroommember.FieldAvatar:
  42353. return m.Avatar()
  42354. }
  42355. return nil, false
  42356. }
  42357. // OldField returns the old value of the field from the database. An error is
  42358. // returned if the mutation operation is not UpdateOne, or the query to the
  42359. // database failed.
  42360. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42361. switch name {
  42362. case wpchatroommember.FieldCreatedAt:
  42363. return m.OldCreatedAt(ctx)
  42364. case wpchatroommember.FieldUpdatedAt:
  42365. return m.OldUpdatedAt(ctx)
  42366. case wpchatroommember.FieldStatus:
  42367. return m.OldStatus(ctx)
  42368. case wpchatroommember.FieldWxWxid:
  42369. return m.OldWxWxid(ctx)
  42370. case wpchatroommember.FieldWxid:
  42371. return m.OldWxid(ctx)
  42372. case wpchatroommember.FieldNickname:
  42373. return m.OldNickname(ctx)
  42374. case wpchatroommember.FieldAvatar:
  42375. return m.OldAvatar(ctx)
  42376. }
  42377. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  42378. }
  42379. // SetField sets the value of a field with the given name. It returns an error if
  42380. // the field is not defined in the schema, or if the type mismatched the field
  42381. // type.
  42382. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  42383. switch name {
  42384. case wpchatroommember.FieldCreatedAt:
  42385. v, ok := value.(time.Time)
  42386. if !ok {
  42387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42388. }
  42389. m.SetCreatedAt(v)
  42390. return nil
  42391. case wpchatroommember.FieldUpdatedAt:
  42392. v, ok := value.(time.Time)
  42393. if !ok {
  42394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42395. }
  42396. m.SetUpdatedAt(v)
  42397. return nil
  42398. case wpchatroommember.FieldStatus:
  42399. v, ok := value.(uint8)
  42400. if !ok {
  42401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42402. }
  42403. m.SetStatus(v)
  42404. return nil
  42405. case wpchatroommember.FieldWxWxid:
  42406. v, ok := value.(string)
  42407. if !ok {
  42408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42409. }
  42410. m.SetWxWxid(v)
  42411. return nil
  42412. case wpchatroommember.FieldWxid:
  42413. v, ok := value.(string)
  42414. if !ok {
  42415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42416. }
  42417. m.SetWxid(v)
  42418. return nil
  42419. case wpchatroommember.FieldNickname:
  42420. v, ok := value.(string)
  42421. if !ok {
  42422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42423. }
  42424. m.SetNickname(v)
  42425. return nil
  42426. case wpchatroommember.FieldAvatar:
  42427. v, ok := value.(string)
  42428. if !ok {
  42429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42430. }
  42431. m.SetAvatar(v)
  42432. return nil
  42433. }
  42434. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  42435. }
  42436. // AddedFields returns all numeric fields that were incremented/decremented during
  42437. // this mutation.
  42438. func (m *WpChatroomMemberMutation) AddedFields() []string {
  42439. var fields []string
  42440. if m.addstatus != nil {
  42441. fields = append(fields, wpchatroommember.FieldStatus)
  42442. }
  42443. return fields
  42444. }
  42445. // AddedField returns the numeric value that was incremented/decremented on a field
  42446. // with the given name. The second boolean return value indicates that this field
  42447. // was not set, or was not defined in the schema.
  42448. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  42449. switch name {
  42450. case wpchatroommember.FieldStatus:
  42451. return m.AddedStatus()
  42452. }
  42453. return nil, false
  42454. }
  42455. // AddField adds the value to the field with the given name. It returns an error if
  42456. // the field is not defined in the schema, or if the type mismatched the field
  42457. // type.
  42458. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  42459. switch name {
  42460. case wpchatroommember.FieldStatus:
  42461. v, ok := value.(int8)
  42462. if !ok {
  42463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42464. }
  42465. m.AddStatus(v)
  42466. return nil
  42467. }
  42468. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  42469. }
  42470. // ClearedFields returns all nullable fields that were cleared during this
  42471. // mutation.
  42472. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  42473. var fields []string
  42474. if m.FieldCleared(wpchatroommember.FieldStatus) {
  42475. fields = append(fields, wpchatroommember.FieldStatus)
  42476. }
  42477. return fields
  42478. }
  42479. // FieldCleared returns a boolean indicating if a field with the given name was
  42480. // cleared in this mutation.
  42481. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  42482. _, ok := m.clearedFields[name]
  42483. return ok
  42484. }
  42485. // ClearField clears the value of the field with the given name. It returns an
  42486. // error if the field is not defined in the schema.
  42487. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  42488. switch name {
  42489. case wpchatroommember.FieldStatus:
  42490. m.ClearStatus()
  42491. return nil
  42492. }
  42493. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  42494. }
  42495. // ResetField resets all changes in the mutation for the field with the given name.
  42496. // It returns an error if the field is not defined in the schema.
  42497. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  42498. switch name {
  42499. case wpchatroommember.FieldCreatedAt:
  42500. m.ResetCreatedAt()
  42501. return nil
  42502. case wpchatroommember.FieldUpdatedAt:
  42503. m.ResetUpdatedAt()
  42504. return nil
  42505. case wpchatroommember.FieldStatus:
  42506. m.ResetStatus()
  42507. return nil
  42508. case wpchatroommember.FieldWxWxid:
  42509. m.ResetWxWxid()
  42510. return nil
  42511. case wpchatroommember.FieldWxid:
  42512. m.ResetWxid()
  42513. return nil
  42514. case wpchatroommember.FieldNickname:
  42515. m.ResetNickname()
  42516. return nil
  42517. case wpchatroommember.FieldAvatar:
  42518. m.ResetAvatar()
  42519. return nil
  42520. }
  42521. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  42522. }
  42523. // AddedEdges returns all edge names that were set/added in this mutation.
  42524. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  42525. edges := make([]string, 0, 0)
  42526. return edges
  42527. }
  42528. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42529. // name in this mutation.
  42530. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  42531. return nil
  42532. }
  42533. // RemovedEdges returns all edge names that were removed in this mutation.
  42534. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  42535. edges := make([]string, 0, 0)
  42536. return edges
  42537. }
  42538. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42539. // the given name in this mutation.
  42540. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  42541. return nil
  42542. }
  42543. // ClearedEdges returns all edge names that were cleared in this mutation.
  42544. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  42545. edges := make([]string, 0, 0)
  42546. return edges
  42547. }
  42548. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42549. // was cleared in this mutation.
  42550. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  42551. return false
  42552. }
  42553. // ClearEdge clears the value of the edge with the given name. It returns an error
  42554. // if that edge is not defined in the schema.
  42555. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  42556. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  42557. }
  42558. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42559. // It returns an error if the edge is not defined in the schema.
  42560. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  42561. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  42562. }
  42563. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  42564. type WxMutation struct {
  42565. config
  42566. op Op
  42567. typ string
  42568. id *uint64
  42569. created_at *time.Time
  42570. updated_at *time.Time
  42571. status *uint8
  42572. addstatus *int8
  42573. deleted_at *time.Time
  42574. port *string
  42575. process_id *string
  42576. callback *string
  42577. wxid *string
  42578. account *string
  42579. nickname *string
  42580. tel *string
  42581. head_big *string
  42582. organization_id *uint64
  42583. addorganization_id *int64
  42584. api_base *string
  42585. api_key *string
  42586. allow_list *[]string
  42587. appendallow_list []string
  42588. group_allow_list *[]string
  42589. appendgroup_allow_list []string
  42590. block_list *[]string
  42591. appendblock_list []string
  42592. group_block_list *[]string
  42593. appendgroup_block_list []string
  42594. ctype *uint64
  42595. addctype *int64
  42596. clearedFields map[string]struct{}
  42597. server *uint64
  42598. clearedserver bool
  42599. agent *uint64
  42600. clearedagent bool
  42601. done bool
  42602. oldValue func(context.Context) (*Wx, error)
  42603. predicates []predicate.Wx
  42604. }
  42605. var _ ent.Mutation = (*WxMutation)(nil)
  42606. // wxOption allows management of the mutation configuration using functional options.
  42607. type wxOption func(*WxMutation)
  42608. // newWxMutation creates new mutation for the Wx entity.
  42609. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  42610. m := &WxMutation{
  42611. config: c,
  42612. op: op,
  42613. typ: TypeWx,
  42614. clearedFields: make(map[string]struct{}),
  42615. }
  42616. for _, opt := range opts {
  42617. opt(m)
  42618. }
  42619. return m
  42620. }
  42621. // withWxID sets the ID field of the mutation.
  42622. func withWxID(id uint64) wxOption {
  42623. return func(m *WxMutation) {
  42624. var (
  42625. err error
  42626. once sync.Once
  42627. value *Wx
  42628. )
  42629. m.oldValue = func(ctx context.Context) (*Wx, error) {
  42630. once.Do(func() {
  42631. if m.done {
  42632. err = errors.New("querying old values post mutation is not allowed")
  42633. } else {
  42634. value, err = m.Client().Wx.Get(ctx, id)
  42635. }
  42636. })
  42637. return value, err
  42638. }
  42639. m.id = &id
  42640. }
  42641. }
  42642. // withWx sets the old Wx of the mutation.
  42643. func withWx(node *Wx) wxOption {
  42644. return func(m *WxMutation) {
  42645. m.oldValue = func(context.Context) (*Wx, error) {
  42646. return node, nil
  42647. }
  42648. m.id = &node.ID
  42649. }
  42650. }
  42651. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42652. // executed in a transaction (ent.Tx), a transactional client is returned.
  42653. func (m WxMutation) Client() *Client {
  42654. client := &Client{config: m.config}
  42655. client.init()
  42656. return client
  42657. }
  42658. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42659. // it returns an error otherwise.
  42660. func (m WxMutation) Tx() (*Tx, error) {
  42661. if _, ok := m.driver.(*txDriver); !ok {
  42662. return nil, errors.New("ent: mutation is not running in a transaction")
  42663. }
  42664. tx := &Tx{config: m.config}
  42665. tx.init()
  42666. return tx, nil
  42667. }
  42668. // SetID sets the value of the id field. Note that this
  42669. // operation is only accepted on creation of Wx entities.
  42670. func (m *WxMutation) SetID(id uint64) {
  42671. m.id = &id
  42672. }
  42673. // ID returns the ID value in the mutation. Note that the ID is only available
  42674. // if it was provided to the builder or after it was returned from the database.
  42675. func (m *WxMutation) ID() (id uint64, exists bool) {
  42676. if m.id == nil {
  42677. return
  42678. }
  42679. return *m.id, true
  42680. }
  42681. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42682. // That means, if the mutation is applied within a transaction with an isolation level such
  42683. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42684. // or updated by the mutation.
  42685. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  42686. switch {
  42687. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42688. id, exists := m.ID()
  42689. if exists {
  42690. return []uint64{id}, nil
  42691. }
  42692. fallthrough
  42693. case m.op.Is(OpUpdate | OpDelete):
  42694. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  42695. default:
  42696. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42697. }
  42698. }
  42699. // SetCreatedAt sets the "created_at" field.
  42700. func (m *WxMutation) SetCreatedAt(t time.Time) {
  42701. m.created_at = &t
  42702. }
  42703. // CreatedAt returns the value of the "created_at" field in the mutation.
  42704. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  42705. v := m.created_at
  42706. if v == nil {
  42707. return
  42708. }
  42709. return *v, true
  42710. }
  42711. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  42712. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42714. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42715. if !m.op.Is(OpUpdateOne) {
  42716. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42717. }
  42718. if m.id == nil || m.oldValue == nil {
  42719. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42720. }
  42721. oldValue, err := m.oldValue(ctx)
  42722. if err != nil {
  42723. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42724. }
  42725. return oldValue.CreatedAt, nil
  42726. }
  42727. // ResetCreatedAt resets all changes to the "created_at" field.
  42728. func (m *WxMutation) ResetCreatedAt() {
  42729. m.created_at = nil
  42730. }
  42731. // SetUpdatedAt sets the "updated_at" field.
  42732. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  42733. m.updated_at = &t
  42734. }
  42735. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42736. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  42737. v := m.updated_at
  42738. if v == nil {
  42739. return
  42740. }
  42741. return *v, true
  42742. }
  42743. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  42744. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42746. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42747. if !m.op.Is(OpUpdateOne) {
  42748. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42749. }
  42750. if m.id == nil || m.oldValue == nil {
  42751. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42752. }
  42753. oldValue, err := m.oldValue(ctx)
  42754. if err != nil {
  42755. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42756. }
  42757. return oldValue.UpdatedAt, nil
  42758. }
  42759. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42760. func (m *WxMutation) ResetUpdatedAt() {
  42761. m.updated_at = nil
  42762. }
  42763. // SetStatus sets the "status" field.
  42764. func (m *WxMutation) SetStatus(u uint8) {
  42765. m.status = &u
  42766. m.addstatus = nil
  42767. }
  42768. // Status returns the value of the "status" field in the mutation.
  42769. func (m *WxMutation) Status() (r uint8, exists bool) {
  42770. v := m.status
  42771. if v == nil {
  42772. return
  42773. }
  42774. return *v, true
  42775. }
  42776. // OldStatus returns the old "status" field's value of the Wx entity.
  42777. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42779. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42780. if !m.op.Is(OpUpdateOne) {
  42781. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42782. }
  42783. if m.id == nil || m.oldValue == nil {
  42784. return v, errors.New("OldStatus requires an ID field in the mutation")
  42785. }
  42786. oldValue, err := m.oldValue(ctx)
  42787. if err != nil {
  42788. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42789. }
  42790. return oldValue.Status, nil
  42791. }
  42792. // AddStatus adds u to the "status" field.
  42793. func (m *WxMutation) AddStatus(u int8) {
  42794. if m.addstatus != nil {
  42795. *m.addstatus += u
  42796. } else {
  42797. m.addstatus = &u
  42798. }
  42799. }
  42800. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42801. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  42802. v := m.addstatus
  42803. if v == nil {
  42804. return
  42805. }
  42806. return *v, true
  42807. }
  42808. // ClearStatus clears the value of the "status" field.
  42809. func (m *WxMutation) ClearStatus() {
  42810. m.status = nil
  42811. m.addstatus = nil
  42812. m.clearedFields[wx.FieldStatus] = struct{}{}
  42813. }
  42814. // StatusCleared returns if the "status" field was cleared in this mutation.
  42815. func (m *WxMutation) StatusCleared() bool {
  42816. _, ok := m.clearedFields[wx.FieldStatus]
  42817. return ok
  42818. }
  42819. // ResetStatus resets all changes to the "status" field.
  42820. func (m *WxMutation) ResetStatus() {
  42821. m.status = nil
  42822. m.addstatus = nil
  42823. delete(m.clearedFields, wx.FieldStatus)
  42824. }
  42825. // SetDeletedAt sets the "deleted_at" field.
  42826. func (m *WxMutation) SetDeletedAt(t time.Time) {
  42827. m.deleted_at = &t
  42828. }
  42829. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42830. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  42831. v := m.deleted_at
  42832. if v == nil {
  42833. return
  42834. }
  42835. return *v, true
  42836. }
  42837. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  42838. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42840. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42841. if !m.op.Is(OpUpdateOne) {
  42842. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42843. }
  42844. if m.id == nil || m.oldValue == nil {
  42845. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42846. }
  42847. oldValue, err := m.oldValue(ctx)
  42848. if err != nil {
  42849. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42850. }
  42851. return oldValue.DeletedAt, nil
  42852. }
  42853. // ClearDeletedAt clears the value of the "deleted_at" field.
  42854. func (m *WxMutation) ClearDeletedAt() {
  42855. m.deleted_at = nil
  42856. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  42857. }
  42858. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42859. func (m *WxMutation) DeletedAtCleared() bool {
  42860. _, ok := m.clearedFields[wx.FieldDeletedAt]
  42861. return ok
  42862. }
  42863. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42864. func (m *WxMutation) ResetDeletedAt() {
  42865. m.deleted_at = nil
  42866. delete(m.clearedFields, wx.FieldDeletedAt)
  42867. }
  42868. // SetServerID sets the "server_id" field.
  42869. func (m *WxMutation) SetServerID(u uint64) {
  42870. m.server = &u
  42871. }
  42872. // ServerID returns the value of the "server_id" field in the mutation.
  42873. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  42874. v := m.server
  42875. if v == nil {
  42876. return
  42877. }
  42878. return *v, true
  42879. }
  42880. // OldServerID returns the old "server_id" field's value of the Wx entity.
  42881. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42883. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  42884. if !m.op.Is(OpUpdateOne) {
  42885. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  42886. }
  42887. if m.id == nil || m.oldValue == nil {
  42888. return v, errors.New("OldServerID requires an ID field in the mutation")
  42889. }
  42890. oldValue, err := m.oldValue(ctx)
  42891. if err != nil {
  42892. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  42893. }
  42894. return oldValue.ServerID, nil
  42895. }
  42896. // ClearServerID clears the value of the "server_id" field.
  42897. func (m *WxMutation) ClearServerID() {
  42898. m.server = nil
  42899. m.clearedFields[wx.FieldServerID] = struct{}{}
  42900. }
  42901. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  42902. func (m *WxMutation) ServerIDCleared() bool {
  42903. _, ok := m.clearedFields[wx.FieldServerID]
  42904. return ok
  42905. }
  42906. // ResetServerID resets all changes to the "server_id" field.
  42907. func (m *WxMutation) ResetServerID() {
  42908. m.server = nil
  42909. delete(m.clearedFields, wx.FieldServerID)
  42910. }
  42911. // SetPort sets the "port" field.
  42912. func (m *WxMutation) SetPort(s string) {
  42913. m.port = &s
  42914. }
  42915. // Port returns the value of the "port" field in the mutation.
  42916. func (m *WxMutation) Port() (r string, exists bool) {
  42917. v := m.port
  42918. if v == nil {
  42919. return
  42920. }
  42921. return *v, true
  42922. }
  42923. // OldPort returns the old "port" field's value of the Wx entity.
  42924. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42926. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  42927. if !m.op.Is(OpUpdateOne) {
  42928. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  42929. }
  42930. if m.id == nil || m.oldValue == nil {
  42931. return v, errors.New("OldPort requires an ID field in the mutation")
  42932. }
  42933. oldValue, err := m.oldValue(ctx)
  42934. if err != nil {
  42935. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  42936. }
  42937. return oldValue.Port, nil
  42938. }
  42939. // ResetPort resets all changes to the "port" field.
  42940. func (m *WxMutation) ResetPort() {
  42941. m.port = nil
  42942. }
  42943. // SetProcessID sets the "process_id" field.
  42944. func (m *WxMutation) SetProcessID(s string) {
  42945. m.process_id = &s
  42946. }
  42947. // ProcessID returns the value of the "process_id" field in the mutation.
  42948. func (m *WxMutation) ProcessID() (r string, exists bool) {
  42949. v := m.process_id
  42950. if v == nil {
  42951. return
  42952. }
  42953. return *v, true
  42954. }
  42955. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  42956. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42958. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  42959. if !m.op.Is(OpUpdateOne) {
  42960. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  42961. }
  42962. if m.id == nil || m.oldValue == nil {
  42963. return v, errors.New("OldProcessID requires an ID field in the mutation")
  42964. }
  42965. oldValue, err := m.oldValue(ctx)
  42966. if err != nil {
  42967. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  42968. }
  42969. return oldValue.ProcessID, nil
  42970. }
  42971. // ResetProcessID resets all changes to the "process_id" field.
  42972. func (m *WxMutation) ResetProcessID() {
  42973. m.process_id = nil
  42974. }
  42975. // SetCallback sets the "callback" field.
  42976. func (m *WxMutation) SetCallback(s string) {
  42977. m.callback = &s
  42978. }
  42979. // Callback returns the value of the "callback" field in the mutation.
  42980. func (m *WxMutation) Callback() (r string, exists bool) {
  42981. v := m.callback
  42982. if v == nil {
  42983. return
  42984. }
  42985. return *v, true
  42986. }
  42987. // OldCallback returns the old "callback" field's value of the Wx entity.
  42988. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42990. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  42991. if !m.op.Is(OpUpdateOne) {
  42992. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  42993. }
  42994. if m.id == nil || m.oldValue == nil {
  42995. return v, errors.New("OldCallback requires an ID field in the mutation")
  42996. }
  42997. oldValue, err := m.oldValue(ctx)
  42998. if err != nil {
  42999. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  43000. }
  43001. return oldValue.Callback, nil
  43002. }
  43003. // ResetCallback resets all changes to the "callback" field.
  43004. func (m *WxMutation) ResetCallback() {
  43005. m.callback = nil
  43006. }
  43007. // SetWxid sets the "wxid" field.
  43008. func (m *WxMutation) SetWxid(s string) {
  43009. m.wxid = &s
  43010. }
  43011. // Wxid returns the value of the "wxid" field in the mutation.
  43012. func (m *WxMutation) Wxid() (r string, exists bool) {
  43013. v := m.wxid
  43014. if v == nil {
  43015. return
  43016. }
  43017. return *v, true
  43018. }
  43019. // OldWxid returns the old "wxid" field's value of the Wx entity.
  43020. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43022. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  43023. if !m.op.Is(OpUpdateOne) {
  43024. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43025. }
  43026. if m.id == nil || m.oldValue == nil {
  43027. return v, errors.New("OldWxid requires an ID field in the mutation")
  43028. }
  43029. oldValue, err := m.oldValue(ctx)
  43030. if err != nil {
  43031. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43032. }
  43033. return oldValue.Wxid, nil
  43034. }
  43035. // ResetWxid resets all changes to the "wxid" field.
  43036. func (m *WxMutation) ResetWxid() {
  43037. m.wxid = nil
  43038. }
  43039. // SetAccount sets the "account" field.
  43040. func (m *WxMutation) SetAccount(s string) {
  43041. m.account = &s
  43042. }
  43043. // Account returns the value of the "account" field in the mutation.
  43044. func (m *WxMutation) Account() (r string, exists bool) {
  43045. v := m.account
  43046. if v == nil {
  43047. return
  43048. }
  43049. return *v, true
  43050. }
  43051. // OldAccount returns the old "account" field's value of the Wx entity.
  43052. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43054. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  43055. if !m.op.Is(OpUpdateOne) {
  43056. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43057. }
  43058. if m.id == nil || m.oldValue == nil {
  43059. return v, errors.New("OldAccount requires an ID field in the mutation")
  43060. }
  43061. oldValue, err := m.oldValue(ctx)
  43062. if err != nil {
  43063. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  43064. }
  43065. return oldValue.Account, nil
  43066. }
  43067. // ResetAccount resets all changes to the "account" field.
  43068. func (m *WxMutation) ResetAccount() {
  43069. m.account = nil
  43070. }
  43071. // SetNickname sets the "nickname" field.
  43072. func (m *WxMutation) SetNickname(s string) {
  43073. m.nickname = &s
  43074. }
  43075. // Nickname returns the value of the "nickname" field in the mutation.
  43076. func (m *WxMutation) Nickname() (r string, exists bool) {
  43077. v := m.nickname
  43078. if v == nil {
  43079. return
  43080. }
  43081. return *v, true
  43082. }
  43083. // OldNickname returns the old "nickname" field's value of the Wx entity.
  43084. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43086. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  43087. if !m.op.Is(OpUpdateOne) {
  43088. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43089. }
  43090. if m.id == nil || m.oldValue == nil {
  43091. return v, errors.New("OldNickname requires an ID field in the mutation")
  43092. }
  43093. oldValue, err := m.oldValue(ctx)
  43094. if err != nil {
  43095. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43096. }
  43097. return oldValue.Nickname, nil
  43098. }
  43099. // ResetNickname resets all changes to the "nickname" field.
  43100. func (m *WxMutation) ResetNickname() {
  43101. m.nickname = nil
  43102. }
  43103. // SetTel sets the "tel" field.
  43104. func (m *WxMutation) SetTel(s string) {
  43105. m.tel = &s
  43106. }
  43107. // Tel returns the value of the "tel" field in the mutation.
  43108. func (m *WxMutation) Tel() (r string, exists bool) {
  43109. v := m.tel
  43110. if v == nil {
  43111. return
  43112. }
  43113. return *v, true
  43114. }
  43115. // OldTel returns the old "tel" field's value of the Wx entity.
  43116. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43118. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  43119. if !m.op.Is(OpUpdateOne) {
  43120. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  43121. }
  43122. if m.id == nil || m.oldValue == nil {
  43123. return v, errors.New("OldTel requires an ID field in the mutation")
  43124. }
  43125. oldValue, err := m.oldValue(ctx)
  43126. if err != nil {
  43127. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  43128. }
  43129. return oldValue.Tel, nil
  43130. }
  43131. // ResetTel resets all changes to the "tel" field.
  43132. func (m *WxMutation) ResetTel() {
  43133. m.tel = nil
  43134. }
  43135. // SetHeadBig sets the "head_big" field.
  43136. func (m *WxMutation) SetHeadBig(s string) {
  43137. m.head_big = &s
  43138. }
  43139. // HeadBig returns the value of the "head_big" field in the mutation.
  43140. func (m *WxMutation) HeadBig() (r string, exists bool) {
  43141. v := m.head_big
  43142. if v == nil {
  43143. return
  43144. }
  43145. return *v, true
  43146. }
  43147. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  43148. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43150. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  43151. if !m.op.Is(OpUpdateOne) {
  43152. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  43153. }
  43154. if m.id == nil || m.oldValue == nil {
  43155. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  43156. }
  43157. oldValue, err := m.oldValue(ctx)
  43158. if err != nil {
  43159. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  43160. }
  43161. return oldValue.HeadBig, nil
  43162. }
  43163. // ResetHeadBig resets all changes to the "head_big" field.
  43164. func (m *WxMutation) ResetHeadBig() {
  43165. m.head_big = nil
  43166. }
  43167. // SetOrganizationID sets the "organization_id" field.
  43168. func (m *WxMutation) SetOrganizationID(u uint64) {
  43169. m.organization_id = &u
  43170. m.addorganization_id = nil
  43171. }
  43172. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43173. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  43174. v := m.organization_id
  43175. if v == nil {
  43176. return
  43177. }
  43178. return *v, true
  43179. }
  43180. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  43181. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43183. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43184. if !m.op.Is(OpUpdateOne) {
  43185. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43186. }
  43187. if m.id == nil || m.oldValue == nil {
  43188. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43189. }
  43190. oldValue, err := m.oldValue(ctx)
  43191. if err != nil {
  43192. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43193. }
  43194. return oldValue.OrganizationID, nil
  43195. }
  43196. // AddOrganizationID adds u to the "organization_id" field.
  43197. func (m *WxMutation) AddOrganizationID(u int64) {
  43198. if m.addorganization_id != nil {
  43199. *m.addorganization_id += u
  43200. } else {
  43201. m.addorganization_id = &u
  43202. }
  43203. }
  43204. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43205. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  43206. v := m.addorganization_id
  43207. if v == nil {
  43208. return
  43209. }
  43210. return *v, true
  43211. }
  43212. // ClearOrganizationID clears the value of the "organization_id" field.
  43213. func (m *WxMutation) ClearOrganizationID() {
  43214. m.organization_id = nil
  43215. m.addorganization_id = nil
  43216. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  43217. }
  43218. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  43219. func (m *WxMutation) OrganizationIDCleared() bool {
  43220. _, ok := m.clearedFields[wx.FieldOrganizationID]
  43221. return ok
  43222. }
  43223. // ResetOrganizationID resets all changes to the "organization_id" field.
  43224. func (m *WxMutation) ResetOrganizationID() {
  43225. m.organization_id = nil
  43226. m.addorganization_id = nil
  43227. delete(m.clearedFields, wx.FieldOrganizationID)
  43228. }
  43229. // SetAgentID sets the "agent_id" field.
  43230. func (m *WxMutation) SetAgentID(u uint64) {
  43231. m.agent = &u
  43232. }
  43233. // AgentID returns the value of the "agent_id" field in the mutation.
  43234. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  43235. v := m.agent
  43236. if v == nil {
  43237. return
  43238. }
  43239. return *v, true
  43240. }
  43241. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  43242. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43244. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  43245. if !m.op.Is(OpUpdateOne) {
  43246. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  43247. }
  43248. if m.id == nil || m.oldValue == nil {
  43249. return v, errors.New("OldAgentID requires an ID field in the mutation")
  43250. }
  43251. oldValue, err := m.oldValue(ctx)
  43252. if err != nil {
  43253. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  43254. }
  43255. return oldValue.AgentID, nil
  43256. }
  43257. // ResetAgentID resets all changes to the "agent_id" field.
  43258. func (m *WxMutation) ResetAgentID() {
  43259. m.agent = nil
  43260. }
  43261. // SetAPIBase sets the "api_base" field.
  43262. func (m *WxMutation) SetAPIBase(s string) {
  43263. m.api_base = &s
  43264. }
  43265. // APIBase returns the value of the "api_base" field in the mutation.
  43266. func (m *WxMutation) APIBase() (r string, exists bool) {
  43267. v := m.api_base
  43268. if v == nil {
  43269. return
  43270. }
  43271. return *v, true
  43272. }
  43273. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  43274. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43276. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43277. if !m.op.Is(OpUpdateOne) {
  43278. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43279. }
  43280. if m.id == nil || m.oldValue == nil {
  43281. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43282. }
  43283. oldValue, err := m.oldValue(ctx)
  43284. if err != nil {
  43285. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43286. }
  43287. return oldValue.APIBase, nil
  43288. }
  43289. // ClearAPIBase clears the value of the "api_base" field.
  43290. func (m *WxMutation) ClearAPIBase() {
  43291. m.api_base = nil
  43292. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  43293. }
  43294. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43295. func (m *WxMutation) APIBaseCleared() bool {
  43296. _, ok := m.clearedFields[wx.FieldAPIBase]
  43297. return ok
  43298. }
  43299. // ResetAPIBase resets all changes to the "api_base" field.
  43300. func (m *WxMutation) ResetAPIBase() {
  43301. m.api_base = nil
  43302. delete(m.clearedFields, wx.FieldAPIBase)
  43303. }
  43304. // SetAPIKey sets the "api_key" field.
  43305. func (m *WxMutation) SetAPIKey(s string) {
  43306. m.api_key = &s
  43307. }
  43308. // APIKey returns the value of the "api_key" field in the mutation.
  43309. func (m *WxMutation) APIKey() (r string, exists bool) {
  43310. v := m.api_key
  43311. if v == nil {
  43312. return
  43313. }
  43314. return *v, true
  43315. }
  43316. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  43317. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43319. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43320. if !m.op.Is(OpUpdateOne) {
  43321. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43322. }
  43323. if m.id == nil || m.oldValue == nil {
  43324. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43325. }
  43326. oldValue, err := m.oldValue(ctx)
  43327. if err != nil {
  43328. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43329. }
  43330. return oldValue.APIKey, nil
  43331. }
  43332. // ClearAPIKey clears the value of the "api_key" field.
  43333. func (m *WxMutation) ClearAPIKey() {
  43334. m.api_key = nil
  43335. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  43336. }
  43337. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43338. func (m *WxMutation) APIKeyCleared() bool {
  43339. _, ok := m.clearedFields[wx.FieldAPIKey]
  43340. return ok
  43341. }
  43342. // ResetAPIKey resets all changes to the "api_key" field.
  43343. func (m *WxMutation) ResetAPIKey() {
  43344. m.api_key = nil
  43345. delete(m.clearedFields, wx.FieldAPIKey)
  43346. }
  43347. // SetAllowList sets the "allow_list" field.
  43348. func (m *WxMutation) SetAllowList(s []string) {
  43349. m.allow_list = &s
  43350. m.appendallow_list = nil
  43351. }
  43352. // AllowList returns the value of the "allow_list" field in the mutation.
  43353. func (m *WxMutation) AllowList() (r []string, exists bool) {
  43354. v := m.allow_list
  43355. if v == nil {
  43356. return
  43357. }
  43358. return *v, true
  43359. }
  43360. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  43361. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43363. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  43364. if !m.op.Is(OpUpdateOne) {
  43365. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  43366. }
  43367. if m.id == nil || m.oldValue == nil {
  43368. return v, errors.New("OldAllowList requires an ID field in the mutation")
  43369. }
  43370. oldValue, err := m.oldValue(ctx)
  43371. if err != nil {
  43372. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  43373. }
  43374. return oldValue.AllowList, nil
  43375. }
  43376. // AppendAllowList adds s to the "allow_list" field.
  43377. func (m *WxMutation) AppendAllowList(s []string) {
  43378. m.appendallow_list = append(m.appendallow_list, s...)
  43379. }
  43380. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  43381. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  43382. if len(m.appendallow_list) == 0 {
  43383. return nil, false
  43384. }
  43385. return m.appendallow_list, true
  43386. }
  43387. // ResetAllowList resets all changes to the "allow_list" field.
  43388. func (m *WxMutation) ResetAllowList() {
  43389. m.allow_list = nil
  43390. m.appendallow_list = nil
  43391. }
  43392. // SetGroupAllowList sets the "group_allow_list" field.
  43393. func (m *WxMutation) SetGroupAllowList(s []string) {
  43394. m.group_allow_list = &s
  43395. m.appendgroup_allow_list = nil
  43396. }
  43397. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  43398. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  43399. v := m.group_allow_list
  43400. if v == nil {
  43401. return
  43402. }
  43403. return *v, true
  43404. }
  43405. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  43406. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43408. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  43409. if !m.op.Is(OpUpdateOne) {
  43410. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  43411. }
  43412. if m.id == nil || m.oldValue == nil {
  43413. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  43414. }
  43415. oldValue, err := m.oldValue(ctx)
  43416. if err != nil {
  43417. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  43418. }
  43419. return oldValue.GroupAllowList, nil
  43420. }
  43421. // AppendGroupAllowList adds s to the "group_allow_list" field.
  43422. func (m *WxMutation) AppendGroupAllowList(s []string) {
  43423. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  43424. }
  43425. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  43426. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  43427. if len(m.appendgroup_allow_list) == 0 {
  43428. return nil, false
  43429. }
  43430. return m.appendgroup_allow_list, true
  43431. }
  43432. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  43433. func (m *WxMutation) ResetGroupAllowList() {
  43434. m.group_allow_list = nil
  43435. m.appendgroup_allow_list = nil
  43436. }
  43437. // SetBlockList sets the "block_list" field.
  43438. func (m *WxMutation) SetBlockList(s []string) {
  43439. m.block_list = &s
  43440. m.appendblock_list = nil
  43441. }
  43442. // BlockList returns the value of the "block_list" field in the mutation.
  43443. func (m *WxMutation) BlockList() (r []string, exists bool) {
  43444. v := m.block_list
  43445. if v == nil {
  43446. return
  43447. }
  43448. return *v, true
  43449. }
  43450. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  43451. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43453. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  43454. if !m.op.Is(OpUpdateOne) {
  43455. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  43456. }
  43457. if m.id == nil || m.oldValue == nil {
  43458. return v, errors.New("OldBlockList requires an ID field in the mutation")
  43459. }
  43460. oldValue, err := m.oldValue(ctx)
  43461. if err != nil {
  43462. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  43463. }
  43464. return oldValue.BlockList, nil
  43465. }
  43466. // AppendBlockList adds s to the "block_list" field.
  43467. func (m *WxMutation) AppendBlockList(s []string) {
  43468. m.appendblock_list = append(m.appendblock_list, s...)
  43469. }
  43470. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  43471. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  43472. if len(m.appendblock_list) == 0 {
  43473. return nil, false
  43474. }
  43475. return m.appendblock_list, true
  43476. }
  43477. // ResetBlockList resets all changes to the "block_list" field.
  43478. func (m *WxMutation) ResetBlockList() {
  43479. m.block_list = nil
  43480. m.appendblock_list = nil
  43481. }
  43482. // SetGroupBlockList sets the "group_block_list" field.
  43483. func (m *WxMutation) SetGroupBlockList(s []string) {
  43484. m.group_block_list = &s
  43485. m.appendgroup_block_list = nil
  43486. }
  43487. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  43488. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  43489. v := m.group_block_list
  43490. if v == nil {
  43491. return
  43492. }
  43493. return *v, true
  43494. }
  43495. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  43496. // If the Wx 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 *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  43499. if !m.op.Is(OpUpdateOne) {
  43500. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  43501. }
  43502. if m.id == nil || m.oldValue == nil {
  43503. return v, errors.New("OldGroupBlockList 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 OldGroupBlockList: %w", err)
  43508. }
  43509. return oldValue.GroupBlockList, nil
  43510. }
  43511. // AppendGroupBlockList adds s to the "group_block_list" field.
  43512. func (m *WxMutation) AppendGroupBlockList(s []string) {
  43513. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  43514. }
  43515. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  43516. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  43517. if len(m.appendgroup_block_list) == 0 {
  43518. return nil, false
  43519. }
  43520. return m.appendgroup_block_list, true
  43521. }
  43522. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  43523. func (m *WxMutation) ResetGroupBlockList() {
  43524. m.group_block_list = nil
  43525. m.appendgroup_block_list = nil
  43526. }
  43527. // SetCtype sets the "ctype" field.
  43528. func (m *WxMutation) SetCtype(u uint64) {
  43529. m.ctype = &u
  43530. m.addctype = nil
  43531. }
  43532. // Ctype returns the value of the "ctype" field in the mutation.
  43533. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  43534. v := m.ctype
  43535. if v == nil {
  43536. return
  43537. }
  43538. return *v, true
  43539. }
  43540. // OldCtype returns the old "ctype" field's value of the Wx entity.
  43541. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43543. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  43544. if !m.op.Is(OpUpdateOne) {
  43545. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  43546. }
  43547. if m.id == nil || m.oldValue == nil {
  43548. return v, errors.New("OldCtype requires an ID field in the mutation")
  43549. }
  43550. oldValue, err := m.oldValue(ctx)
  43551. if err != nil {
  43552. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  43553. }
  43554. return oldValue.Ctype, nil
  43555. }
  43556. // AddCtype adds u to the "ctype" field.
  43557. func (m *WxMutation) AddCtype(u int64) {
  43558. if m.addctype != nil {
  43559. *m.addctype += u
  43560. } else {
  43561. m.addctype = &u
  43562. }
  43563. }
  43564. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  43565. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  43566. v := m.addctype
  43567. if v == nil {
  43568. return
  43569. }
  43570. return *v, true
  43571. }
  43572. // ClearCtype clears the value of the "ctype" field.
  43573. func (m *WxMutation) ClearCtype() {
  43574. m.ctype = nil
  43575. m.addctype = nil
  43576. m.clearedFields[wx.FieldCtype] = struct{}{}
  43577. }
  43578. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  43579. func (m *WxMutation) CtypeCleared() bool {
  43580. _, ok := m.clearedFields[wx.FieldCtype]
  43581. return ok
  43582. }
  43583. // ResetCtype resets all changes to the "ctype" field.
  43584. func (m *WxMutation) ResetCtype() {
  43585. m.ctype = nil
  43586. m.addctype = nil
  43587. delete(m.clearedFields, wx.FieldCtype)
  43588. }
  43589. // ClearServer clears the "server" edge to the Server entity.
  43590. func (m *WxMutation) ClearServer() {
  43591. m.clearedserver = true
  43592. m.clearedFields[wx.FieldServerID] = struct{}{}
  43593. }
  43594. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  43595. func (m *WxMutation) ServerCleared() bool {
  43596. return m.ServerIDCleared() || m.clearedserver
  43597. }
  43598. // ServerIDs returns the "server" edge IDs in the mutation.
  43599. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43600. // ServerID instead. It exists only for internal usage by the builders.
  43601. func (m *WxMutation) ServerIDs() (ids []uint64) {
  43602. if id := m.server; id != nil {
  43603. ids = append(ids, *id)
  43604. }
  43605. return
  43606. }
  43607. // ResetServer resets all changes to the "server" edge.
  43608. func (m *WxMutation) ResetServer() {
  43609. m.server = nil
  43610. m.clearedserver = false
  43611. }
  43612. // ClearAgent clears the "agent" edge to the Agent entity.
  43613. func (m *WxMutation) ClearAgent() {
  43614. m.clearedagent = true
  43615. m.clearedFields[wx.FieldAgentID] = struct{}{}
  43616. }
  43617. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  43618. func (m *WxMutation) AgentCleared() bool {
  43619. return m.clearedagent
  43620. }
  43621. // AgentIDs returns the "agent" edge IDs in the mutation.
  43622. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43623. // AgentID instead. It exists only for internal usage by the builders.
  43624. func (m *WxMutation) AgentIDs() (ids []uint64) {
  43625. if id := m.agent; id != nil {
  43626. ids = append(ids, *id)
  43627. }
  43628. return
  43629. }
  43630. // ResetAgent resets all changes to the "agent" edge.
  43631. func (m *WxMutation) ResetAgent() {
  43632. m.agent = nil
  43633. m.clearedagent = false
  43634. }
  43635. // Where appends a list predicates to the WxMutation builder.
  43636. func (m *WxMutation) Where(ps ...predicate.Wx) {
  43637. m.predicates = append(m.predicates, ps...)
  43638. }
  43639. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  43640. // users can use type-assertion to append predicates that do not depend on any generated package.
  43641. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  43642. p := make([]predicate.Wx, len(ps))
  43643. for i := range ps {
  43644. p[i] = ps[i]
  43645. }
  43646. m.Where(p...)
  43647. }
  43648. // Op returns the operation name.
  43649. func (m *WxMutation) Op() Op {
  43650. return m.op
  43651. }
  43652. // SetOp allows setting the mutation operation.
  43653. func (m *WxMutation) SetOp(op Op) {
  43654. m.op = op
  43655. }
  43656. // Type returns the node type of this mutation (Wx).
  43657. func (m *WxMutation) Type() string {
  43658. return m.typ
  43659. }
  43660. // Fields returns all fields that were changed during this mutation. Note that in
  43661. // order to get all numeric fields that were incremented/decremented, call
  43662. // AddedFields().
  43663. func (m *WxMutation) Fields() []string {
  43664. fields := make([]string, 0, 22)
  43665. if m.created_at != nil {
  43666. fields = append(fields, wx.FieldCreatedAt)
  43667. }
  43668. if m.updated_at != nil {
  43669. fields = append(fields, wx.FieldUpdatedAt)
  43670. }
  43671. if m.status != nil {
  43672. fields = append(fields, wx.FieldStatus)
  43673. }
  43674. if m.deleted_at != nil {
  43675. fields = append(fields, wx.FieldDeletedAt)
  43676. }
  43677. if m.server != nil {
  43678. fields = append(fields, wx.FieldServerID)
  43679. }
  43680. if m.port != nil {
  43681. fields = append(fields, wx.FieldPort)
  43682. }
  43683. if m.process_id != nil {
  43684. fields = append(fields, wx.FieldProcessID)
  43685. }
  43686. if m.callback != nil {
  43687. fields = append(fields, wx.FieldCallback)
  43688. }
  43689. if m.wxid != nil {
  43690. fields = append(fields, wx.FieldWxid)
  43691. }
  43692. if m.account != nil {
  43693. fields = append(fields, wx.FieldAccount)
  43694. }
  43695. if m.nickname != nil {
  43696. fields = append(fields, wx.FieldNickname)
  43697. }
  43698. if m.tel != nil {
  43699. fields = append(fields, wx.FieldTel)
  43700. }
  43701. if m.head_big != nil {
  43702. fields = append(fields, wx.FieldHeadBig)
  43703. }
  43704. if m.organization_id != nil {
  43705. fields = append(fields, wx.FieldOrganizationID)
  43706. }
  43707. if m.agent != nil {
  43708. fields = append(fields, wx.FieldAgentID)
  43709. }
  43710. if m.api_base != nil {
  43711. fields = append(fields, wx.FieldAPIBase)
  43712. }
  43713. if m.api_key != nil {
  43714. fields = append(fields, wx.FieldAPIKey)
  43715. }
  43716. if m.allow_list != nil {
  43717. fields = append(fields, wx.FieldAllowList)
  43718. }
  43719. if m.group_allow_list != nil {
  43720. fields = append(fields, wx.FieldGroupAllowList)
  43721. }
  43722. if m.block_list != nil {
  43723. fields = append(fields, wx.FieldBlockList)
  43724. }
  43725. if m.group_block_list != nil {
  43726. fields = append(fields, wx.FieldGroupBlockList)
  43727. }
  43728. if m.ctype != nil {
  43729. fields = append(fields, wx.FieldCtype)
  43730. }
  43731. return fields
  43732. }
  43733. // Field returns the value of a field with the given name. The second boolean
  43734. // return value indicates that this field was not set, or was not defined in the
  43735. // schema.
  43736. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  43737. switch name {
  43738. case wx.FieldCreatedAt:
  43739. return m.CreatedAt()
  43740. case wx.FieldUpdatedAt:
  43741. return m.UpdatedAt()
  43742. case wx.FieldStatus:
  43743. return m.Status()
  43744. case wx.FieldDeletedAt:
  43745. return m.DeletedAt()
  43746. case wx.FieldServerID:
  43747. return m.ServerID()
  43748. case wx.FieldPort:
  43749. return m.Port()
  43750. case wx.FieldProcessID:
  43751. return m.ProcessID()
  43752. case wx.FieldCallback:
  43753. return m.Callback()
  43754. case wx.FieldWxid:
  43755. return m.Wxid()
  43756. case wx.FieldAccount:
  43757. return m.Account()
  43758. case wx.FieldNickname:
  43759. return m.Nickname()
  43760. case wx.FieldTel:
  43761. return m.Tel()
  43762. case wx.FieldHeadBig:
  43763. return m.HeadBig()
  43764. case wx.FieldOrganizationID:
  43765. return m.OrganizationID()
  43766. case wx.FieldAgentID:
  43767. return m.AgentID()
  43768. case wx.FieldAPIBase:
  43769. return m.APIBase()
  43770. case wx.FieldAPIKey:
  43771. return m.APIKey()
  43772. case wx.FieldAllowList:
  43773. return m.AllowList()
  43774. case wx.FieldGroupAllowList:
  43775. return m.GroupAllowList()
  43776. case wx.FieldBlockList:
  43777. return m.BlockList()
  43778. case wx.FieldGroupBlockList:
  43779. return m.GroupBlockList()
  43780. case wx.FieldCtype:
  43781. return m.Ctype()
  43782. }
  43783. return nil, false
  43784. }
  43785. // OldField returns the old value of the field from the database. An error is
  43786. // returned if the mutation operation is not UpdateOne, or the query to the
  43787. // database failed.
  43788. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43789. switch name {
  43790. case wx.FieldCreatedAt:
  43791. return m.OldCreatedAt(ctx)
  43792. case wx.FieldUpdatedAt:
  43793. return m.OldUpdatedAt(ctx)
  43794. case wx.FieldStatus:
  43795. return m.OldStatus(ctx)
  43796. case wx.FieldDeletedAt:
  43797. return m.OldDeletedAt(ctx)
  43798. case wx.FieldServerID:
  43799. return m.OldServerID(ctx)
  43800. case wx.FieldPort:
  43801. return m.OldPort(ctx)
  43802. case wx.FieldProcessID:
  43803. return m.OldProcessID(ctx)
  43804. case wx.FieldCallback:
  43805. return m.OldCallback(ctx)
  43806. case wx.FieldWxid:
  43807. return m.OldWxid(ctx)
  43808. case wx.FieldAccount:
  43809. return m.OldAccount(ctx)
  43810. case wx.FieldNickname:
  43811. return m.OldNickname(ctx)
  43812. case wx.FieldTel:
  43813. return m.OldTel(ctx)
  43814. case wx.FieldHeadBig:
  43815. return m.OldHeadBig(ctx)
  43816. case wx.FieldOrganizationID:
  43817. return m.OldOrganizationID(ctx)
  43818. case wx.FieldAgentID:
  43819. return m.OldAgentID(ctx)
  43820. case wx.FieldAPIBase:
  43821. return m.OldAPIBase(ctx)
  43822. case wx.FieldAPIKey:
  43823. return m.OldAPIKey(ctx)
  43824. case wx.FieldAllowList:
  43825. return m.OldAllowList(ctx)
  43826. case wx.FieldGroupAllowList:
  43827. return m.OldGroupAllowList(ctx)
  43828. case wx.FieldBlockList:
  43829. return m.OldBlockList(ctx)
  43830. case wx.FieldGroupBlockList:
  43831. return m.OldGroupBlockList(ctx)
  43832. case wx.FieldCtype:
  43833. return m.OldCtype(ctx)
  43834. }
  43835. return nil, fmt.Errorf("unknown Wx field %s", name)
  43836. }
  43837. // SetField sets the value of a field with the given name. It returns an error if
  43838. // the field is not defined in the schema, or if the type mismatched the field
  43839. // type.
  43840. func (m *WxMutation) SetField(name string, value ent.Value) error {
  43841. switch name {
  43842. case wx.FieldCreatedAt:
  43843. v, ok := value.(time.Time)
  43844. if !ok {
  43845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43846. }
  43847. m.SetCreatedAt(v)
  43848. return nil
  43849. case wx.FieldUpdatedAt:
  43850. v, ok := value.(time.Time)
  43851. if !ok {
  43852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43853. }
  43854. m.SetUpdatedAt(v)
  43855. return nil
  43856. case wx.FieldStatus:
  43857. v, ok := value.(uint8)
  43858. if !ok {
  43859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43860. }
  43861. m.SetStatus(v)
  43862. return nil
  43863. case wx.FieldDeletedAt:
  43864. v, ok := value.(time.Time)
  43865. if !ok {
  43866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43867. }
  43868. m.SetDeletedAt(v)
  43869. return nil
  43870. case wx.FieldServerID:
  43871. v, ok := value.(uint64)
  43872. if !ok {
  43873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43874. }
  43875. m.SetServerID(v)
  43876. return nil
  43877. case wx.FieldPort:
  43878. v, ok := value.(string)
  43879. if !ok {
  43880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43881. }
  43882. m.SetPort(v)
  43883. return nil
  43884. case wx.FieldProcessID:
  43885. v, ok := value.(string)
  43886. if !ok {
  43887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43888. }
  43889. m.SetProcessID(v)
  43890. return nil
  43891. case wx.FieldCallback:
  43892. v, ok := value.(string)
  43893. if !ok {
  43894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43895. }
  43896. m.SetCallback(v)
  43897. return nil
  43898. case wx.FieldWxid:
  43899. v, ok := value.(string)
  43900. if !ok {
  43901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43902. }
  43903. m.SetWxid(v)
  43904. return nil
  43905. case wx.FieldAccount:
  43906. v, ok := value.(string)
  43907. if !ok {
  43908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43909. }
  43910. m.SetAccount(v)
  43911. return nil
  43912. case wx.FieldNickname:
  43913. v, ok := value.(string)
  43914. if !ok {
  43915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43916. }
  43917. m.SetNickname(v)
  43918. return nil
  43919. case wx.FieldTel:
  43920. v, ok := value.(string)
  43921. if !ok {
  43922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43923. }
  43924. m.SetTel(v)
  43925. return nil
  43926. case wx.FieldHeadBig:
  43927. v, ok := value.(string)
  43928. if !ok {
  43929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43930. }
  43931. m.SetHeadBig(v)
  43932. return nil
  43933. case wx.FieldOrganizationID:
  43934. v, ok := value.(uint64)
  43935. if !ok {
  43936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43937. }
  43938. m.SetOrganizationID(v)
  43939. return nil
  43940. case wx.FieldAgentID:
  43941. v, ok := value.(uint64)
  43942. if !ok {
  43943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43944. }
  43945. m.SetAgentID(v)
  43946. return nil
  43947. case wx.FieldAPIBase:
  43948. v, ok := value.(string)
  43949. if !ok {
  43950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43951. }
  43952. m.SetAPIBase(v)
  43953. return nil
  43954. case wx.FieldAPIKey:
  43955. v, ok := value.(string)
  43956. if !ok {
  43957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43958. }
  43959. m.SetAPIKey(v)
  43960. return nil
  43961. case wx.FieldAllowList:
  43962. v, ok := value.([]string)
  43963. if !ok {
  43964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43965. }
  43966. m.SetAllowList(v)
  43967. return nil
  43968. case wx.FieldGroupAllowList:
  43969. v, ok := value.([]string)
  43970. if !ok {
  43971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43972. }
  43973. m.SetGroupAllowList(v)
  43974. return nil
  43975. case wx.FieldBlockList:
  43976. v, ok := value.([]string)
  43977. if !ok {
  43978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43979. }
  43980. m.SetBlockList(v)
  43981. return nil
  43982. case wx.FieldGroupBlockList:
  43983. v, ok := value.([]string)
  43984. if !ok {
  43985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43986. }
  43987. m.SetGroupBlockList(v)
  43988. return nil
  43989. case wx.FieldCtype:
  43990. v, ok := value.(uint64)
  43991. if !ok {
  43992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43993. }
  43994. m.SetCtype(v)
  43995. return nil
  43996. }
  43997. return fmt.Errorf("unknown Wx field %s", name)
  43998. }
  43999. // AddedFields returns all numeric fields that were incremented/decremented during
  44000. // this mutation.
  44001. func (m *WxMutation) AddedFields() []string {
  44002. var fields []string
  44003. if m.addstatus != nil {
  44004. fields = append(fields, wx.FieldStatus)
  44005. }
  44006. if m.addorganization_id != nil {
  44007. fields = append(fields, wx.FieldOrganizationID)
  44008. }
  44009. if m.addctype != nil {
  44010. fields = append(fields, wx.FieldCtype)
  44011. }
  44012. return fields
  44013. }
  44014. // AddedField returns the numeric value that was incremented/decremented on a field
  44015. // with the given name. The second boolean return value indicates that this field
  44016. // was not set, or was not defined in the schema.
  44017. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  44018. switch name {
  44019. case wx.FieldStatus:
  44020. return m.AddedStatus()
  44021. case wx.FieldOrganizationID:
  44022. return m.AddedOrganizationID()
  44023. case wx.FieldCtype:
  44024. return m.AddedCtype()
  44025. }
  44026. return nil, false
  44027. }
  44028. // AddField adds the value to the field with the given name. It returns an error if
  44029. // the field is not defined in the schema, or if the type mismatched the field
  44030. // type.
  44031. func (m *WxMutation) AddField(name string, value ent.Value) error {
  44032. switch name {
  44033. case wx.FieldStatus:
  44034. v, ok := value.(int8)
  44035. if !ok {
  44036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44037. }
  44038. m.AddStatus(v)
  44039. return nil
  44040. case wx.FieldOrganizationID:
  44041. v, ok := value.(int64)
  44042. if !ok {
  44043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44044. }
  44045. m.AddOrganizationID(v)
  44046. return nil
  44047. case wx.FieldCtype:
  44048. v, ok := value.(int64)
  44049. if !ok {
  44050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44051. }
  44052. m.AddCtype(v)
  44053. return nil
  44054. }
  44055. return fmt.Errorf("unknown Wx numeric field %s", name)
  44056. }
  44057. // ClearedFields returns all nullable fields that were cleared during this
  44058. // mutation.
  44059. func (m *WxMutation) ClearedFields() []string {
  44060. var fields []string
  44061. if m.FieldCleared(wx.FieldStatus) {
  44062. fields = append(fields, wx.FieldStatus)
  44063. }
  44064. if m.FieldCleared(wx.FieldDeletedAt) {
  44065. fields = append(fields, wx.FieldDeletedAt)
  44066. }
  44067. if m.FieldCleared(wx.FieldServerID) {
  44068. fields = append(fields, wx.FieldServerID)
  44069. }
  44070. if m.FieldCleared(wx.FieldOrganizationID) {
  44071. fields = append(fields, wx.FieldOrganizationID)
  44072. }
  44073. if m.FieldCleared(wx.FieldAPIBase) {
  44074. fields = append(fields, wx.FieldAPIBase)
  44075. }
  44076. if m.FieldCleared(wx.FieldAPIKey) {
  44077. fields = append(fields, wx.FieldAPIKey)
  44078. }
  44079. if m.FieldCleared(wx.FieldCtype) {
  44080. fields = append(fields, wx.FieldCtype)
  44081. }
  44082. return fields
  44083. }
  44084. // FieldCleared returns a boolean indicating if a field with the given name was
  44085. // cleared in this mutation.
  44086. func (m *WxMutation) FieldCleared(name string) bool {
  44087. _, ok := m.clearedFields[name]
  44088. return ok
  44089. }
  44090. // ClearField clears the value of the field with the given name. It returns an
  44091. // error if the field is not defined in the schema.
  44092. func (m *WxMutation) ClearField(name string) error {
  44093. switch name {
  44094. case wx.FieldStatus:
  44095. m.ClearStatus()
  44096. return nil
  44097. case wx.FieldDeletedAt:
  44098. m.ClearDeletedAt()
  44099. return nil
  44100. case wx.FieldServerID:
  44101. m.ClearServerID()
  44102. return nil
  44103. case wx.FieldOrganizationID:
  44104. m.ClearOrganizationID()
  44105. return nil
  44106. case wx.FieldAPIBase:
  44107. m.ClearAPIBase()
  44108. return nil
  44109. case wx.FieldAPIKey:
  44110. m.ClearAPIKey()
  44111. return nil
  44112. case wx.FieldCtype:
  44113. m.ClearCtype()
  44114. return nil
  44115. }
  44116. return fmt.Errorf("unknown Wx nullable field %s", name)
  44117. }
  44118. // ResetField resets all changes in the mutation for the field with the given name.
  44119. // It returns an error if the field is not defined in the schema.
  44120. func (m *WxMutation) ResetField(name string) error {
  44121. switch name {
  44122. case wx.FieldCreatedAt:
  44123. m.ResetCreatedAt()
  44124. return nil
  44125. case wx.FieldUpdatedAt:
  44126. m.ResetUpdatedAt()
  44127. return nil
  44128. case wx.FieldStatus:
  44129. m.ResetStatus()
  44130. return nil
  44131. case wx.FieldDeletedAt:
  44132. m.ResetDeletedAt()
  44133. return nil
  44134. case wx.FieldServerID:
  44135. m.ResetServerID()
  44136. return nil
  44137. case wx.FieldPort:
  44138. m.ResetPort()
  44139. return nil
  44140. case wx.FieldProcessID:
  44141. m.ResetProcessID()
  44142. return nil
  44143. case wx.FieldCallback:
  44144. m.ResetCallback()
  44145. return nil
  44146. case wx.FieldWxid:
  44147. m.ResetWxid()
  44148. return nil
  44149. case wx.FieldAccount:
  44150. m.ResetAccount()
  44151. return nil
  44152. case wx.FieldNickname:
  44153. m.ResetNickname()
  44154. return nil
  44155. case wx.FieldTel:
  44156. m.ResetTel()
  44157. return nil
  44158. case wx.FieldHeadBig:
  44159. m.ResetHeadBig()
  44160. return nil
  44161. case wx.FieldOrganizationID:
  44162. m.ResetOrganizationID()
  44163. return nil
  44164. case wx.FieldAgentID:
  44165. m.ResetAgentID()
  44166. return nil
  44167. case wx.FieldAPIBase:
  44168. m.ResetAPIBase()
  44169. return nil
  44170. case wx.FieldAPIKey:
  44171. m.ResetAPIKey()
  44172. return nil
  44173. case wx.FieldAllowList:
  44174. m.ResetAllowList()
  44175. return nil
  44176. case wx.FieldGroupAllowList:
  44177. m.ResetGroupAllowList()
  44178. return nil
  44179. case wx.FieldBlockList:
  44180. m.ResetBlockList()
  44181. return nil
  44182. case wx.FieldGroupBlockList:
  44183. m.ResetGroupBlockList()
  44184. return nil
  44185. case wx.FieldCtype:
  44186. m.ResetCtype()
  44187. return nil
  44188. }
  44189. return fmt.Errorf("unknown Wx field %s", name)
  44190. }
  44191. // AddedEdges returns all edge names that were set/added in this mutation.
  44192. func (m *WxMutation) AddedEdges() []string {
  44193. edges := make([]string, 0, 2)
  44194. if m.server != nil {
  44195. edges = append(edges, wx.EdgeServer)
  44196. }
  44197. if m.agent != nil {
  44198. edges = append(edges, wx.EdgeAgent)
  44199. }
  44200. return edges
  44201. }
  44202. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44203. // name in this mutation.
  44204. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  44205. switch name {
  44206. case wx.EdgeServer:
  44207. if id := m.server; id != nil {
  44208. return []ent.Value{*id}
  44209. }
  44210. case wx.EdgeAgent:
  44211. if id := m.agent; id != nil {
  44212. return []ent.Value{*id}
  44213. }
  44214. }
  44215. return nil
  44216. }
  44217. // RemovedEdges returns all edge names that were removed in this mutation.
  44218. func (m *WxMutation) RemovedEdges() []string {
  44219. edges := make([]string, 0, 2)
  44220. return edges
  44221. }
  44222. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44223. // the given name in this mutation.
  44224. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  44225. return nil
  44226. }
  44227. // ClearedEdges returns all edge names that were cleared in this mutation.
  44228. func (m *WxMutation) ClearedEdges() []string {
  44229. edges := make([]string, 0, 2)
  44230. if m.clearedserver {
  44231. edges = append(edges, wx.EdgeServer)
  44232. }
  44233. if m.clearedagent {
  44234. edges = append(edges, wx.EdgeAgent)
  44235. }
  44236. return edges
  44237. }
  44238. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44239. // was cleared in this mutation.
  44240. func (m *WxMutation) EdgeCleared(name string) bool {
  44241. switch name {
  44242. case wx.EdgeServer:
  44243. return m.clearedserver
  44244. case wx.EdgeAgent:
  44245. return m.clearedagent
  44246. }
  44247. return false
  44248. }
  44249. // ClearEdge clears the value of the edge with the given name. It returns an error
  44250. // if that edge is not defined in the schema.
  44251. func (m *WxMutation) ClearEdge(name string) error {
  44252. switch name {
  44253. case wx.EdgeServer:
  44254. m.ClearServer()
  44255. return nil
  44256. case wx.EdgeAgent:
  44257. m.ClearAgent()
  44258. return nil
  44259. }
  44260. return fmt.Errorf("unknown Wx unique edge %s", name)
  44261. }
  44262. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44263. // It returns an error if the edge is not defined in the schema.
  44264. func (m *WxMutation) ResetEdge(name string) error {
  44265. switch name {
  44266. case wx.EdgeServer:
  44267. m.ResetServer()
  44268. return nil
  44269. case wx.EdgeAgent:
  44270. m.ResetAgent()
  44271. return nil
  44272. }
  44273. return fmt.Errorf("unknown Wx edge %s", name)
  44274. }
  44275. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  44276. type WxCardMutation struct {
  44277. config
  44278. op Op
  44279. typ string
  44280. id *uint64
  44281. created_at *time.Time
  44282. updated_at *time.Time
  44283. deleted_at *time.Time
  44284. user_id *uint64
  44285. adduser_id *int64
  44286. wx_user_id *uint64
  44287. addwx_user_id *int64
  44288. avatar *string
  44289. logo *string
  44290. name *string
  44291. company *string
  44292. address *string
  44293. phone *string
  44294. official_account *string
  44295. wechat_account *string
  44296. email *string
  44297. api_base *string
  44298. api_key *string
  44299. ai_info *string
  44300. intro *string
  44301. clearedFields map[string]struct{}
  44302. done bool
  44303. oldValue func(context.Context) (*WxCard, error)
  44304. predicates []predicate.WxCard
  44305. }
  44306. var _ ent.Mutation = (*WxCardMutation)(nil)
  44307. // wxcardOption allows management of the mutation configuration using functional options.
  44308. type wxcardOption func(*WxCardMutation)
  44309. // newWxCardMutation creates new mutation for the WxCard entity.
  44310. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  44311. m := &WxCardMutation{
  44312. config: c,
  44313. op: op,
  44314. typ: TypeWxCard,
  44315. clearedFields: make(map[string]struct{}),
  44316. }
  44317. for _, opt := range opts {
  44318. opt(m)
  44319. }
  44320. return m
  44321. }
  44322. // withWxCardID sets the ID field of the mutation.
  44323. func withWxCardID(id uint64) wxcardOption {
  44324. return func(m *WxCardMutation) {
  44325. var (
  44326. err error
  44327. once sync.Once
  44328. value *WxCard
  44329. )
  44330. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  44331. once.Do(func() {
  44332. if m.done {
  44333. err = errors.New("querying old values post mutation is not allowed")
  44334. } else {
  44335. value, err = m.Client().WxCard.Get(ctx, id)
  44336. }
  44337. })
  44338. return value, err
  44339. }
  44340. m.id = &id
  44341. }
  44342. }
  44343. // withWxCard sets the old WxCard of the mutation.
  44344. func withWxCard(node *WxCard) wxcardOption {
  44345. return func(m *WxCardMutation) {
  44346. m.oldValue = func(context.Context) (*WxCard, error) {
  44347. return node, nil
  44348. }
  44349. m.id = &node.ID
  44350. }
  44351. }
  44352. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44353. // executed in a transaction (ent.Tx), a transactional client is returned.
  44354. func (m WxCardMutation) Client() *Client {
  44355. client := &Client{config: m.config}
  44356. client.init()
  44357. return client
  44358. }
  44359. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44360. // it returns an error otherwise.
  44361. func (m WxCardMutation) Tx() (*Tx, error) {
  44362. if _, ok := m.driver.(*txDriver); !ok {
  44363. return nil, errors.New("ent: mutation is not running in a transaction")
  44364. }
  44365. tx := &Tx{config: m.config}
  44366. tx.init()
  44367. return tx, nil
  44368. }
  44369. // SetID sets the value of the id field. Note that this
  44370. // operation is only accepted on creation of WxCard entities.
  44371. func (m *WxCardMutation) SetID(id uint64) {
  44372. m.id = &id
  44373. }
  44374. // ID returns the ID value in the mutation. Note that the ID is only available
  44375. // if it was provided to the builder or after it was returned from the database.
  44376. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  44377. if m.id == nil {
  44378. return
  44379. }
  44380. return *m.id, true
  44381. }
  44382. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44383. // That means, if the mutation is applied within a transaction with an isolation level such
  44384. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44385. // or updated by the mutation.
  44386. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  44387. switch {
  44388. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44389. id, exists := m.ID()
  44390. if exists {
  44391. return []uint64{id}, nil
  44392. }
  44393. fallthrough
  44394. case m.op.Is(OpUpdate | OpDelete):
  44395. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  44396. default:
  44397. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44398. }
  44399. }
  44400. // SetCreatedAt sets the "created_at" field.
  44401. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  44402. m.created_at = &t
  44403. }
  44404. // CreatedAt returns the value of the "created_at" field in the mutation.
  44405. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  44406. v := m.created_at
  44407. if v == nil {
  44408. return
  44409. }
  44410. return *v, true
  44411. }
  44412. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  44413. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44415. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44416. if !m.op.Is(OpUpdateOne) {
  44417. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44418. }
  44419. if m.id == nil || m.oldValue == nil {
  44420. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44421. }
  44422. oldValue, err := m.oldValue(ctx)
  44423. if err != nil {
  44424. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44425. }
  44426. return oldValue.CreatedAt, nil
  44427. }
  44428. // ResetCreatedAt resets all changes to the "created_at" field.
  44429. func (m *WxCardMutation) ResetCreatedAt() {
  44430. m.created_at = nil
  44431. }
  44432. // SetUpdatedAt sets the "updated_at" field.
  44433. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  44434. m.updated_at = &t
  44435. }
  44436. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44437. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  44438. v := m.updated_at
  44439. if v == nil {
  44440. return
  44441. }
  44442. return *v, true
  44443. }
  44444. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  44445. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44447. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44448. if !m.op.Is(OpUpdateOne) {
  44449. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44450. }
  44451. if m.id == nil || m.oldValue == nil {
  44452. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44453. }
  44454. oldValue, err := m.oldValue(ctx)
  44455. if err != nil {
  44456. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44457. }
  44458. return oldValue.UpdatedAt, nil
  44459. }
  44460. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44461. func (m *WxCardMutation) ResetUpdatedAt() {
  44462. m.updated_at = nil
  44463. }
  44464. // SetDeletedAt sets the "deleted_at" field.
  44465. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  44466. m.deleted_at = &t
  44467. }
  44468. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44469. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  44470. v := m.deleted_at
  44471. if v == nil {
  44472. return
  44473. }
  44474. return *v, true
  44475. }
  44476. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  44477. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44479. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44480. if !m.op.Is(OpUpdateOne) {
  44481. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44482. }
  44483. if m.id == nil || m.oldValue == nil {
  44484. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44485. }
  44486. oldValue, err := m.oldValue(ctx)
  44487. if err != nil {
  44488. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44489. }
  44490. return oldValue.DeletedAt, nil
  44491. }
  44492. // ClearDeletedAt clears the value of the "deleted_at" field.
  44493. func (m *WxCardMutation) ClearDeletedAt() {
  44494. m.deleted_at = nil
  44495. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  44496. }
  44497. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44498. func (m *WxCardMutation) DeletedAtCleared() bool {
  44499. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  44500. return ok
  44501. }
  44502. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44503. func (m *WxCardMutation) ResetDeletedAt() {
  44504. m.deleted_at = nil
  44505. delete(m.clearedFields, wxcard.FieldDeletedAt)
  44506. }
  44507. // SetUserID sets the "user_id" field.
  44508. func (m *WxCardMutation) SetUserID(u uint64) {
  44509. m.user_id = &u
  44510. m.adduser_id = nil
  44511. }
  44512. // UserID returns the value of the "user_id" field in the mutation.
  44513. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  44514. v := m.user_id
  44515. if v == nil {
  44516. return
  44517. }
  44518. return *v, true
  44519. }
  44520. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  44521. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44523. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  44524. if !m.op.Is(OpUpdateOne) {
  44525. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  44526. }
  44527. if m.id == nil || m.oldValue == nil {
  44528. return v, errors.New("OldUserID requires an ID field in the mutation")
  44529. }
  44530. oldValue, err := m.oldValue(ctx)
  44531. if err != nil {
  44532. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  44533. }
  44534. return oldValue.UserID, nil
  44535. }
  44536. // AddUserID adds u to the "user_id" field.
  44537. func (m *WxCardMutation) AddUserID(u int64) {
  44538. if m.adduser_id != nil {
  44539. *m.adduser_id += u
  44540. } else {
  44541. m.adduser_id = &u
  44542. }
  44543. }
  44544. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44545. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  44546. v := m.adduser_id
  44547. if v == nil {
  44548. return
  44549. }
  44550. return *v, true
  44551. }
  44552. // ClearUserID clears the value of the "user_id" field.
  44553. func (m *WxCardMutation) ClearUserID() {
  44554. m.user_id = nil
  44555. m.adduser_id = nil
  44556. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  44557. }
  44558. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44559. func (m *WxCardMutation) UserIDCleared() bool {
  44560. _, ok := m.clearedFields[wxcard.FieldUserID]
  44561. return ok
  44562. }
  44563. // ResetUserID resets all changes to the "user_id" field.
  44564. func (m *WxCardMutation) ResetUserID() {
  44565. m.user_id = nil
  44566. m.adduser_id = nil
  44567. delete(m.clearedFields, wxcard.FieldUserID)
  44568. }
  44569. // SetWxUserID sets the "wx_user_id" field.
  44570. func (m *WxCardMutation) SetWxUserID(u uint64) {
  44571. m.wx_user_id = &u
  44572. m.addwx_user_id = nil
  44573. }
  44574. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  44575. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  44576. v := m.wx_user_id
  44577. if v == nil {
  44578. return
  44579. }
  44580. return *v, true
  44581. }
  44582. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  44583. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44585. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  44586. if !m.op.Is(OpUpdateOne) {
  44587. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  44588. }
  44589. if m.id == nil || m.oldValue == nil {
  44590. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  44591. }
  44592. oldValue, err := m.oldValue(ctx)
  44593. if err != nil {
  44594. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  44595. }
  44596. return oldValue.WxUserID, nil
  44597. }
  44598. // AddWxUserID adds u to the "wx_user_id" field.
  44599. func (m *WxCardMutation) AddWxUserID(u int64) {
  44600. if m.addwx_user_id != nil {
  44601. *m.addwx_user_id += u
  44602. } else {
  44603. m.addwx_user_id = &u
  44604. }
  44605. }
  44606. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  44607. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  44608. v := m.addwx_user_id
  44609. if v == nil {
  44610. return
  44611. }
  44612. return *v, true
  44613. }
  44614. // ClearWxUserID clears the value of the "wx_user_id" field.
  44615. func (m *WxCardMutation) ClearWxUserID() {
  44616. m.wx_user_id = nil
  44617. m.addwx_user_id = nil
  44618. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  44619. }
  44620. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  44621. func (m *WxCardMutation) WxUserIDCleared() bool {
  44622. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  44623. return ok
  44624. }
  44625. // ResetWxUserID resets all changes to the "wx_user_id" field.
  44626. func (m *WxCardMutation) ResetWxUserID() {
  44627. m.wx_user_id = nil
  44628. m.addwx_user_id = nil
  44629. delete(m.clearedFields, wxcard.FieldWxUserID)
  44630. }
  44631. // SetAvatar sets the "avatar" field.
  44632. func (m *WxCardMutation) SetAvatar(s string) {
  44633. m.avatar = &s
  44634. }
  44635. // Avatar returns the value of the "avatar" field in the mutation.
  44636. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  44637. v := m.avatar
  44638. if v == nil {
  44639. return
  44640. }
  44641. return *v, true
  44642. }
  44643. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  44644. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44646. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44647. if !m.op.Is(OpUpdateOne) {
  44648. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44649. }
  44650. if m.id == nil || m.oldValue == nil {
  44651. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44652. }
  44653. oldValue, err := m.oldValue(ctx)
  44654. if err != nil {
  44655. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44656. }
  44657. return oldValue.Avatar, nil
  44658. }
  44659. // ResetAvatar resets all changes to the "avatar" field.
  44660. func (m *WxCardMutation) ResetAvatar() {
  44661. m.avatar = nil
  44662. }
  44663. // SetLogo sets the "logo" field.
  44664. func (m *WxCardMutation) SetLogo(s string) {
  44665. m.logo = &s
  44666. }
  44667. // Logo returns the value of the "logo" field in the mutation.
  44668. func (m *WxCardMutation) Logo() (r string, exists bool) {
  44669. v := m.logo
  44670. if v == nil {
  44671. return
  44672. }
  44673. return *v, true
  44674. }
  44675. // OldLogo returns the old "logo" field's value of the WxCard entity.
  44676. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44678. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  44679. if !m.op.Is(OpUpdateOne) {
  44680. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  44681. }
  44682. if m.id == nil || m.oldValue == nil {
  44683. return v, errors.New("OldLogo requires an ID field in the mutation")
  44684. }
  44685. oldValue, err := m.oldValue(ctx)
  44686. if err != nil {
  44687. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  44688. }
  44689. return oldValue.Logo, nil
  44690. }
  44691. // ResetLogo resets all changes to the "logo" field.
  44692. func (m *WxCardMutation) ResetLogo() {
  44693. m.logo = nil
  44694. }
  44695. // SetName sets the "name" field.
  44696. func (m *WxCardMutation) SetName(s string) {
  44697. m.name = &s
  44698. }
  44699. // Name returns the value of the "name" field in the mutation.
  44700. func (m *WxCardMutation) Name() (r string, exists bool) {
  44701. v := m.name
  44702. if v == nil {
  44703. return
  44704. }
  44705. return *v, true
  44706. }
  44707. // OldName returns the old "name" field's value of the WxCard entity.
  44708. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44710. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  44711. if !m.op.Is(OpUpdateOne) {
  44712. return v, errors.New("OldName is only allowed on UpdateOne operations")
  44713. }
  44714. if m.id == nil || m.oldValue == nil {
  44715. return v, errors.New("OldName requires an ID field in the mutation")
  44716. }
  44717. oldValue, err := m.oldValue(ctx)
  44718. if err != nil {
  44719. return v, fmt.Errorf("querying old value for OldName: %w", err)
  44720. }
  44721. return oldValue.Name, nil
  44722. }
  44723. // ResetName resets all changes to the "name" field.
  44724. func (m *WxCardMutation) ResetName() {
  44725. m.name = nil
  44726. }
  44727. // SetCompany sets the "company" field.
  44728. func (m *WxCardMutation) SetCompany(s string) {
  44729. m.company = &s
  44730. }
  44731. // Company returns the value of the "company" field in the mutation.
  44732. func (m *WxCardMutation) Company() (r string, exists bool) {
  44733. v := m.company
  44734. if v == nil {
  44735. return
  44736. }
  44737. return *v, true
  44738. }
  44739. // OldCompany returns the old "company" field's value of the WxCard entity.
  44740. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44742. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  44743. if !m.op.Is(OpUpdateOne) {
  44744. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  44745. }
  44746. if m.id == nil || m.oldValue == nil {
  44747. return v, errors.New("OldCompany requires an ID field in the mutation")
  44748. }
  44749. oldValue, err := m.oldValue(ctx)
  44750. if err != nil {
  44751. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  44752. }
  44753. return oldValue.Company, nil
  44754. }
  44755. // ResetCompany resets all changes to the "company" field.
  44756. func (m *WxCardMutation) ResetCompany() {
  44757. m.company = nil
  44758. }
  44759. // SetAddress sets the "address" field.
  44760. func (m *WxCardMutation) SetAddress(s string) {
  44761. m.address = &s
  44762. }
  44763. // Address returns the value of the "address" field in the mutation.
  44764. func (m *WxCardMutation) Address() (r string, exists bool) {
  44765. v := m.address
  44766. if v == nil {
  44767. return
  44768. }
  44769. return *v, true
  44770. }
  44771. // OldAddress returns the old "address" field's value of the WxCard entity.
  44772. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44774. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  44775. if !m.op.Is(OpUpdateOne) {
  44776. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  44777. }
  44778. if m.id == nil || m.oldValue == nil {
  44779. return v, errors.New("OldAddress requires an ID field in the mutation")
  44780. }
  44781. oldValue, err := m.oldValue(ctx)
  44782. if err != nil {
  44783. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  44784. }
  44785. return oldValue.Address, nil
  44786. }
  44787. // ResetAddress resets all changes to the "address" field.
  44788. func (m *WxCardMutation) ResetAddress() {
  44789. m.address = nil
  44790. }
  44791. // SetPhone sets the "phone" field.
  44792. func (m *WxCardMutation) SetPhone(s string) {
  44793. m.phone = &s
  44794. }
  44795. // Phone returns the value of the "phone" field in the mutation.
  44796. func (m *WxCardMutation) Phone() (r string, exists bool) {
  44797. v := m.phone
  44798. if v == nil {
  44799. return
  44800. }
  44801. return *v, true
  44802. }
  44803. // OldPhone returns the old "phone" field's value of the WxCard entity.
  44804. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44806. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  44807. if !m.op.Is(OpUpdateOne) {
  44808. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44809. }
  44810. if m.id == nil || m.oldValue == nil {
  44811. return v, errors.New("OldPhone requires an ID field in the mutation")
  44812. }
  44813. oldValue, err := m.oldValue(ctx)
  44814. if err != nil {
  44815. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44816. }
  44817. return oldValue.Phone, nil
  44818. }
  44819. // ResetPhone resets all changes to the "phone" field.
  44820. func (m *WxCardMutation) ResetPhone() {
  44821. m.phone = nil
  44822. }
  44823. // SetOfficialAccount sets the "official_account" field.
  44824. func (m *WxCardMutation) SetOfficialAccount(s string) {
  44825. m.official_account = &s
  44826. }
  44827. // OfficialAccount returns the value of the "official_account" field in the mutation.
  44828. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  44829. v := m.official_account
  44830. if v == nil {
  44831. return
  44832. }
  44833. return *v, true
  44834. }
  44835. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  44836. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44838. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  44839. if !m.op.Is(OpUpdateOne) {
  44840. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  44841. }
  44842. if m.id == nil || m.oldValue == nil {
  44843. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  44844. }
  44845. oldValue, err := m.oldValue(ctx)
  44846. if err != nil {
  44847. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  44848. }
  44849. return oldValue.OfficialAccount, nil
  44850. }
  44851. // ResetOfficialAccount resets all changes to the "official_account" field.
  44852. func (m *WxCardMutation) ResetOfficialAccount() {
  44853. m.official_account = nil
  44854. }
  44855. // SetWechatAccount sets the "wechat_account" field.
  44856. func (m *WxCardMutation) SetWechatAccount(s string) {
  44857. m.wechat_account = &s
  44858. }
  44859. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  44860. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  44861. v := m.wechat_account
  44862. if v == nil {
  44863. return
  44864. }
  44865. return *v, true
  44866. }
  44867. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  44868. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44870. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  44871. if !m.op.Is(OpUpdateOne) {
  44872. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  44873. }
  44874. if m.id == nil || m.oldValue == nil {
  44875. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  44876. }
  44877. oldValue, err := m.oldValue(ctx)
  44878. if err != nil {
  44879. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  44880. }
  44881. return oldValue.WechatAccount, nil
  44882. }
  44883. // ResetWechatAccount resets all changes to the "wechat_account" field.
  44884. func (m *WxCardMutation) ResetWechatAccount() {
  44885. m.wechat_account = nil
  44886. }
  44887. // SetEmail sets the "email" field.
  44888. func (m *WxCardMutation) SetEmail(s string) {
  44889. m.email = &s
  44890. }
  44891. // Email returns the value of the "email" field in the mutation.
  44892. func (m *WxCardMutation) Email() (r string, exists bool) {
  44893. v := m.email
  44894. if v == nil {
  44895. return
  44896. }
  44897. return *v, true
  44898. }
  44899. // OldEmail returns the old "email" field's value of the WxCard entity.
  44900. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44902. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  44903. if !m.op.Is(OpUpdateOne) {
  44904. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  44905. }
  44906. if m.id == nil || m.oldValue == nil {
  44907. return v, errors.New("OldEmail requires an ID field in the mutation")
  44908. }
  44909. oldValue, err := m.oldValue(ctx)
  44910. if err != nil {
  44911. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  44912. }
  44913. return oldValue.Email, nil
  44914. }
  44915. // ClearEmail clears the value of the "email" field.
  44916. func (m *WxCardMutation) ClearEmail() {
  44917. m.email = nil
  44918. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  44919. }
  44920. // EmailCleared returns if the "email" field was cleared in this mutation.
  44921. func (m *WxCardMutation) EmailCleared() bool {
  44922. _, ok := m.clearedFields[wxcard.FieldEmail]
  44923. return ok
  44924. }
  44925. // ResetEmail resets all changes to the "email" field.
  44926. func (m *WxCardMutation) ResetEmail() {
  44927. m.email = nil
  44928. delete(m.clearedFields, wxcard.FieldEmail)
  44929. }
  44930. // SetAPIBase sets the "api_base" field.
  44931. func (m *WxCardMutation) SetAPIBase(s string) {
  44932. m.api_base = &s
  44933. }
  44934. // APIBase returns the value of the "api_base" field in the mutation.
  44935. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  44936. v := m.api_base
  44937. if v == nil {
  44938. return
  44939. }
  44940. return *v, true
  44941. }
  44942. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  44943. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44945. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  44946. if !m.op.Is(OpUpdateOne) {
  44947. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  44948. }
  44949. if m.id == nil || m.oldValue == nil {
  44950. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  44951. }
  44952. oldValue, err := m.oldValue(ctx)
  44953. if err != nil {
  44954. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  44955. }
  44956. return oldValue.APIBase, nil
  44957. }
  44958. // ClearAPIBase clears the value of the "api_base" field.
  44959. func (m *WxCardMutation) ClearAPIBase() {
  44960. m.api_base = nil
  44961. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  44962. }
  44963. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  44964. func (m *WxCardMutation) APIBaseCleared() bool {
  44965. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  44966. return ok
  44967. }
  44968. // ResetAPIBase resets all changes to the "api_base" field.
  44969. func (m *WxCardMutation) ResetAPIBase() {
  44970. m.api_base = nil
  44971. delete(m.clearedFields, wxcard.FieldAPIBase)
  44972. }
  44973. // SetAPIKey sets the "api_key" field.
  44974. func (m *WxCardMutation) SetAPIKey(s string) {
  44975. m.api_key = &s
  44976. }
  44977. // APIKey returns the value of the "api_key" field in the mutation.
  44978. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  44979. v := m.api_key
  44980. if v == nil {
  44981. return
  44982. }
  44983. return *v, true
  44984. }
  44985. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  44986. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44988. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  44989. if !m.op.Is(OpUpdateOne) {
  44990. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  44991. }
  44992. if m.id == nil || m.oldValue == nil {
  44993. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  44994. }
  44995. oldValue, err := m.oldValue(ctx)
  44996. if err != nil {
  44997. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  44998. }
  44999. return oldValue.APIKey, nil
  45000. }
  45001. // ClearAPIKey clears the value of the "api_key" field.
  45002. func (m *WxCardMutation) ClearAPIKey() {
  45003. m.api_key = nil
  45004. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  45005. }
  45006. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  45007. func (m *WxCardMutation) APIKeyCleared() bool {
  45008. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  45009. return ok
  45010. }
  45011. // ResetAPIKey resets all changes to the "api_key" field.
  45012. func (m *WxCardMutation) ResetAPIKey() {
  45013. m.api_key = nil
  45014. delete(m.clearedFields, wxcard.FieldAPIKey)
  45015. }
  45016. // SetAiInfo sets the "ai_info" field.
  45017. func (m *WxCardMutation) SetAiInfo(s string) {
  45018. m.ai_info = &s
  45019. }
  45020. // AiInfo returns the value of the "ai_info" field in the mutation.
  45021. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  45022. v := m.ai_info
  45023. if v == nil {
  45024. return
  45025. }
  45026. return *v, true
  45027. }
  45028. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  45029. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45031. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  45032. if !m.op.Is(OpUpdateOne) {
  45033. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  45034. }
  45035. if m.id == nil || m.oldValue == nil {
  45036. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  45037. }
  45038. oldValue, err := m.oldValue(ctx)
  45039. if err != nil {
  45040. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  45041. }
  45042. return oldValue.AiInfo, nil
  45043. }
  45044. // ClearAiInfo clears the value of the "ai_info" field.
  45045. func (m *WxCardMutation) ClearAiInfo() {
  45046. m.ai_info = nil
  45047. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  45048. }
  45049. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  45050. func (m *WxCardMutation) AiInfoCleared() bool {
  45051. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  45052. return ok
  45053. }
  45054. // ResetAiInfo resets all changes to the "ai_info" field.
  45055. func (m *WxCardMutation) ResetAiInfo() {
  45056. m.ai_info = nil
  45057. delete(m.clearedFields, wxcard.FieldAiInfo)
  45058. }
  45059. // SetIntro sets the "intro" field.
  45060. func (m *WxCardMutation) SetIntro(s string) {
  45061. m.intro = &s
  45062. }
  45063. // Intro returns the value of the "intro" field in the mutation.
  45064. func (m *WxCardMutation) Intro() (r string, exists bool) {
  45065. v := m.intro
  45066. if v == nil {
  45067. return
  45068. }
  45069. return *v, true
  45070. }
  45071. // OldIntro returns the old "intro" field's value of the WxCard entity.
  45072. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45074. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  45075. if !m.op.Is(OpUpdateOne) {
  45076. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  45077. }
  45078. if m.id == nil || m.oldValue == nil {
  45079. return v, errors.New("OldIntro requires an ID field in the mutation")
  45080. }
  45081. oldValue, err := m.oldValue(ctx)
  45082. if err != nil {
  45083. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  45084. }
  45085. return oldValue.Intro, nil
  45086. }
  45087. // ClearIntro clears the value of the "intro" field.
  45088. func (m *WxCardMutation) ClearIntro() {
  45089. m.intro = nil
  45090. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  45091. }
  45092. // IntroCleared returns if the "intro" field was cleared in this mutation.
  45093. func (m *WxCardMutation) IntroCleared() bool {
  45094. _, ok := m.clearedFields[wxcard.FieldIntro]
  45095. return ok
  45096. }
  45097. // ResetIntro resets all changes to the "intro" field.
  45098. func (m *WxCardMutation) ResetIntro() {
  45099. m.intro = nil
  45100. delete(m.clearedFields, wxcard.FieldIntro)
  45101. }
  45102. // Where appends a list predicates to the WxCardMutation builder.
  45103. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  45104. m.predicates = append(m.predicates, ps...)
  45105. }
  45106. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  45107. // users can use type-assertion to append predicates that do not depend on any generated package.
  45108. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  45109. p := make([]predicate.WxCard, len(ps))
  45110. for i := range ps {
  45111. p[i] = ps[i]
  45112. }
  45113. m.Where(p...)
  45114. }
  45115. // Op returns the operation name.
  45116. func (m *WxCardMutation) Op() Op {
  45117. return m.op
  45118. }
  45119. // SetOp allows setting the mutation operation.
  45120. func (m *WxCardMutation) SetOp(op Op) {
  45121. m.op = op
  45122. }
  45123. // Type returns the node type of this mutation (WxCard).
  45124. func (m *WxCardMutation) Type() string {
  45125. return m.typ
  45126. }
  45127. // Fields returns all fields that were changed during this mutation. Note that in
  45128. // order to get all numeric fields that were incremented/decremented, call
  45129. // AddedFields().
  45130. func (m *WxCardMutation) Fields() []string {
  45131. fields := make([]string, 0, 18)
  45132. if m.created_at != nil {
  45133. fields = append(fields, wxcard.FieldCreatedAt)
  45134. }
  45135. if m.updated_at != nil {
  45136. fields = append(fields, wxcard.FieldUpdatedAt)
  45137. }
  45138. if m.deleted_at != nil {
  45139. fields = append(fields, wxcard.FieldDeletedAt)
  45140. }
  45141. if m.user_id != nil {
  45142. fields = append(fields, wxcard.FieldUserID)
  45143. }
  45144. if m.wx_user_id != nil {
  45145. fields = append(fields, wxcard.FieldWxUserID)
  45146. }
  45147. if m.avatar != nil {
  45148. fields = append(fields, wxcard.FieldAvatar)
  45149. }
  45150. if m.logo != nil {
  45151. fields = append(fields, wxcard.FieldLogo)
  45152. }
  45153. if m.name != nil {
  45154. fields = append(fields, wxcard.FieldName)
  45155. }
  45156. if m.company != nil {
  45157. fields = append(fields, wxcard.FieldCompany)
  45158. }
  45159. if m.address != nil {
  45160. fields = append(fields, wxcard.FieldAddress)
  45161. }
  45162. if m.phone != nil {
  45163. fields = append(fields, wxcard.FieldPhone)
  45164. }
  45165. if m.official_account != nil {
  45166. fields = append(fields, wxcard.FieldOfficialAccount)
  45167. }
  45168. if m.wechat_account != nil {
  45169. fields = append(fields, wxcard.FieldWechatAccount)
  45170. }
  45171. if m.email != nil {
  45172. fields = append(fields, wxcard.FieldEmail)
  45173. }
  45174. if m.api_base != nil {
  45175. fields = append(fields, wxcard.FieldAPIBase)
  45176. }
  45177. if m.api_key != nil {
  45178. fields = append(fields, wxcard.FieldAPIKey)
  45179. }
  45180. if m.ai_info != nil {
  45181. fields = append(fields, wxcard.FieldAiInfo)
  45182. }
  45183. if m.intro != nil {
  45184. fields = append(fields, wxcard.FieldIntro)
  45185. }
  45186. return fields
  45187. }
  45188. // Field returns the value of a field with the given name. The second boolean
  45189. // return value indicates that this field was not set, or was not defined in the
  45190. // schema.
  45191. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  45192. switch name {
  45193. case wxcard.FieldCreatedAt:
  45194. return m.CreatedAt()
  45195. case wxcard.FieldUpdatedAt:
  45196. return m.UpdatedAt()
  45197. case wxcard.FieldDeletedAt:
  45198. return m.DeletedAt()
  45199. case wxcard.FieldUserID:
  45200. return m.UserID()
  45201. case wxcard.FieldWxUserID:
  45202. return m.WxUserID()
  45203. case wxcard.FieldAvatar:
  45204. return m.Avatar()
  45205. case wxcard.FieldLogo:
  45206. return m.Logo()
  45207. case wxcard.FieldName:
  45208. return m.Name()
  45209. case wxcard.FieldCompany:
  45210. return m.Company()
  45211. case wxcard.FieldAddress:
  45212. return m.Address()
  45213. case wxcard.FieldPhone:
  45214. return m.Phone()
  45215. case wxcard.FieldOfficialAccount:
  45216. return m.OfficialAccount()
  45217. case wxcard.FieldWechatAccount:
  45218. return m.WechatAccount()
  45219. case wxcard.FieldEmail:
  45220. return m.Email()
  45221. case wxcard.FieldAPIBase:
  45222. return m.APIBase()
  45223. case wxcard.FieldAPIKey:
  45224. return m.APIKey()
  45225. case wxcard.FieldAiInfo:
  45226. return m.AiInfo()
  45227. case wxcard.FieldIntro:
  45228. return m.Intro()
  45229. }
  45230. return nil, false
  45231. }
  45232. // OldField returns the old value of the field from the database. An error is
  45233. // returned if the mutation operation is not UpdateOne, or the query to the
  45234. // database failed.
  45235. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45236. switch name {
  45237. case wxcard.FieldCreatedAt:
  45238. return m.OldCreatedAt(ctx)
  45239. case wxcard.FieldUpdatedAt:
  45240. return m.OldUpdatedAt(ctx)
  45241. case wxcard.FieldDeletedAt:
  45242. return m.OldDeletedAt(ctx)
  45243. case wxcard.FieldUserID:
  45244. return m.OldUserID(ctx)
  45245. case wxcard.FieldWxUserID:
  45246. return m.OldWxUserID(ctx)
  45247. case wxcard.FieldAvatar:
  45248. return m.OldAvatar(ctx)
  45249. case wxcard.FieldLogo:
  45250. return m.OldLogo(ctx)
  45251. case wxcard.FieldName:
  45252. return m.OldName(ctx)
  45253. case wxcard.FieldCompany:
  45254. return m.OldCompany(ctx)
  45255. case wxcard.FieldAddress:
  45256. return m.OldAddress(ctx)
  45257. case wxcard.FieldPhone:
  45258. return m.OldPhone(ctx)
  45259. case wxcard.FieldOfficialAccount:
  45260. return m.OldOfficialAccount(ctx)
  45261. case wxcard.FieldWechatAccount:
  45262. return m.OldWechatAccount(ctx)
  45263. case wxcard.FieldEmail:
  45264. return m.OldEmail(ctx)
  45265. case wxcard.FieldAPIBase:
  45266. return m.OldAPIBase(ctx)
  45267. case wxcard.FieldAPIKey:
  45268. return m.OldAPIKey(ctx)
  45269. case wxcard.FieldAiInfo:
  45270. return m.OldAiInfo(ctx)
  45271. case wxcard.FieldIntro:
  45272. return m.OldIntro(ctx)
  45273. }
  45274. return nil, fmt.Errorf("unknown WxCard field %s", name)
  45275. }
  45276. // SetField sets the value of a field with the given name. It returns an error if
  45277. // the field is not defined in the schema, or if the type mismatched the field
  45278. // type.
  45279. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  45280. switch name {
  45281. case wxcard.FieldCreatedAt:
  45282. v, ok := value.(time.Time)
  45283. if !ok {
  45284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45285. }
  45286. m.SetCreatedAt(v)
  45287. return nil
  45288. case wxcard.FieldUpdatedAt:
  45289. v, ok := value.(time.Time)
  45290. if !ok {
  45291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45292. }
  45293. m.SetUpdatedAt(v)
  45294. return nil
  45295. case wxcard.FieldDeletedAt:
  45296. v, ok := value.(time.Time)
  45297. if !ok {
  45298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45299. }
  45300. m.SetDeletedAt(v)
  45301. return nil
  45302. case wxcard.FieldUserID:
  45303. v, ok := value.(uint64)
  45304. if !ok {
  45305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45306. }
  45307. m.SetUserID(v)
  45308. return nil
  45309. case wxcard.FieldWxUserID:
  45310. v, ok := value.(uint64)
  45311. if !ok {
  45312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45313. }
  45314. m.SetWxUserID(v)
  45315. return nil
  45316. case wxcard.FieldAvatar:
  45317. v, ok := value.(string)
  45318. if !ok {
  45319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45320. }
  45321. m.SetAvatar(v)
  45322. return nil
  45323. case wxcard.FieldLogo:
  45324. v, ok := value.(string)
  45325. if !ok {
  45326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45327. }
  45328. m.SetLogo(v)
  45329. return nil
  45330. case wxcard.FieldName:
  45331. v, ok := value.(string)
  45332. if !ok {
  45333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45334. }
  45335. m.SetName(v)
  45336. return nil
  45337. case wxcard.FieldCompany:
  45338. v, ok := value.(string)
  45339. if !ok {
  45340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45341. }
  45342. m.SetCompany(v)
  45343. return nil
  45344. case wxcard.FieldAddress:
  45345. v, ok := value.(string)
  45346. if !ok {
  45347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45348. }
  45349. m.SetAddress(v)
  45350. return nil
  45351. case wxcard.FieldPhone:
  45352. v, ok := value.(string)
  45353. if !ok {
  45354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45355. }
  45356. m.SetPhone(v)
  45357. return nil
  45358. case wxcard.FieldOfficialAccount:
  45359. v, ok := value.(string)
  45360. if !ok {
  45361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45362. }
  45363. m.SetOfficialAccount(v)
  45364. return nil
  45365. case wxcard.FieldWechatAccount:
  45366. v, ok := value.(string)
  45367. if !ok {
  45368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45369. }
  45370. m.SetWechatAccount(v)
  45371. return nil
  45372. case wxcard.FieldEmail:
  45373. v, ok := value.(string)
  45374. if !ok {
  45375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45376. }
  45377. m.SetEmail(v)
  45378. return nil
  45379. case wxcard.FieldAPIBase:
  45380. v, ok := value.(string)
  45381. if !ok {
  45382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45383. }
  45384. m.SetAPIBase(v)
  45385. return nil
  45386. case wxcard.FieldAPIKey:
  45387. v, ok := value.(string)
  45388. if !ok {
  45389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45390. }
  45391. m.SetAPIKey(v)
  45392. return nil
  45393. case wxcard.FieldAiInfo:
  45394. v, ok := value.(string)
  45395. if !ok {
  45396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45397. }
  45398. m.SetAiInfo(v)
  45399. return nil
  45400. case wxcard.FieldIntro:
  45401. v, ok := value.(string)
  45402. if !ok {
  45403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45404. }
  45405. m.SetIntro(v)
  45406. return nil
  45407. }
  45408. return fmt.Errorf("unknown WxCard field %s", name)
  45409. }
  45410. // AddedFields returns all numeric fields that were incremented/decremented during
  45411. // this mutation.
  45412. func (m *WxCardMutation) AddedFields() []string {
  45413. var fields []string
  45414. if m.adduser_id != nil {
  45415. fields = append(fields, wxcard.FieldUserID)
  45416. }
  45417. if m.addwx_user_id != nil {
  45418. fields = append(fields, wxcard.FieldWxUserID)
  45419. }
  45420. return fields
  45421. }
  45422. // AddedField returns the numeric value that was incremented/decremented on a field
  45423. // with the given name. The second boolean return value indicates that this field
  45424. // was not set, or was not defined in the schema.
  45425. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  45426. switch name {
  45427. case wxcard.FieldUserID:
  45428. return m.AddedUserID()
  45429. case wxcard.FieldWxUserID:
  45430. return m.AddedWxUserID()
  45431. }
  45432. return nil, false
  45433. }
  45434. // AddField adds the value to the field with the given name. It returns an error if
  45435. // the field is not defined in the schema, or if the type mismatched the field
  45436. // type.
  45437. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  45438. switch name {
  45439. case wxcard.FieldUserID:
  45440. v, ok := value.(int64)
  45441. if !ok {
  45442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45443. }
  45444. m.AddUserID(v)
  45445. return nil
  45446. case wxcard.FieldWxUserID:
  45447. v, ok := value.(int64)
  45448. if !ok {
  45449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45450. }
  45451. m.AddWxUserID(v)
  45452. return nil
  45453. }
  45454. return fmt.Errorf("unknown WxCard numeric field %s", name)
  45455. }
  45456. // ClearedFields returns all nullable fields that were cleared during this
  45457. // mutation.
  45458. func (m *WxCardMutation) ClearedFields() []string {
  45459. var fields []string
  45460. if m.FieldCleared(wxcard.FieldDeletedAt) {
  45461. fields = append(fields, wxcard.FieldDeletedAt)
  45462. }
  45463. if m.FieldCleared(wxcard.FieldUserID) {
  45464. fields = append(fields, wxcard.FieldUserID)
  45465. }
  45466. if m.FieldCleared(wxcard.FieldWxUserID) {
  45467. fields = append(fields, wxcard.FieldWxUserID)
  45468. }
  45469. if m.FieldCleared(wxcard.FieldEmail) {
  45470. fields = append(fields, wxcard.FieldEmail)
  45471. }
  45472. if m.FieldCleared(wxcard.FieldAPIBase) {
  45473. fields = append(fields, wxcard.FieldAPIBase)
  45474. }
  45475. if m.FieldCleared(wxcard.FieldAPIKey) {
  45476. fields = append(fields, wxcard.FieldAPIKey)
  45477. }
  45478. if m.FieldCleared(wxcard.FieldAiInfo) {
  45479. fields = append(fields, wxcard.FieldAiInfo)
  45480. }
  45481. if m.FieldCleared(wxcard.FieldIntro) {
  45482. fields = append(fields, wxcard.FieldIntro)
  45483. }
  45484. return fields
  45485. }
  45486. // FieldCleared returns a boolean indicating if a field with the given name was
  45487. // cleared in this mutation.
  45488. func (m *WxCardMutation) FieldCleared(name string) bool {
  45489. _, ok := m.clearedFields[name]
  45490. return ok
  45491. }
  45492. // ClearField clears the value of the field with the given name. It returns an
  45493. // error if the field is not defined in the schema.
  45494. func (m *WxCardMutation) ClearField(name string) error {
  45495. switch name {
  45496. case wxcard.FieldDeletedAt:
  45497. m.ClearDeletedAt()
  45498. return nil
  45499. case wxcard.FieldUserID:
  45500. m.ClearUserID()
  45501. return nil
  45502. case wxcard.FieldWxUserID:
  45503. m.ClearWxUserID()
  45504. return nil
  45505. case wxcard.FieldEmail:
  45506. m.ClearEmail()
  45507. return nil
  45508. case wxcard.FieldAPIBase:
  45509. m.ClearAPIBase()
  45510. return nil
  45511. case wxcard.FieldAPIKey:
  45512. m.ClearAPIKey()
  45513. return nil
  45514. case wxcard.FieldAiInfo:
  45515. m.ClearAiInfo()
  45516. return nil
  45517. case wxcard.FieldIntro:
  45518. m.ClearIntro()
  45519. return nil
  45520. }
  45521. return fmt.Errorf("unknown WxCard nullable field %s", name)
  45522. }
  45523. // ResetField resets all changes in the mutation for the field with the given name.
  45524. // It returns an error if the field is not defined in the schema.
  45525. func (m *WxCardMutation) ResetField(name string) error {
  45526. switch name {
  45527. case wxcard.FieldCreatedAt:
  45528. m.ResetCreatedAt()
  45529. return nil
  45530. case wxcard.FieldUpdatedAt:
  45531. m.ResetUpdatedAt()
  45532. return nil
  45533. case wxcard.FieldDeletedAt:
  45534. m.ResetDeletedAt()
  45535. return nil
  45536. case wxcard.FieldUserID:
  45537. m.ResetUserID()
  45538. return nil
  45539. case wxcard.FieldWxUserID:
  45540. m.ResetWxUserID()
  45541. return nil
  45542. case wxcard.FieldAvatar:
  45543. m.ResetAvatar()
  45544. return nil
  45545. case wxcard.FieldLogo:
  45546. m.ResetLogo()
  45547. return nil
  45548. case wxcard.FieldName:
  45549. m.ResetName()
  45550. return nil
  45551. case wxcard.FieldCompany:
  45552. m.ResetCompany()
  45553. return nil
  45554. case wxcard.FieldAddress:
  45555. m.ResetAddress()
  45556. return nil
  45557. case wxcard.FieldPhone:
  45558. m.ResetPhone()
  45559. return nil
  45560. case wxcard.FieldOfficialAccount:
  45561. m.ResetOfficialAccount()
  45562. return nil
  45563. case wxcard.FieldWechatAccount:
  45564. m.ResetWechatAccount()
  45565. return nil
  45566. case wxcard.FieldEmail:
  45567. m.ResetEmail()
  45568. return nil
  45569. case wxcard.FieldAPIBase:
  45570. m.ResetAPIBase()
  45571. return nil
  45572. case wxcard.FieldAPIKey:
  45573. m.ResetAPIKey()
  45574. return nil
  45575. case wxcard.FieldAiInfo:
  45576. m.ResetAiInfo()
  45577. return nil
  45578. case wxcard.FieldIntro:
  45579. m.ResetIntro()
  45580. return nil
  45581. }
  45582. return fmt.Errorf("unknown WxCard field %s", name)
  45583. }
  45584. // AddedEdges returns all edge names that were set/added in this mutation.
  45585. func (m *WxCardMutation) AddedEdges() []string {
  45586. edges := make([]string, 0, 0)
  45587. return edges
  45588. }
  45589. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45590. // name in this mutation.
  45591. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  45592. return nil
  45593. }
  45594. // RemovedEdges returns all edge names that were removed in this mutation.
  45595. func (m *WxCardMutation) RemovedEdges() []string {
  45596. edges := make([]string, 0, 0)
  45597. return edges
  45598. }
  45599. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45600. // the given name in this mutation.
  45601. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  45602. return nil
  45603. }
  45604. // ClearedEdges returns all edge names that were cleared in this mutation.
  45605. func (m *WxCardMutation) ClearedEdges() []string {
  45606. edges := make([]string, 0, 0)
  45607. return edges
  45608. }
  45609. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45610. // was cleared in this mutation.
  45611. func (m *WxCardMutation) EdgeCleared(name string) bool {
  45612. return false
  45613. }
  45614. // ClearEdge clears the value of the edge with the given name. It returns an error
  45615. // if that edge is not defined in the schema.
  45616. func (m *WxCardMutation) ClearEdge(name string) error {
  45617. return fmt.Errorf("unknown WxCard unique edge %s", name)
  45618. }
  45619. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45620. // It returns an error if the edge is not defined in the schema.
  45621. func (m *WxCardMutation) ResetEdge(name string) error {
  45622. return fmt.Errorf("unknown WxCard edge %s", name)
  45623. }
  45624. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  45625. type WxCardUserMutation struct {
  45626. config
  45627. op Op
  45628. typ string
  45629. id *uint64
  45630. created_at *time.Time
  45631. updated_at *time.Time
  45632. deleted_at *time.Time
  45633. wxid *string
  45634. account *string
  45635. avatar *string
  45636. nickname *string
  45637. remark *string
  45638. phone *string
  45639. open_id *string
  45640. union_id *string
  45641. session_key *string
  45642. is_vip *int
  45643. addis_vip *int
  45644. clearedFields map[string]struct{}
  45645. done bool
  45646. oldValue func(context.Context) (*WxCardUser, error)
  45647. predicates []predicate.WxCardUser
  45648. }
  45649. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  45650. // wxcarduserOption allows management of the mutation configuration using functional options.
  45651. type wxcarduserOption func(*WxCardUserMutation)
  45652. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  45653. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  45654. m := &WxCardUserMutation{
  45655. config: c,
  45656. op: op,
  45657. typ: TypeWxCardUser,
  45658. clearedFields: make(map[string]struct{}),
  45659. }
  45660. for _, opt := range opts {
  45661. opt(m)
  45662. }
  45663. return m
  45664. }
  45665. // withWxCardUserID sets the ID field of the mutation.
  45666. func withWxCardUserID(id uint64) wxcarduserOption {
  45667. return func(m *WxCardUserMutation) {
  45668. var (
  45669. err error
  45670. once sync.Once
  45671. value *WxCardUser
  45672. )
  45673. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  45674. once.Do(func() {
  45675. if m.done {
  45676. err = errors.New("querying old values post mutation is not allowed")
  45677. } else {
  45678. value, err = m.Client().WxCardUser.Get(ctx, id)
  45679. }
  45680. })
  45681. return value, err
  45682. }
  45683. m.id = &id
  45684. }
  45685. }
  45686. // withWxCardUser sets the old WxCardUser of the mutation.
  45687. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  45688. return func(m *WxCardUserMutation) {
  45689. m.oldValue = func(context.Context) (*WxCardUser, error) {
  45690. return node, nil
  45691. }
  45692. m.id = &node.ID
  45693. }
  45694. }
  45695. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45696. // executed in a transaction (ent.Tx), a transactional client is returned.
  45697. func (m WxCardUserMutation) Client() *Client {
  45698. client := &Client{config: m.config}
  45699. client.init()
  45700. return client
  45701. }
  45702. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45703. // it returns an error otherwise.
  45704. func (m WxCardUserMutation) Tx() (*Tx, error) {
  45705. if _, ok := m.driver.(*txDriver); !ok {
  45706. return nil, errors.New("ent: mutation is not running in a transaction")
  45707. }
  45708. tx := &Tx{config: m.config}
  45709. tx.init()
  45710. return tx, nil
  45711. }
  45712. // SetID sets the value of the id field. Note that this
  45713. // operation is only accepted on creation of WxCardUser entities.
  45714. func (m *WxCardUserMutation) SetID(id uint64) {
  45715. m.id = &id
  45716. }
  45717. // ID returns the ID value in the mutation. Note that the ID is only available
  45718. // if it was provided to the builder or after it was returned from the database.
  45719. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  45720. if m.id == nil {
  45721. return
  45722. }
  45723. return *m.id, true
  45724. }
  45725. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45726. // That means, if the mutation is applied within a transaction with an isolation level such
  45727. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45728. // or updated by the mutation.
  45729. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  45730. switch {
  45731. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45732. id, exists := m.ID()
  45733. if exists {
  45734. return []uint64{id}, nil
  45735. }
  45736. fallthrough
  45737. case m.op.Is(OpUpdate | OpDelete):
  45738. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  45739. default:
  45740. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45741. }
  45742. }
  45743. // SetCreatedAt sets the "created_at" field.
  45744. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  45745. m.created_at = &t
  45746. }
  45747. // CreatedAt returns the value of the "created_at" field in the mutation.
  45748. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  45749. v := m.created_at
  45750. if v == nil {
  45751. return
  45752. }
  45753. return *v, true
  45754. }
  45755. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  45756. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45758. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45759. if !m.op.Is(OpUpdateOne) {
  45760. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45761. }
  45762. if m.id == nil || m.oldValue == nil {
  45763. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45764. }
  45765. oldValue, err := m.oldValue(ctx)
  45766. if err != nil {
  45767. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45768. }
  45769. return oldValue.CreatedAt, nil
  45770. }
  45771. // ResetCreatedAt resets all changes to the "created_at" field.
  45772. func (m *WxCardUserMutation) ResetCreatedAt() {
  45773. m.created_at = nil
  45774. }
  45775. // SetUpdatedAt sets the "updated_at" field.
  45776. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  45777. m.updated_at = &t
  45778. }
  45779. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45780. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  45781. v := m.updated_at
  45782. if v == nil {
  45783. return
  45784. }
  45785. return *v, true
  45786. }
  45787. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  45788. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45790. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45791. if !m.op.Is(OpUpdateOne) {
  45792. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45793. }
  45794. if m.id == nil || m.oldValue == nil {
  45795. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45796. }
  45797. oldValue, err := m.oldValue(ctx)
  45798. if err != nil {
  45799. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45800. }
  45801. return oldValue.UpdatedAt, nil
  45802. }
  45803. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45804. func (m *WxCardUserMutation) ResetUpdatedAt() {
  45805. m.updated_at = nil
  45806. }
  45807. // SetDeletedAt sets the "deleted_at" field.
  45808. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  45809. m.deleted_at = &t
  45810. }
  45811. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45812. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  45813. v := m.deleted_at
  45814. if v == nil {
  45815. return
  45816. }
  45817. return *v, true
  45818. }
  45819. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  45820. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45822. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45823. if !m.op.Is(OpUpdateOne) {
  45824. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45825. }
  45826. if m.id == nil || m.oldValue == nil {
  45827. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45828. }
  45829. oldValue, err := m.oldValue(ctx)
  45830. if err != nil {
  45831. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45832. }
  45833. return oldValue.DeletedAt, nil
  45834. }
  45835. // ClearDeletedAt clears the value of the "deleted_at" field.
  45836. func (m *WxCardUserMutation) ClearDeletedAt() {
  45837. m.deleted_at = nil
  45838. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  45839. }
  45840. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45841. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  45842. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  45843. return ok
  45844. }
  45845. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45846. func (m *WxCardUserMutation) ResetDeletedAt() {
  45847. m.deleted_at = nil
  45848. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  45849. }
  45850. // SetWxid sets the "wxid" field.
  45851. func (m *WxCardUserMutation) SetWxid(s string) {
  45852. m.wxid = &s
  45853. }
  45854. // Wxid returns the value of the "wxid" field in the mutation.
  45855. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  45856. v := m.wxid
  45857. if v == nil {
  45858. return
  45859. }
  45860. return *v, true
  45861. }
  45862. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  45863. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45865. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  45866. if !m.op.Is(OpUpdateOne) {
  45867. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45868. }
  45869. if m.id == nil || m.oldValue == nil {
  45870. return v, errors.New("OldWxid requires an ID field in the mutation")
  45871. }
  45872. oldValue, err := m.oldValue(ctx)
  45873. if err != nil {
  45874. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45875. }
  45876. return oldValue.Wxid, nil
  45877. }
  45878. // ResetWxid resets all changes to the "wxid" field.
  45879. func (m *WxCardUserMutation) ResetWxid() {
  45880. m.wxid = nil
  45881. }
  45882. // SetAccount sets the "account" field.
  45883. func (m *WxCardUserMutation) SetAccount(s string) {
  45884. m.account = &s
  45885. }
  45886. // Account returns the value of the "account" field in the mutation.
  45887. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  45888. v := m.account
  45889. if v == nil {
  45890. return
  45891. }
  45892. return *v, true
  45893. }
  45894. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  45895. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45897. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  45898. if !m.op.Is(OpUpdateOne) {
  45899. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  45900. }
  45901. if m.id == nil || m.oldValue == nil {
  45902. return v, errors.New("OldAccount requires an ID field in the mutation")
  45903. }
  45904. oldValue, err := m.oldValue(ctx)
  45905. if err != nil {
  45906. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  45907. }
  45908. return oldValue.Account, nil
  45909. }
  45910. // ResetAccount resets all changes to the "account" field.
  45911. func (m *WxCardUserMutation) ResetAccount() {
  45912. m.account = nil
  45913. }
  45914. // SetAvatar sets the "avatar" field.
  45915. func (m *WxCardUserMutation) SetAvatar(s string) {
  45916. m.avatar = &s
  45917. }
  45918. // Avatar returns the value of the "avatar" field in the mutation.
  45919. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  45920. v := m.avatar
  45921. if v == nil {
  45922. return
  45923. }
  45924. return *v, true
  45925. }
  45926. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  45927. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45929. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45930. if !m.op.Is(OpUpdateOne) {
  45931. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45932. }
  45933. if m.id == nil || m.oldValue == nil {
  45934. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45935. }
  45936. oldValue, err := m.oldValue(ctx)
  45937. if err != nil {
  45938. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45939. }
  45940. return oldValue.Avatar, nil
  45941. }
  45942. // ResetAvatar resets all changes to the "avatar" field.
  45943. func (m *WxCardUserMutation) ResetAvatar() {
  45944. m.avatar = nil
  45945. }
  45946. // SetNickname sets the "nickname" field.
  45947. func (m *WxCardUserMutation) SetNickname(s string) {
  45948. m.nickname = &s
  45949. }
  45950. // Nickname returns the value of the "nickname" field in the mutation.
  45951. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  45952. v := m.nickname
  45953. if v == nil {
  45954. return
  45955. }
  45956. return *v, true
  45957. }
  45958. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  45959. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45961. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  45962. if !m.op.Is(OpUpdateOne) {
  45963. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45964. }
  45965. if m.id == nil || m.oldValue == nil {
  45966. return v, errors.New("OldNickname requires an ID field in the mutation")
  45967. }
  45968. oldValue, err := m.oldValue(ctx)
  45969. if err != nil {
  45970. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45971. }
  45972. return oldValue.Nickname, nil
  45973. }
  45974. // ResetNickname resets all changes to the "nickname" field.
  45975. func (m *WxCardUserMutation) ResetNickname() {
  45976. m.nickname = nil
  45977. }
  45978. // SetRemark sets the "remark" field.
  45979. func (m *WxCardUserMutation) SetRemark(s string) {
  45980. m.remark = &s
  45981. }
  45982. // Remark returns the value of the "remark" field in the mutation.
  45983. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  45984. v := m.remark
  45985. if v == nil {
  45986. return
  45987. }
  45988. return *v, true
  45989. }
  45990. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  45991. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45993. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  45994. if !m.op.Is(OpUpdateOne) {
  45995. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  45996. }
  45997. if m.id == nil || m.oldValue == nil {
  45998. return v, errors.New("OldRemark requires an ID field in the mutation")
  45999. }
  46000. oldValue, err := m.oldValue(ctx)
  46001. if err != nil {
  46002. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  46003. }
  46004. return oldValue.Remark, nil
  46005. }
  46006. // ResetRemark resets all changes to the "remark" field.
  46007. func (m *WxCardUserMutation) ResetRemark() {
  46008. m.remark = nil
  46009. }
  46010. // SetPhone sets the "phone" field.
  46011. func (m *WxCardUserMutation) SetPhone(s string) {
  46012. m.phone = &s
  46013. }
  46014. // Phone returns the value of the "phone" field in the mutation.
  46015. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  46016. v := m.phone
  46017. if v == nil {
  46018. return
  46019. }
  46020. return *v, true
  46021. }
  46022. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  46023. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46025. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  46026. if !m.op.Is(OpUpdateOne) {
  46027. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  46028. }
  46029. if m.id == nil || m.oldValue == nil {
  46030. return v, errors.New("OldPhone requires an ID field in the mutation")
  46031. }
  46032. oldValue, err := m.oldValue(ctx)
  46033. if err != nil {
  46034. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  46035. }
  46036. return oldValue.Phone, nil
  46037. }
  46038. // ResetPhone resets all changes to the "phone" field.
  46039. func (m *WxCardUserMutation) ResetPhone() {
  46040. m.phone = nil
  46041. }
  46042. // SetOpenID sets the "open_id" field.
  46043. func (m *WxCardUserMutation) SetOpenID(s string) {
  46044. m.open_id = &s
  46045. }
  46046. // OpenID returns the value of the "open_id" field in the mutation.
  46047. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  46048. v := m.open_id
  46049. if v == nil {
  46050. return
  46051. }
  46052. return *v, true
  46053. }
  46054. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  46055. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46057. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  46058. if !m.op.Is(OpUpdateOne) {
  46059. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  46060. }
  46061. if m.id == nil || m.oldValue == nil {
  46062. return v, errors.New("OldOpenID requires an ID field in the mutation")
  46063. }
  46064. oldValue, err := m.oldValue(ctx)
  46065. if err != nil {
  46066. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  46067. }
  46068. return oldValue.OpenID, nil
  46069. }
  46070. // ResetOpenID resets all changes to the "open_id" field.
  46071. func (m *WxCardUserMutation) ResetOpenID() {
  46072. m.open_id = nil
  46073. }
  46074. // SetUnionID sets the "union_id" field.
  46075. func (m *WxCardUserMutation) SetUnionID(s string) {
  46076. m.union_id = &s
  46077. }
  46078. // UnionID returns the value of the "union_id" field in the mutation.
  46079. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  46080. v := m.union_id
  46081. if v == nil {
  46082. return
  46083. }
  46084. return *v, true
  46085. }
  46086. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  46087. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46089. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  46090. if !m.op.Is(OpUpdateOne) {
  46091. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  46092. }
  46093. if m.id == nil || m.oldValue == nil {
  46094. return v, errors.New("OldUnionID requires an ID field in the mutation")
  46095. }
  46096. oldValue, err := m.oldValue(ctx)
  46097. if err != nil {
  46098. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  46099. }
  46100. return oldValue.UnionID, nil
  46101. }
  46102. // ResetUnionID resets all changes to the "union_id" field.
  46103. func (m *WxCardUserMutation) ResetUnionID() {
  46104. m.union_id = nil
  46105. }
  46106. // SetSessionKey sets the "session_key" field.
  46107. func (m *WxCardUserMutation) SetSessionKey(s string) {
  46108. m.session_key = &s
  46109. }
  46110. // SessionKey returns the value of the "session_key" field in the mutation.
  46111. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  46112. v := m.session_key
  46113. if v == nil {
  46114. return
  46115. }
  46116. return *v, true
  46117. }
  46118. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  46119. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46121. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  46122. if !m.op.Is(OpUpdateOne) {
  46123. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  46124. }
  46125. if m.id == nil || m.oldValue == nil {
  46126. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  46127. }
  46128. oldValue, err := m.oldValue(ctx)
  46129. if err != nil {
  46130. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  46131. }
  46132. return oldValue.SessionKey, nil
  46133. }
  46134. // ResetSessionKey resets all changes to the "session_key" field.
  46135. func (m *WxCardUserMutation) ResetSessionKey() {
  46136. m.session_key = nil
  46137. }
  46138. // SetIsVip sets the "is_vip" field.
  46139. func (m *WxCardUserMutation) SetIsVip(i int) {
  46140. m.is_vip = &i
  46141. m.addis_vip = nil
  46142. }
  46143. // IsVip returns the value of the "is_vip" field in the mutation.
  46144. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  46145. v := m.is_vip
  46146. if v == nil {
  46147. return
  46148. }
  46149. return *v, true
  46150. }
  46151. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  46152. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46154. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  46155. if !m.op.Is(OpUpdateOne) {
  46156. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  46157. }
  46158. if m.id == nil || m.oldValue == nil {
  46159. return v, errors.New("OldIsVip requires an ID field in the mutation")
  46160. }
  46161. oldValue, err := m.oldValue(ctx)
  46162. if err != nil {
  46163. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  46164. }
  46165. return oldValue.IsVip, nil
  46166. }
  46167. // AddIsVip adds i to the "is_vip" field.
  46168. func (m *WxCardUserMutation) AddIsVip(i int) {
  46169. if m.addis_vip != nil {
  46170. *m.addis_vip += i
  46171. } else {
  46172. m.addis_vip = &i
  46173. }
  46174. }
  46175. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  46176. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  46177. v := m.addis_vip
  46178. if v == nil {
  46179. return
  46180. }
  46181. return *v, true
  46182. }
  46183. // ResetIsVip resets all changes to the "is_vip" field.
  46184. func (m *WxCardUserMutation) ResetIsVip() {
  46185. m.is_vip = nil
  46186. m.addis_vip = nil
  46187. }
  46188. // Where appends a list predicates to the WxCardUserMutation builder.
  46189. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  46190. m.predicates = append(m.predicates, ps...)
  46191. }
  46192. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  46193. // users can use type-assertion to append predicates that do not depend on any generated package.
  46194. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  46195. p := make([]predicate.WxCardUser, len(ps))
  46196. for i := range ps {
  46197. p[i] = ps[i]
  46198. }
  46199. m.Where(p...)
  46200. }
  46201. // Op returns the operation name.
  46202. func (m *WxCardUserMutation) Op() Op {
  46203. return m.op
  46204. }
  46205. // SetOp allows setting the mutation operation.
  46206. func (m *WxCardUserMutation) SetOp(op Op) {
  46207. m.op = op
  46208. }
  46209. // Type returns the node type of this mutation (WxCardUser).
  46210. func (m *WxCardUserMutation) Type() string {
  46211. return m.typ
  46212. }
  46213. // Fields returns all fields that were changed during this mutation. Note that in
  46214. // order to get all numeric fields that were incremented/decremented, call
  46215. // AddedFields().
  46216. func (m *WxCardUserMutation) Fields() []string {
  46217. fields := make([]string, 0, 13)
  46218. if m.created_at != nil {
  46219. fields = append(fields, wxcarduser.FieldCreatedAt)
  46220. }
  46221. if m.updated_at != nil {
  46222. fields = append(fields, wxcarduser.FieldUpdatedAt)
  46223. }
  46224. if m.deleted_at != nil {
  46225. fields = append(fields, wxcarduser.FieldDeletedAt)
  46226. }
  46227. if m.wxid != nil {
  46228. fields = append(fields, wxcarduser.FieldWxid)
  46229. }
  46230. if m.account != nil {
  46231. fields = append(fields, wxcarduser.FieldAccount)
  46232. }
  46233. if m.avatar != nil {
  46234. fields = append(fields, wxcarduser.FieldAvatar)
  46235. }
  46236. if m.nickname != nil {
  46237. fields = append(fields, wxcarduser.FieldNickname)
  46238. }
  46239. if m.remark != nil {
  46240. fields = append(fields, wxcarduser.FieldRemark)
  46241. }
  46242. if m.phone != nil {
  46243. fields = append(fields, wxcarduser.FieldPhone)
  46244. }
  46245. if m.open_id != nil {
  46246. fields = append(fields, wxcarduser.FieldOpenID)
  46247. }
  46248. if m.union_id != nil {
  46249. fields = append(fields, wxcarduser.FieldUnionID)
  46250. }
  46251. if m.session_key != nil {
  46252. fields = append(fields, wxcarduser.FieldSessionKey)
  46253. }
  46254. if m.is_vip != nil {
  46255. fields = append(fields, wxcarduser.FieldIsVip)
  46256. }
  46257. return fields
  46258. }
  46259. // Field returns the value of a field with the given name. The second boolean
  46260. // return value indicates that this field was not set, or was not defined in the
  46261. // schema.
  46262. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  46263. switch name {
  46264. case wxcarduser.FieldCreatedAt:
  46265. return m.CreatedAt()
  46266. case wxcarduser.FieldUpdatedAt:
  46267. return m.UpdatedAt()
  46268. case wxcarduser.FieldDeletedAt:
  46269. return m.DeletedAt()
  46270. case wxcarduser.FieldWxid:
  46271. return m.Wxid()
  46272. case wxcarduser.FieldAccount:
  46273. return m.Account()
  46274. case wxcarduser.FieldAvatar:
  46275. return m.Avatar()
  46276. case wxcarduser.FieldNickname:
  46277. return m.Nickname()
  46278. case wxcarduser.FieldRemark:
  46279. return m.Remark()
  46280. case wxcarduser.FieldPhone:
  46281. return m.Phone()
  46282. case wxcarduser.FieldOpenID:
  46283. return m.OpenID()
  46284. case wxcarduser.FieldUnionID:
  46285. return m.UnionID()
  46286. case wxcarduser.FieldSessionKey:
  46287. return m.SessionKey()
  46288. case wxcarduser.FieldIsVip:
  46289. return m.IsVip()
  46290. }
  46291. return nil, false
  46292. }
  46293. // OldField returns the old value of the field from the database. An error is
  46294. // returned if the mutation operation is not UpdateOne, or the query to the
  46295. // database failed.
  46296. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46297. switch name {
  46298. case wxcarduser.FieldCreatedAt:
  46299. return m.OldCreatedAt(ctx)
  46300. case wxcarduser.FieldUpdatedAt:
  46301. return m.OldUpdatedAt(ctx)
  46302. case wxcarduser.FieldDeletedAt:
  46303. return m.OldDeletedAt(ctx)
  46304. case wxcarduser.FieldWxid:
  46305. return m.OldWxid(ctx)
  46306. case wxcarduser.FieldAccount:
  46307. return m.OldAccount(ctx)
  46308. case wxcarduser.FieldAvatar:
  46309. return m.OldAvatar(ctx)
  46310. case wxcarduser.FieldNickname:
  46311. return m.OldNickname(ctx)
  46312. case wxcarduser.FieldRemark:
  46313. return m.OldRemark(ctx)
  46314. case wxcarduser.FieldPhone:
  46315. return m.OldPhone(ctx)
  46316. case wxcarduser.FieldOpenID:
  46317. return m.OldOpenID(ctx)
  46318. case wxcarduser.FieldUnionID:
  46319. return m.OldUnionID(ctx)
  46320. case wxcarduser.FieldSessionKey:
  46321. return m.OldSessionKey(ctx)
  46322. case wxcarduser.FieldIsVip:
  46323. return m.OldIsVip(ctx)
  46324. }
  46325. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  46326. }
  46327. // SetField sets the value of a field with the given name. It returns an error if
  46328. // the field is not defined in the schema, or if the type mismatched the field
  46329. // type.
  46330. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  46331. switch name {
  46332. case wxcarduser.FieldCreatedAt:
  46333. v, ok := value.(time.Time)
  46334. if !ok {
  46335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46336. }
  46337. m.SetCreatedAt(v)
  46338. return nil
  46339. case wxcarduser.FieldUpdatedAt:
  46340. v, ok := value.(time.Time)
  46341. if !ok {
  46342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46343. }
  46344. m.SetUpdatedAt(v)
  46345. return nil
  46346. case wxcarduser.FieldDeletedAt:
  46347. v, ok := value.(time.Time)
  46348. if !ok {
  46349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46350. }
  46351. m.SetDeletedAt(v)
  46352. return nil
  46353. case wxcarduser.FieldWxid:
  46354. v, ok := value.(string)
  46355. if !ok {
  46356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46357. }
  46358. m.SetWxid(v)
  46359. return nil
  46360. case wxcarduser.FieldAccount:
  46361. v, ok := value.(string)
  46362. if !ok {
  46363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46364. }
  46365. m.SetAccount(v)
  46366. return nil
  46367. case wxcarduser.FieldAvatar:
  46368. v, ok := value.(string)
  46369. if !ok {
  46370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46371. }
  46372. m.SetAvatar(v)
  46373. return nil
  46374. case wxcarduser.FieldNickname:
  46375. v, ok := value.(string)
  46376. if !ok {
  46377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46378. }
  46379. m.SetNickname(v)
  46380. return nil
  46381. case wxcarduser.FieldRemark:
  46382. v, ok := value.(string)
  46383. if !ok {
  46384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46385. }
  46386. m.SetRemark(v)
  46387. return nil
  46388. case wxcarduser.FieldPhone:
  46389. v, ok := value.(string)
  46390. if !ok {
  46391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46392. }
  46393. m.SetPhone(v)
  46394. return nil
  46395. case wxcarduser.FieldOpenID:
  46396. v, ok := value.(string)
  46397. if !ok {
  46398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46399. }
  46400. m.SetOpenID(v)
  46401. return nil
  46402. case wxcarduser.FieldUnionID:
  46403. v, ok := value.(string)
  46404. if !ok {
  46405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46406. }
  46407. m.SetUnionID(v)
  46408. return nil
  46409. case wxcarduser.FieldSessionKey:
  46410. v, ok := value.(string)
  46411. if !ok {
  46412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46413. }
  46414. m.SetSessionKey(v)
  46415. return nil
  46416. case wxcarduser.FieldIsVip:
  46417. v, ok := value.(int)
  46418. if !ok {
  46419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46420. }
  46421. m.SetIsVip(v)
  46422. return nil
  46423. }
  46424. return fmt.Errorf("unknown WxCardUser field %s", name)
  46425. }
  46426. // AddedFields returns all numeric fields that were incremented/decremented during
  46427. // this mutation.
  46428. func (m *WxCardUserMutation) AddedFields() []string {
  46429. var fields []string
  46430. if m.addis_vip != nil {
  46431. fields = append(fields, wxcarduser.FieldIsVip)
  46432. }
  46433. return fields
  46434. }
  46435. // AddedField returns the numeric value that was incremented/decremented on a field
  46436. // with the given name. The second boolean return value indicates that this field
  46437. // was not set, or was not defined in the schema.
  46438. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  46439. switch name {
  46440. case wxcarduser.FieldIsVip:
  46441. return m.AddedIsVip()
  46442. }
  46443. return nil, false
  46444. }
  46445. // AddField adds the value to the field with the given name. It returns an error if
  46446. // the field is not defined in the schema, or if the type mismatched the field
  46447. // type.
  46448. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  46449. switch name {
  46450. case wxcarduser.FieldIsVip:
  46451. v, ok := value.(int)
  46452. if !ok {
  46453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46454. }
  46455. m.AddIsVip(v)
  46456. return nil
  46457. }
  46458. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  46459. }
  46460. // ClearedFields returns all nullable fields that were cleared during this
  46461. // mutation.
  46462. func (m *WxCardUserMutation) ClearedFields() []string {
  46463. var fields []string
  46464. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  46465. fields = append(fields, wxcarduser.FieldDeletedAt)
  46466. }
  46467. return fields
  46468. }
  46469. // FieldCleared returns a boolean indicating if a field with the given name was
  46470. // cleared in this mutation.
  46471. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  46472. _, ok := m.clearedFields[name]
  46473. return ok
  46474. }
  46475. // ClearField clears the value of the field with the given name. It returns an
  46476. // error if the field is not defined in the schema.
  46477. func (m *WxCardUserMutation) ClearField(name string) error {
  46478. switch name {
  46479. case wxcarduser.FieldDeletedAt:
  46480. m.ClearDeletedAt()
  46481. return nil
  46482. }
  46483. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  46484. }
  46485. // ResetField resets all changes in the mutation for the field with the given name.
  46486. // It returns an error if the field is not defined in the schema.
  46487. func (m *WxCardUserMutation) ResetField(name string) error {
  46488. switch name {
  46489. case wxcarduser.FieldCreatedAt:
  46490. m.ResetCreatedAt()
  46491. return nil
  46492. case wxcarduser.FieldUpdatedAt:
  46493. m.ResetUpdatedAt()
  46494. return nil
  46495. case wxcarduser.FieldDeletedAt:
  46496. m.ResetDeletedAt()
  46497. return nil
  46498. case wxcarduser.FieldWxid:
  46499. m.ResetWxid()
  46500. return nil
  46501. case wxcarduser.FieldAccount:
  46502. m.ResetAccount()
  46503. return nil
  46504. case wxcarduser.FieldAvatar:
  46505. m.ResetAvatar()
  46506. return nil
  46507. case wxcarduser.FieldNickname:
  46508. m.ResetNickname()
  46509. return nil
  46510. case wxcarduser.FieldRemark:
  46511. m.ResetRemark()
  46512. return nil
  46513. case wxcarduser.FieldPhone:
  46514. m.ResetPhone()
  46515. return nil
  46516. case wxcarduser.FieldOpenID:
  46517. m.ResetOpenID()
  46518. return nil
  46519. case wxcarduser.FieldUnionID:
  46520. m.ResetUnionID()
  46521. return nil
  46522. case wxcarduser.FieldSessionKey:
  46523. m.ResetSessionKey()
  46524. return nil
  46525. case wxcarduser.FieldIsVip:
  46526. m.ResetIsVip()
  46527. return nil
  46528. }
  46529. return fmt.Errorf("unknown WxCardUser field %s", name)
  46530. }
  46531. // AddedEdges returns all edge names that were set/added in this mutation.
  46532. func (m *WxCardUserMutation) AddedEdges() []string {
  46533. edges := make([]string, 0, 0)
  46534. return edges
  46535. }
  46536. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46537. // name in this mutation.
  46538. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  46539. return nil
  46540. }
  46541. // RemovedEdges returns all edge names that were removed in this mutation.
  46542. func (m *WxCardUserMutation) RemovedEdges() []string {
  46543. edges := make([]string, 0, 0)
  46544. return edges
  46545. }
  46546. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46547. // the given name in this mutation.
  46548. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  46549. return nil
  46550. }
  46551. // ClearedEdges returns all edge names that were cleared in this mutation.
  46552. func (m *WxCardUserMutation) ClearedEdges() []string {
  46553. edges := make([]string, 0, 0)
  46554. return edges
  46555. }
  46556. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46557. // was cleared in this mutation.
  46558. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  46559. return false
  46560. }
  46561. // ClearEdge clears the value of the edge with the given name. It returns an error
  46562. // if that edge is not defined in the schema.
  46563. func (m *WxCardUserMutation) ClearEdge(name string) error {
  46564. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  46565. }
  46566. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46567. // It returns an error if the edge is not defined in the schema.
  46568. func (m *WxCardUserMutation) ResetEdge(name string) error {
  46569. return fmt.Errorf("unknown WxCardUser edge %s", name)
  46570. }
  46571. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  46572. type WxCardVisitMutation struct {
  46573. config
  46574. op Op
  46575. typ string
  46576. id *uint64
  46577. created_at *time.Time
  46578. updated_at *time.Time
  46579. deleted_at *time.Time
  46580. user_id *uint64
  46581. adduser_id *int64
  46582. bot_id *uint64
  46583. addbot_id *int64
  46584. bot_type *uint8
  46585. addbot_type *int8
  46586. clearedFields map[string]struct{}
  46587. done bool
  46588. oldValue func(context.Context) (*WxCardVisit, error)
  46589. predicates []predicate.WxCardVisit
  46590. }
  46591. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  46592. // wxcardvisitOption allows management of the mutation configuration using functional options.
  46593. type wxcardvisitOption func(*WxCardVisitMutation)
  46594. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  46595. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  46596. m := &WxCardVisitMutation{
  46597. config: c,
  46598. op: op,
  46599. typ: TypeWxCardVisit,
  46600. clearedFields: make(map[string]struct{}),
  46601. }
  46602. for _, opt := range opts {
  46603. opt(m)
  46604. }
  46605. return m
  46606. }
  46607. // withWxCardVisitID sets the ID field of the mutation.
  46608. func withWxCardVisitID(id uint64) wxcardvisitOption {
  46609. return func(m *WxCardVisitMutation) {
  46610. var (
  46611. err error
  46612. once sync.Once
  46613. value *WxCardVisit
  46614. )
  46615. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  46616. once.Do(func() {
  46617. if m.done {
  46618. err = errors.New("querying old values post mutation is not allowed")
  46619. } else {
  46620. value, err = m.Client().WxCardVisit.Get(ctx, id)
  46621. }
  46622. })
  46623. return value, err
  46624. }
  46625. m.id = &id
  46626. }
  46627. }
  46628. // withWxCardVisit sets the old WxCardVisit of the mutation.
  46629. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  46630. return func(m *WxCardVisitMutation) {
  46631. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  46632. return node, nil
  46633. }
  46634. m.id = &node.ID
  46635. }
  46636. }
  46637. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46638. // executed in a transaction (ent.Tx), a transactional client is returned.
  46639. func (m WxCardVisitMutation) Client() *Client {
  46640. client := &Client{config: m.config}
  46641. client.init()
  46642. return client
  46643. }
  46644. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46645. // it returns an error otherwise.
  46646. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  46647. if _, ok := m.driver.(*txDriver); !ok {
  46648. return nil, errors.New("ent: mutation is not running in a transaction")
  46649. }
  46650. tx := &Tx{config: m.config}
  46651. tx.init()
  46652. return tx, nil
  46653. }
  46654. // SetID sets the value of the id field. Note that this
  46655. // operation is only accepted on creation of WxCardVisit entities.
  46656. func (m *WxCardVisitMutation) SetID(id uint64) {
  46657. m.id = &id
  46658. }
  46659. // ID returns the ID value in the mutation. Note that the ID is only available
  46660. // if it was provided to the builder or after it was returned from the database.
  46661. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  46662. if m.id == nil {
  46663. return
  46664. }
  46665. return *m.id, true
  46666. }
  46667. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46668. // That means, if the mutation is applied within a transaction with an isolation level such
  46669. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46670. // or updated by the mutation.
  46671. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  46672. switch {
  46673. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46674. id, exists := m.ID()
  46675. if exists {
  46676. return []uint64{id}, nil
  46677. }
  46678. fallthrough
  46679. case m.op.Is(OpUpdate | OpDelete):
  46680. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  46681. default:
  46682. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46683. }
  46684. }
  46685. // SetCreatedAt sets the "created_at" field.
  46686. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  46687. m.created_at = &t
  46688. }
  46689. // CreatedAt returns the value of the "created_at" field in the mutation.
  46690. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  46691. v := m.created_at
  46692. if v == nil {
  46693. return
  46694. }
  46695. return *v, true
  46696. }
  46697. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  46698. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46700. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46701. if !m.op.Is(OpUpdateOne) {
  46702. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46703. }
  46704. if m.id == nil || m.oldValue == nil {
  46705. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46706. }
  46707. oldValue, err := m.oldValue(ctx)
  46708. if err != nil {
  46709. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46710. }
  46711. return oldValue.CreatedAt, nil
  46712. }
  46713. // ResetCreatedAt resets all changes to the "created_at" field.
  46714. func (m *WxCardVisitMutation) ResetCreatedAt() {
  46715. m.created_at = nil
  46716. }
  46717. // SetUpdatedAt sets the "updated_at" field.
  46718. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  46719. m.updated_at = &t
  46720. }
  46721. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46722. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  46723. v := m.updated_at
  46724. if v == nil {
  46725. return
  46726. }
  46727. return *v, true
  46728. }
  46729. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  46730. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46732. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46733. if !m.op.Is(OpUpdateOne) {
  46734. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46735. }
  46736. if m.id == nil || m.oldValue == nil {
  46737. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46738. }
  46739. oldValue, err := m.oldValue(ctx)
  46740. if err != nil {
  46741. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46742. }
  46743. return oldValue.UpdatedAt, nil
  46744. }
  46745. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46746. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  46747. m.updated_at = nil
  46748. }
  46749. // SetDeletedAt sets the "deleted_at" field.
  46750. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  46751. m.deleted_at = &t
  46752. }
  46753. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46754. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  46755. v := m.deleted_at
  46756. if v == nil {
  46757. return
  46758. }
  46759. return *v, true
  46760. }
  46761. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  46762. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46764. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46765. if !m.op.Is(OpUpdateOne) {
  46766. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46767. }
  46768. if m.id == nil || m.oldValue == nil {
  46769. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46770. }
  46771. oldValue, err := m.oldValue(ctx)
  46772. if err != nil {
  46773. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46774. }
  46775. return oldValue.DeletedAt, nil
  46776. }
  46777. // ClearDeletedAt clears the value of the "deleted_at" field.
  46778. func (m *WxCardVisitMutation) ClearDeletedAt() {
  46779. m.deleted_at = nil
  46780. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  46781. }
  46782. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46783. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  46784. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  46785. return ok
  46786. }
  46787. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46788. func (m *WxCardVisitMutation) ResetDeletedAt() {
  46789. m.deleted_at = nil
  46790. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  46791. }
  46792. // SetUserID sets the "user_id" field.
  46793. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  46794. m.user_id = &u
  46795. m.adduser_id = nil
  46796. }
  46797. // UserID returns the value of the "user_id" field in the mutation.
  46798. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  46799. v := m.user_id
  46800. if v == nil {
  46801. return
  46802. }
  46803. return *v, true
  46804. }
  46805. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  46806. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46808. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  46809. if !m.op.Is(OpUpdateOne) {
  46810. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  46811. }
  46812. if m.id == nil || m.oldValue == nil {
  46813. return v, errors.New("OldUserID requires an ID field in the mutation")
  46814. }
  46815. oldValue, err := m.oldValue(ctx)
  46816. if err != nil {
  46817. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  46818. }
  46819. return oldValue.UserID, nil
  46820. }
  46821. // AddUserID adds u to the "user_id" field.
  46822. func (m *WxCardVisitMutation) AddUserID(u int64) {
  46823. if m.adduser_id != nil {
  46824. *m.adduser_id += u
  46825. } else {
  46826. m.adduser_id = &u
  46827. }
  46828. }
  46829. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  46830. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  46831. v := m.adduser_id
  46832. if v == nil {
  46833. return
  46834. }
  46835. return *v, true
  46836. }
  46837. // ClearUserID clears the value of the "user_id" field.
  46838. func (m *WxCardVisitMutation) ClearUserID() {
  46839. m.user_id = nil
  46840. m.adduser_id = nil
  46841. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  46842. }
  46843. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  46844. func (m *WxCardVisitMutation) UserIDCleared() bool {
  46845. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  46846. return ok
  46847. }
  46848. // ResetUserID resets all changes to the "user_id" field.
  46849. func (m *WxCardVisitMutation) ResetUserID() {
  46850. m.user_id = nil
  46851. m.adduser_id = nil
  46852. delete(m.clearedFields, wxcardvisit.FieldUserID)
  46853. }
  46854. // SetBotID sets the "bot_id" field.
  46855. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  46856. m.bot_id = &u
  46857. m.addbot_id = nil
  46858. }
  46859. // BotID returns the value of the "bot_id" field in the mutation.
  46860. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  46861. v := m.bot_id
  46862. if v == nil {
  46863. return
  46864. }
  46865. return *v, true
  46866. }
  46867. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  46868. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46870. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  46871. if !m.op.Is(OpUpdateOne) {
  46872. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  46873. }
  46874. if m.id == nil || m.oldValue == nil {
  46875. return v, errors.New("OldBotID requires an ID field in the mutation")
  46876. }
  46877. oldValue, err := m.oldValue(ctx)
  46878. if err != nil {
  46879. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  46880. }
  46881. return oldValue.BotID, nil
  46882. }
  46883. // AddBotID adds u to the "bot_id" field.
  46884. func (m *WxCardVisitMutation) AddBotID(u int64) {
  46885. if m.addbot_id != nil {
  46886. *m.addbot_id += u
  46887. } else {
  46888. m.addbot_id = &u
  46889. }
  46890. }
  46891. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  46892. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  46893. v := m.addbot_id
  46894. if v == nil {
  46895. return
  46896. }
  46897. return *v, true
  46898. }
  46899. // ResetBotID resets all changes to the "bot_id" field.
  46900. func (m *WxCardVisitMutation) ResetBotID() {
  46901. m.bot_id = nil
  46902. m.addbot_id = nil
  46903. }
  46904. // SetBotType sets the "bot_type" field.
  46905. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  46906. m.bot_type = &u
  46907. m.addbot_type = nil
  46908. }
  46909. // BotType returns the value of the "bot_type" field in the mutation.
  46910. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  46911. v := m.bot_type
  46912. if v == nil {
  46913. return
  46914. }
  46915. return *v, true
  46916. }
  46917. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  46918. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46920. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  46921. if !m.op.Is(OpUpdateOne) {
  46922. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  46923. }
  46924. if m.id == nil || m.oldValue == nil {
  46925. return v, errors.New("OldBotType requires an ID field in the mutation")
  46926. }
  46927. oldValue, err := m.oldValue(ctx)
  46928. if err != nil {
  46929. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  46930. }
  46931. return oldValue.BotType, nil
  46932. }
  46933. // AddBotType adds u to the "bot_type" field.
  46934. func (m *WxCardVisitMutation) AddBotType(u int8) {
  46935. if m.addbot_type != nil {
  46936. *m.addbot_type += u
  46937. } else {
  46938. m.addbot_type = &u
  46939. }
  46940. }
  46941. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  46942. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  46943. v := m.addbot_type
  46944. if v == nil {
  46945. return
  46946. }
  46947. return *v, true
  46948. }
  46949. // ResetBotType resets all changes to the "bot_type" field.
  46950. func (m *WxCardVisitMutation) ResetBotType() {
  46951. m.bot_type = nil
  46952. m.addbot_type = nil
  46953. }
  46954. // Where appends a list predicates to the WxCardVisitMutation builder.
  46955. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  46956. m.predicates = append(m.predicates, ps...)
  46957. }
  46958. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  46959. // users can use type-assertion to append predicates that do not depend on any generated package.
  46960. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  46961. p := make([]predicate.WxCardVisit, len(ps))
  46962. for i := range ps {
  46963. p[i] = ps[i]
  46964. }
  46965. m.Where(p...)
  46966. }
  46967. // Op returns the operation name.
  46968. func (m *WxCardVisitMutation) Op() Op {
  46969. return m.op
  46970. }
  46971. // SetOp allows setting the mutation operation.
  46972. func (m *WxCardVisitMutation) SetOp(op Op) {
  46973. m.op = op
  46974. }
  46975. // Type returns the node type of this mutation (WxCardVisit).
  46976. func (m *WxCardVisitMutation) Type() string {
  46977. return m.typ
  46978. }
  46979. // Fields returns all fields that were changed during this mutation. Note that in
  46980. // order to get all numeric fields that were incremented/decremented, call
  46981. // AddedFields().
  46982. func (m *WxCardVisitMutation) Fields() []string {
  46983. fields := make([]string, 0, 6)
  46984. if m.created_at != nil {
  46985. fields = append(fields, wxcardvisit.FieldCreatedAt)
  46986. }
  46987. if m.updated_at != nil {
  46988. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  46989. }
  46990. if m.deleted_at != nil {
  46991. fields = append(fields, wxcardvisit.FieldDeletedAt)
  46992. }
  46993. if m.user_id != nil {
  46994. fields = append(fields, wxcardvisit.FieldUserID)
  46995. }
  46996. if m.bot_id != nil {
  46997. fields = append(fields, wxcardvisit.FieldBotID)
  46998. }
  46999. if m.bot_type != nil {
  47000. fields = append(fields, wxcardvisit.FieldBotType)
  47001. }
  47002. return fields
  47003. }
  47004. // Field returns the value of a field with the given name. The second boolean
  47005. // return value indicates that this field was not set, or was not defined in the
  47006. // schema.
  47007. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  47008. switch name {
  47009. case wxcardvisit.FieldCreatedAt:
  47010. return m.CreatedAt()
  47011. case wxcardvisit.FieldUpdatedAt:
  47012. return m.UpdatedAt()
  47013. case wxcardvisit.FieldDeletedAt:
  47014. return m.DeletedAt()
  47015. case wxcardvisit.FieldUserID:
  47016. return m.UserID()
  47017. case wxcardvisit.FieldBotID:
  47018. return m.BotID()
  47019. case wxcardvisit.FieldBotType:
  47020. return m.BotType()
  47021. }
  47022. return nil, false
  47023. }
  47024. // OldField returns the old value of the field from the database. An error is
  47025. // returned if the mutation operation is not UpdateOne, or the query to the
  47026. // database failed.
  47027. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47028. switch name {
  47029. case wxcardvisit.FieldCreatedAt:
  47030. return m.OldCreatedAt(ctx)
  47031. case wxcardvisit.FieldUpdatedAt:
  47032. return m.OldUpdatedAt(ctx)
  47033. case wxcardvisit.FieldDeletedAt:
  47034. return m.OldDeletedAt(ctx)
  47035. case wxcardvisit.FieldUserID:
  47036. return m.OldUserID(ctx)
  47037. case wxcardvisit.FieldBotID:
  47038. return m.OldBotID(ctx)
  47039. case wxcardvisit.FieldBotType:
  47040. return m.OldBotType(ctx)
  47041. }
  47042. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  47043. }
  47044. // SetField sets the value of a field with the given name. It returns an error if
  47045. // the field is not defined in the schema, or if the type mismatched the field
  47046. // type.
  47047. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  47048. switch name {
  47049. case wxcardvisit.FieldCreatedAt:
  47050. v, ok := value.(time.Time)
  47051. if !ok {
  47052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47053. }
  47054. m.SetCreatedAt(v)
  47055. return nil
  47056. case wxcardvisit.FieldUpdatedAt:
  47057. v, ok := value.(time.Time)
  47058. if !ok {
  47059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47060. }
  47061. m.SetUpdatedAt(v)
  47062. return nil
  47063. case wxcardvisit.FieldDeletedAt:
  47064. v, ok := value.(time.Time)
  47065. if !ok {
  47066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47067. }
  47068. m.SetDeletedAt(v)
  47069. return nil
  47070. case wxcardvisit.FieldUserID:
  47071. v, ok := value.(uint64)
  47072. if !ok {
  47073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47074. }
  47075. m.SetUserID(v)
  47076. return nil
  47077. case wxcardvisit.FieldBotID:
  47078. v, ok := value.(uint64)
  47079. if !ok {
  47080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47081. }
  47082. m.SetBotID(v)
  47083. return nil
  47084. case wxcardvisit.FieldBotType:
  47085. v, ok := value.(uint8)
  47086. if !ok {
  47087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47088. }
  47089. m.SetBotType(v)
  47090. return nil
  47091. }
  47092. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47093. }
  47094. // AddedFields returns all numeric fields that were incremented/decremented during
  47095. // this mutation.
  47096. func (m *WxCardVisitMutation) AddedFields() []string {
  47097. var fields []string
  47098. if m.adduser_id != nil {
  47099. fields = append(fields, wxcardvisit.FieldUserID)
  47100. }
  47101. if m.addbot_id != nil {
  47102. fields = append(fields, wxcardvisit.FieldBotID)
  47103. }
  47104. if m.addbot_type != nil {
  47105. fields = append(fields, wxcardvisit.FieldBotType)
  47106. }
  47107. return fields
  47108. }
  47109. // AddedField returns the numeric value that was incremented/decremented on a field
  47110. // with the given name. The second boolean return value indicates that this field
  47111. // was not set, or was not defined in the schema.
  47112. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  47113. switch name {
  47114. case wxcardvisit.FieldUserID:
  47115. return m.AddedUserID()
  47116. case wxcardvisit.FieldBotID:
  47117. return m.AddedBotID()
  47118. case wxcardvisit.FieldBotType:
  47119. return m.AddedBotType()
  47120. }
  47121. return nil, false
  47122. }
  47123. // AddField adds the value to the field with the given name. It returns an error if
  47124. // the field is not defined in the schema, or if the type mismatched the field
  47125. // type.
  47126. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  47127. switch name {
  47128. case wxcardvisit.FieldUserID:
  47129. v, ok := value.(int64)
  47130. if !ok {
  47131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47132. }
  47133. m.AddUserID(v)
  47134. return nil
  47135. case wxcardvisit.FieldBotID:
  47136. v, ok := value.(int64)
  47137. if !ok {
  47138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47139. }
  47140. m.AddBotID(v)
  47141. return nil
  47142. case wxcardvisit.FieldBotType:
  47143. v, ok := value.(int8)
  47144. if !ok {
  47145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47146. }
  47147. m.AddBotType(v)
  47148. return nil
  47149. }
  47150. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  47151. }
  47152. // ClearedFields returns all nullable fields that were cleared during this
  47153. // mutation.
  47154. func (m *WxCardVisitMutation) ClearedFields() []string {
  47155. var fields []string
  47156. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  47157. fields = append(fields, wxcardvisit.FieldDeletedAt)
  47158. }
  47159. if m.FieldCleared(wxcardvisit.FieldUserID) {
  47160. fields = append(fields, wxcardvisit.FieldUserID)
  47161. }
  47162. return fields
  47163. }
  47164. // FieldCleared returns a boolean indicating if a field with the given name was
  47165. // cleared in this mutation.
  47166. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  47167. _, ok := m.clearedFields[name]
  47168. return ok
  47169. }
  47170. // ClearField clears the value of the field with the given name. It returns an
  47171. // error if the field is not defined in the schema.
  47172. func (m *WxCardVisitMutation) ClearField(name string) error {
  47173. switch name {
  47174. case wxcardvisit.FieldDeletedAt:
  47175. m.ClearDeletedAt()
  47176. return nil
  47177. case wxcardvisit.FieldUserID:
  47178. m.ClearUserID()
  47179. return nil
  47180. }
  47181. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  47182. }
  47183. // ResetField resets all changes in the mutation for the field with the given name.
  47184. // It returns an error if the field is not defined in the schema.
  47185. func (m *WxCardVisitMutation) ResetField(name string) error {
  47186. switch name {
  47187. case wxcardvisit.FieldCreatedAt:
  47188. m.ResetCreatedAt()
  47189. return nil
  47190. case wxcardvisit.FieldUpdatedAt:
  47191. m.ResetUpdatedAt()
  47192. return nil
  47193. case wxcardvisit.FieldDeletedAt:
  47194. m.ResetDeletedAt()
  47195. return nil
  47196. case wxcardvisit.FieldUserID:
  47197. m.ResetUserID()
  47198. return nil
  47199. case wxcardvisit.FieldBotID:
  47200. m.ResetBotID()
  47201. return nil
  47202. case wxcardvisit.FieldBotType:
  47203. m.ResetBotType()
  47204. return nil
  47205. }
  47206. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47207. }
  47208. // AddedEdges returns all edge names that were set/added in this mutation.
  47209. func (m *WxCardVisitMutation) AddedEdges() []string {
  47210. edges := make([]string, 0, 0)
  47211. return edges
  47212. }
  47213. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47214. // name in this mutation.
  47215. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  47216. return nil
  47217. }
  47218. // RemovedEdges returns all edge names that were removed in this mutation.
  47219. func (m *WxCardVisitMutation) RemovedEdges() []string {
  47220. edges := make([]string, 0, 0)
  47221. return edges
  47222. }
  47223. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47224. // the given name in this mutation.
  47225. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  47226. return nil
  47227. }
  47228. // ClearedEdges returns all edge names that were cleared in this mutation.
  47229. func (m *WxCardVisitMutation) ClearedEdges() []string {
  47230. edges := make([]string, 0, 0)
  47231. return edges
  47232. }
  47233. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47234. // was cleared in this mutation.
  47235. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  47236. return false
  47237. }
  47238. // ClearEdge clears the value of the edge with the given name. It returns an error
  47239. // if that edge is not defined in the schema.
  47240. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  47241. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  47242. }
  47243. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47244. // It returns an error if the edge is not defined in the schema.
  47245. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  47246. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  47247. }