mutation.go 1.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/contact"
  19. "wechat-api/ent/contactfield"
  20. "wechat-api/ent/contactfieldtemplate"
  21. "wechat-api/ent/creditbalance"
  22. "wechat-api/ent/creditusage"
  23. "wechat-api/ent/custom_types"
  24. "wechat-api/ent/employee"
  25. "wechat-api/ent/employeeconfig"
  26. "wechat-api/ent/label"
  27. "wechat-api/ent/labelrelationship"
  28. "wechat-api/ent/labeltagging"
  29. "wechat-api/ent/message"
  30. "wechat-api/ent/messagerecords"
  31. "wechat-api/ent/msg"
  32. "wechat-api/ent/payrecharge"
  33. "wechat-api/ent/predicate"
  34. "wechat-api/ent/server"
  35. "wechat-api/ent/sopnode"
  36. "wechat-api/ent/sopstage"
  37. "wechat-api/ent/soptask"
  38. "wechat-api/ent/token"
  39. "wechat-api/ent/tutorial"
  40. "wechat-api/ent/usagedetail"
  41. "wechat-api/ent/usagestatisticday"
  42. "wechat-api/ent/usagestatistichour"
  43. "wechat-api/ent/usagestatisticmonth"
  44. "wechat-api/ent/usagetotal"
  45. "wechat-api/ent/whatsapp"
  46. "wechat-api/ent/whatsappchannel"
  47. "wechat-api/ent/workexperience"
  48. "wechat-api/ent/wpchatroom"
  49. "wechat-api/ent/wpchatroommember"
  50. "wechat-api/ent/wx"
  51. "wechat-api/ent/wxcard"
  52. "wechat-api/ent/wxcarduser"
  53. "wechat-api/ent/wxcardvisit"
  54. "wechat-api/ent/xunji"
  55. "wechat-api/ent/xunjiservice"
  56. "entgo.io/ent"
  57. "entgo.io/ent/dialect/sql"
  58. )
  59. const (
  60. // Operation types.
  61. OpCreate = ent.OpCreate
  62. OpDelete = ent.OpDelete
  63. OpDeleteOne = ent.OpDeleteOne
  64. OpUpdate = ent.OpUpdate
  65. OpUpdateOne = ent.OpUpdateOne
  66. // Node types.
  67. TypeAgent = "Agent"
  68. TypeAgentBase = "AgentBase"
  69. TypeAliyunAvatar = "AliyunAvatar"
  70. TypeAllocAgent = "AllocAgent"
  71. TypeApiKey = "ApiKey"
  72. TypeBatchMsg = "BatchMsg"
  73. TypeCategory = "Category"
  74. TypeChatRecords = "ChatRecords"
  75. TypeChatSession = "ChatSession"
  76. TypeContact = "Contact"
  77. TypeContactField = "ContactField"
  78. TypeContactFieldTemplate = "ContactFieldTemplate"
  79. TypeCreditBalance = "CreditBalance"
  80. TypeCreditUsage = "CreditUsage"
  81. TypeEmployee = "Employee"
  82. TypeEmployeeConfig = "EmployeeConfig"
  83. TypeLabel = "Label"
  84. TypeLabelRelationship = "LabelRelationship"
  85. TypeLabelTagging = "LabelTagging"
  86. TypeMessage = "Message"
  87. TypeMessageRecords = "MessageRecords"
  88. TypeMsg = "Msg"
  89. TypePayRecharge = "PayRecharge"
  90. TypeServer = "Server"
  91. TypeSopNode = "SopNode"
  92. TypeSopStage = "SopStage"
  93. TypeSopTask = "SopTask"
  94. TypeToken = "Token"
  95. TypeTutorial = "Tutorial"
  96. TypeUsageDetail = "UsageDetail"
  97. TypeUsageStatisticDay = "UsageStatisticDay"
  98. TypeUsageStatisticHour = "UsageStatisticHour"
  99. TypeUsageStatisticMonth = "UsageStatisticMonth"
  100. TypeUsageTotal = "UsageTotal"
  101. TypeWhatsapp = "Whatsapp"
  102. TypeWhatsappChannel = "WhatsappChannel"
  103. TypeWorkExperience = "WorkExperience"
  104. TypeWpChatroom = "WpChatroom"
  105. TypeWpChatroomMember = "WpChatroomMember"
  106. TypeWx = "Wx"
  107. TypeWxCard = "WxCard"
  108. TypeWxCardUser = "WxCardUser"
  109. TypeWxCardVisit = "WxCardVisit"
  110. TypeXunji = "Xunji"
  111. TypeXunjiService = "XunjiService"
  112. )
  113. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  114. type AgentMutation struct {
  115. config
  116. op Op
  117. typ string
  118. id *uint64
  119. created_at *time.Time
  120. updated_at *time.Time
  121. deleted_at *time.Time
  122. name *string
  123. role *string
  124. status *int
  125. addstatus *int
  126. background *string
  127. examples *string
  128. organization_id *uint64
  129. addorganization_id *int64
  130. dataset_id *string
  131. collection_id *string
  132. clearedFields map[string]struct{}
  133. wx_agent map[uint64]struct{}
  134. removedwx_agent map[uint64]struct{}
  135. clearedwx_agent bool
  136. token_agent map[uint64]struct{}
  137. removedtoken_agent map[uint64]struct{}
  138. clearedtoken_agent bool
  139. wa_agent map[uint64]struct{}
  140. removedwa_agent map[uint64]struct{}
  141. clearedwa_agent bool
  142. xjs_agent map[uint64]struct{}
  143. removedxjs_agent map[uint64]struct{}
  144. clearedxjs_agent bool
  145. key_agent map[uint64]struct{}
  146. removedkey_agent map[uint64]struct{}
  147. clearedkey_agent bool
  148. done bool
  149. oldValue func(context.Context) (*Agent, error)
  150. predicates []predicate.Agent
  151. }
  152. var _ ent.Mutation = (*AgentMutation)(nil)
  153. // agentOption allows management of the mutation configuration using functional options.
  154. type agentOption func(*AgentMutation)
  155. // newAgentMutation creates new mutation for the Agent entity.
  156. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  157. m := &AgentMutation{
  158. config: c,
  159. op: op,
  160. typ: TypeAgent,
  161. clearedFields: make(map[string]struct{}),
  162. }
  163. for _, opt := range opts {
  164. opt(m)
  165. }
  166. return m
  167. }
  168. // withAgentID sets the ID field of the mutation.
  169. func withAgentID(id uint64) agentOption {
  170. return func(m *AgentMutation) {
  171. var (
  172. err error
  173. once sync.Once
  174. value *Agent
  175. )
  176. m.oldValue = func(ctx context.Context) (*Agent, error) {
  177. once.Do(func() {
  178. if m.done {
  179. err = errors.New("querying old values post mutation is not allowed")
  180. } else {
  181. value, err = m.Client().Agent.Get(ctx, id)
  182. }
  183. })
  184. return value, err
  185. }
  186. m.id = &id
  187. }
  188. }
  189. // withAgent sets the old Agent of the mutation.
  190. func withAgent(node *Agent) agentOption {
  191. return func(m *AgentMutation) {
  192. m.oldValue = func(context.Context) (*Agent, error) {
  193. return node, nil
  194. }
  195. m.id = &node.ID
  196. }
  197. }
  198. // Client returns a new `ent.Client` from the mutation. If the mutation was
  199. // executed in a transaction (ent.Tx), a transactional client is returned.
  200. func (m AgentMutation) Client() *Client {
  201. client := &Client{config: m.config}
  202. client.init()
  203. return client
  204. }
  205. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  206. // it returns an error otherwise.
  207. func (m AgentMutation) Tx() (*Tx, error) {
  208. if _, ok := m.driver.(*txDriver); !ok {
  209. return nil, errors.New("ent: mutation is not running in a transaction")
  210. }
  211. tx := &Tx{config: m.config}
  212. tx.init()
  213. return tx, nil
  214. }
  215. // SetID sets the value of the id field. Note that this
  216. // operation is only accepted on creation of Agent entities.
  217. func (m *AgentMutation) SetID(id uint64) {
  218. m.id = &id
  219. }
  220. // ID returns the ID value in the mutation. Note that the ID is only available
  221. // if it was provided to the builder or after it was returned from the database.
  222. func (m *AgentMutation) ID() (id uint64, exists bool) {
  223. if m.id == nil {
  224. return
  225. }
  226. return *m.id, true
  227. }
  228. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  229. // That means, if the mutation is applied within a transaction with an isolation level such
  230. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  231. // or updated by the mutation.
  232. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  233. switch {
  234. case m.op.Is(OpUpdateOne | OpDeleteOne):
  235. id, exists := m.ID()
  236. if exists {
  237. return []uint64{id}, nil
  238. }
  239. fallthrough
  240. case m.op.Is(OpUpdate | OpDelete):
  241. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  242. default:
  243. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  244. }
  245. }
  246. // SetCreatedAt sets the "created_at" field.
  247. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  248. m.created_at = &t
  249. }
  250. // CreatedAt returns the value of the "created_at" field in the mutation.
  251. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  252. v := m.created_at
  253. if v == nil {
  254. return
  255. }
  256. return *v, true
  257. }
  258. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  259. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  261. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  262. if !m.op.Is(OpUpdateOne) {
  263. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  264. }
  265. if m.id == nil || m.oldValue == nil {
  266. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  267. }
  268. oldValue, err := m.oldValue(ctx)
  269. if err != nil {
  270. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  271. }
  272. return oldValue.CreatedAt, nil
  273. }
  274. // ResetCreatedAt resets all changes to the "created_at" field.
  275. func (m *AgentMutation) ResetCreatedAt() {
  276. m.created_at = nil
  277. }
  278. // SetUpdatedAt sets the "updated_at" field.
  279. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  280. m.updated_at = &t
  281. }
  282. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  283. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  284. v := m.updated_at
  285. if v == nil {
  286. return
  287. }
  288. return *v, true
  289. }
  290. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  291. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  293. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  294. if !m.op.Is(OpUpdateOne) {
  295. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  296. }
  297. if m.id == nil || m.oldValue == nil {
  298. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  299. }
  300. oldValue, err := m.oldValue(ctx)
  301. if err != nil {
  302. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  303. }
  304. return oldValue.UpdatedAt, nil
  305. }
  306. // ResetUpdatedAt resets all changes to the "updated_at" field.
  307. func (m *AgentMutation) ResetUpdatedAt() {
  308. m.updated_at = nil
  309. }
  310. // SetDeletedAt sets the "deleted_at" field.
  311. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  312. m.deleted_at = &t
  313. }
  314. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  315. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  316. v := m.deleted_at
  317. if v == nil {
  318. return
  319. }
  320. return *v, true
  321. }
  322. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  323. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  325. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  326. if !m.op.Is(OpUpdateOne) {
  327. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  328. }
  329. if m.id == nil || m.oldValue == nil {
  330. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  331. }
  332. oldValue, err := m.oldValue(ctx)
  333. if err != nil {
  334. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  335. }
  336. return oldValue.DeletedAt, nil
  337. }
  338. // ClearDeletedAt clears the value of the "deleted_at" field.
  339. func (m *AgentMutation) ClearDeletedAt() {
  340. m.deleted_at = nil
  341. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  342. }
  343. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  344. func (m *AgentMutation) DeletedAtCleared() bool {
  345. _, ok := m.clearedFields[agent.FieldDeletedAt]
  346. return ok
  347. }
  348. // ResetDeletedAt resets all changes to the "deleted_at" field.
  349. func (m *AgentMutation) ResetDeletedAt() {
  350. m.deleted_at = nil
  351. delete(m.clearedFields, agent.FieldDeletedAt)
  352. }
  353. // SetName sets the "name" field.
  354. func (m *AgentMutation) SetName(s string) {
  355. m.name = &s
  356. }
  357. // Name returns the value of the "name" field in the mutation.
  358. func (m *AgentMutation) Name() (r string, exists bool) {
  359. v := m.name
  360. if v == nil {
  361. return
  362. }
  363. return *v, true
  364. }
  365. // OldName returns the old "name" field's value of the Agent entity.
  366. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  368. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  369. if !m.op.Is(OpUpdateOne) {
  370. return v, errors.New("OldName is only allowed on UpdateOne operations")
  371. }
  372. if m.id == nil || m.oldValue == nil {
  373. return v, errors.New("OldName requires an ID field in the mutation")
  374. }
  375. oldValue, err := m.oldValue(ctx)
  376. if err != nil {
  377. return v, fmt.Errorf("querying old value for OldName: %w", err)
  378. }
  379. return oldValue.Name, nil
  380. }
  381. // ResetName resets all changes to the "name" field.
  382. func (m *AgentMutation) ResetName() {
  383. m.name = nil
  384. }
  385. // SetRole sets the "role" field.
  386. func (m *AgentMutation) SetRole(s string) {
  387. m.role = &s
  388. }
  389. // Role returns the value of the "role" field in the mutation.
  390. func (m *AgentMutation) Role() (r string, exists bool) {
  391. v := m.role
  392. if v == nil {
  393. return
  394. }
  395. return *v, true
  396. }
  397. // OldRole returns the old "role" field's value of the Agent entity.
  398. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  400. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  401. if !m.op.Is(OpUpdateOne) {
  402. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  403. }
  404. if m.id == nil || m.oldValue == nil {
  405. return v, errors.New("OldRole requires an ID field in the mutation")
  406. }
  407. oldValue, err := m.oldValue(ctx)
  408. if err != nil {
  409. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  410. }
  411. return oldValue.Role, nil
  412. }
  413. // ResetRole resets all changes to the "role" field.
  414. func (m *AgentMutation) ResetRole() {
  415. m.role = nil
  416. }
  417. // SetStatus sets the "status" field.
  418. func (m *AgentMutation) SetStatus(i int) {
  419. m.status = &i
  420. m.addstatus = nil
  421. }
  422. // Status returns the value of the "status" field in the mutation.
  423. func (m *AgentMutation) Status() (r int, exists bool) {
  424. v := m.status
  425. if v == nil {
  426. return
  427. }
  428. return *v, true
  429. }
  430. // OldStatus returns the old "status" field's value of the Agent entity.
  431. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  433. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  434. if !m.op.Is(OpUpdateOne) {
  435. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  436. }
  437. if m.id == nil || m.oldValue == nil {
  438. return v, errors.New("OldStatus requires an ID field in the mutation")
  439. }
  440. oldValue, err := m.oldValue(ctx)
  441. if err != nil {
  442. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  443. }
  444. return oldValue.Status, nil
  445. }
  446. // AddStatus adds i to the "status" field.
  447. func (m *AgentMutation) AddStatus(i int) {
  448. if m.addstatus != nil {
  449. *m.addstatus += i
  450. } else {
  451. m.addstatus = &i
  452. }
  453. }
  454. // AddedStatus returns the value that was added to the "status" field in this mutation.
  455. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  456. v := m.addstatus
  457. if v == nil {
  458. return
  459. }
  460. return *v, true
  461. }
  462. // ClearStatus clears the value of the "status" field.
  463. func (m *AgentMutation) ClearStatus() {
  464. m.status = nil
  465. m.addstatus = nil
  466. m.clearedFields[agent.FieldStatus] = struct{}{}
  467. }
  468. // StatusCleared returns if the "status" field was cleared in this mutation.
  469. func (m *AgentMutation) StatusCleared() bool {
  470. _, ok := m.clearedFields[agent.FieldStatus]
  471. return ok
  472. }
  473. // ResetStatus resets all changes to the "status" field.
  474. func (m *AgentMutation) ResetStatus() {
  475. m.status = nil
  476. m.addstatus = nil
  477. delete(m.clearedFields, agent.FieldStatus)
  478. }
  479. // SetBackground sets the "background" field.
  480. func (m *AgentMutation) SetBackground(s string) {
  481. m.background = &s
  482. }
  483. // Background returns the value of the "background" field in the mutation.
  484. func (m *AgentMutation) Background() (r string, exists bool) {
  485. v := m.background
  486. if v == nil {
  487. return
  488. }
  489. return *v, true
  490. }
  491. // OldBackground returns the old "background" field's value of the Agent entity.
  492. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  494. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  495. if !m.op.Is(OpUpdateOne) {
  496. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  497. }
  498. if m.id == nil || m.oldValue == nil {
  499. return v, errors.New("OldBackground requires an ID field in the mutation")
  500. }
  501. oldValue, err := m.oldValue(ctx)
  502. if err != nil {
  503. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  504. }
  505. return oldValue.Background, nil
  506. }
  507. // ClearBackground clears the value of the "background" field.
  508. func (m *AgentMutation) ClearBackground() {
  509. m.background = nil
  510. m.clearedFields[agent.FieldBackground] = struct{}{}
  511. }
  512. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  513. func (m *AgentMutation) BackgroundCleared() bool {
  514. _, ok := m.clearedFields[agent.FieldBackground]
  515. return ok
  516. }
  517. // ResetBackground resets all changes to the "background" field.
  518. func (m *AgentMutation) ResetBackground() {
  519. m.background = nil
  520. delete(m.clearedFields, agent.FieldBackground)
  521. }
  522. // SetExamples sets the "examples" field.
  523. func (m *AgentMutation) SetExamples(s string) {
  524. m.examples = &s
  525. }
  526. // Examples returns the value of the "examples" field in the mutation.
  527. func (m *AgentMutation) Examples() (r string, exists bool) {
  528. v := m.examples
  529. if v == nil {
  530. return
  531. }
  532. return *v, true
  533. }
  534. // OldExamples returns the old "examples" field's value of the Agent entity.
  535. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  537. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  538. if !m.op.Is(OpUpdateOne) {
  539. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  540. }
  541. if m.id == nil || m.oldValue == nil {
  542. return v, errors.New("OldExamples requires an ID field in the mutation")
  543. }
  544. oldValue, err := m.oldValue(ctx)
  545. if err != nil {
  546. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  547. }
  548. return oldValue.Examples, nil
  549. }
  550. // ClearExamples clears the value of the "examples" field.
  551. func (m *AgentMutation) ClearExamples() {
  552. m.examples = nil
  553. m.clearedFields[agent.FieldExamples] = struct{}{}
  554. }
  555. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  556. func (m *AgentMutation) ExamplesCleared() bool {
  557. _, ok := m.clearedFields[agent.FieldExamples]
  558. return ok
  559. }
  560. // ResetExamples resets all changes to the "examples" field.
  561. func (m *AgentMutation) ResetExamples() {
  562. m.examples = nil
  563. delete(m.clearedFields, agent.FieldExamples)
  564. }
  565. // SetOrganizationID sets the "organization_id" field.
  566. func (m *AgentMutation) SetOrganizationID(u uint64) {
  567. m.organization_id = &u
  568. m.addorganization_id = nil
  569. }
  570. // OrganizationID returns the value of the "organization_id" field in the mutation.
  571. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  572. v := m.organization_id
  573. if v == nil {
  574. return
  575. }
  576. return *v, true
  577. }
  578. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  579. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  581. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  582. if !m.op.Is(OpUpdateOne) {
  583. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  584. }
  585. if m.id == nil || m.oldValue == nil {
  586. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  587. }
  588. oldValue, err := m.oldValue(ctx)
  589. if err != nil {
  590. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  591. }
  592. return oldValue.OrganizationID, nil
  593. }
  594. // AddOrganizationID adds u to the "organization_id" field.
  595. func (m *AgentMutation) AddOrganizationID(u int64) {
  596. if m.addorganization_id != nil {
  597. *m.addorganization_id += u
  598. } else {
  599. m.addorganization_id = &u
  600. }
  601. }
  602. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  603. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  604. v := m.addorganization_id
  605. if v == nil {
  606. return
  607. }
  608. return *v, true
  609. }
  610. // ResetOrganizationID resets all changes to the "organization_id" field.
  611. func (m *AgentMutation) ResetOrganizationID() {
  612. m.organization_id = nil
  613. m.addorganization_id = nil
  614. }
  615. // SetDatasetID sets the "dataset_id" field.
  616. func (m *AgentMutation) SetDatasetID(s string) {
  617. m.dataset_id = &s
  618. }
  619. // DatasetID returns the value of the "dataset_id" field in the mutation.
  620. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  621. v := m.dataset_id
  622. if v == nil {
  623. return
  624. }
  625. return *v, true
  626. }
  627. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  628. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  630. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  631. if !m.op.Is(OpUpdateOne) {
  632. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  633. }
  634. if m.id == nil || m.oldValue == nil {
  635. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  636. }
  637. oldValue, err := m.oldValue(ctx)
  638. if err != nil {
  639. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  640. }
  641. return oldValue.DatasetID, nil
  642. }
  643. // ResetDatasetID resets all changes to the "dataset_id" field.
  644. func (m *AgentMutation) ResetDatasetID() {
  645. m.dataset_id = nil
  646. }
  647. // SetCollectionID sets the "collection_id" field.
  648. func (m *AgentMutation) SetCollectionID(s string) {
  649. m.collection_id = &s
  650. }
  651. // CollectionID returns the value of the "collection_id" field in the mutation.
  652. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  653. v := m.collection_id
  654. if v == nil {
  655. return
  656. }
  657. return *v, true
  658. }
  659. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  660. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  662. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  663. if !m.op.Is(OpUpdateOne) {
  664. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  665. }
  666. if m.id == nil || m.oldValue == nil {
  667. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  668. }
  669. oldValue, err := m.oldValue(ctx)
  670. if err != nil {
  671. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  672. }
  673. return oldValue.CollectionID, nil
  674. }
  675. // ResetCollectionID resets all changes to the "collection_id" field.
  676. func (m *AgentMutation) ResetCollectionID() {
  677. m.collection_id = nil
  678. }
  679. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  680. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  681. if m.wx_agent == nil {
  682. m.wx_agent = make(map[uint64]struct{})
  683. }
  684. for i := range ids {
  685. m.wx_agent[ids[i]] = struct{}{}
  686. }
  687. }
  688. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  689. func (m *AgentMutation) ClearWxAgent() {
  690. m.clearedwx_agent = true
  691. }
  692. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  693. func (m *AgentMutation) WxAgentCleared() bool {
  694. return m.clearedwx_agent
  695. }
  696. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  697. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  698. if m.removedwx_agent == nil {
  699. m.removedwx_agent = make(map[uint64]struct{})
  700. }
  701. for i := range ids {
  702. delete(m.wx_agent, ids[i])
  703. m.removedwx_agent[ids[i]] = struct{}{}
  704. }
  705. }
  706. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  707. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  708. for id := range m.removedwx_agent {
  709. ids = append(ids, id)
  710. }
  711. return
  712. }
  713. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  714. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  715. for id := range m.wx_agent {
  716. ids = append(ids, id)
  717. }
  718. return
  719. }
  720. // ResetWxAgent resets all changes to the "wx_agent" edge.
  721. func (m *AgentMutation) ResetWxAgent() {
  722. m.wx_agent = nil
  723. m.clearedwx_agent = false
  724. m.removedwx_agent = nil
  725. }
  726. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  727. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  728. if m.token_agent == nil {
  729. m.token_agent = make(map[uint64]struct{})
  730. }
  731. for i := range ids {
  732. m.token_agent[ids[i]] = struct{}{}
  733. }
  734. }
  735. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  736. func (m *AgentMutation) ClearTokenAgent() {
  737. m.clearedtoken_agent = true
  738. }
  739. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  740. func (m *AgentMutation) TokenAgentCleared() bool {
  741. return m.clearedtoken_agent
  742. }
  743. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  744. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  745. if m.removedtoken_agent == nil {
  746. m.removedtoken_agent = make(map[uint64]struct{})
  747. }
  748. for i := range ids {
  749. delete(m.token_agent, ids[i])
  750. m.removedtoken_agent[ids[i]] = struct{}{}
  751. }
  752. }
  753. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  754. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  755. for id := range m.removedtoken_agent {
  756. ids = append(ids, id)
  757. }
  758. return
  759. }
  760. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  761. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  762. for id := range m.token_agent {
  763. ids = append(ids, id)
  764. }
  765. return
  766. }
  767. // ResetTokenAgent resets all changes to the "token_agent" edge.
  768. func (m *AgentMutation) ResetTokenAgent() {
  769. m.token_agent = nil
  770. m.clearedtoken_agent = false
  771. m.removedtoken_agent = nil
  772. }
  773. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  774. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  775. if m.wa_agent == nil {
  776. m.wa_agent = make(map[uint64]struct{})
  777. }
  778. for i := range ids {
  779. m.wa_agent[ids[i]] = struct{}{}
  780. }
  781. }
  782. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  783. func (m *AgentMutation) ClearWaAgent() {
  784. m.clearedwa_agent = true
  785. }
  786. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  787. func (m *AgentMutation) WaAgentCleared() bool {
  788. return m.clearedwa_agent
  789. }
  790. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  791. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  792. if m.removedwa_agent == nil {
  793. m.removedwa_agent = make(map[uint64]struct{})
  794. }
  795. for i := range ids {
  796. delete(m.wa_agent, ids[i])
  797. m.removedwa_agent[ids[i]] = struct{}{}
  798. }
  799. }
  800. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  801. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  802. for id := range m.removedwa_agent {
  803. ids = append(ids, id)
  804. }
  805. return
  806. }
  807. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  808. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  809. for id := range m.wa_agent {
  810. ids = append(ids, id)
  811. }
  812. return
  813. }
  814. // ResetWaAgent resets all changes to the "wa_agent" edge.
  815. func (m *AgentMutation) ResetWaAgent() {
  816. m.wa_agent = nil
  817. m.clearedwa_agent = false
  818. m.removedwa_agent = nil
  819. }
  820. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  821. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  822. if m.xjs_agent == nil {
  823. m.xjs_agent = make(map[uint64]struct{})
  824. }
  825. for i := range ids {
  826. m.xjs_agent[ids[i]] = struct{}{}
  827. }
  828. }
  829. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  830. func (m *AgentMutation) ClearXjsAgent() {
  831. m.clearedxjs_agent = true
  832. }
  833. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  834. func (m *AgentMutation) XjsAgentCleared() bool {
  835. return m.clearedxjs_agent
  836. }
  837. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  838. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  839. if m.removedxjs_agent == nil {
  840. m.removedxjs_agent = make(map[uint64]struct{})
  841. }
  842. for i := range ids {
  843. delete(m.xjs_agent, ids[i])
  844. m.removedxjs_agent[ids[i]] = struct{}{}
  845. }
  846. }
  847. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  848. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  849. for id := range m.removedxjs_agent {
  850. ids = append(ids, id)
  851. }
  852. return
  853. }
  854. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  855. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  856. for id := range m.xjs_agent {
  857. ids = append(ids, id)
  858. }
  859. return
  860. }
  861. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  862. func (m *AgentMutation) ResetXjsAgent() {
  863. m.xjs_agent = nil
  864. m.clearedxjs_agent = false
  865. m.removedxjs_agent = nil
  866. }
  867. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  868. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  869. if m.key_agent == nil {
  870. m.key_agent = make(map[uint64]struct{})
  871. }
  872. for i := range ids {
  873. m.key_agent[ids[i]] = struct{}{}
  874. }
  875. }
  876. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  877. func (m *AgentMutation) ClearKeyAgent() {
  878. m.clearedkey_agent = true
  879. }
  880. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  881. func (m *AgentMutation) KeyAgentCleared() bool {
  882. return m.clearedkey_agent
  883. }
  884. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  885. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  886. if m.removedkey_agent == nil {
  887. m.removedkey_agent = make(map[uint64]struct{})
  888. }
  889. for i := range ids {
  890. delete(m.key_agent, ids[i])
  891. m.removedkey_agent[ids[i]] = struct{}{}
  892. }
  893. }
  894. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  895. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  896. for id := range m.removedkey_agent {
  897. ids = append(ids, id)
  898. }
  899. return
  900. }
  901. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  902. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  903. for id := range m.key_agent {
  904. ids = append(ids, id)
  905. }
  906. return
  907. }
  908. // ResetKeyAgent resets all changes to the "key_agent" edge.
  909. func (m *AgentMutation) ResetKeyAgent() {
  910. m.key_agent = nil
  911. m.clearedkey_agent = false
  912. m.removedkey_agent = nil
  913. }
  914. // Where appends a list predicates to the AgentMutation builder.
  915. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  916. m.predicates = append(m.predicates, ps...)
  917. }
  918. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  919. // users can use type-assertion to append predicates that do not depend on any generated package.
  920. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  921. p := make([]predicate.Agent, len(ps))
  922. for i := range ps {
  923. p[i] = ps[i]
  924. }
  925. m.Where(p...)
  926. }
  927. // Op returns the operation name.
  928. func (m *AgentMutation) Op() Op {
  929. return m.op
  930. }
  931. // SetOp allows setting the mutation operation.
  932. func (m *AgentMutation) SetOp(op Op) {
  933. m.op = op
  934. }
  935. // Type returns the node type of this mutation (Agent).
  936. func (m *AgentMutation) Type() string {
  937. return m.typ
  938. }
  939. // Fields returns all fields that were changed during this mutation. Note that in
  940. // order to get all numeric fields that were incremented/decremented, call
  941. // AddedFields().
  942. func (m *AgentMutation) Fields() []string {
  943. fields := make([]string, 0, 11)
  944. if m.created_at != nil {
  945. fields = append(fields, agent.FieldCreatedAt)
  946. }
  947. if m.updated_at != nil {
  948. fields = append(fields, agent.FieldUpdatedAt)
  949. }
  950. if m.deleted_at != nil {
  951. fields = append(fields, agent.FieldDeletedAt)
  952. }
  953. if m.name != nil {
  954. fields = append(fields, agent.FieldName)
  955. }
  956. if m.role != nil {
  957. fields = append(fields, agent.FieldRole)
  958. }
  959. if m.status != nil {
  960. fields = append(fields, agent.FieldStatus)
  961. }
  962. if m.background != nil {
  963. fields = append(fields, agent.FieldBackground)
  964. }
  965. if m.examples != nil {
  966. fields = append(fields, agent.FieldExamples)
  967. }
  968. if m.organization_id != nil {
  969. fields = append(fields, agent.FieldOrganizationID)
  970. }
  971. if m.dataset_id != nil {
  972. fields = append(fields, agent.FieldDatasetID)
  973. }
  974. if m.collection_id != nil {
  975. fields = append(fields, agent.FieldCollectionID)
  976. }
  977. return fields
  978. }
  979. // Field returns the value of a field with the given name. The second boolean
  980. // return value indicates that this field was not set, or was not defined in the
  981. // schema.
  982. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  983. switch name {
  984. case agent.FieldCreatedAt:
  985. return m.CreatedAt()
  986. case agent.FieldUpdatedAt:
  987. return m.UpdatedAt()
  988. case agent.FieldDeletedAt:
  989. return m.DeletedAt()
  990. case agent.FieldName:
  991. return m.Name()
  992. case agent.FieldRole:
  993. return m.Role()
  994. case agent.FieldStatus:
  995. return m.Status()
  996. case agent.FieldBackground:
  997. return m.Background()
  998. case agent.FieldExamples:
  999. return m.Examples()
  1000. case agent.FieldOrganizationID:
  1001. return m.OrganizationID()
  1002. case agent.FieldDatasetID:
  1003. return m.DatasetID()
  1004. case agent.FieldCollectionID:
  1005. return m.CollectionID()
  1006. }
  1007. return nil, false
  1008. }
  1009. // OldField returns the old value of the field from the database. An error is
  1010. // returned if the mutation operation is not UpdateOne, or the query to the
  1011. // database failed.
  1012. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1013. switch name {
  1014. case agent.FieldCreatedAt:
  1015. return m.OldCreatedAt(ctx)
  1016. case agent.FieldUpdatedAt:
  1017. return m.OldUpdatedAt(ctx)
  1018. case agent.FieldDeletedAt:
  1019. return m.OldDeletedAt(ctx)
  1020. case agent.FieldName:
  1021. return m.OldName(ctx)
  1022. case agent.FieldRole:
  1023. return m.OldRole(ctx)
  1024. case agent.FieldStatus:
  1025. return m.OldStatus(ctx)
  1026. case agent.FieldBackground:
  1027. return m.OldBackground(ctx)
  1028. case agent.FieldExamples:
  1029. return m.OldExamples(ctx)
  1030. case agent.FieldOrganizationID:
  1031. return m.OldOrganizationID(ctx)
  1032. case agent.FieldDatasetID:
  1033. return m.OldDatasetID(ctx)
  1034. case agent.FieldCollectionID:
  1035. return m.OldCollectionID(ctx)
  1036. }
  1037. return nil, fmt.Errorf("unknown Agent field %s", name)
  1038. }
  1039. // SetField sets the value of a field with the given name. It returns an error if
  1040. // the field is not defined in the schema, or if the type mismatched the field
  1041. // type.
  1042. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1043. switch name {
  1044. case agent.FieldCreatedAt:
  1045. v, ok := value.(time.Time)
  1046. if !ok {
  1047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1048. }
  1049. m.SetCreatedAt(v)
  1050. return nil
  1051. case agent.FieldUpdatedAt:
  1052. v, ok := value.(time.Time)
  1053. if !ok {
  1054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1055. }
  1056. m.SetUpdatedAt(v)
  1057. return nil
  1058. case agent.FieldDeletedAt:
  1059. v, ok := value.(time.Time)
  1060. if !ok {
  1061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1062. }
  1063. m.SetDeletedAt(v)
  1064. return nil
  1065. case agent.FieldName:
  1066. v, ok := value.(string)
  1067. if !ok {
  1068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1069. }
  1070. m.SetName(v)
  1071. return nil
  1072. case agent.FieldRole:
  1073. v, ok := value.(string)
  1074. if !ok {
  1075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1076. }
  1077. m.SetRole(v)
  1078. return nil
  1079. case agent.FieldStatus:
  1080. v, ok := value.(int)
  1081. if !ok {
  1082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1083. }
  1084. m.SetStatus(v)
  1085. return nil
  1086. case agent.FieldBackground:
  1087. v, ok := value.(string)
  1088. if !ok {
  1089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1090. }
  1091. m.SetBackground(v)
  1092. return nil
  1093. case agent.FieldExamples:
  1094. v, ok := value.(string)
  1095. if !ok {
  1096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1097. }
  1098. m.SetExamples(v)
  1099. return nil
  1100. case agent.FieldOrganizationID:
  1101. v, ok := value.(uint64)
  1102. if !ok {
  1103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1104. }
  1105. m.SetOrganizationID(v)
  1106. return nil
  1107. case agent.FieldDatasetID:
  1108. v, ok := value.(string)
  1109. if !ok {
  1110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1111. }
  1112. m.SetDatasetID(v)
  1113. return nil
  1114. case agent.FieldCollectionID:
  1115. v, ok := value.(string)
  1116. if !ok {
  1117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1118. }
  1119. m.SetCollectionID(v)
  1120. return nil
  1121. }
  1122. return fmt.Errorf("unknown Agent field %s", name)
  1123. }
  1124. // AddedFields returns all numeric fields that were incremented/decremented during
  1125. // this mutation.
  1126. func (m *AgentMutation) AddedFields() []string {
  1127. var fields []string
  1128. if m.addstatus != nil {
  1129. fields = append(fields, agent.FieldStatus)
  1130. }
  1131. if m.addorganization_id != nil {
  1132. fields = append(fields, agent.FieldOrganizationID)
  1133. }
  1134. return fields
  1135. }
  1136. // AddedField returns the numeric value that was incremented/decremented on a field
  1137. // with the given name. The second boolean return value indicates that this field
  1138. // was not set, or was not defined in the schema.
  1139. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1140. switch name {
  1141. case agent.FieldStatus:
  1142. return m.AddedStatus()
  1143. case agent.FieldOrganizationID:
  1144. return m.AddedOrganizationID()
  1145. }
  1146. return nil, false
  1147. }
  1148. // AddField adds the value to the field with the given name. It returns an error if
  1149. // the field is not defined in the schema, or if the type mismatched the field
  1150. // type.
  1151. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1152. switch name {
  1153. case agent.FieldStatus:
  1154. v, ok := value.(int)
  1155. if !ok {
  1156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1157. }
  1158. m.AddStatus(v)
  1159. return nil
  1160. case agent.FieldOrganizationID:
  1161. v, ok := value.(int64)
  1162. if !ok {
  1163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1164. }
  1165. m.AddOrganizationID(v)
  1166. return nil
  1167. }
  1168. return fmt.Errorf("unknown Agent numeric field %s", name)
  1169. }
  1170. // ClearedFields returns all nullable fields that were cleared during this
  1171. // mutation.
  1172. func (m *AgentMutation) ClearedFields() []string {
  1173. var fields []string
  1174. if m.FieldCleared(agent.FieldDeletedAt) {
  1175. fields = append(fields, agent.FieldDeletedAt)
  1176. }
  1177. if m.FieldCleared(agent.FieldStatus) {
  1178. fields = append(fields, agent.FieldStatus)
  1179. }
  1180. if m.FieldCleared(agent.FieldBackground) {
  1181. fields = append(fields, agent.FieldBackground)
  1182. }
  1183. if m.FieldCleared(agent.FieldExamples) {
  1184. fields = append(fields, agent.FieldExamples)
  1185. }
  1186. return fields
  1187. }
  1188. // FieldCleared returns a boolean indicating if a field with the given name was
  1189. // cleared in this mutation.
  1190. func (m *AgentMutation) FieldCleared(name string) bool {
  1191. _, ok := m.clearedFields[name]
  1192. return ok
  1193. }
  1194. // ClearField clears the value of the field with the given name. It returns an
  1195. // error if the field is not defined in the schema.
  1196. func (m *AgentMutation) ClearField(name string) error {
  1197. switch name {
  1198. case agent.FieldDeletedAt:
  1199. m.ClearDeletedAt()
  1200. return nil
  1201. case agent.FieldStatus:
  1202. m.ClearStatus()
  1203. return nil
  1204. case agent.FieldBackground:
  1205. m.ClearBackground()
  1206. return nil
  1207. case agent.FieldExamples:
  1208. m.ClearExamples()
  1209. return nil
  1210. }
  1211. return fmt.Errorf("unknown Agent nullable field %s", name)
  1212. }
  1213. // ResetField resets all changes in the mutation for the field with the given name.
  1214. // It returns an error if the field is not defined in the schema.
  1215. func (m *AgentMutation) ResetField(name string) error {
  1216. switch name {
  1217. case agent.FieldCreatedAt:
  1218. m.ResetCreatedAt()
  1219. return nil
  1220. case agent.FieldUpdatedAt:
  1221. m.ResetUpdatedAt()
  1222. return nil
  1223. case agent.FieldDeletedAt:
  1224. m.ResetDeletedAt()
  1225. return nil
  1226. case agent.FieldName:
  1227. m.ResetName()
  1228. return nil
  1229. case agent.FieldRole:
  1230. m.ResetRole()
  1231. return nil
  1232. case agent.FieldStatus:
  1233. m.ResetStatus()
  1234. return nil
  1235. case agent.FieldBackground:
  1236. m.ResetBackground()
  1237. return nil
  1238. case agent.FieldExamples:
  1239. m.ResetExamples()
  1240. return nil
  1241. case agent.FieldOrganizationID:
  1242. m.ResetOrganizationID()
  1243. return nil
  1244. case agent.FieldDatasetID:
  1245. m.ResetDatasetID()
  1246. return nil
  1247. case agent.FieldCollectionID:
  1248. m.ResetCollectionID()
  1249. return nil
  1250. }
  1251. return fmt.Errorf("unknown Agent field %s", name)
  1252. }
  1253. // AddedEdges returns all edge names that were set/added in this mutation.
  1254. func (m *AgentMutation) AddedEdges() []string {
  1255. edges := make([]string, 0, 5)
  1256. if m.wx_agent != nil {
  1257. edges = append(edges, agent.EdgeWxAgent)
  1258. }
  1259. if m.token_agent != nil {
  1260. edges = append(edges, agent.EdgeTokenAgent)
  1261. }
  1262. if m.wa_agent != nil {
  1263. edges = append(edges, agent.EdgeWaAgent)
  1264. }
  1265. if m.xjs_agent != nil {
  1266. edges = append(edges, agent.EdgeXjsAgent)
  1267. }
  1268. if m.key_agent != nil {
  1269. edges = append(edges, agent.EdgeKeyAgent)
  1270. }
  1271. return edges
  1272. }
  1273. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1274. // name in this mutation.
  1275. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1276. switch name {
  1277. case agent.EdgeWxAgent:
  1278. ids := make([]ent.Value, 0, len(m.wx_agent))
  1279. for id := range m.wx_agent {
  1280. ids = append(ids, id)
  1281. }
  1282. return ids
  1283. case agent.EdgeTokenAgent:
  1284. ids := make([]ent.Value, 0, len(m.token_agent))
  1285. for id := range m.token_agent {
  1286. ids = append(ids, id)
  1287. }
  1288. return ids
  1289. case agent.EdgeWaAgent:
  1290. ids := make([]ent.Value, 0, len(m.wa_agent))
  1291. for id := range m.wa_agent {
  1292. ids = append(ids, id)
  1293. }
  1294. return ids
  1295. case agent.EdgeXjsAgent:
  1296. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1297. for id := range m.xjs_agent {
  1298. ids = append(ids, id)
  1299. }
  1300. return ids
  1301. case agent.EdgeKeyAgent:
  1302. ids := make([]ent.Value, 0, len(m.key_agent))
  1303. for id := range m.key_agent {
  1304. ids = append(ids, id)
  1305. }
  1306. return ids
  1307. }
  1308. return nil
  1309. }
  1310. // RemovedEdges returns all edge names that were removed in this mutation.
  1311. func (m *AgentMutation) RemovedEdges() []string {
  1312. edges := make([]string, 0, 5)
  1313. if m.removedwx_agent != nil {
  1314. edges = append(edges, agent.EdgeWxAgent)
  1315. }
  1316. if m.removedtoken_agent != nil {
  1317. edges = append(edges, agent.EdgeTokenAgent)
  1318. }
  1319. if m.removedwa_agent != nil {
  1320. edges = append(edges, agent.EdgeWaAgent)
  1321. }
  1322. if m.removedxjs_agent != nil {
  1323. edges = append(edges, agent.EdgeXjsAgent)
  1324. }
  1325. if m.removedkey_agent != nil {
  1326. edges = append(edges, agent.EdgeKeyAgent)
  1327. }
  1328. return edges
  1329. }
  1330. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1331. // the given name in this mutation.
  1332. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1333. switch name {
  1334. case agent.EdgeWxAgent:
  1335. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1336. for id := range m.removedwx_agent {
  1337. ids = append(ids, id)
  1338. }
  1339. return ids
  1340. case agent.EdgeTokenAgent:
  1341. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1342. for id := range m.removedtoken_agent {
  1343. ids = append(ids, id)
  1344. }
  1345. return ids
  1346. case agent.EdgeWaAgent:
  1347. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1348. for id := range m.removedwa_agent {
  1349. ids = append(ids, id)
  1350. }
  1351. return ids
  1352. case agent.EdgeXjsAgent:
  1353. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1354. for id := range m.removedxjs_agent {
  1355. ids = append(ids, id)
  1356. }
  1357. return ids
  1358. case agent.EdgeKeyAgent:
  1359. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1360. for id := range m.removedkey_agent {
  1361. ids = append(ids, id)
  1362. }
  1363. return ids
  1364. }
  1365. return nil
  1366. }
  1367. // ClearedEdges returns all edge names that were cleared in this mutation.
  1368. func (m *AgentMutation) ClearedEdges() []string {
  1369. edges := make([]string, 0, 5)
  1370. if m.clearedwx_agent {
  1371. edges = append(edges, agent.EdgeWxAgent)
  1372. }
  1373. if m.clearedtoken_agent {
  1374. edges = append(edges, agent.EdgeTokenAgent)
  1375. }
  1376. if m.clearedwa_agent {
  1377. edges = append(edges, agent.EdgeWaAgent)
  1378. }
  1379. if m.clearedxjs_agent {
  1380. edges = append(edges, agent.EdgeXjsAgent)
  1381. }
  1382. if m.clearedkey_agent {
  1383. edges = append(edges, agent.EdgeKeyAgent)
  1384. }
  1385. return edges
  1386. }
  1387. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1388. // was cleared in this mutation.
  1389. func (m *AgentMutation) EdgeCleared(name string) bool {
  1390. switch name {
  1391. case agent.EdgeWxAgent:
  1392. return m.clearedwx_agent
  1393. case agent.EdgeTokenAgent:
  1394. return m.clearedtoken_agent
  1395. case agent.EdgeWaAgent:
  1396. return m.clearedwa_agent
  1397. case agent.EdgeXjsAgent:
  1398. return m.clearedxjs_agent
  1399. case agent.EdgeKeyAgent:
  1400. return m.clearedkey_agent
  1401. }
  1402. return false
  1403. }
  1404. // ClearEdge clears the value of the edge with the given name. It returns an error
  1405. // if that edge is not defined in the schema.
  1406. func (m *AgentMutation) ClearEdge(name string) error {
  1407. switch name {
  1408. }
  1409. return fmt.Errorf("unknown Agent unique edge %s", name)
  1410. }
  1411. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1412. // It returns an error if the edge is not defined in the schema.
  1413. func (m *AgentMutation) ResetEdge(name string) error {
  1414. switch name {
  1415. case agent.EdgeWxAgent:
  1416. m.ResetWxAgent()
  1417. return nil
  1418. case agent.EdgeTokenAgent:
  1419. m.ResetTokenAgent()
  1420. return nil
  1421. case agent.EdgeWaAgent:
  1422. m.ResetWaAgent()
  1423. return nil
  1424. case agent.EdgeXjsAgent:
  1425. m.ResetXjsAgent()
  1426. return nil
  1427. case agent.EdgeKeyAgent:
  1428. m.ResetKeyAgent()
  1429. return nil
  1430. }
  1431. return fmt.Errorf("unknown Agent edge %s", name)
  1432. }
  1433. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1434. type AgentBaseMutation struct {
  1435. config
  1436. op Op
  1437. typ string
  1438. id *string
  1439. q *string
  1440. a *string
  1441. chunk_index *uint64
  1442. addchunk_index *int64
  1443. indexes *[]string
  1444. appendindexes []string
  1445. dataset_id *string
  1446. collection_id *string
  1447. source_name *string
  1448. can_write *[]bool
  1449. appendcan_write []bool
  1450. is_owner *[]bool
  1451. appendis_owner []bool
  1452. clearedFields map[string]struct{}
  1453. wx_agent map[uint64]struct{}
  1454. removedwx_agent map[uint64]struct{}
  1455. clearedwx_agent bool
  1456. done bool
  1457. oldValue func(context.Context) (*AgentBase, error)
  1458. predicates []predicate.AgentBase
  1459. }
  1460. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1461. // agentbaseOption allows management of the mutation configuration using functional options.
  1462. type agentbaseOption func(*AgentBaseMutation)
  1463. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1464. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1465. m := &AgentBaseMutation{
  1466. config: c,
  1467. op: op,
  1468. typ: TypeAgentBase,
  1469. clearedFields: make(map[string]struct{}),
  1470. }
  1471. for _, opt := range opts {
  1472. opt(m)
  1473. }
  1474. return m
  1475. }
  1476. // withAgentBaseID sets the ID field of the mutation.
  1477. func withAgentBaseID(id string) agentbaseOption {
  1478. return func(m *AgentBaseMutation) {
  1479. var (
  1480. err error
  1481. once sync.Once
  1482. value *AgentBase
  1483. )
  1484. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1485. once.Do(func() {
  1486. if m.done {
  1487. err = errors.New("querying old values post mutation is not allowed")
  1488. } else {
  1489. value, err = m.Client().AgentBase.Get(ctx, id)
  1490. }
  1491. })
  1492. return value, err
  1493. }
  1494. m.id = &id
  1495. }
  1496. }
  1497. // withAgentBase sets the old AgentBase of the mutation.
  1498. func withAgentBase(node *AgentBase) agentbaseOption {
  1499. return func(m *AgentBaseMutation) {
  1500. m.oldValue = func(context.Context) (*AgentBase, error) {
  1501. return node, nil
  1502. }
  1503. m.id = &node.ID
  1504. }
  1505. }
  1506. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1507. // executed in a transaction (ent.Tx), a transactional client is returned.
  1508. func (m AgentBaseMutation) Client() *Client {
  1509. client := &Client{config: m.config}
  1510. client.init()
  1511. return client
  1512. }
  1513. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1514. // it returns an error otherwise.
  1515. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1516. if _, ok := m.driver.(*txDriver); !ok {
  1517. return nil, errors.New("ent: mutation is not running in a transaction")
  1518. }
  1519. tx := &Tx{config: m.config}
  1520. tx.init()
  1521. return tx, nil
  1522. }
  1523. // SetID sets the value of the id field. Note that this
  1524. // operation is only accepted on creation of AgentBase entities.
  1525. func (m *AgentBaseMutation) SetID(id string) {
  1526. m.id = &id
  1527. }
  1528. // ID returns the ID value in the mutation. Note that the ID is only available
  1529. // if it was provided to the builder or after it was returned from the database.
  1530. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1531. if m.id == nil {
  1532. return
  1533. }
  1534. return *m.id, true
  1535. }
  1536. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1537. // That means, if the mutation is applied within a transaction with an isolation level such
  1538. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1539. // or updated by the mutation.
  1540. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1541. switch {
  1542. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1543. id, exists := m.ID()
  1544. if exists {
  1545. return []string{id}, nil
  1546. }
  1547. fallthrough
  1548. case m.op.Is(OpUpdate | OpDelete):
  1549. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1550. default:
  1551. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1552. }
  1553. }
  1554. // SetQ sets the "q" field.
  1555. func (m *AgentBaseMutation) SetQ(s string) {
  1556. m.q = &s
  1557. }
  1558. // Q returns the value of the "q" field in the mutation.
  1559. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1560. v := m.q
  1561. if v == nil {
  1562. return
  1563. }
  1564. return *v, true
  1565. }
  1566. // OldQ returns the old "q" field's value of the AgentBase entity.
  1567. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1569. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1570. if !m.op.Is(OpUpdateOne) {
  1571. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1572. }
  1573. if m.id == nil || m.oldValue == nil {
  1574. return v, errors.New("OldQ requires an ID field in the mutation")
  1575. }
  1576. oldValue, err := m.oldValue(ctx)
  1577. if err != nil {
  1578. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1579. }
  1580. return oldValue.Q, nil
  1581. }
  1582. // ClearQ clears the value of the "q" field.
  1583. func (m *AgentBaseMutation) ClearQ() {
  1584. m.q = nil
  1585. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1586. }
  1587. // QCleared returns if the "q" field was cleared in this mutation.
  1588. func (m *AgentBaseMutation) QCleared() bool {
  1589. _, ok := m.clearedFields[agentbase.FieldQ]
  1590. return ok
  1591. }
  1592. // ResetQ resets all changes to the "q" field.
  1593. func (m *AgentBaseMutation) ResetQ() {
  1594. m.q = nil
  1595. delete(m.clearedFields, agentbase.FieldQ)
  1596. }
  1597. // SetA sets the "a" field.
  1598. func (m *AgentBaseMutation) SetA(s string) {
  1599. m.a = &s
  1600. }
  1601. // A returns the value of the "a" field in the mutation.
  1602. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1603. v := m.a
  1604. if v == nil {
  1605. return
  1606. }
  1607. return *v, true
  1608. }
  1609. // OldA returns the old "a" field's value of the AgentBase entity.
  1610. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1612. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1613. if !m.op.Is(OpUpdateOne) {
  1614. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1615. }
  1616. if m.id == nil || m.oldValue == nil {
  1617. return v, errors.New("OldA requires an ID field in the mutation")
  1618. }
  1619. oldValue, err := m.oldValue(ctx)
  1620. if err != nil {
  1621. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1622. }
  1623. return oldValue.A, nil
  1624. }
  1625. // ClearA clears the value of the "a" field.
  1626. func (m *AgentBaseMutation) ClearA() {
  1627. m.a = nil
  1628. m.clearedFields[agentbase.FieldA] = struct{}{}
  1629. }
  1630. // ACleared returns if the "a" field was cleared in this mutation.
  1631. func (m *AgentBaseMutation) ACleared() bool {
  1632. _, ok := m.clearedFields[agentbase.FieldA]
  1633. return ok
  1634. }
  1635. // ResetA resets all changes to the "a" field.
  1636. func (m *AgentBaseMutation) ResetA() {
  1637. m.a = nil
  1638. delete(m.clearedFields, agentbase.FieldA)
  1639. }
  1640. // SetChunkIndex sets the "chunk_index" field.
  1641. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1642. m.chunk_index = &u
  1643. m.addchunk_index = nil
  1644. }
  1645. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1646. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1647. v := m.chunk_index
  1648. if v == nil {
  1649. return
  1650. }
  1651. return *v, true
  1652. }
  1653. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1654. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1656. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1657. if !m.op.Is(OpUpdateOne) {
  1658. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1659. }
  1660. if m.id == nil || m.oldValue == nil {
  1661. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1662. }
  1663. oldValue, err := m.oldValue(ctx)
  1664. if err != nil {
  1665. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1666. }
  1667. return oldValue.ChunkIndex, nil
  1668. }
  1669. // AddChunkIndex adds u to the "chunk_index" field.
  1670. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1671. if m.addchunk_index != nil {
  1672. *m.addchunk_index += u
  1673. } else {
  1674. m.addchunk_index = &u
  1675. }
  1676. }
  1677. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1678. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1679. v := m.addchunk_index
  1680. if v == nil {
  1681. return
  1682. }
  1683. return *v, true
  1684. }
  1685. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1686. func (m *AgentBaseMutation) ResetChunkIndex() {
  1687. m.chunk_index = nil
  1688. m.addchunk_index = nil
  1689. }
  1690. // SetIndexes sets the "indexes" field.
  1691. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1692. m.indexes = &s
  1693. m.appendindexes = nil
  1694. }
  1695. // Indexes returns the value of the "indexes" field in the mutation.
  1696. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1697. v := m.indexes
  1698. if v == nil {
  1699. return
  1700. }
  1701. return *v, true
  1702. }
  1703. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1704. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1706. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1707. if !m.op.Is(OpUpdateOne) {
  1708. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1709. }
  1710. if m.id == nil || m.oldValue == nil {
  1711. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1712. }
  1713. oldValue, err := m.oldValue(ctx)
  1714. if err != nil {
  1715. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1716. }
  1717. return oldValue.Indexes, nil
  1718. }
  1719. // AppendIndexes adds s to the "indexes" field.
  1720. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1721. m.appendindexes = append(m.appendindexes, s...)
  1722. }
  1723. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1724. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1725. if len(m.appendindexes) == 0 {
  1726. return nil, false
  1727. }
  1728. return m.appendindexes, true
  1729. }
  1730. // ClearIndexes clears the value of the "indexes" field.
  1731. func (m *AgentBaseMutation) ClearIndexes() {
  1732. m.indexes = nil
  1733. m.appendindexes = nil
  1734. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1735. }
  1736. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1737. func (m *AgentBaseMutation) IndexesCleared() bool {
  1738. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1739. return ok
  1740. }
  1741. // ResetIndexes resets all changes to the "indexes" field.
  1742. func (m *AgentBaseMutation) ResetIndexes() {
  1743. m.indexes = nil
  1744. m.appendindexes = nil
  1745. delete(m.clearedFields, agentbase.FieldIndexes)
  1746. }
  1747. // SetDatasetID sets the "dataset_id" field.
  1748. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1749. m.dataset_id = &s
  1750. }
  1751. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1752. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1753. v := m.dataset_id
  1754. if v == nil {
  1755. return
  1756. }
  1757. return *v, true
  1758. }
  1759. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1760. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1762. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1763. if !m.op.Is(OpUpdateOne) {
  1764. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1765. }
  1766. if m.id == nil || m.oldValue == nil {
  1767. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1768. }
  1769. oldValue, err := m.oldValue(ctx)
  1770. if err != nil {
  1771. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1772. }
  1773. return oldValue.DatasetID, nil
  1774. }
  1775. // ClearDatasetID clears the value of the "dataset_id" field.
  1776. func (m *AgentBaseMutation) ClearDatasetID() {
  1777. m.dataset_id = nil
  1778. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1779. }
  1780. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1781. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1782. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1783. return ok
  1784. }
  1785. // ResetDatasetID resets all changes to the "dataset_id" field.
  1786. func (m *AgentBaseMutation) ResetDatasetID() {
  1787. m.dataset_id = nil
  1788. delete(m.clearedFields, agentbase.FieldDatasetID)
  1789. }
  1790. // SetCollectionID sets the "collection_id" field.
  1791. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1792. m.collection_id = &s
  1793. }
  1794. // CollectionID returns the value of the "collection_id" field in the mutation.
  1795. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1796. v := m.collection_id
  1797. if v == nil {
  1798. return
  1799. }
  1800. return *v, true
  1801. }
  1802. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1803. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1805. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1806. if !m.op.Is(OpUpdateOne) {
  1807. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1808. }
  1809. if m.id == nil || m.oldValue == nil {
  1810. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1811. }
  1812. oldValue, err := m.oldValue(ctx)
  1813. if err != nil {
  1814. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1815. }
  1816. return oldValue.CollectionID, nil
  1817. }
  1818. // ClearCollectionID clears the value of the "collection_id" field.
  1819. func (m *AgentBaseMutation) ClearCollectionID() {
  1820. m.collection_id = nil
  1821. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1822. }
  1823. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1824. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1825. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1826. return ok
  1827. }
  1828. // ResetCollectionID resets all changes to the "collection_id" field.
  1829. func (m *AgentBaseMutation) ResetCollectionID() {
  1830. m.collection_id = nil
  1831. delete(m.clearedFields, agentbase.FieldCollectionID)
  1832. }
  1833. // SetSourceName sets the "source_name" field.
  1834. func (m *AgentBaseMutation) SetSourceName(s string) {
  1835. m.source_name = &s
  1836. }
  1837. // SourceName returns the value of the "source_name" field in the mutation.
  1838. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1839. v := m.source_name
  1840. if v == nil {
  1841. return
  1842. }
  1843. return *v, true
  1844. }
  1845. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1846. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1848. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1849. if !m.op.Is(OpUpdateOne) {
  1850. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1851. }
  1852. if m.id == nil || m.oldValue == nil {
  1853. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1854. }
  1855. oldValue, err := m.oldValue(ctx)
  1856. if err != nil {
  1857. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1858. }
  1859. return oldValue.SourceName, nil
  1860. }
  1861. // ClearSourceName clears the value of the "source_name" field.
  1862. func (m *AgentBaseMutation) ClearSourceName() {
  1863. m.source_name = nil
  1864. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1865. }
  1866. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1867. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1868. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1869. return ok
  1870. }
  1871. // ResetSourceName resets all changes to the "source_name" field.
  1872. func (m *AgentBaseMutation) ResetSourceName() {
  1873. m.source_name = nil
  1874. delete(m.clearedFields, agentbase.FieldSourceName)
  1875. }
  1876. // SetCanWrite sets the "can_write" field.
  1877. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1878. m.can_write = &b
  1879. m.appendcan_write = nil
  1880. }
  1881. // CanWrite returns the value of the "can_write" field in the mutation.
  1882. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1883. v := m.can_write
  1884. if v == nil {
  1885. return
  1886. }
  1887. return *v, true
  1888. }
  1889. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1890. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1892. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1893. if !m.op.Is(OpUpdateOne) {
  1894. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1895. }
  1896. if m.id == nil || m.oldValue == nil {
  1897. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1898. }
  1899. oldValue, err := m.oldValue(ctx)
  1900. if err != nil {
  1901. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1902. }
  1903. return oldValue.CanWrite, nil
  1904. }
  1905. // AppendCanWrite adds b to the "can_write" field.
  1906. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1907. m.appendcan_write = append(m.appendcan_write, b...)
  1908. }
  1909. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1910. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1911. if len(m.appendcan_write) == 0 {
  1912. return nil, false
  1913. }
  1914. return m.appendcan_write, true
  1915. }
  1916. // ClearCanWrite clears the value of the "can_write" field.
  1917. func (m *AgentBaseMutation) ClearCanWrite() {
  1918. m.can_write = nil
  1919. m.appendcan_write = nil
  1920. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1921. }
  1922. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1923. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1924. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1925. return ok
  1926. }
  1927. // ResetCanWrite resets all changes to the "can_write" field.
  1928. func (m *AgentBaseMutation) ResetCanWrite() {
  1929. m.can_write = nil
  1930. m.appendcan_write = nil
  1931. delete(m.clearedFields, agentbase.FieldCanWrite)
  1932. }
  1933. // SetIsOwner sets the "is_owner" field.
  1934. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1935. m.is_owner = &b
  1936. m.appendis_owner = nil
  1937. }
  1938. // IsOwner returns the value of the "is_owner" field in the mutation.
  1939. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1940. v := m.is_owner
  1941. if v == nil {
  1942. return
  1943. }
  1944. return *v, true
  1945. }
  1946. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1947. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1949. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1950. if !m.op.Is(OpUpdateOne) {
  1951. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1952. }
  1953. if m.id == nil || m.oldValue == nil {
  1954. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1955. }
  1956. oldValue, err := m.oldValue(ctx)
  1957. if err != nil {
  1958. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1959. }
  1960. return oldValue.IsOwner, nil
  1961. }
  1962. // AppendIsOwner adds b to the "is_owner" field.
  1963. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1964. m.appendis_owner = append(m.appendis_owner, b...)
  1965. }
  1966. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1967. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1968. if len(m.appendis_owner) == 0 {
  1969. return nil, false
  1970. }
  1971. return m.appendis_owner, true
  1972. }
  1973. // ClearIsOwner clears the value of the "is_owner" field.
  1974. func (m *AgentBaseMutation) ClearIsOwner() {
  1975. m.is_owner = nil
  1976. m.appendis_owner = nil
  1977. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1978. }
  1979. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1980. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1981. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1982. return ok
  1983. }
  1984. // ResetIsOwner resets all changes to the "is_owner" field.
  1985. func (m *AgentBaseMutation) ResetIsOwner() {
  1986. m.is_owner = nil
  1987. m.appendis_owner = nil
  1988. delete(m.clearedFields, agentbase.FieldIsOwner)
  1989. }
  1990. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1991. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1992. if m.wx_agent == nil {
  1993. m.wx_agent = make(map[uint64]struct{})
  1994. }
  1995. for i := range ids {
  1996. m.wx_agent[ids[i]] = struct{}{}
  1997. }
  1998. }
  1999. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2000. func (m *AgentBaseMutation) ClearWxAgent() {
  2001. m.clearedwx_agent = true
  2002. }
  2003. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2004. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2005. return m.clearedwx_agent
  2006. }
  2007. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2008. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2009. if m.removedwx_agent == nil {
  2010. m.removedwx_agent = make(map[uint64]struct{})
  2011. }
  2012. for i := range ids {
  2013. delete(m.wx_agent, ids[i])
  2014. m.removedwx_agent[ids[i]] = struct{}{}
  2015. }
  2016. }
  2017. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2018. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2019. for id := range m.removedwx_agent {
  2020. ids = append(ids, id)
  2021. }
  2022. return
  2023. }
  2024. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2025. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2026. for id := range m.wx_agent {
  2027. ids = append(ids, id)
  2028. }
  2029. return
  2030. }
  2031. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2032. func (m *AgentBaseMutation) ResetWxAgent() {
  2033. m.wx_agent = nil
  2034. m.clearedwx_agent = false
  2035. m.removedwx_agent = nil
  2036. }
  2037. // Where appends a list predicates to the AgentBaseMutation builder.
  2038. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2039. m.predicates = append(m.predicates, ps...)
  2040. }
  2041. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2042. // users can use type-assertion to append predicates that do not depend on any generated package.
  2043. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2044. p := make([]predicate.AgentBase, len(ps))
  2045. for i := range ps {
  2046. p[i] = ps[i]
  2047. }
  2048. m.Where(p...)
  2049. }
  2050. // Op returns the operation name.
  2051. func (m *AgentBaseMutation) Op() Op {
  2052. return m.op
  2053. }
  2054. // SetOp allows setting the mutation operation.
  2055. func (m *AgentBaseMutation) SetOp(op Op) {
  2056. m.op = op
  2057. }
  2058. // Type returns the node type of this mutation (AgentBase).
  2059. func (m *AgentBaseMutation) Type() string {
  2060. return m.typ
  2061. }
  2062. // Fields returns all fields that were changed during this mutation. Note that in
  2063. // order to get all numeric fields that were incremented/decremented, call
  2064. // AddedFields().
  2065. func (m *AgentBaseMutation) Fields() []string {
  2066. fields := make([]string, 0, 9)
  2067. if m.q != nil {
  2068. fields = append(fields, agentbase.FieldQ)
  2069. }
  2070. if m.a != nil {
  2071. fields = append(fields, agentbase.FieldA)
  2072. }
  2073. if m.chunk_index != nil {
  2074. fields = append(fields, agentbase.FieldChunkIndex)
  2075. }
  2076. if m.indexes != nil {
  2077. fields = append(fields, agentbase.FieldIndexes)
  2078. }
  2079. if m.dataset_id != nil {
  2080. fields = append(fields, agentbase.FieldDatasetID)
  2081. }
  2082. if m.collection_id != nil {
  2083. fields = append(fields, agentbase.FieldCollectionID)
  2084. }
  2085. if m.source_name != nil {
  2086. fields = append(fields, agentbase.FieldSourceName)
  2087. }
  2088. if m.can_write != nil {
  2089. fields = append(fields, agentbase.FieldCanWrite)
  2090. }
  2091. if m.is_owner != nil {
  2092. fields = append(fields, agentbase.FieldIsOwner)
  2093. }
  2094. return fields
  2095. }
  2096. // Field returns the value of a field with the given name. The second boolean
  2097. // return value indicates that this field was not set, or was not defined in the
  2098. // schema.
  2099. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2100. switch name {
  2101. case agentbase.FieldQ:
  2102. return m.Q()
  2103. case agentbase.FieldA:
  2104. return m.A()
  2105. case agentbase.FieldChunkIndex:
  2106. return m.ChunkIndex()
  2107. case agentbase.FieldIndexes:
  2108. return m.Indexes()
  2109. case agentbase.FieldDatasetID:
  2110. return m.DatasetID()
  2111. case agentbase.FieldCollectionID:
  2112. return m.CollectionID()
  2113. case agentbase.FieldSourceName:
  2114. return m.SourceName()
  2115. case agentbase.FieldCanWrite:
  2116. return m.CanWrite()
  2117. case agentbase.FieldIsOwner:
  2118. return m.IsOwner()
  2119. }
  2120. return nil, false
  2121. }
  2122. // OldField returns the old value of the field from the database. An error is
  2123. // returned if the mutation operation is not UpdateOne, or the query to the
  2124. // database failed.
  2125. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2126. switch name {
  2127. case agentbase.FieldQ:
  2128. return m.OldQ(ctx)
  2129. case agentbase.FieldA:
  2130. return m.OldA(ctx)
  2131. case agentbase.FieldChunkIndex:
  2132. return m.OldChunkIndex(ctx)
  2133. case agentbase.FieldIndexes:
  2134. return m.OldIndexes(ctx)
  2135. case agentbase.FieldDatasetID:
  2136. return m.OldDatasetID(ctx)
  2137. case agentbase.FieldCollectionID:
  2138. return m.OldCollectionID(ctx)
  2139. case agentbase.FieldSourceName:
  2140. return m.OldSourceName(ctx)
  2141. case agentbase.FieldCanWrite:
  2142. return m.OldCanWrite(ctx)
  2143. case agentbase.FieldIsOwner:
  2144. return m.OldIsOwner(ctx)
  2145. }
  2146. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2147. }
  2148. // SetField sets the value of a field with the given name. It returns an error if
  2149. // the field is not defined in the schema, or if the type mismatched the field
  2150. // type.
  2151. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2152. switch name {
  2153. case agentbase.FieldQ:
  2154. v, ok := value.(string)
  2155. if !ok {
  2156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2157. }
  2158. m.SetQ(v)
  2159. return nil
  2160. case agentbase.FieldA:
  2161. v, ok := value.(string)
  2162. if !ok {
  2163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2164. }
  2165. m.SetA(v)
  2166. return nil
  2167. case agentbase.FieldChunkIndex:
  2168. v, ok := value.(uint64)
  2169. if !ok {
  2170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2171. }
  2172. m.SetChunkIndex(v)
  2173. return nil
  2174. case agentbase.FieldIndexes:
  2175. v, ok := value.([]string)
  2176. if !ok {
  2177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2178. }
  2179. m.SetIndexes(v)
  2180. return nil
  2181. case agentbase.FieldDatasetID:
  2182. v, ok := value.(string)
  2183. if !ok {
  2184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2185. }
  2186. m.SetDatasetID(v)
  2187. return nil
  2188. case agentbase.FieldCollectionID:
  2189. v, ok := value.(string)
  2190. if !ok {
  2191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2192. }
  2193. m.SetCollectionID(v)
  2194. return nil
  2195. case agentbase.FieldSourceName:
  2196. v, ok := value.(string)
  2197. if !ok {
  2198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2199. }
  2200. m.SetSourceName(v)
  2201. return nil
  2202. case agentbase.FieldCanWrite:
  2203. v, ok := value.([]bool)
  2204. if !ok {
  2205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2206. }
  2207. m.SetCanWrite(v)
  2208. return nil
  2209. case agentbase.FieldIsOwner:
  2210. v, ok := value.([]bool)
  2211. if !ok {
  2212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2213. }
  2214. m.SetIsOwner(v)
  2215. return nil
  2216. }
  2217. return fmt.Errorf("unknown AgentBase field %s", name)
  2218. }
  2219. // AddedFields returns all numeric fields that were incremented/decremented during
  2220. // this mutation.
  2221. func (m *AgentBaseMutation) AddedFields() []string {
  2222. var fields []string
  2223. if m.addchunk_index != nil {
  2224. fields = append(fields, agentbase.FieldChunkIndex)
  2225. }
  2226. return fields
  2227. }
  2228. // AddedField returns the numeric value that was incremented/decremented on a field
  2229. // with the given name. The second boolean return value indicates that this field
  2230. // was not set, or was not defined in the schema.
  2231. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2232. switch name {
  2233. case agentbase.FieldChunkIndex:
  2234. return m.AddedChunkIndex()
  2235. }
  2236. return nil, false
  2237. }
  2238. // AddField adds the value to the field with the given name. It returns an error if
  2239. // the field is not defined in the schema, or if the type mismatched the field
  2240. // type.
  2241. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2242. switch name {
  2243. case agentbase.FieldChunkIndex:
  2244. v, ok := value.(int64)
  2245. if !ok {
  2246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2247. }
  2248. m.AddChunkIndex(v)
  2249. return nil
  2250. }
  2251. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2252. }
  2253. // ClearedFields returns all nullable fields that were cleared during this
  2254. // mutation.
  2255. func (m *AgentBaseMutation) ClearedFields() []string {
  2256. var fields []string
  2257. if m.FieldCleared(agentbase.FieldQ) {
  2258. fields = append(fields, agentbase.FieldQ)
  2259. }
  2260. if m.FieldCleared(agentbase.FieldA) {
  2261. fields = append(fields, agentbase.FieldA)
  2262. }
  2263. if m.FieldCleared(agentbase.FieldIndexes) {
  2264. fields = append(fields, agentbase.FieldIndexes)
  2265. }
  2266. if m.FieldCleared(agentbase.FieldDatasetID) {
  2267. fields = append(fields, agentbase.FieldDatasetID)
  2268. }
  2269. if m.FieldCleared(agentbase.FieldCollectionID) {
  2270. fields = append(fields, agentbase.FieldCollectionID)
  2271. }
  2272. if m.FieldCleared(agentbase.FieldSourceName) {
  2273. fields = append(fields, agentbase.FieldSourceName)
  2274. }
  2275. if m.FieldCleared(agentbase.FieldCanWrite) {
  2276. fields = append(fields, agentbase.FieldCanWrite)
  2277. }
  2278. if m.FieldCleared(agentbase.FieldIsOwner) {
  2279. fields = append(fields, agentbase.FieldIsOwner)
  2280. }
  2281. return fields
  2282. }
  2283. // FieldCleared returns a boolean indicating if a field with the given name was
  2284. // cleared in this mutation.
  2285. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2286. _, ok := m.clearedFields[name]
  2287. return ok
  2288. }
  2289. // ClearField clears the value of the field with the given name. It returns an
  2290. // error if the field is not defined in the schema.
  2291. func (m *AgentBaseMutation) ClearField(name string) error {
  2292. switch name {
  2293. case agentbase.FieldQ:
  2294. m.ClearQ()
  2295. return nil
  2296. case agentbase.FieldA:
  2297. m.ClearA()
  2298. return nil
  2299. case agentbase.FieldIndexes:
  2300. m.ClearIndexes()
  2301. return nil
  2302. case agentbase.FieldDatasetID:
  2303. m.ClearDatasetID()
  2304. return nil
  2305. case agentbase.FieldCollectionID:
  2306. m.ClearCollectionID()
  2307. return nil
  2308. case agentbase.FieldSourceName:
  2309. m.ClearSourceName()
  2310. return nil
  2311. case agentbase.FieldCanWrite:
  2312. m.ClearCanWrite()
  2313. return nil
  2314. case agentbase.FieldIsOwner:
  2315. m.ClearIsOwner()
  2316. return nil
  2317. }
  2318. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2319. }
  2320. // ResetField resets all changes in the mutation for the field with the given name.
  2321. // It returns an error if the field is not defined in the schema.
  2322. func (m *AgentBaseMutation) ResetField(name string) error {
  2323. switch name {
  2324. case agentbase.FieldQ:
  2325. m.ResetQ()
  2326. return nil
  2327. case agentbase.FieldA:
  2328. m.ResetA()
  2329. return nil
  2330. case agentbase.FieldChunkIndex:
  2331. m.ResetChunkIndex()
  2332. return nil
  2333. case agentbase.FieldIndexes:
  2334. m.ResetIndexes()
  2335. return nil
  2336. case agentbase.FieldDatasetID:
  2337. m.ResetDatasetID()
  2338. return nil
  2339. case agentbase.FieldCollectionID:
  2340. m.ResetCollectionID()
  2341. return nil
  2342. case agentbase.FieldSourceName:
  2343. m.ResetSourceName()
  2344. return nil
  2345. case agentbase.FieldCanWrite:
  2346. m.ResetCanWrite()
  2347. return nil
  2348. case agentbase.FieldIsOwner:
  2349. m.ResetIsOwner()
  2350. return nil
  2351. }
  2352. return fmt.Errorf("unknown AgentBase field %s", name)
  2353. }
  2354. // AddedEdges returns all edge names that were set/added in this mutation.
  2355. func (m *AgentBaseMutation) AddedEdges() []string {
  2356. edges := make([]string, 0, 1)
  2357. if m.wx_agent != nil {
  2358. edges = append(edges, agentbase.EdgeWxAgent)
  2359. }
  2360. return edges
  2361. }
  2362. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2363. // name in this mutation.
  2364. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2365. switch name {
  2366. case agentbase.EdgeWxAgent:
  2367. ids := make([]ent.Value, 0, len(m.wx_agent))
  2368. for id := range m.wx_agent {
  2369. ids = append(ids, id)
  2370. }
  2371. return ids
  2372. }
  2373. return nil
  2374. }
  2375. // RemovedEdges returns all edge names that were removed in this mutation.
  2376. func (m *AgentBaseMutation) RemovedEdges() []string {
  2377. edges := make([]string, 0, 1)
  2378. if m.removedwx_agent != nil {
  2379. edges = append(edges, agentbase.EdgeWxAgent)
  2380. }
  2381. return edges
  2382. }
  2383. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2384. // the given name in this mutation.
  2385. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2386. switch name {
  2387. case agentbase.EdgeWxAgent:
  2388. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2389. for id := range m.removedwx_agent {
  2390. ids = append(ids, id)
  2391. }
  2392. return ids
  2393. }
  2394. return nil
  2395. }
  2396. // ClearedEdges returns all edge names that were cleared in this mutation.
  2397. func (m *AgentBaseMutation) ClearedEdges() []string {
  2398. edges := make([]string, 0, 1)
  2399. if m.clearedwx_agent {
  2400. edges = append(edges, agentbase.EdgeWxAgent)
  2401. }
  2402. return edges
  2403. }
  2404. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2405. // was cleared in this mutation.
  2406. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2407. switch name {
  2408. case agentbase.EdgeWxAgent:
  2409. return m.clearedwx_agent
  2410. }
  2411. return false
  2412. }
  2413. // ClearEdge clears the value of the edge with the given name. It returns an error
  2414. // if that edge is not defined in the schema.
  2415. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2416. switch name {
  2417. }
  2418. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2419. }
  2420. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2421. // It returns an error if the edge is not defined in the schema.
  2422. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2423. switch name {
  2424. case agentbase.EdgeWxAgent:
  2425. m.ResetWxAgent()
  2426. return nil
  2427. }
  2428. return fmt.Errorf("unknown AgentBase edge %s", name)
  2429. }
  2430. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2431. type AliyunAvatarMutation struct {
  2432. config
  2433. op Op
  2434. typ string
  2435. id *uint64
  2436. created_at *time.Time
  2437. updated_at *time.Time
  2438. deleted_at *time.Time
  2439. user_id *uint64
  2440. adduser_id *int64
  2441. biz_id *string
  2442. access_key_id *string
  2443. access_key_secret *string
  2444. app_id *string
  2445. tenant_id *uint64
  2446. addtenant_id *int64
  2447. response *string
  2448. token *string
  2449. session_id *string
  2450. clearedFields map[string]struct{}
  2451. done bool
  2452. oldValue func(context.Context) (*AliyunAvatar, error)
  2453. predicates []predicate.AliyunAvatar
  2454. }
  2455. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2456. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2457. type aliyunavatarOption func(*AliyunAvatarMutation)
  2458. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2459. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2460. m := &AliyunAvatarMutation{
  2461. config: c,
  2462. op: op,
  2463. typ: TypeAliyunAvatar,
  2464. clearedFields: make(map[string]struct{}),
  2465. }
  2466. for _, opt := range opts {
  2467. opt(m)
  2468. }
  2469. return m
  2470. }
  2471. // withAliyunAvatarID sets the ID field of the mutation.
  2472. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2473. return func(m *AliyunAvatarMutation) {
  2474. var (
  2475. err error
  2476. once sync.Once
  2477. value *AliyunAvatar
  2478. )
  2479. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2480. once.Do(func() {
  2481. if m.done {
  2482. err = errors.New("querying old values post mutation is not allowed")
  2483. } else {
  2484. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2485. }
  2486. })
  2487. return value, err
  2488. }
  2489. m.id = &id
  2490. }
  2491. }
  2492. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2493. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2494. return func(m *AliyunAvatarMutation) {
  2495. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2496. return node, nil
  2497. }
  2498. m.id = &node.ID
  2499. }
  2500. }
  2501. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2502. // executed in a transaction (ent.Tx), a transactional client is returned.
  2503. func (m AliyunAvatarMutation) Client() *Client {
  2504. client := &Client{config: m.config}
  2505. client.init()
  2506. return client
  2507. }
  2508. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2509. // it returns an error otherwise.
  2510. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2511. if _, ok := m.driver.(*txDriver); !ok {
  2512. return nil, errors.New("ent: mutation is not running in a transaction")
  2513. }
  2514. tx := &Tx{config: m.config}
  2515. tx.init()
  2516. return tx, nil
  2517. }
  2518. // SetID sets the value of the id field. Note that this
  2519. // operation is only accepted on creation of AliyunAvatar entities.
  2520. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2521. m.id = &id
  2522. }
  2523. // ID returns the ID value in the mutation. Note that the ID is only available
  2524. // if it was provided to the builder or after it was returned from the database.
  2525. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2526. if m.id == nil {
  2527. return
  2528. }
  2529. return *m.id, true
  2530. }
  2531. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2532. // That means, if the mutation is applied within a transaction with an isolation level such
  2533. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2534. // or updated by the mutation.
  2535. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2536. switch {
  2537. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2538. id, exists := m.ID()
  2539. if exists {
  2540. return []uint64{id}, nil
  2541. }
  2542. fallthrough
  2543. case m.op.Is(OpUpdate | OpDelete):
  2544. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2545. default:
  2546. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2547. }
  2548. }
  2549. // SetCreatedAt sets the "created_at" field.
  2550. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2551. m.created_at = &t
  2552. }
  2553. // CreatedAt returns the value of the "created_at" field in the mutation.
  2554. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2555. v := m.created_at
  2556. if v == nil {
  2557. return
  2558. }
  2559. return *v, true
  2560. }
  2561. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2562. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2564. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2565. if !m.op.Is(OpUpdateOne) {
  2566. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2567. }
  2568. if m.id == nil || m.oldValue == nil {
  2569. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2570. }
  2571. oldValue, err := m.oldValue(ctx)
  2572. if err != nil {
  2573. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2574. }
  2575. return oldValue.CreatedAt, nil
  2576. }
  2577. // ResetCreatedAt resets all changes to the "created_at" field.
  2578. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2579. m.created_at = nil
  2580. }
  2581. // SetUpdatedAt sets the "updated_at" field.
  2582. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2583. m.updated_at = &t
  2584. }
  2585. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2586. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2587. v := m.updated_at
  2588. if v == nil {
  2589. return
  2590. }
  2591. return *v, true
  2592. }
  2593. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2594. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2596. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2597. if !m.op.Is(OpUpdateOne) {
  2598. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2599. }
  2600. if m.id == nil || m.oldValue == nil {
  2601. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2602. }
  2603. oldValue, err := m.oldValue(ctx)
  2604. if err != nil {
  2605. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2606. }
  2607. return oldValue.UpdatedAt, nil
  2608. }
  2609. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2610. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2611. m.updated_at = nil
  2612. }
  2613. // SetDeletedAt sets the "deleted_at" field.
  2614. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2615. m.deleted_at = &t
  2616. }
  2617. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2618. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2619. v := m.deleted_at
  2620. if v == nil {
  2621. return
  2622. }
  2623. return *v, true
  2624. }
  2625. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2626. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2628. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2629. if !m.op.Is(OpUpdateOne) {
  2630. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2631. }
  2632. if m.id == nil || m.oldValue == nil {
  2633. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2634. }
  2635. oldValue, err := m.oldValue(ctx)
  2636. if err != nil {
  2637. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2638. }
  2639. return oldValue.DeletedAt, nil
  2640. }
  2641. // ClearDeletedAt clears the value of the "deleted_at" field.
  2642. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2643. m.deleted_at = nil
  2644. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2645. }
  2646. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2647. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2648. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2649. return ok
  2650. }
  2651. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2652. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2653. m.deleted_at = nil
  2654. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2655. }
  2656. // SetUserID sets the "user_id" field.
  2657. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2658. m.user_id = &u
  2659. m.adduser_id = nil
  2660. }
  2661. // UserID returns the value of the "user_id" field in the mutation.
  2662. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2663. v := m.user_id
  2664. if v == nil {
  2665. return
  2666. }
  2667. return *v, true
  2668. }
  2669. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2670. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2672. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2673. if !m.op.Is(OpUpdateOne) {
  2674. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2675. }
  2676. if m.id == nil || m.oldValue == nil {
  2677. return v, errors.New("OldUserID requires an ID field in the mutation")
  2678. }
  2679. oldValue, err := m.oldValue(ctx)
  2680. if err != nil {
  2681. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2682. }
  2683. return oldValue.UserID, nil
  2684. }
  2685. // AddUserID adds u to the "user_id" field.
  2686. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2687. if m.adduser_id != nil {
  2688. *m.adduser_id += u
  2689. } else {
  2690. m.adduser_id = &u
  2691. }
  2692. }
  2693. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2694. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2695. v := m.adduser_id
  2696. if v == nil {
  2697. return
  2698. }
  2699. return *v, true
  2700. }
  2701. // ResetUserID resets all changes to the "user_id" field.
  2702. func (m *AliyunAvatarMutation) ResetUserID() {
  2703. m.user_id = nil
  2704. m.adduser_id = nil
  2705. }
  2706. // SetBizID sets the "biz_id" field.
  2707. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2708. m.biz_id = &s
  2709. }
  2710. // BizID returns the value of the "biz_id" field in the mutation.
  2711. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2712. v := m.biz_id
  2713. if v == nil {
  2714. return
  2715. }
  2716. return *v, true
  2717. }
  2718. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2719. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2721. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2722. if !m.op.Is(OpUpdateOne) {
  2723. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2724. }
  2725. if m.id == nil || m.oldValue == nil {
  2726. return v, errors.New("OldBizID requires an ID field in the mutation")
  2727. }
  2728. oldValue, err := m.oldValue(ctx)
  2729. if err != nil {
  2730. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2731. }
  2732. return oldValue.BizID, nil
  2733. }
  2734. // ResetBizID resets all changes to the "biz_id" field.
  2735. func (m *AliyunAvatarMutation) ResetBizID() {
  2736. m.biz_id = nil
  2737. }
  2738. // SetAccessKeyID sets the "access_key_id" field.
  2739. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2740. m.access_key_id = &s
  2741. }
  2742. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2743. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2744. v := m.access_key_id
  2745. if v == nil {
  2746. return
  2747. }
  2748. return *v, true
  2749. }
  2750. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2751. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2753. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2754. if !m.op.Is(OpUpdateOne) {
  2755. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2756. }
  2757. if m.id == nil || m.oldValue == nil {
  2758. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2759. }
  2760. oldValue, err := m.oldValue(ctx)
  2761. if err != nil {
  2762. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2763. }
  2764. return oldValue.AccessKeyID, nil
  2765. }
  2766. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2767. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2768. m.access_key_id = nil
  2769. }
  2770. // SetAccessKeySecret sets the "access_key_secret" field.
  2771. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2772. m.access_key_secret = &s
  2773. }
  2774. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2775. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2776. v := m.access_key_secret
  2777. if v == nil {
  2778. return
  2779. }
  2780. return *v, true
  2781. }
  2782. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2783. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2785. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2786. if !m.op.Is(OpUpdateOne) {
  2787. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2788. }
  2789. if m.id == nil || m.oldValue == nil {
  2790. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2791. }
  2792. oldValue, err := m.oldValue(ctx)
  2793. if err != nil {
  2794. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2795. }
  2796. return oldValue.AccessKeySecret, nil
  2797. }
  2798. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2799. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2800. m.access_key_secret = nil
  2801. }
  2802. // SetAppID sets the "app_id" field.
  2803. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2804. m.app_id = &s
  2805. }
  2806. // AppID returns the value of the "app_id" field in the mutation.
  2807. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2808. v := m.app_id
  2809. if v == nil {
  2810. return
  2811. }
  2812. return *v, true
  2813. }
  2814. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2815. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2817. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2818. if !m.op.Is(OpUpdateOne) {
  2819. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2820. }
  2821. if m.id == nil || m.oldValue == nil {
  2822. return v, errors.New("OldAppID requires an ID field in the mutation")
  2823. }
  2824. oldValue, err := m.oldValue(ctx)
  2825. if err != nil {
  2826. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2827. }
  2828. return oldValue.AppID, nil
  2829. }
  2830. // ClearAppID clears the value of the "app_id" field.
  2831. func (m *AliyunAvatarMutation) ClearAppID() {
  2832. m.app_id = nil
  2833. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2834. }
  2835. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2836. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2837. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2838. return ok
  2839. }
  2840. // ResetAppID resets all changes to the "app_id" field.
  2841. func (m *AliyunAvatarMutation) ResetAppID() {
  2842. m.app_id = nil
  2843. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2844. }
  2845. // SetTenantID sets the "tenant_id" field.
  2846. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2847. m.tenant_id = &u
  2848. m.addtenant_id = nil
  2849. }
  2850. // TenantID returns the value of the "tenant_id" field in the mutation.
  2851. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2852. v := m.tenant_id
  2853. if v == nil {
  2854. return
  2855. }
  2856. return *v, true
  2857. }
  2858. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2859. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2861. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2862. if !m.op.Is(OpUpdateOne) {
  2863. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2864. }
  2865. if m.id == nil || m.oldValue == nil {
  2866. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2867. }
  2868. oldValue, err := m.oldValue(ctx)
  2869. if err != nil {
  2870. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2871. }
  2872. return oldValue.TenantID, nil
  2873. }
  2874. // AddTenantID adds u to the "tenant_id" field.
  2875. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2876. if m.addtenant_id != nil {
  2877. *m.addtenant_id += u
  2878. } else {
  2879. m.addtenant_id = &u
  2880. }
  2881. }
  2882. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2883. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2884. v := m.addtenant_id
  2885. if v == nil {
  2886. return
  2887. }
  2888. return *v, true
  2889. }
  2890. // ResetTenantID resets all changes to the "tenant_id" field.
  2891. func (m *AliyunAvatarMutation) ResetTenantID() {
  2892. m.tenant_id = nil
  2893. m.addtenant_id = nil
  2894. }
  2895. // SetResponse sets the "response" field.
  2896. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2897. m.response = &s
  2898. }
  2899. // Response returns the value of the "response" field in the mutation.
  2900. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2901. v := m.response
  2902. if v == nil {
  2903. return
  2904. }
  2905. return *v, true
  2906. }
  2907. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2908. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2910. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2911. if !m.op.Is(OpUpdateOne) {
  2912. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2913. }
  2914. if m.id == nil || m.oldValue == nil {
  2915. return v, errors.New("OldResponse requires an ID field in the mutation")
  2916. }
  2917. oldValue, err := m.oldValue(ctx)
  2918. if err != nil {
  2919. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2920. }
  2921. return oldValue.Response, nil
  2922. }
  2923. // ResetResponse resets all changes to the "response" field.
  2924. func (m *AliyunAvatarMutation) ResetResponse() {
  2925. m.response = nil
  2926. }
  2927. // SetToken sets the "token" field.
  2928. func (m *AliyunAvatarMutation) SetToken(s string) {
  2929. m.token = &s
  2930. }
  2931. // Token returns the value of the "token" field in the mutation.
  2932. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2933. v := m.token
  2934. if v == nil {
  2935. return
  2936. }
  2937. return *v, true
  2938. }
  2939. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2940. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2942. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2943. if !m.op.Is(OpUpdateOne) {
  2944. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2945. }
  2946. if m.id == nil || m.oldValue == nil {
  2947. return v, errors.New("OldToken requires an ID field in the mutation")
  2948. }
  2949. oldValue, err := m.oldValue(ctx)
  2950. if err != nil {
  2951. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2952. }
  2953. return oldValue.Token, nil
  2954. }
  2955. // ResetToken resets all changes to the "token" field.
  2956. func (m *AliyunAvatarMutation) ResetToken() {
  2957. m.token = nil
  2958. }
  2959. // SetSessionID sets the "session_id" field.
  2960. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2961. m.session_id = &s
  2962. }
  2963. // SessionID returns the value of the "session_id" field in the mutation.
  2964. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2965. v := m.session_id
  2966. if v == nil {
  2967. return
  2968. }
  2969. return *v, true
  2970. }
  2971. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2972. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2974. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2975. if !m.op.Is(OpUpdateOne) {
  2976. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2977. }
  2978. if m.id == nil || m.oldValue == nil {
  2979. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2980. }
  2981. oldValue, err := m.oldValue(ctx)
  2982. if err != nil {
  2983. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2984. }
  2985. return oldValue.SessionID, nil
  2986. }
  2987. // ResetSessionID resets all changes to the "session_id" field.
  2988. func (m *AliyunAvatarMutation) ResetSessionID() {
  2989. m.session_id = nil
  2990. }
  2991. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2992. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2993. m.predicates = append(m.predicates, ps...)
  2994. }
  2995. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2996. // users can use type-assertion to append predicates that do not depend on any generated package.
  2997. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2998. p := make([]predicate.AliyunAvatar, len(ps))
  2999. for i := range ps {
  3000. p[i] = ps[i]
  3001. }
  3002. m.Where(p...)
  3003. }
  3004. // Op returns the operation name.
  3005. func (m *AliyunAvatarMutation) Op() Op {
  3006. return m.op
  3007. }
  3008. // SetOp allows setting the mutation operation.
  3009. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3010. m.op = op
  3011. }
  3012. // Type returns the node type of this mutation (AliyunAvatar).
  3013. func (m *AliyunAvatarMutation) Type() string {
  3014. return m.typ
  3015. }
  3016. // Fields returns all fields that were changed during this mutation. Note that in
  3017. // order to get all numeric fields that were incremented/decremented, call
  3018. // AddedFields().
  3019. func (m *AliyunAvatarMutation) Fields() []string {
  3020. fields := make([]string, 0, 12)
  3021. if m.created_at != nil {
  3022. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3023. }
  3024. if m.updated_at != nil {
  3025. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3026. }
  3027. if m.deleted_at != nil {
  3028. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3029. }
  3030. if m.user_id != nil {
  3031. fields = append(fields, aliyunavatar.FieldUserID)
  3032. }
  3033. if m.biz_id != nil {
  3034. fields = append(fields, aliyunavatar.FieldBizID)
  3035. }
  3036. if m.access_key_id != nil {
  3037. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3038. }
  3039. if m.access_key_secret != nil {
  3040. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3041. }
  3042. if m.app_id != nil {
  3043. fields = append(fields, aliyunavatar.FieldAppID)
  3044. }
  3045. if m.tenant_id != nil {
  3046. fields = append(fields, aliyunavatar.FieldTenantID)
  3047. }
  3048. if m.response != nil {
  3049. fields = append(fields, aliyunavatar.FieldResponse)
  3050. }
  3051. if m.token != nil {
  3052. fields = append(fields, aliyunavatar.FieldToken)
  3053. }
  3054. if m.session_id != nil {
  3055. fields = append(fields, aliyunavatar.FieldSessionID)
  3056. }
  3057. return fields
  3058. }
  3059. // Field returns the value of a field with the given name. The second boolean
  3060. // return value indicates that this field was not set, or was not defined in the
  3061. // schema.
  3062. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3063. switch name {
  3064. case aliyunavatar.FieldCreatedAt:
  3065. return m.CreatedAt()
  3066. case aliyunavatar.FieldUpdatedAt:
  3067. return m.UpdatedAt()
  3068. case aliyunavatar.FieldDeletedAt:
  3069. return m.DeletedAt()
  3070. case aliyunavatar.FieldUserID:
  3071. return m.UserID()
  3072. case aliyunavatar.FieldBizID:
  3073. return m.BizID()
  3074. case aliyunavatar.FieldAccessKeyID:
  3075. return m.AccessKeyID()
  3076. case aliyunavatar.FieldAccessKeySecret:
  3077. return m.AccessKeySecret()
  3078. case aliyunavatar.FieldAppID:
  3079. return m.AppID()
  3080. case aliyunavatar.FieldTenantID:
  3081. return m.TenantID()
  3082. case aliyunavatar.FieldResponse:
  3083. return m.Response()
  3084. case aliyunavatar.FieldToken:
  3085. return m.Token()
  3086. case aliyunavatar.FieldSessionID:
  3087. return m.SessionID()
  3088. }
  3089. return nil, false
  3090. }
  3091. // OldField returns the old value of the field from the database. An error is
  3092. // returned if the mutation operation is not UpdateOne, or the query to the
  3093. // database failed.
  3094. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3095. switch name {
  3096. case aliyunavatar.FieldCreatedAt:
  3097. return m.OldCreatedAt(ctx)
  3098. case aliyunavatar.FieldUpdatedAt:
  3099. return m.OldUpdatedAt(ctx)
  3100. case aliyunavatar.FieldDeletedAt:
  3101. return m.OldDeletedAt(ctx)
  3102. case aliyunavatar.FieldUserID:
  3103. return m.OldUserID(ctx)
  3104. case aliyunavatar.FieldBizID:
  3105. return m.OldBizID(ctx)
  3106. case aliyunavatar.FieldAccessKeyID:
  3107. return m.OldAccessKeyID(ctx)
  3108. case aliyunavatar.FieldAccessKeySecret:
  3109. return m.OldAccessKeySecret(ctx)
  3110. case aliyunavatar.FieldAppID:
  3111. return m.OldAppID(ctx)
  3112. case aliyunavatar.FieldTenantID:
  3113. return m.OldTenantID(ctx)
  3114. case aliyunavatar.FieldResponse:
  3115. return m.OldResponse(ctx)
  3116. case aliyunavatar.FieldToken:
  3117. return m.OldToken(ctx)
  3118. case aliyunavatar.FieldSessionID:
  3119. return m.OldSessionID(ctx)
  3120. }
  3121. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3122. }
  3123. // SetField sets the value of a field with the given name. It returns an error if
  3124. // the field is not defined in the schema, or if the type mismatched the field
  3125. // type.
  3126. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3127. switch name {
  3128. case aliyunavatar.FieldCreatedAt:
  3129. v, ok := value.(time.Time)
  3130. if !ok {
  3131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3132. }
  3133. m.SetCreatedAt(v)
  3134. return nil
  3135. case aliyunavatar.FieldUpdatedAt:
  3136. v, ok := value.(time.Time)
  3137. if !ok {
  3138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3139. }
  3140. m.SetUpdatedAt(v)
  3141. return nil
  3142. case aliyunavatar.FieldDeletedAt:
  3143. v, ok := value.(time.Time)
  3144. if !ok {
  3145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3146. }
  3147. m.SetDeletedAt(v)
  3148. return nil
  3149. case aliyunavatar.FieldUserID:
  3150. v, ok := value.(uint64)
  3151. if !ok {
  3152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3153. }
  3154. m.SetUserID(v)
  3155. return nil
  3156. case aliyunavatar.FieldBizID:
  3157. v, ok := value.(string)
  3158. if !ok {
  3159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3160. }
  3161. m.SetBizID(v)
  3162. return nil
  3163. case aliyunavatar.FieldAccessKeyID:
  3164. v, ok := value.(string)
  3165. if !ok {
  3166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3167. }
  3168. m.SetAccessKeyID(v)
  3169. return nil
  3170. case aliyunavatar.FieldAccessKeySecret:
  3171. v, ok := value.(string)
  3172. if !ok {
  3173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3174. }
  3175. m.SetAccessKeySecret(v)
  3176. return nil
  3177. case aliyunavatar.FieldAppID:
  3178. v, ok := value.(string)
  3179. if !ok {
  3180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3181. }
  3182. m.SetAppID(v)
  3183. return nil
  3184. case aliyunavatar.FieldTenantID:
  3185. v, ok := value.(uint64)
  3186. if !ok {
  3187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3188. }
  3189. m.SetTenantID(v)
  3190. return nil
  3191. case aliyunavatar.FieldResponse:
  3192. v, ok := value.(string)
  3193. if !ok {
  3194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3195. }
  3196. m.SetResponse(v)
  3197. return nil
  3198. case aliyunavatar.FieldToken:
  3199. v, ok := value.(string)
  3200. if !ok {
  3201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3202. }
  3203. m.SetToken(v)
  3204. return nil
  3205. case aliyunavatar.FieldSessionID:
  3206. v, ok := value.(string)
  3207. if !ok {
  3208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3209. }
  3210. m.SetSessionID(v)
  3211. return nil
  3212. }
  3213. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3214. }
  3215. // AddedFields returns all numeric fields that were incremented/decremented during
  3216. // this mutation.
  3217. func (m *AliyunAvatarMutation) AddedFields() []string {
  3218. var fields []string
  3219. if m.adduser_id != nil {
  3220. fields = append(fields, aliyunavatar.FieldUserID)
  3221. }
  3222. if m.addtenant_id != nil {
  3223. fields = append(fields, aliyunavatar.FieldTenantID)
  3224. }
  3225. return fields
  3226. }
  3227. // AddedField returns the numeric value that was incremented/decremented on a field
  3228. // with the given name. The second boolean return value indicates that this field
  3229. // was not set, or was not defined in the schema.
  3230. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3231. switch name {
  3232. case aliyunavatar.FieldUserID:
  3233. return m.AddedUserID()
  3234. case aliyunavatar.FieldTenantID:
  3235. return m.AddedTenantID()
  3236. }
  3237. return nil, false
  3238. }
  3239. // AddField adds the value to the field with the given name. It returns an error if
  3240. // the field is not defined in the schema, or if the type mismatched the field
  3241. // type.
  3242. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3243. switch name {
  3244. case aliyunavatar.FieldUserID:
  3245. v, ok := value.(int64)
  3246. if !ok {
  3247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3248. }
  3249. m.AddUserID(v)
  3250. return nil
  3251. case aliyunavatar.FieldTenantID:
  3252. v, ok := value.(int64)
  3253. if !ok {
  3254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3255. }
  3256. m.AddTenantID(v)
  3257. return nil
  3258. }
  3259. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3260. }
  3261. // ClearedFields returns all nullable fields that were cleared during this
  3262. // mutation.
  3263. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3264. var fields []string
  3265. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3266. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3267. }
  3268. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3269. fields = append(fields, aliyunavatar.FieldAppID)
  3270. }
  3271. return fields
  3272. }
  3273. // FieldCleared returns a boolean indicating if a field with the given name was
  3274. // cleared in this mutation.
  3275. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3276. _, ok := m.clearedFields[name]
  3277. return ok
  3278. }
  3279. // ClearField clears the value of the field with the given name. It returns an
  3280. // error if the field is not defined in the schema.
  3281. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3282. switch name {
  3283. case aliyunavatar.FieldDeletedAt:
  3284. m.ClearDeletedAt()
  3285. return nil
  3286. case aliyunavatar.FieldAppID:
  3287. m.ClearAppID()
  3288. return nil
  3289. }
  3290. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3291. }
  3292. // ResetField resets all changes in the mutation for the field with the given name.
  3293. // It returns an error if the field is not defined in the schema.
  3294. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3295. switch name {
  3296. case aliyunavatar.FieldCreatedAt:
  3297. m.ResetCreatedAt()
  3298. return nil
  3299. case aliyunavatar.FieldUpdatedAt:
  3300. m.ResetUpdatedAt()
  3301. return nil
  3302. case aliyunavatar.FieldDeletedAt:
  3303. m.ResetDeletedAt()
  3304. return nil
  3305. case aliyunavatar.FieldUserID:
  3306. m.ResetUserID()
  3307. return nil
  3308. case aliyunavatar.FieldBizID:
  3309. m.ResetBizID()
  3310. return nil
  3311. case aliyunavatar.FieldAccessKeyID:
  3312. m.ResetAccessKeyID()
  3313. return nil
  3314. case aliyunavatar.FieldAccessKeySecret:
  3315. m.ResetAccessKeySecret()
  3316. return nil
  3317. case aliyunavatar.FieldAppID:
  3318. m.ResetAppID()
  3319. return nil
  3320. case aliyunavatar.FieldTenantID:
  3321. m.ResetTenantID()
  3322. return nil
  3323. case aliyunavatar.FieldResponse:
  3324. m.ResetResponse()
  3325. return nil
  3326. case aliyunavatar.FieldToken:
  3327. m.ResetToken()
  3328. return nil
  3329. case aliyunavatar.FieldSessionID:
  3330. m.ResetSessionID()
  3331. return nil
  3332. }
  3333. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3334. }
  3335. // AddedEdges returns all edge names that were set/added in this mutation.
  3336. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3337. edges := make([]string, 0, 0)
  3338. return edges
  3339. }
  3340. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3341. // name in this mutation.
  3342. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3343. return nil
  3344. }
  3345. // RemovedEdges returns all edge names that were removed in this mutation.
  3346. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3347. edges := make([]string, 0, 0)
  3348. return edges
  3349. }
  3350. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3351. // the given name in this mutation.
  3352. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3353. return nil
  3354. }
  3355. // ClearedEdges returns all edge names that were cleared in this mutation.
  3356. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3357. edges := make([]string, 0, 0)
  3358. return edges
  3359. }
  3360. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3361. // was cleared in this mutation.
  3362. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3363. return false
  3364. }
  3365. // ClearEdge clears the value of the edge with the given name. It returns an error
  3366. // if that edge is not defined in the schema.
  3367. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3368. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3369. }
  3370. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3371. // It returns an error if the edge is not defined in the schema.
  3372. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3373. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3374. }
  3375. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3376. type AllocAgentMutation struct {
  3377. config
  3378. op Op
  3379. typ string
  3380. id *uint64
  3381. created_at *time.Time
  3382. updated_at *time.Time
  3383. deleted_at *time.Time
  3384. user_id *string
  3385. organization_id *uint64
  3386. addorganization_id *int64
  3387. agents *[]uint64
  3388. appendagents []uint64
  3389. status *int
  3390. addstatus *int
  3391. clearedFields map[string]struct{}
  3392. done bool
  3393. oldValue func(context.Context) (*AllocAgent, error)
  3394. predicates []predicate.AllocAgent
  3395. }
  3396. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3397. // allocagentOption allows management of the mutation configuration using functional options.
  3398. type allocagentOption func(*AllocAgentMutation)
  3399. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3400. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3401. m := &AllocAgentMutation{
  3402. config: c,
  3403. op: op,
  3404. typ: TypeAllocAgent,
  3405. clearedFields: make(map[string]struct{}),
  3406. }
  3407. for _, opt := range opts {
  3408. opt(m)
  3409. }
  3410. return m
  3411. }
  3412. // withAllocAgentID sets the ID field of the mutation.
  3413. func withAllocAgentID(id uint64) allocagentOption {
  3414. return func(m *AllocAgentMutation) {
  3415. var (
  3416. err error
  3417. once sync.Once
  3418. value *AllocAgent
  3419. )
  3420. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3421. once.Do(func() {
  3422. if m.done {
  3423. err = errors.New("querying old values post mutation is not allowed")
  3424. } else {
  3425. value, err = m.Client().AllocAgent.Get(ctx, id)
  3426. }
  3427. })
  3428. return value, err
  3429. }
  3430. m.id = &id
  3431. }
  3432. }
  3433. // withAllocAgent sets the old AllocAgent of the mutation.
  3434. func withAllocAgent(node *AllocAgent) allocagentOption {
  3435. return func(m *AllocAgentMutation) {
  3436. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3437. return node, nil
  3438. }
  3439. m.id = &node.ID
  3440. }
  3441. }
  3442. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3443. // executed in a transaction (ent.Tx), a transactional client is returned.
  3444. func (m AllocAgentMutation) Client() *Client {
  3445. client := &Client{config: m.config}
  3446. client.init()
  3447. return client
  3448. }
  3449. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3450. // it returns an error otherwise.
  3451. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3452. if _, ok := m.driver.(*txDriver); !ok {
  3453. return nil, errors.New("ent: mutation is not running in a transaction")
  3454. }
  3455. tx := &Tx{config: m.config}
  3456. tx.init()
  3457. return tx, nil
  3458. }
  3459. // SetID sets the value of the id field. Note that this
  3460. // operation is only accepted on creation of AllocAgent entities.
  3461. func (m *AllocAgentMutation) SetID(id uint64) {
  3462. m.id = &id
  3463. }
  3464. // ID returns the ID value in the mutation. Note that the ID is only available
  3465. // if it was provided to the builder or after it was returned from the database.
  3466. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3467. if m.id == nil {
  3468. return
  3469. }
  3470. return *m.id, true
  3471. }
  3472. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3473. // That means, if the mutation is applied within a transaction with an isolation level such
  3474. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3475. // or updated by the mutation.
  3476. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3477. switch {
  3478. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3479. id, exists := m.ID()
  3480. if exists {
  3481. return []uint64{id}, nil
  3482. }
  3483. fallthrough
  3484. case m.op.Is(OpUpdate | OpDelete):
  3485. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3486. default:
  3487. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3488. }
  3489. }
  3490. // SetCreatedAt sets the "created_at" field.
  3491. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3492. m.created_at = &t
  3493. }
  3494. // CreatedAt returns the value of the "created_at" field in the mutation.
  3495. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3496. v := m.created_at
  3497. if v == nil {
  3498. return
  3499. }
  3500. return *v, true
  3501. }
  3502. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3503. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3505. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3506. if !m.op.Is(OpUpdateOne) {
  3507. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3508. }
  3509. if m.id == nil || m.oldValue == nil {
  3510. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3511. }
  3512. oldValue, err := m.oldValue(ctx)
  3513. if err != nil {
  3514. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3515. }
  3516. return oldValue.CreatedAt, nil
  3517. }
  3518. // ResetCreatedAt resets all changes to the "created_at" field.
  3519. func (m *AllocAgentMutation) ResetCreatedAt() {
  3520. m.created_at = nil
  3521. }
  3522. // SetUpdatedAt sets the "updated_at" field.
  3523. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3524. m.updated_at = &t
  3525. }
  3526. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3527. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3528. v := m.updated_at
  3529. if v == nil {
  3530. return
  3531. }
  3532. return *v, true
  3533. }
  3534. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3535. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3537. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3538. if !m.op.Is(OpUpdateOne) {
  3539. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3540. }
  3541. if m.id == nil || m.oldValue == nil {
  3542. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3543. }
  3544. oldValue, err := m.oldValue(ctx)
  3545. if err != nil {
  3546. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3547. }
  3548. return oldValue.UpdatedAt, nil
  3549. }
  3550. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3551. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3552. m.updated_at = nil
  3553. }
  3554. // SetDeletedAt sets the "deleted_at" field.
  3555. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3556. m.deleted_at = &t
  3557. }
  3558. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3559. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3560. v := m.deleted_at
  3561. if v == nil {
  3562. return
  3563. }
  3564. return *v, true
  3565. }
  3566. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3567. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3569. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3570. if !m.op.Is(OpUpdateOne) {
  3571. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3572. }
  3573. if m.id == nil || m.oldValue == nil {
  3574. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3575. }
  3576. oldValue, err := m.oldValue(ctx)
  3577. if err != nil {
  3578. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3579. }
  3580. return oldValue.DeletedAt, nil
  3581. }
  3582. // ClearDeletedAt clears the value of the "deleted_at" field.
  3583. func (m *AllocAgentMutation) ClearDeletedAt() {
  3584. m.deleted_at = nil
  3585. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3586. }
  3587. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3588. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3589. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3590. return ok
  3591. }
  3592. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3593. func (m *AllocAgentMutation) ResetDeletedAt() {
  3594. m.deleted_at = nil
  3595. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3596. }
  3597. // SetUserID sets the "user_id" field.
  3598. func (m *AllocAgentMutation) SetUserID(s string) {
  3599. m.user_id = &s
  3600. }
  3601. // UserID returns the value of the "user_id" field in the mutation.
  3602. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3603. v := m.user_id
  3604. if v == nil {
  3605. return
  3606. }
  3607. return *v, true
  3608. }
  3609. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3610. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3612. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3613. if !m.op.Is(OpUpdateOne) {
  3614. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3615. }
  3616. if m.id == nil || m.oldValue == nil {
  3617. return v, errors.New("OldUserID requires an ID field in the mutation")
  3618. }
  3619. oldValue, err := m.oldValue(ctx)
  3620. if err != nil {
  3621. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3622. }
  3623. return oldValue.UserID, nil
  3624. }
  3625. // ClearUserID clears the value of the "user_id" field.
  3626. func (m *AllocAgentMutation) ClearUserID() {
  3627. m.user_id = nil
  3628. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3629. }
  3630. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3631. func (m *AllocAgentMutation) UserIDCleared() bool {
  3632. _, ok := m.clearedFields[allocagent.FieldUserID]
  3633. return ok
  3634. }
  3635. // ResetUserID resets all changes to the "user_id" field.
  3636. func (m *AllocAgentMutation) ResetUserID() {
  3637. m.user_id = nil
  3638. delete(m.clearedFields, allocagent.FieldUserID)
  3639. }
  3640. // SetOrganizationID sets the "organization_id" field.
  3641. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3642. m.organization_id = &u
  3643. m.addorganization_id = nil
  3644. }
  3645. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3646. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3647. v := m.organization_id
  3648. if v == nil {
  3649. return
  3650. }
  3651. return *v, true
  3652. }
  3653. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3654. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3656. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3657. if !m.op.Is(OpUpdateOne) {
  3658. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3659. }
  3660. if m.id == nil || m.oldValue == nil {
  3661. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3662. }
  3663. oldValue, err := m.oldValue(ctx)
  3664. if err != nil {
  3665. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3666. }
  3667. return oldValue.OrganizationID, nil
  3668. }
  3669. // AddOrganizationID adds u to the "organization_id" field.
  3670. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3671. if m.addorganization_id != nil {
  3672. *m.addorganization_id += u
  3673. } else {
  3674. m.addorganization_id = &u
  3675. }
  3676. }
  3677. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3678. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3679. v := m.addorganization_id
  3680. if v == nil {
  3681. return
  3682. }
  3683. return *v, true
  3684. }
  3685. // ClearOrganizationID clears the value of the "organization_id" field.
  3686. func (m *AllocAgentMutation) ClearOrganizationID() {
  3687. m.organization_id = nil
  3688. m.addorganization_id = nil
  3689. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3690. }
  3691. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3692. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3693. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3694. return ok
  3695. }
  3696. // ResetOrganizationID resets all changes to the "organization_id" field.
  3697. func (m *AllocAgentMutation) ResetOrganizationID() {
  3698. m.organization_id = nil
  3699. m.addorganization_id = nil
  3700. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3701. }
  3702. // SetAgents sets the "agents" field.
  3703. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3704. m.agents = &u
  3705. m.appendagents = nil
  3706. }
  3707. // Agents returns the value of the "agents" field in the mutation.
  3708. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3709. v := m.agents
  3710. if v == nil {
  3711. return
  3712. }
  3713. return *v, true
  3714. }
  3715. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3716. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3718. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3719. if !m.op.Is(OpUpdateOne) {
  3720. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3721. }
  3722. if m.id == nil || m.oldValue == nil {
  3723. return v, errors.New("OldAgents requires an ID field in the mutation")
  3724. }
  3725. oldValue, err := m.oldValue(ctx)
  3726. if err != nil {
  3727. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3728. }
  3729. return oldValue.Agents, nil
  3730. }
  3731. // AppendAgents adds u to the "agents" field.
  3732. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3733. m.appendagents = append(m.appendagents, u...)
  3734. }
  3735. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3736. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3737. if len(m.appendagents) == 0 {
  3738. return nil, false
  3739. }
  3740. return m.appendagents, true
  3741. }
  3742. // ResetAgents resets all changes to the "agents" field.
  3743. func (m *AllocAgentMutation) ResetAgents() {
  3744. m.agents = nil
  3745. m.appendagents = nil
  3746. }
  3747. // SetStatus sets the "status" field.
  3748. func (m *AllocAgentMutation) SetStatus(i int) {
  3749. m.status = &i
  3750. m.addstatus = nil
  3751. }
  3752. // Status returns the value of the "status" field in the mutation.
  3753. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3754. v := m.status
  3755. if v == nil {
  3756. return
  3757. }
  3758. return *v, true
  3759. }
  3760. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3761. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3763. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3764. if !m.op.Is(OpUpdateOne) {
  3765. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3766. }
  3767. if m.id == nil || m.oldValue == nil {
  3768. return v, errors.New("OldStatus requires an ID field in the mutation")
  3769. }
  3770. oldValue, err := m.oldValue(ctx)
  3771. if err != nil {
  3772. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3773. }
  3774. return oldValue.Status, nil
  3775. }
  3776. // AddStatus adds i to the "status" field.
  3777. func (m *AllocAgentMutation) AddStatus(i int) {
  3778. if m.addstatus != nil {
  3779. *m.addstatus += i
  3780. } else {
  3781. m.addstatus = &i
  3782. }
  3783. }
  3784. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3785. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3786. v := m.addstatus
  3787. if v == nil {
  3788. return
  3789. }
  3790. return *v, true
  3791. }
  3792. // ClearStatus clears the value of the "status" field.
  3793. func (m *AllocAgentMutation) ClearStatus() {
  3794. m.status = nil
  3795. m.addstatus = nil
  3796. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3797. }
  3798. // StatusCleared returns if the "status" field was cleared in this mutation.
  3799. func (m *AllocAgentMutation) StatusCleared() bool {
  3800. _, ok := m.clearedFields[allocagent.FieldStatus]
  3801. return ok
  3802. }
  3803. // ResetStatus resets all changes to the "status" field.
  3804. func (m *AllocAgentMutation) ResetStatus() {
  3805. m.status = nil
  3806. m.addstatus = nil
  3807. delete(m.clearedFields, allocagent.FieldStatus)
  3808. }
  3809. // Where appends a list predicates to the AllocAgentMutation builder.
  3810. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3811. m.predicates = append(m.predicates, ps...)
  3812. }
  3813. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3814. // users can use type-assertion to append predicates that do not depend on any generated package.
  3815. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3816. p := make([]predicate.AllocAgent, len(ps))
  3817. for i := range ps {
  3818. p[i] = ps[i]
  3819. }
  3820. m.Where(p...)
  3821. }
  3822. // Op returns the operation name.
  3823. func (m *AllocAgentMutation) Op() Op {
  3824. return m.op
  3825. }
  3826. // SetOp allows setting the mutation operation.
  3827. func (m *AllocAgentMutation) SetOp(op Op) {
  3828. m.op = op
  3829. }
  3830. // Type returns the node type of this mutation (AllocAgent).
  3831. func (m *AllocAgentMutation) Type() string {
  3832. return m.typ
  3833. }
  3834. // Fields returns all fields that were changed during this mutation. Note that in
  3835. // order to get all numeric fields that were incremented/decremented, call
  3836. // AddedFields().
  3837. func (m *AllocAgentMutation) Fields() []string {
  3838. fields := make([]string, 0, 7)
  3839. if m.created_at != nil {
  3840. fields = append(fields, allocagent.FieldCreatedAt)
  3841. }
  3842. if m.updated_at != nil {
  3843. fields = append(fields, allocagent.FieldUpdatedAt)
  3844. }
  3845. if m.deleted_at != nil {
  3846. fields = append(fields, allocagent.FieldDeletedAt)
  3847. }
  3848. if m.user_id != nil {
  3849. fields = append(fields, allocagent.FieldUserID)
  3850. }
  3851. if m.organization_id != nil {
  3852. fields = append(fields, allocagent.FieldOrganizationID)
  3853. }
  3854. if m.agents != nil {
  3855. fields = append(fields, allocagent.FieldAgents)
  3856. }
  3857. if m.status != nil {
  3858. fields = append(fields, allocagent.FieldStatus)
  3859. }
  3860. return fields
  3861. }
  3862. // Field returns the value of a field with the given name. The second boolean
  3863. // return value indicates that this field was not set, or was not defined in the
  3864. // schema.
  3865. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3866. switch name {
  3867. case allocagent.FieldCreatedAt:
  3868. return m.CreatedAt()
  3869. case allocagent.FieldUpdatedAt:
  3870. return m.UpdatedAt()
  3871. case allocagent.FieldDeletedAt:
  3872. return m.DeletedAt()
  3873. case allocagent.FieldUserID:
  3874. return m.UserID()
  3875. case allocagent.FieldOrganizationID:
  3876. return m.OrganizationID()
  3877. case allocagent.FieldAgents:
  3878. return m.Agents()
  3879. case allocagent.FieldStatus:
  3880. return m.Status()
  3881. }
  3882. return nil, false
  3883. }
  3884. // OldField returns the old value of the field from the database. An error is
  3885. // returned if the mutation operation is not UpdateOne, or the query to the
  3886. // database failed.
  3887. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3888. switch name {
  3889. case allocagent.FieldCreatedAt:
  3890. return m.OldCreatedAt(ctx)
  3891. case allocagent.FieldUpdatedAt:
  3892. return m.OldUpdatedAt(ctx)
  3893. case allocagent.FieldDeletedAt:
  3894. return m.OldDeletedAt(ctx)
  3895. case allocagent.FieldUserID:
  3896. return m.OldUserID(ctx)
  3897. case allocagent.FieldOrganizationID:
  3898. return m.OldOrganizationID(ctx)
  3899. case allocagent.FieldAgents:
  3900. return m.OldAgents(ctx)
  3901. case allocagent.FieldStatus:
  3902. return m.OldStatus(ctx)
  3903. }
  3904. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3905. }
  3906. // SetField sets the value of a field with the given name. It returns an error if
  3907. // the field is not defined in the schema, or if the type mismatched the field
  3908. // type.
  3909. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3910. switch name {
  3911. case allocagent.FieldCreatedAt:
  3912. v, ok := value.(time.Time)
  3913. if !ok {
  3914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3915. }
  3916. m.SetCreatedAt(v)
  3917. return nil
  3918. case allocagent.FieldUpdatedAt:
  3919. v, ok := value.(time.Time)
  3920. if !ok {
  3921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3922. }
  3923. m.SetUpdatedAt(v)
  3924. return nil
  3925. case allocagent.FieldDeletedAt:
  3926. v, ok := value.(time.Time)
  3927. if !ok {
  3928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3929. }
  3930. m.SetDeletedAt(v)
  3931. return nil
  3932. case allocagent.FieldUserID:
  3933. v, ok := value.(string)
  3934. if !ok {
  3935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3936. }
  3937. m.SetUserID(v)
  3938. return nil
  3939. case allocagent.FieldOrganizationID:
  3940. v, ok := value.(uint64)
  3941. if !ok {
  3942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3943. }
  3944. m.SetOrganizationID(v)
  3945. return nil
  3946. case allocagent.FieldAgents:
  3947. v, ok := value.([]uint64)
  3948. if !ok {
  3949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3950. }
  3951. m.SetAgents(v)
  3952. return nil
  3953. case allocagent.FieldStatus:
  3954. v, ok := value.(int)
  3955. if !ok {
  3956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3957. }
  3958. m.SetStatus(v)
  3959. return nil
  3960. }
  3961. return fmt.Errorf("unknown AllocAgent field %s", name)
  3962. }
  3963. // AddedFields returns all numeric fields that were incremented/decremented during
  3964. // this mutation.
  3965. func (m *AllocAgentMutation) AddedFields() []string {
  3966. var fields []string
  3967. if m.addorganization_id != nil {
  3968. fields = append(fields, allocagent.FieldOrganizationID)
  3969. }
  3970. if m.addstatus != nil {
  3971. fields = append(fields, allocagent.FieldStatus)
  3972. }
  3973. return fields
  3974. }
  3975. // AddedField returns the numeric value that was incremented/decremented on a field
  3976. // with the given name. The second boolean return value indicates that this field
  3977. // was not set, or was not defined in the schema.
  3978. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3979. switch name {
  3980. case allocagent.FieldOrganizationID:
  3981. return m.AddedOrganizationID()
  3982. case allocagent.FieldStatus:
  3983. return m.AddedStatus()
  3984. }
  3985. return nil, false
  3986. }
  3987. // AddField adds the value to the field with the given name. It returns an error if
  3988. // the field is not defined in the schema, or if the type mismatched the field
  3989. // type.
  3990. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3991. switch name {
  3992. case allocagent.FieldOrganizationID:
  3993. v, ok := value.(int64)
  3994. if !ok {
  3995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3996. }
  3997. m.AddOrganizationID(v)
  3998. return nil
  3999. case allocagent.FieldStatus:
  4000. v, ok := value.(int)
  4001. if !ok {
  4002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4003. }
  4004. m.AddStatus(v)
  4005. return nil
  4006. }
  4007. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4008. }
  4009. // ClearedFields returns all nullable fields that were cleared during this
  4010. // mutation.
  4011. func (m *AllocAgentMutation) ClearedFields() []string {
  4012. var fields []string
  4013. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4014. fields = append(fields, allocagent.FieldDeletedAt)
  4015. }
  4016. if m.FieldCleared(allocagent.FieldUserID) {
  4017. fields = append(fields, allocagent.FieldUserID)
  4018. }
  4019. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4020. fields = append(fields, allocagent.FieldOrganizationID)
  4021. }
  4022. if m.FieldCleared(allocagent.FieldStatus) {
  4023. fields = append(fields, allocagent.FieldStatus)
  4024. }
  4025. return fields
  4026. }
  4027. // FieldCleared returns a boolean indicating if a field with the given name was
  4028. // cleared in this mutation.
  4029. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4030. _, ok := m.clearedFields[name]
  4031. return ok
  4032. }
  4033. // ClearField clears the value of the field with the given name. It returns an
  4034. // error if the field is not defined in the schema.
  4035. func (m *AllocAgentMutation) ClearField(name string) error {
  4036. switch name {
  4037. case allocagent.FieldDeletedAt:
  4038. m.ClearDeletedAt()
  4039. return nil
  4040. case allocagent.FieldUserID:
  4041. m.ClearUserID()
  4042. return nil
  4043. case allocagent.FieldOrganizationID:
  4044. m.ClearOrganizationID()
  4045. return nil
  4046. case allocagent.FieldStatus:
  4047. m.ClearStatus()
  4048. return nil
  4049. }
  4050. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4051. }
  4052. // ResetField resets all changes in the mutation for the field with the given name.
  4053. // It returns an error if the field is not defined in the schema.
  4054. func (m *AllocAgentMutation) ResetField(name string) error {
  4055. switch name {
  4056. case allocagent.FieldCreatedAt:
  4057. m.ResetCreatedAt()
  4058. return nil
  4059. case allocagent.FieldUpdatedAt:
  4060. m.ResetUpdatedAt()
  4061. return nil
  4062. case allocagent.FieldDeletedAt:
  4063. m.ResetDeletedAt()
  4064. return nil
  4065. case allocagent.FieldUserID:
  4066. m.ResetUserID()
  4067. return nil
  4068. case allocagent.FieldOrganizationID:
  4069. m.ResetOrganizationID()
  4070. return nil
  4071. case allocagent.FieldAgents:
  4072. m.ResetAgents()
  4073. return nil
  4074. case allocagent.FieldStatus:
  4075. m.ResetStatus()
  4076. return nil
  4077. }
  4078. return fmt.Errorf("unknown AllocAgent field %s", name)
  4079. }
  4080. // AddedEdges returns all edge names that were set/added in this mutation.
  4081. func (m *AllocAgentMutation) AddedEdges() []string {
  4082. edges := make([]string, 0, 0)
  4083. return edges
  4084. }
  4085. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4086. // name in this mutation.
  4087. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4088. return nil
  4089. }
  4090. // RemovedEdges returns all edge names that were removed in this mutation.
  4091. func (m *AllocAgentMutation) RemovedEdges() []string {
  4092. edges := make([]string, 0, 0)
  4093. return edges
  4094. }
  4095. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4096. // the given name in this mutation.
  4097. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4098. return nil
  4099. }
  4100. // ClearedEdges returns all edge names that were cleared in this mutation.
  4101. func (m *AllocAgentMutation) ClearedEdges() []string {
  4102. edges := make([]string, 0, 0)
  4103. return edges
  4104. }
  4105. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4106. // was cleared in this mutation.
  4107. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4108. return false
  4109. }
  4110. // ClearEdge clears the value of the edge with the given name. It returns an error
  4111. // if that edge is not defined in the schema.
  4112. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4113. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4114. }
  4115. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4116. // It returns an error if the edge is not defined in the schema.
  4117. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4118. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4119. }
  4120. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4121. type ApiKeyMutation struct {
  4122. config
  4123. op Op
  4124. typ string
  4125. id *uint64
  4126. created_at *time.Time
  4127. updated_at *time.Time
  4128. deleted_at *time.Time
  4129. title *string
  4130. key *string
  4131. organization_id *uint64
  4132. addorganization_id *int64
  4133. custom_agent_base *string
  4134. custom_agent_key *string
  4135. openai_base *string
  4136. openai_key *string
  4137. clearedFields map[string]struct{}
  4138. agent *uint64
  4139. clearedagent bool
  4140. done bool
  4141. oldValue func(context.Context) (*ApiKey, error)
  4142. predicates []predicate.ApiKey
  4143. }
  4144. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4145. // apikeyOption allows management of the mutation configuration using functional options.
  4146. type apikeyOption func(*ApiKeyMutation)
  4147. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4148. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4149. m := &ApiKeyMutation{
  4150. config: c,
  4151. op: op,
  4152. typ: TypeApiKey,
  4153. clearedFields: make(map[string]struct{}),
  4154. }
  4155. for _, opt := range opts {
  4156. opt(m)
  4157. }
  4158. return m
  4159. }
  4160. // withApiKeyID sets the ID field of the mutation.
  4161. func withApiKeyID(id uint64) apikeyOption {
  4162. return func(m *ApiKeyMutation) {
  4163. var (
  4164. err error
  4165. once sync.Once
  4166. value *ApiKey
  4167. )
  4168. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4169. once.Do(func() {
  4170. if m.done {
  4171. err = errors.New("querying old values post mutation is not allowed")
  4172. } else {
  4173. value, err = m.Client().ApiKey.Get(ctx, id)
  4174. }
  4175. })
  4176. return value, err
  4177. }
  4178. m.id = &id
  4179. }
  4180. }
  4181. // withApiKey sets the old ApiKey of the mutation.
  4182. func withApiKey(node *ApiKey) apikeyOption {
  4183. return func(m *ApiKeyMutation) {
  4184. m.oldValue = func(context.Context) (*ApiKey, error) {
  4185. return node, nil
  4186. }
  4187. m.id = &node.ID
  4188. }
  4189. }
  4190. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4191. // executed in a transaction (ent.Tx), a transactional client is returned.
  4192. func (m ApiKeyMutation) Client() *Client {
  4193. client := &Client{config: m.config}
  4194. client.init()
  4195. return client
  4196. }
  4197. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4198. // it returns an error otherwise.
  4199. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4200. if _, ok := m.driver.(*txDriver); !ok {
  4201. return nil, errors.New("ent: mutation is not running in a transaction")
  4202. }
  4203. tx := &Tx{config: m.config}
  4204. tx.init()
  4205. return tx, nil
  4206. }
  4207. // SetID sets the value of the id field. Note that this
  4208. // operation is only accepted on creation of ApiKey entities.
  4209. func (m *ApiKeyMutation) SetID(id uint64) {
  4210. m.id = &id
  4211. }
  4212. // ID returns the ID value in the mutation. Note that the ID is only available
  4213. // if it was provided to the builder or after it was returned from the database.
  4214. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4215. if m.id == nil {
  4216. return
  4217. }
  4218. return *m.id, true
  4219. }
  4220. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4221. // That means, if the mutation is applied within a transaction with an isolation level such
  4222. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4223. // or updated by the mutation.
  4224. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4225. switch {
  4226. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4227. id, exists := m.ID()
  4228. if exists {
  4229. return []uint64{id}, nil
  4230. }
  4231. fallthrough
  4232. case m.op.Is(OpUpdate | OpDelete):
  4233. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4234. default:
  4235. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4236. }
  4237. }
  4238. // SetCreatedAt sets the "created_at" field.
  4239. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4240. m.created_at = &t
  4241. }
  4242. // CreatedAt returns the value of the "created_at" field in the mutation.
  4243. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4244. v := m.created_at
  4245. if v == nil {
  4246. return
  4247. }
  4248. return *v, true
  4249. }
  4250. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4251. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4253. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4254. if !m.op.Is(OpUpdateOne) {
  4255. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4256. }
  4257. if m.id == nil || m.oldValue == nil {
  4258. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4259. }
  4260. oldValue, err := m.oldValue(ctx)
  4261. if err != nil {
  4262. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4263. }
  4264. return oldValue.CreatedAt, nil
  4265. }
  4266. // ResetCreatedAt resets all changes to the "created_at" field.
  4267. func (m *ApiKeyMutation) ResetCreatedAt() {
  4268. m.created_at = nil
  4269. }
  4270. // SetUpdatedAt sets the "updated_at" field.
  4271. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4272. m.updated_at = &t
  4273. }
  4274. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4275. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4276. v := m.updated_at
  4277. if v == nil {
  4278. return
  4279. }
  4280. return *v, true
  4281. }
  4282. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4283. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4285. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4286. if !m.op.Is(OpUpdateOne) {
  4287. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4288. }
  4289. if m.id == nil || m.oldValue == nil {
  4290. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4291. }
  4292. oldValue, err := m.oldValue(ctx)
  4293. if err != nil {
  4294. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4295. }
  4296. return oldValue.UpdatedAt, nil
  4297. }
  4298. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4299. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4300. m.updated_at = nil
  4301. }
  4302. // SetDeletedAt sets the "deleted_at" field.
  4303. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4304. m.deleted_at = &t
  4305. }
  4306. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4307. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4308. v := m.deleted_at
  4309. if v == nil {
  4310. return
  4311. }
  4312. return *v, true
  4313. }
  4314. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4315. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4317. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4318. if !m.op.Is(OpUpdateOne) {
  4319. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4320. }
  4321. if m.id == nil || m.oldValue == nil {
  4322. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4323. }
  4324. oldValue, err := m.oldValue(ctx)
  4325. if err != nil {
  4326. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4327. }
  4328. return oldValue.DeletedAt, nil
  4329. }
  4330. // ClearDeletedAt clears the value of the "deleted_at" field.
  4331. func (m *ApiKeyMutation) ClearDeletedAt() {
  4332. m.deleted_at = nil
  4333. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4334. }
  4335. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4336. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4337. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4338. return ok
  4339. }
  4340. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4341. func (m *ApiKeyMutation) ResetDeletedAt() {
  4342. m.deleted_at = nil
  4343. delete(m.clearedFields, apikey.FieldDeletedAt)
  4344. }
  4345. // SetTitle sets the "title" field.
  4346. func (m *ApiKeyMutation) SetTitle(s string) {
  4347. m.title = &s
  4348. }
  4349. // Title returns the value of the "title" field in the mutation.
  4350. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4351. v := m.title
  4352. if v == nil {
  4353. return
  4354. }
  4355. return *v, true
  4356. }
  4357. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4358. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4360. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4361. if !m.op.Is(OpUpdateOne) {
  4362. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4363. }
  4364. if m.id == nil || m.oldValue == nil {
  4365. return v, errors.New("OldTitle requires an ID field in the mutation")
  4366. }
  4367. oldValue, err := m.oldValue(ctx)
  4368. if err != nil {
  4369. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4370. }
  4371. return oldValue.Title, nil
  4372. }
  4373. // ClearTitle clears the value of the "title" field.
  4374. func (m *ApiKeyMutation) ClearTitle() {
  4375. m.title = nil
  4376. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4377. }
  4378. // TitleCleared returns if the "title" field was cleared in this mutation.
  4379. func (m *ApiKeyMutation) TitleCleared() bool {
  4380. _, ok := m.clearedFields[apikey.FieldTitle]
  4381. return ok
  4382. }
  4383. // ResetTitle resets all changes to the "title" field.
  4384. func (m *ApiKeyMutation) ResetTitle() {
  4385. m.title = nil
  4386. delete(m.clearedFields, apikey.FieldTitle)
  4387. }
  4388. // SetKey sets the "key" field.
  4389. func (m *ApiKeyMutation) SetKey(s string) {
  4390. m.key = &s
  4391. }
  4392. // Key returns the value of the "key" field in the mutation.
  4393. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4394. v := m.key
  4395. if v == nil {
  4396. return
  4397. }
  4398. return *v, true
  4399. }
  4400. // OldKey returns the old "key" field's value of the ApiKey entity.
  4401. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4403. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4404. if !m.op.Is(OpUpdateOne) {
  4405. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4406. }
  4407. if m.id == nil || m.oldValue == nil {
  4408. return v, errors.New("OldKey requires an ID field in the mutation")
  4409. }
  4410. oldValue, err := m.oldValue(ctx)
  4411. if err != nil {
  4412. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4413. }
  4414. return oldValue.Key, nil
  4415. }
  4416. // ClearKey clears the value of the "key" field.
  4417. func (m *ApiKeyMutation) ClearKey() {
  4418. m.key = nil
  4419. m.clearedFields[apikey.FieldKey] = struct{}{}
  4420. }
  4421. // KeyCleared returns if the "key" field was cleared in this mutation.
  4422. func (m *ApiKeyMutation) KeyCleared() bool {
  4423. _, ok := m.clearedFields[apikey.FieldKey]
  4424. return ok
  4425. }
  4426. // ResetKey resets all changes to the "key" field.
  4427. func (m *ApiKeyMutation) ResetKey() {
  4428. m.key = nil
  4429. delete(m.clearedFields, apikey.FieldKey)
  4430. }
  4431. // SetOrganizationID sets the "organization_id" field.
  4432. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4433. m.organization_id = &u
  4434. m.addorganization_id = nil
  4435. }
  4436. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4437. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4438. v := m.organization_id
  4439. if v == nil {
  4440. return
  4441. }
  4442. return *v, true
  4443. }
  4444. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4445. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4447. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4448. if !m.op.Is(OpUpdateOne) {
  4449. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4450. }
  4451. if m.id == nil || m.oldValue == nil {
  4452. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4453. }
  4454. oldValue, err := m.oldValue(ctx)
  4455. if err != nil {
  4456. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4457. }
  4458. return oldValue.OrganizationID, nil
  4459. }
  4460. // AddOrganizationID adds u to the "organization_id" field.
  4461. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4462. if m.addorganization_id != nil {
  4463. *m.addorganization_id += u
  4464. } else {
  4465. m.addorganization_id = &u
  4466. }
  4467. }
  4468. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4469. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4470. v := m.addorganization_id
  4471. if v == nil {
  4472. return
  4473. }
  4474. return *v, true
  4475. }
  4476. // ResetOrganizationID resets all changes to the "organization_id" field.
  4477. func (m *ApiKeyMutation) ResetOrganizationID() {
  4478. m.organization_id = nil
  4479. m.addorganization_id = nil
  4480. }
  4481. // SetAgentID sets the "agent_id" field.
  4482. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4483. m.agent = &u
  4484. }
  4485. // AgentID returns the value of the "agent_id" field in the mutation.
  4486. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4487. v := m.agent
  4488. if v == nil {
  4489. return
  4490. }
  4491. return *v, true
  4492. }
  4493. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4494. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4496. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4497. if !m.op.Is(OpUpdateOne) {
  4498. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4499. }
  4500. if m.id == nil || m.oldValue == nil {
  4501. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4502. }
  4503. oldValue, err := m.oldValue(ctx)
  4504. if err != nil {
  4505. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4506. }
  4507. return oldValue.AgentID, nil
  4508. }
  4509. // ResetAgentID resets all changes to the "agent_id" field.
  4510. func (m *ApiKeyMutation) ResetAgentID() {
  4511. m.agent = nil
  4512. }
  4513. // SetCustomAgentBase sets the "custom_agent_base" field.
  4514. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4515. m.custom_agent_base = &s
  4516. }
  4517. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4518. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4519. v := m.custom_agent_base
  4520. if v == nil {
  4521. return
  4522. }
  4523. return *v, true
  4524. }
  4525. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4526. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4528. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4529. if !m.op.Is(OpUpdateOne) {
  4530. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4531. }
  4532. if m.id == nil || m.oldValue == nil {
  4533. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4534. }
  4535. oldValue, err := m.oldValue(ctx)
  4536. if err != nil {
  4537. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4538. }
  4539. return oldValue.CustomAgentBase, nil
  4540. }
  4541. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4542. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4543. m.custom_agent_base = nil
  4544. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4545. }
  4546. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4547. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4548. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4549. return ok
  4550. }
  4551. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4552. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4553. m.custom_agent_base = nil
  4554. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4555. }
  4556. // SetCustomAgentKey sets the "custom_agent_key" field.
  4557. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4558. m.custom_agent_key = &s
  4559. }
  4560. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4561. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4562. v := m.custom_agent_key
  4563. if v == nil {
  4564. return
  4565. }
  4566. return *v, true
  4567. }
  4568. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4569. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4571. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4572. if !m.op.Is(OpUpdateOne) {
  4573. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4574. }
  4575. if m.id == nil || m.oldValue == nil {
  4576. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4577. }
  4578. oldValue, err := m.oldValue(ctx)
  4579. if err != nil {
  4580. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4581. }
  4582. return oldValue.CustomAgentKey, nil
  4583. }
  4584. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4585. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4586. m.custom_agent_key = nil
  4587. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4588. }
  4589. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4590. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4591. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4592. return ok
  4593. }
  4594. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4595. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4596. m.custom_agent_key = nil
  4597. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4598. }
  4599. // SetOpenaiBase sets the "openai_base" field.
  4600. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4601. m.openai_base = &s
  4602. }
  4603. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4604. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4605. v := m.openai_base
  4606. if v == nil {
  4607. return
  4608. }
  4609. return *v, true
  4610. }
  4611. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4612. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4614. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4615. if !m.op.Is(OpUpdateOne) {
  4616. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4617. }
  4618. if m.id == nil || m.oldValue == nil {
  4619. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4620. }
  4621. oldValue, err := m.oldValue(ctx)
  4622. if err != nil {
  4623. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4624. }
  4625. return oldValue.OpenaiBase, nil
  4626. }
  4627. // ClearOpenaiBase clears the value of the "openai_base" field.
  4628. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4629. m.openai_base = nil
  4630. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4631. }
  4632. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4633. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4634. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4635. return ok
  4636. }
  4637. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4638. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4639. m.openai_base = nil
  4640. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4641. }
  4642. // SetOpenaiKey sets the "openai_key" field.
  4643. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4644. m.openai_key = &s
  4645. }
  4646. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4647. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4648. v := m.openai_key
  4649. if v == nil {
  4650. return
  4651. }
  4652. return *v, true
  4653. }
  4654. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4655. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4657. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4658. if !m.op.Is(OpUpdateOne) {
  4659. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4660. }
  4661. if m.id == nil || m.oldValue == nil {
  4662. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4663. }
  4664. oldValue, err := m.oldValue(ctx)
  4665. if err != nil {
  4666. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4667. }
  4668. return oldValue.OpenaiKey, nil
  4669. }
  4670. // ClearOpenaiKey clears the value of the "openai_key" field.
  4671. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4672. m.openai_key = nil
  4673. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4674. }
  4675. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4676. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4677. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4678. return ok
  4679. }
  4680. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4681. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4682. m.openai_key = nil
  4683. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4684. }
  4685. // ClearAgent clears the "agent" edge to the Agent entity.
  4686. func (m *ApiKeyMutation) ClearAgent() {
  4687. m.clearedagent = true
  4688. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4689. }
  4690. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4691. func (m *ApiKeyMutation) AgentCleared() bool {
  4692. return m.clearedagent
  4693. }
  4694. // AgentIDs returns the "agent" edge IDs in the mutation.
  4695. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4696. // AgentID instead. It exists only for internal usage by the builders.
  4697. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4698. if id := m.agent; id != nil {
  4699. ids = append(ids, *id)
  4700. }
  4701. return
  4702. }
  4703. // ResetAgent resets all changes to the "agent" edge.
  4704. func (m *ApiKeyMutation) ResetAgent() {
  4705. m.agent = nil
  4706. m.clearedagent = false
  4707. }
  4708. // Where appends a list predicates to the ApiKeyMutation builder.
  4709. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4710. m.predicates = append(m.predicates, ps...)
  4711. }
  4712. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4713. // users can use type-assertion to append predicates that do not depend on any generated package.
  4714. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4715. p := make([]predicate.ApiKey, len(ps))
  4716. for i := range ps {
  4717. p[i] = ps[i]
  4718. }
  4719. m.Where(p...)
  4720. }
  4721. // Op returns the operation name.
  4722. func (m *ApiKeyMutation) Op() Op {
  4723. return m.op
  4724. }
  4725. // SetOp allows setting the mutation operation.
  4726. func (m *ApiKeyMutation) SetOp(op Op) {
  4727. m.op = op
  4728. }
  4729. // Type returns the node type of this mutation (ApiKey).
  4730. func (m *ApiKeyMutation) Type() string {
  4731. return m.typ
  4732. }
  4733. // Fields returns all fields that were changed during this mutation. Note that in
  4734. // order to get all numeric fields that were incremented/decremented, call
  4735. // AddedFields().
  4736. func (m *ApiKeyMutation) Fields() []string {
  4737. fields := make([]string, 0, 11)
  4738. if m.created_at != nil {
  4739. fields = append(fields, apikey.FieldCreatedAt)
  4740. }
  4741. if m.updated_at != nil {
  4742. fields = append(fields, apikey.FieldUpdatedAt)
  4743. }
  4744. if m.deleted_at != nil {
  4745. fields = append(fields, apikey.FieldDeletedAt)
  4746. }
  4747. if m.title != nil {
  4748. fields = append(fields, apikey.FieldTitle)
  4749. }
  4750. if m.key != nil {
  4751. fields = append(fields, apikey.FieldKey)
  4752. }
  4753. if m.organization_id != nil {
  4754. fields = append(fields, apikey.FieldOrganizationID)
  4755. }
  4756. if m.agent != nil {
  4757. fields = append(fields, apikey.FieldAgentID)
  4758. }
  4759. if m.custom_agent_base != nil {
  4760. fields = append(fields, apikey.FieldCustomAgentBase)
  4761. }
  4762. if m.custom_agent_key != nil {
  4763. fields = append(fields, apikey.FieldCustomAgentKey)
  4764. }
  4765. if m.openai_base != nil {
  4766. fields = append(fields, apikey.FieldOpenaiBase)
  4767. }
  4768. if m.openai_key != nil {
  4769. fields = append(fields, apikey.FieldOpenaiKey)
  4770. }
  4771. return fields
  4772. }
  4773. // Field returns the value of a field with the given name. The second boolean
  4774. // return value indicates that this field was not set, or was not defined in the
  4775. // schema.
  4776. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4777. switch name {
  4778. case apikey.FieldCreatedAt:
  4779. return m.CreatedAt()
  4780. case apikey.FieldUpdatedAt:
  4781. return m.UpdatedAt()
  4782. case apikey.FieldDeletedAt:
  4783. return m.DeletedAt()
  4784. case apikey.FieldTitle:
  4785. return m.Title()
  4786. case apikey.FieldKey:
  4787. return m.Key()
  4788. case apikey.FieldOrganizationID:
  4789. return m.OrganizationID()
  4790. case apikey.FieldAgentID:
  4791. return m.AgentID()
  4792. case apikey.FieldCustomAgentBase:
  4793. return m.CustomAgentBase()
  4794. case apikey.FieldCustomAgentKey:
  4795. return m.CustomAgentKey()
  4796. case apikey.FieldOpenaiBase:
  4797. return m.OpenaiBase()
  4798. case apikey.FieldOpenaiKey:
  4799. return m.OpenaiKey()
  4800. }
  4801. return nil, false
  4802. }
  4803. // OldField returns the old value of the field from the database. An error is
  4804. // returned if the mutation operation is not UpdateOne, or the query to the
  4805. // database failed.
  4806. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4807. switch name {
  4808. case apikey.FieldCreatedAt:
  4809. return m.OldCreatedAt(ctx)
  4810. case apikey.FieldUpdatedAt:
  4811. return m.OldUpdatedAt(ctx)
  4812. case apikey.FieldDeletedAt:
  4813. return m.OldDeletedAt(ctx)
  4814. case apikey.FieldTitle:
  4815. return m.OldTitle(ctx)
  4816. case apikey.FieldKey:
  4817. return m.OldKey(ctx)
  4818. case apikey.FieldOrganizationID:
  4819. return m.OldOrganizationID(ctx)
  4820. case apikey.FieldAgentID:
  4821. return m.OldAgentID(ctx)
  4822. case apikey.FieldCustomAgentBase:
  4823. return m.OldCustomAgentBase(ctx)
  4824. case apikey.FieldCustomAgentKey:
  4825. return m.OldCustomAgentKey(ctx)
  4826. case apikey.FieldOpenaiBase:
  4827. return m.OldOpenaiBase(ctx)
  4828. case apikey.FieldOpenaiKey:
  4829. return m.OldOpenaiKey(ctx)
  4830. }
  4831. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4832. }
  4833. // SetField sets the value of a field with the given name. It returns an error if
  4834. // the field is not defined in the schema, or if the type mismatched the field
  4835. // type.
  4836. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4837. switch name {
  4838. case apikey.FieldCreatedAt:
  4839. v, ok := value.(time.Time)
  4840. if !ok {
  4841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4842. }
  4843. m.SetCreatedAt(v)
  4844. return nil
  4845. case apikey.FieldUpdatedAt:
  4846. v, ok := value.(time.Time)
  4847. if !ok {
  4848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4849. }
  4850. m.SetUpdatedAt(v)
  4851. return nil
  4852. case apikey.FieldDeletedAt:
  4853. v, ok := value.(time.Time)
  4854. if !ok {
  4855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4856. }
  4857. m.SetDeletedAt(v)
  4858. return nil
  4859. case apikey.FieldTitle:
  4860. v, ok := value.(string)
  4861. if !ok {
  4862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4863. }
  4864. m.SetTitle(v)
  4865. return nil
  4866. case apikey.FieldKey:
  4867. v, ok := value.(string)
  4868. if !ok {
  4869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4870. }
  4871. m.SetKey(v)
  4872. return nil
  4873. case apikey.FieldOrganizationID:
  4874. v, ok := value.(uint64)
  4875. if !ok {
  4876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4877. }
  4878. m.SetOrganizationID(v)
  4879. return nil
  4880. case apikey.FieldAgentID:
  4881. v, ok := value.(uint64)
  4882. if !ok {
  4883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4884. }
  4885. m.SetAgentID(v)
  4886. return nil
  4887. case apikey.FieldCustomAgentBase:
  4888. v, ok := value.(string)
  4889. if !ok {
  4890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4891. }
  4892. m.SetCustomAgentBase(v)
  4893. return nil
  4894. case apikey.FieldCustomAgentKey:
  4895. v, ok := value.(string)
  4896. if !ok {
  4897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4898. }
  4899. m.SetCustomAgentKey(v)
  4900. return nil
  4901. case apikey.FieldOpenaiBase:
  4902. v, ok := value.(string)
  4903. if !ok {
  4904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4905. }
  4906. m.SetOpenaiBase(v)
  4907. return nil
  4908. case apikey.FieldOpenaiKey:
  4909. v, ok := value.(string)
  4910. if !ok {
  4911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4912. }
  4913. m.SetOpenaiKey(v)
  4914. return nil
  4915. }
  4916. return fmt.Errorf("unknown ApiKey field %s", name)
  4917. }
  4918. // AddedFields returns all numeric fields that were incremented/decremented during
  4919. // this mutation.
  4920. func (m *ApiKeyMutation) AddedFields() []string {
  4921. var fields []string
  4922. if m.addorganization_id != nil {
  4923. fields = append(fields, apikey.FieldOrganizationID)
  4924. }
  4925. return fields
  4926. }
  4927. // AddedField returns the numeric value that was incremented/decremented on a field
  4928. // with the given name. The second boolean return value indicates that this field
  4929. // was not set, or was not defined in the schema.
  4930. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4931. switch name {
  4932. case apikey.FieldOrganizationID:
  4933. return m.AddedOrganizationID()
  4934. }
  4935. return nil, false
  4936. }
  4937. // AddField adds the value to the field with the given name. It returns an error if
  4938. // the field is not defined in the schema, or if the type mismatched the field
  4939. // type.
  4940. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4941. switch name {
  4942. case apikey.FieldOrganizationID:
  4943. v, ok := value.(int64)
  4944. if !ok {
  4945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4946. }
  4947. m.AddOrganizationID(v)
  4948. return nil
  4949. }
  4950. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4951. }
  4952. // ClearedFields returns all nullable fields that were cleared during this
  4953. // mutation.
  4954. func (m *ApiKeyMutation) ClearedFields() []string {
  4955. var fields []string
  4956. if m.FieldCleared(apikey.FieldDeletedAt) {
  4957. fields = append(fields, apikey.FieldDeletedAt)
  4958. }
  4959. if m.FieldCleared(apikey.FieldTitle) {
  4960. fields = append(fields, apikey.FieldTitle)
  4961. }
  4962. if m.FieldCleared(apikey.FieldKey) {
  4963. fields = append(fields, apikey.FieldKey)
  4964. }
  4965. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4966. fields = append(fields, apikey.FieldCustomAgentBase)
  4967. }
  4968. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4969. fields = append(fields, apikey.FieldCustomAgentKey)
  4970. }
  4971. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4972. fields = append(fields, apikey.FieldOpenaiBase)
  4973. }
  4974. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4975. fields = append(fields, apikey.FieldOpenaiKey)
  4976. }
  4977. return fields
  4978. }
  4979. // FieldCleared returns a boolean indicating if a field with the given name was
  4980. // cleared in this mutation.
  4981. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4982. _, ok := m.clearedFields[name]
  4983. return ok
  4984. }
  4985. // ClearField clears the value of the field with the given name. It returns an
  4986. // error if the field is not defined in the schema.
  4987. func (m *ApiKeyMutation) ClearField(name string) error {
  4988. switch name {
  4989. case apikey.FieldDeletedAt:
  4990. m.ClearDeletedAt()
  4991. return nil
  4992. case apikey.FieldTitle:
  4993. m.ClearTitle()
  4994. return nil
  4995. case apikey.FieldKey:
  4996. m.ClearKey()
  4997. return nil
  4998. case apikey.FieldCustomAgentBase:
  4999. m.ClearCustomAgentBase()
  5000. return nil
  5001. case apikey.FieldCustomAgentKey:
  5002. m.ClearCustomAgentKey()
  5003. return nil
  5004. case apikey.FieldOpenaiBase:
  5005. m.ClearOpenaiBase()
  5006. return nil
  5007. case apikey.FieldOpenaiKey:
  5008. m.ClearOpenaiKey()
  5009. return nil
  5010. }
  5011. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5012. }
  5013. // ResetField resets all changes in the mutation for the field with the given name.
  5014. // It returns an error if the field is not defined in the schema.
  5015. func (m *ApiKeyMutation) ResetField(name string) error {
  5016. switch name {
  5017. case apikey.FieldCreatedAt:
  5018. m.ResetCreatedAt()
  5019. return nil
  5020. case apikey.FieldUpdatedAt:
  5021. m.ResetUpdatedAt()
  5022. return nil
  5023. case apikey.FieldDeletedAt:
  5024. m.ResetDeletedAt()
  5025. return nil
  5026. case apikey.FieldTitle:
  5027. m.ResetTitle()
  5028. return nil
  5029. case apikey.FieldKey:
  5030. m.ResetKey()
  5031. return nil
  5032. case apikey.FieldOrganizationID:
  5033. m.ResetOrganizationID()
  5034. return nil
  5035. case apikey.FieldAgentID:
  5036. m.ResetAgentID()
  5037. return nil
  5038. case apikey.FieldCustomAgentBase:
  5039. m.ResetCustomAgentBase()
  5040. return nil
  5041. case apikey.FieldCustomAgentKey:
  5042. m.ResetCustomAgentKey()
  5043. return nil
  5044. case apikey.FieldOpenaiBase:
  5045. m.ResetOpenaiBase()
  5046. return nil
  5047. case apikey.FieldOpenaiKey:
  5048. m.ResetOpenaiKey()
  5049. return nil
  5050. }
  5051. return fmt.Errorf("unknown ApiKey field %s", name)
  5052. }
  5053. // AddedEdges returns all edge names that were set/added in this mutation.
  5054. func (m *ApiKeyMutation) AddedEdges() []string {
  5055. edges := make([]string, 0, 1)
  5056. if m.agent != nil {
  5057. edges = append(edges, apikey.EdgeAgent)
  5058. }
  5059. return edges
  5060. }
  5061. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5062. // name in this mutation.
  5063. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5064. switch name {
  5065. case apikey.EdgeAgent:
  5066. if id := m.agent; id != nil {
  5067. return []ent.Value{*id}
  5068. }
  5069. }
  5070. return nil
  5071. }
  5072. // RemovedEdges returns all edge names that were removed in this mutation.
  5073. func (m *ApiKeyMutation) RemovedEdges() []string {
  5074. edges := make([]string, 0, 1)
  5075. return edges
  5076. }
  5077. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5078. // the given name in this mutation.
  5079. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5080. return nil
  5081. }
  5082. // ClearedEdges returns all edge names that were cleared in this mutation.
  5083. func (m *ApiKeyMutation) ClearedEdges() []string {
  5084. edges := make([]string, 0, 1)
  5085. if m.clearedagent {
  5086. edges = append(edges, apikey.EdgeAgent)
  5087. }
  5088. return edges
  5089. }
  5090. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5091. // was cleared in this mutation.
  5092. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5093. switch name {
  5094. case apikey.EdgeAgent:
  5095. return m.clearedagent
  5096. }
  5097. return false
  5098. }
  5099. // ClearEdge clears the value of the edge with the given name. It returns an error
  5100. // if that edge is not defined in the schema.
  5101. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5102. switch name {
  5103. case apikey.EdgeAgent:
  5104. m.ClearAgent()
  5105. return nil
  5106. }
  5107. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5108. }
  5109. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5110. // It returns an error if the edge is not defined in the schema.
  5111. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5112. switch name {
  5113. case apikey.EdgeAgent:
  5114. m.ResetAgent()
  5115. return nil
  5116. }
  5117. return fmt.Errorf("unknown ApiKey edge %s", name)
  5118. }
  5119. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5120. type BatchMsgMutation struct {
  5121. config
  5122. op Op
  5123. typ string
  5124. id *uint64
  5125. created_at *time.Time
  5126. updated_at *time.Time
  5127. deleted_at *time.Time
  5128. status *uint8
  5129. addstatus *int8
  5130. batch_no *string
  5131. task_name *string
  5132. fromwxid *string
  5133. msg *string
  5134. tag *string
  5135. tagids *string
  5136. total *int32
  5137. addtotal *int32
  5138. success *int32
  5139. addsuccess *int32
  5140. fail *int32
  5141. addfail *int32
  5142. start_time *time.Time
  5143. stop_time *time.Time
  5144. send_time *time.Time
  5145. _type *int32
  5146. add_type *int32
  5147. organization_id *uint64
  5148. addorganization_id *int64
  5149. ctype *uint64
  5150. addctype *int64
  5151. cc *string
  5152. phone *string
  5153. template_name *string
  5154. template_code *string
  5155. lang *string
  5156. clearedFields map[string]struct{}
  5157. done bool
  5158. oldValue func(context.Context) (*BatchMsg, error)
  5159. predicates []predicate.BatchMsg
  5160. }
  5161. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5162. // batchmsgOption allows management of the mutation configuration using functional options.
  5163. type batchmsgOption func(*BatchMsgMutation)
  5164. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5165. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5166. m := &BatchMsgMutation{
  5167. config: c,
  5168. op: op,
  5169. typ: TypeBatchMsg,
  5170. clearedFields: make(map[string]struct{}),
  5171. }
  5172. for _, opt := range opts {
  5173. opt(m)
  5174. }
  5175. return m
  5176. }
  5177. // withBatchMsgID sets the ID field of the mutation.
  5178. func withBatchMsgID(id uint64) batchmsgOption {
  5179. return func(m *BatchMsgMutation) {
  5180. var (
  5181. err error
  5182. once sync.Once
  5183. value *BatchMsg
  5184. )
  5185. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5186. once.Do(func() {
  5187. if m.done {
  5188. err = errors.New("querying old values post mutation is not allowed")
  5189. } else {
  5190. value, err = m.Client().BatchMsg.Get(ctx, id)
  5191. }
  5192. })
  5193. return value, err
  5194. }
  5195. m.id = &id
  5196. }
  5197. }
  5198. // withBatchMsg sets the old BatchMsg of the mutation.
  5199. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5200. return func(m *BatchMsgMutation) {
  5201. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5202. return node, nil
  5203. }
  5204. m.id = &node.ID
  5205. }
  5206. }
  5207. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5208. // executed in a transaction (ent.Tx), a transactional client is returned.
  5209. func (m BatchMsgMutation) Client() *Client {
  5210. client := &Client{config: m.config}
  5211. client.init()
  5212. return client
  5213. }
  5214. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5215. // it returns an error otherwise.
  5216. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5217. if _, ok := m.driver.(*txDriver); !ok {
  5218. return nil, errors.New("ent: mutation is not running in a transaction")
  5219. }
  5220. tx := &Tx{config: m.config}
  5221. tx.init()
  5222. return tx, nil
  5223. }
  5224. // SetID sets the value of the id field. Note that this
  5225. // operation is only accepted on creation of BatchMsg entities.
  5226. func (m *BatchMsgMutation) SetID(id uint64) {
  5227. m.id = &id
  5228. }
  5229. // ID returns the ID value in the mutation. Note that the ID is only available
  5230. // if it was provided to the builder or after it was returned from the database.
  5231. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5232. if m.id == nil {
  5233. return
  5234. }
  5235. return *m.id, true
  5236. }
  5237. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5238. // That means, if the mutation is applied within a transaction with an isolation level such
  5239. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5240. // or updated by the mutation.
  5241. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5242. switch {
  5243. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5244. id, exists := m.ID()
  5245. if exists {
  5246. return []uint64{id}, nil
  5247. }
  5248. fallthrough
  5249. case m.op.Is(OpUpdate | OpDelete):
  5250. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5251. default:
  5252. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5253. }
  5254. }
  5255. // SetCreatedAt sets the "created_at" field.
  5256. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5257. m.created_at = &t
  5258. }
  5259. // CreatedAt returns the value of the "created_at" field in the mutation.
  5260. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5261. v := m.created_at
  5262. if v == nil {
  5263. return
  5264. }
  5265. return *v, true
  5266. }
  5267. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5268. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5270. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5271. if !m.op.Is(OpUpdateOne) {
  5272. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5273. }
  5274. if m.id == nil || m.oldValue == nil {
  5275. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5276. }
  5277. oldValue, err := m.oldValue(ctx)
  5278. if err != nil {
  5279. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5280. }
  5281. return oldValue.CreatedAt, nil
  5282. }
  5283. // ResetCreatedAt resets all changes to the "created_at" field.
  5284. func (m *BatchMsgMutation) ResetCreatedAt() {
  5285. m.created_at = nil
  5286. }
  5287. // SetUpdatedAt sets the "updated_at" field.
  5288. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5289. m.updated_at = &t
  5290. }
  5291. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5292. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5293. v := m.updated_at
  5294. if v == nil {
  5295. return
  5296. }
  5297. return *v, true
  5298. }
  5299. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5300. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5302. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5303. if !m.op.Is(OpUpdateOne) {
  5304. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5305. }
  5306. if m.id == nil || m.oldValue == nil {
  5307. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5308. }
  5309. oldValue, err := m.oldValue(ctx)
  5310. if err != nil {
  5311. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5312. }
  5313. return oldValue.UpdatedAt, nil
  5314. }
  5315. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5316. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5317. m.updated_at = nil
  5318. }
  5319. // SetDeletedAt sets the "deleted_at" field.
  5320. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5321. m.deleted_at = &t
  5322. }
  5323. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5324. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5325. v := m.deleted_at
  5326. if v == nil {
  5327. return
  5328. }
  5329. return *v, true
  5330. }
  5331. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5332. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5334. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5335. if !m.op.Is(OpUpdateOne) {
  5336. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5337. }
  5338. if m.id == nil || m.oldValue == nil {
  5339. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5340. }
  5341. oldValue, err := m.oldValue(ctx)
  5342. if err != nil {
  5343. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5344. }
  5345. return oldValue.DeletedAt, nil
  5346. }
  5347. // ClearDeletedAt clears the value of the "deleted_at" field.
  5348. func (m *BatchMsgMutation) ClearDeletedAt() {
  5349. m.deleted_at = nil
  5350. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5351. }
  5352. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5353. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5354. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5355. return ok
  5356. }
  5357. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5358. func (m *BatchMsgMutation) ResetDeletedAt() {
  5359. m.deleted_at = nil
  5360. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5361. }
  5362. // SetStatus sets the "status" field.
  5363. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5364. m.status = &u
  5365. m.addstatus = nil
  5366. }
  5367. // Status returns the value of the "status" field in the mutation.
  5368. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5369. v := m.status
  5370. if v == nil {
  5371. return
  5372. }
  5373. return *v, true
  5374. }
  5375. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5376. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5378. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5379. if !m.op.Is(OpUpdateOne) {
  5380. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5381. }
  5382. if m.id == nil || m.oldValue == nil {
  5383. return v, errors.New("OldStatus requires an ID field in the mutation")
  5384. }
  5385. oldValue, err := m.oldValue(ctx)
  5386. if err != nil {
  5387. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5388. }
  5389. return oldValue.Status, nil
  5390. }
  5391. // AddStatus adds u to the "status" field.
  5392. func (m *BatchMsgMutation) AddStatus(u int8) {
  5393. if m.addstatus != nil {
  5394. *m.addstatus += u
  5395. } else {
  5396. m.addstatus = &u
  5397. }
  5398. }
  5399. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5400. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5401. v := m.addstatus
  5402. if v == nil {
  5403. return
  5404. }
  5405. return *v, true
  5406. }
  5407. // ClearStatus clears the value of the "status" field.
  5408. func (m *BatchMsgMutation) ClearStatus() {
  5409. m.status = nil
  5410. m.addstatus = nil
  5411. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5412. }
  5413. // StatusCleared returns if the "status" field was cleared in this mutation.
  5414. func (m *BatchMsgMutation) StatusCleared() bool {
  5415. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5416. return ok
  5417. }
  5418. // ResetStatus resets all changes to the "status" field.
  5419. func (m *BatchMsgMutation) ResetStatus() {
  5420. m.status = nil
  5421. m.addstatus = nil
  5422. delete(m.clearedFields, batchmsg.FieldStatus)
  5423. }
  5424. // SetBatchNo sets the "batch_no" field.
  5425. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5426. m.batch_no = &s
  5427. }
  5428. // BatchNo returns the value of the "batch_no" field in the mutation.
  5429. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5430. v := m.batch_no
  5431. if v == nil {
  5432. return
  5433. }
  5434. return *v, true
  5435. }
  5436. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5437. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5439. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5440. if !m.op.Is(OpUpdateOne) {
  5441. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5442. }
  5443. if m.id == nil || m.oldValue == nil {
  5444. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5445. }
  5446. oldValue, err := m.oldValue(ctx)
  5447. if err != nil {
  5448. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5449. }
  5450. return oldValue.BatchNo, nil
  5451. }
  5452. // ClearBatchNo clears the value of the "batch_no" field.
  5453. func (m *BatchMsgMutation) ClearBatchNo() {
  5454. m.batch_no = nil
  5455. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5456. }
  5457. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5458. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5459. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5460. return ok
  5461. }
  5462. // ResetBatchNo resets all changes to the "batch_no" field.
  5463. func (m *BatchMsgMutation) ResetBatchNo() {
  5464. m.batch_no = nil
  5465. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5466. }
  5467. // SetTaskName sets the "task_name" field.
  5468. func (m *BatchMsgMutation) SetTaskName(s string) {
  5469. m.task_name = &s
  5470. }
  5471. // TaskName returns the value of the "task_name" field in the mutation.
  5472. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5473. v := m.task_name
  5474. if v == nil {
  5475. return
  5476. }
  5477. return *v, true
  5478. }
  5479. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5480. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5482. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5483. if !m.op.Is(OpUpdateOne) {
  5484. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5485. }
  5486. if m.id == nil || m.oldValue == nil {
  5487. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5488. }
  5489. oldValue, err := m.oldValue(ctx)
  5490. if err != nil {
  5491. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5492. }
  5493. return oldValue.TaskName, nil
  5494. }
  5495. // ClearTaskName clears the value of the "task_name" field.
  5496. func (m *BatchMsgMutation) ClearTaskName() {
  5497. m.task_name = nil
  5498. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5499. }
  5500. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5501. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5502. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5503. return ok
  5504. }
  5505. // ResetTaskName resets all changes to the "task_name" field.
  5506. func (m *BatchMsgMutation) ResetTaskName() {
  5507. m.task_name = nil
  5508. delete(m.clearedFields, batchmsg.FieldTaskName)
  5509. }
  5510. // SetFromwxid sets the "fromwxid" field.
  5511. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5512. m.fromwxid = &s
  5513. }
  5514. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5515. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5516. v := m.fromwxid
  5517. if v == nil {
  5518. return
  5519. }
  5520. return *v, true
  5521. }
  5522. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5523. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5525. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5526. if !m.op.Is(OpUpdateOne) {
  5527. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5528. }
  5529. if m.id == nil || m.oldValue == nil {
  5530. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5531. }
  5532. oldValue, err := m.oldValue(ctx)
  5533. if err != nil {
  5534. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5535. }
  5536. return oldValue.Fromwxid, nil
  5537. }
  5538. // ClearFromwxid clears the value of the "fromwxid" field.
  5539. func (m *BatchMsgMutation) ClearFromwxid() {
  5540. m.fromwxid = nil
  5541. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5542. }
  5543. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5544. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5545. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5546. return ok
  5547. }
  5548. // ResetFromwxid resets all changes to the "fromwxid" field.
  5549. func (m *BatchMsgMutation) ResetFromwxid() {
  5550. m.fromwxid = nil
  5551. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5552. }
  5553. // SetMsg sets the "msg" field.
  5554. func (m *BatchMsgMutation) SetMsg(s string) {
  5555. m.msg = &s
  5556. }
  5557. // Msg returns the value of the "msg" field in the mutation.
  5558. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5559. v := m.msg
  5560. if v == nil {
  5561. return
  5562. }
  5563. return *v, true
  5564. }
  5565. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5566. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5568. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5569. if !m.op.Is(OpUpdateOne) {
  5570. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5571. }
  5572. if m.id == nil || m.oldValue == nil {
  5573. return v, errors.New("OldMsg requires an ID field in the mutation")
  5574. }
  5575. oldValue, err := m.oldValue(ctx)
  5576. if err != nil {
  5577. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5578. }
  5579. return oldValue.Msg, nil
  5580. }
  5581. // ClearMsg clears the value of the "msg" field.
  5582. func (m *BatchMsgMutation) ClearMsg() {
  5583. m.msg = nil
  5584. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5585. }
  5586. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5587. func (m *BatchMsgMutation) MsgCleared() bool {
  5588. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5589. return ok
  5590. }
  5591. // ResetMsg resets all changes to the "msg" field.
  5592. func (m *BatchMsgMutation) ResetMsg() {
  5593. m.msg = nil
  5594. delete(m.clearedFields, batchmsg.FieldMsg)
  5595. }
  5596. // SetTag sets the "tag" field.
  5597. func (m *BatchMsgMutation) SetTag(s string) {
  5598. m.tag = &s
  5599. }
  5600. // Tag returns the value of the "tag" field in the mutation.
  5601. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5602. v := m.tag
  5603. if v == nil {
  5604. return
  5605. }
  5606. return *v, true
  5607. }
  5608. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5609. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5611. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5612. if !m.op.Is(OpUpdateOne) {
  5613. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5614. }
  5615. if m.id == nil || m.oldValue == nil {
  5616. return v, errors.New("OldTag requires an ID field in the mutation")
  5617. }
  5618. oldValue, err := m.oldValue(ctx)
  5619. if err != nil {
  5620. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5621. }
  5622. return oldValue.Tag, nil
  5623. }
  5624. // ClearTag clears the value of the "tag" field.
  5625. func (m *BatchMsgMutation) ClearTag() {
  5626. m.tag = nil
  5627. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5628. }
  5629. // TagCleared returns if the "tag" field was cleared in this mutation.
  5630. func (m *BatchMsgMutation) TagCleared() bool {
  5631. _, ok := m.clearedFields[batchmsg.FieldTag]
  5632. return ok
  5633. }
  5634. // ResetTag resets all changes to the "tag" field.
  5635. func (m *BatchMsgMutation) ResetTag() {
  5636. m.tag = nil
  5637. delete(m.clearedFields, batchmsg.FieldTag)
  5638. }
  5639. // SetTagids sets the "tagids" field.
  5640. func (m *BatchMsgMutation) SetTagids(s string) {
  5641. m.tagids = &s
  5642. }
  5643. // Tagids returns the value of the "tagids" field in the mutation.
  5644. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5645. v := m.tagids
  5646. if v == nil {
  5647. return
  5648. }
  5649. return *v, true
  5650. }
  5651. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5652. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5654. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5655. if !m.op.Is(OpUpdateOne) {
  5656. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5657. }
  5658. if m.id == nil || m.oldValue == nil {
  5659. return v, errors.New("OldTagids requires an ID field in the mutation")
  5660. }
  5661. oldValue, err := m.oldValue(ctx)
  5662. if err != nil {
  5663. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5664. }
  5665. return oldValue.Tagids, nil
  5666. }
  5667. // ClearTagids clears the value of the "tagids" field.
  5668. func (m *BatchMsgMutation) ClearTagids() {
  5669. m.tagids = nil
  5670. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5671. }
  5672. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5673. func (m *BatchMsgMutation) TagidsCleared() bool {
  5674. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5675. return ok
  5676. }
  5677. // ResetTagids resets all changes to the "tagids" field.
  5678. func (m *BatchMsgMutation) ResetTagids() {
  5679. m.tagids = nil
  5680. delete(m.clearedFields, batchmsg.FieldTagids)
  5681. }
  5682. // SetTotal sets the "total" field.
  5683. func (m *BatchMsgMutation) SetTotal(i int32) {
  5684. m.total = &i
  5685. m.addtotal = nil
  5686. }
  5687. // Total returns the value of the "total" field in the mutation.
  5688. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5689. v := m.total
  5690. if v == nil {
  5691. return
  5692. }
  5693. return *v, true
  5694. }
  5695. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5696. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5698. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5699. if !m.op.Is(OpUpdateOne) {
  5700. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5701. }
  5702. if m.id == nil || m.oldValue == nil {
  5703. return v, errors.New("OldTotal requires an ID field in the mutation")
  5704. }
  5705. oldValue, err := m.oldValue(ctx)
  5706. if err != nil {
  5707. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5708. }
  5709. return oldValue.Total, nil
  5710. }
  5711. // AddTotal adds i to the "total" field.
  5712. func (m *BatchMsgMutation) AddTotal(i int32) {
  5713. if m.addtotal != nil {
  5714. *m.addtotal += i
  5715. } else {
  5716. m.addtotal = &i
  5717. }
  5718. }
  5719. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5720. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5721. v := m.addtotal
  5722. if v == nil {
  5723. return
  5724. }
  5725. return *v, true
  5726. }
  5727. // ClearTotal clears the value of the "total" field.
  5728. func (m *BatchMsgMutation) ClearTotal() {
  5729. m.total = nil
  5730. m.addtotal = nil
  5731. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5732. }
  5733. // TotalCleared returns if the "total" field was cleared in this mutation.
  5734. func (m *BatchMsgMutation) TotalCleared() bool {
  5735. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5736. return ok
  5737. }
  5738. // ResetTotal resets all changes to the "total" field.
  5739. func (m *BatchMsgMutation) ResetTotal() {
  5740. m.total = nil
  5741. m.addtotal = nil
  5742. delete(m.clearedFields, batchmsg.FieldTotal)
  5743. }
  5744. // SetSuccess sets the "success" field.
  5745. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5746. m.success = &i
  5747. m.addsuccess = nil
  5748. }
  5749. // Success returns the value of the "success" field in the mutation.
  5750. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5751. v := m.success
  5752. if v == nil {
  5753. return
  5754. }
  5755. return *v, true
  5756. }
  5757. // OldSuccess returns the old "success" 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) OldSuccess(ctx context.Context) (v int32, err error) {
  5761. if !m.op.Is(OpUpdateOne) {
  5762. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5763. }
  5764. if m.id == nil || m.oldValue == nil {
  5765. return v, errors.New("OldSuccess 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 OldSuccess: %w", err)
  5770. }
  5771. return oldValue.Success, nil
  5772. }
  5773. // AddSuccess adds i to the "success" field.
  5774. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5775. if m.addsuccess != nil {
  5776. *m.addsuccess += i
  5777. } else {
  5778. m.addsuccess = &i
  5779. }
  5780. }
  5781. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5782. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5783. v := m.addsuccess
  5784. if v == nil {
  5785. return
  5786. }
  5787. return *v, true
  5788. }
  5789. // ClearSuccess clears the value of the "success" field.
  5790. func (m *BatchMsgMutation) ClearSuccess() {
  5791. m.success = nil
  5792. m.addsuccess = nil
  5793. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5794. }
  5795. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5796. func (m *BatchMsgMutation) SuccessCleared() bool {
  5797. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5798. return ok
  5799. }
  5800. // ResetSuccess resets all changes to the "success" field.
  5801. func (m *BatchMsgMutation) ResetSuccess() {
  5802. m.success = nil
  5803. m.addsuccess = nil
  5804. delete(m.clearedFields, batchmsg.FieldSuccess)
  5805. }
  5806. // SetFail sets the "fail" field.
  5807. func (m *BatchMsgMutation) SetFail(i int32) {
  5808. m.fail = &i
  5809. m.addfail = nil
  5810. }
  5811. // Fail returns the value of the "fail" field in the mutation.
  5812. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5813. v := m.fail
  5814. if v == nil {
  5815. return
  5816. }
  5817. return *v, true
  5818. }
  5819. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5820. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5822. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5823. if !m.op.Is(OpUpdateOne) {
  5824. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5825. }
  5826. if m.id == nil || m.oldValue == nil {
  5827. return v, errors.New("OldFail requires an ID field in the mutation")
  5828. }
  5829. oldValue, err := m.oldValue(ctx)
  5830. if err != nil {
  5831. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5832. }
  5833. return oldValue.Fail, nil
  5834. }
  5835. // AddFail adds i to the "fail" field.
  5836. func (m *BatchMsgMutation) AddFail(i int32) {
  5837. if m.addfail != nil {
  5838. *m.addfail += i
  5839. } else {
  5840. m.addfail = &i
  5841. }
  5842. }
  5843. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5844. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5845. v := m.addfail
  5846. if v == nil {
  5847. return
  5848. }
  5849. return *v, true
  5850. }
  5851. // ClearFail clears the value of the "fail" field.
  5852. func (m *BatchMsgMutation) ClearFail() {
  5853. m.fail = nil
  5854. m.addfail = nil
  5855. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5856. }
  5857. // FailCleared returns if the "fail" field was cleared in this mutation.
  5858. func (m *BatchMsgMutation) FailCleared() bool {
  5859. _, ok := m.clearedFields[batchmsg.FieldFail]
  5860. return ok
  5861. }
  5862. // ResetFail resets all changes to the "fail" field.
  5863. func (m *BatchMsgMutation) ResetFail() {
  5864. m.fail = nil
  5865. m.addfail = nil
  5866. delete(m.clearedFields, batchmsg.FieldFail)
  5867. }
  5868. // SetStartTime sets the "start_time" field.
  5869. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5870. m.start_time = &t
  5871. }
  5872. // StartTime returns the value of the "start_time" field in the mutation.
  5873. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5874. v := m.start_time
  5875. if v == nil {
  5876. return
  5877. }
  5878. return *v, true
  5879. }
  5880. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5881. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5883. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5884. if !m.op.Is(OpUpdateOne) {
  5885. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5886. }
  5887. if m.id == nil || m.oldValue == nil {
  5888. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5889. }
  5890. oldValue, err := m.oldValue(ctx)
  5891. if err != nil {
  5892. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5893. }
  5894. return oldValue.StartTime, nil
  5895. }
  5896. // ClearStartTime clears the value of the "start_time" field.
  5897. func (m *BatchMsgMutation) ClearStartTime() {
  5898. m.start_time = nil
  5899. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5900. }
  5901. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5902. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5903. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5904. return ok
  5905. }
  5906. // ResetStartTime resets all changes to the "start_time" field.
  5907. func (m *BatchMsgMutation) ResetStartTime() {
  5908. m.start_time = nil
  5909. delete(m.clearedFields, batchmsg.FieldStartTime)
  5910. }
  5911. // SetStopTime sets the "stop_time" field.
  5912. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5913. m.stop_time = &t
  5914. }
  5915. // StopTime returns the value of the "stop_time" field in the mutation.
  5916. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5917. v := m.stop_time
  5918. if v == nil {
  5919. return
  5920. }
  5921. return *v, true
  5922. }
  5923. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5924. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5926. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5927. if !m.op.Is(OpUpdateOne) {
  5928. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5929. }
  5930. if m.id == nil || m.oldValue == nil {
  5931. return v, errors.New("OldStopTime requires an ID field in the mutation")
  5932. }
  5933. oldValue, err := m.oldValue(ctx)
  5934. if err != nil {
  5935. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  5936. }
  5937. return oldValue.StopTime, nil
  5938. }
  5939. // ClearStopTime clears the value of the "stop_time" field.
  5940. func (m *BatchMsgMutation) ClearStopTime() {
  5941. m.stop_time = nil
  5942. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5943. }
  5944. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5945. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5946. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5947. return ok
  5948. }
  5949. // ResetStopTime resets all changes to the "stop_time" field.
  5950. func (m *BatchMsgMutation) ResetStopTime() {
  5951. m.stop_time = nil
  5952. delete(m.clearedFields, batchmsg.FieldStopTime)
  5953. }
  5954. // SetSendTime sets the "send_time" field.
  5955. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5956. m.send_time = &t
  5957. }
  5958. // SendTime returns the value of the "send_time" field in the mutation.
  5959. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5960. v := m.send_time
  5961. if v == nil {
  5962. return
  5963. }
  5964. return *v, true
  5965. }
  5966. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  5967. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5969. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5970. if !m.op.Is(OpUpdateOne) {
  5971. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5972. }
  5973. if m.id == nil || m.oldValue == nil {
  5974. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5975. }
  5976. oldValue, err := m.oldValue(ctx)
  5977. if err != nil {
  5978. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5979. }
  5980. return oldValue.SendTime, nil
  5981. }
  5982. // ClearSendTime clears the value of the "send_time" field.
  5983. func (m *BatchMsgMutation) ClearSendTime() {
  5984. m.send_time = nil
  5985. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5986. }
  5987. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5988. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5989. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5990. return ok
  5991. }
  5992. // ResetSendTime resets all changes to the "send_time" field.
  5993. func (m *BatchMsgMutation) ResetSendTime() {
  5994. m.send_time = nil
  5995. delete(m.clearedFields, batchmsg.FieldSendTime)
  5996. }
  5997. // SetType sets the "type" field.
  5998. func (m *BatchMsgMutation) SetType(i int32) {
  5999. m._type = &i
  6000. m.add_type = nil
  6001. }
  6002. // GetType returns the value of the "type" field in the mutation.
  6003. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6004. v := m._type
  6005. if v == nil {
  6006. return
  6007. }
  6008. return *v, true
  6009. }
  6010. // OldType returns the old "type" field's value of the BatchMsg entity.
  6011. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6013. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6014. if !m.op.Is(OpUpdateOne) {
  6015. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6016. }
  6017. if m.id == nil || m.oldValue == nil {
  6018. return v, errors.New("OldType requires an ID field in the mutation")
  6019. }
  6020. oldValue, err := m.oldValue(ctx)
  6021. if err != nil {
  6022. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6023. }
  6024. return oldValue.Type, nil
  6025. }
  6026. // AddType adds i to the "type" field.
  6027. func (m *BatchMsgMutation) AddType(i int32) {
  6028. if m.add_type != nil {
  6029. *m.add_type += i
  6030. } else {
  6031. m.add_type = &i
  6032. }
  6033. }
  6034. // AddedType returns the value that was added to the "type" field in this mutation.
  6035. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6036. v := m.add_type
  6037. if v == nil {
  6038. return
  6039. }
  6040. return *v, true
  6041. }
  6042. // ClearType clears the value of the "type" field.
  6043. func (m *BatchMsgMutation) ClearType() {
  6044. m._type = nil
  6045. m.add_type = nil
  6046. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6047. }
  6048. // TypeCleared returns if the "type" field was cleared in this mutation.
  6049. func (m *BatchMsgMutation) TypeCleared() bool {
  6050. _, ok := m.clearedFields[batchmsg.FieldType]
  6051. return ok
  6052. }
  6053. // ResetType resets all changes to the "type" field.
  6054. func (m *BatchMsgMutation) ResetType() {
  6055. m._type = nil
  6056. m.add_type = nil
  6057. delete(m.clearedFields, batchmsg.FieldType)
  6058. }
  6059. // SetOrganizationID sets the "organization_id" field.
  6060. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6061. m.organization_id = &u
  6062. m.addorganization_id = nil
  6063. }
  6064. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6065. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6066. v := m.organization_id
  6067. if v == nil {
  6068. return
  6069. }
  6070. return *v, true
  6071. }
  6072. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6073. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6075. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6076. if !m.op.Is(OpUpdateOne) {
  6077. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6078. }
  6079. if m.id == nil || m.oldValue == nil {
  6080. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6081. }
  6082. oldValue, err := m.oldValue(ctx)
  6083. if err != nil {
  6084. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6085. }
  6086. return oldValue.OrganizationID, nil
  6087. }
  6088. // AddOrganizationID adds u to the "organization_id" field.
  6089. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6090. if m.addorganization_id != nil {
  6091. *m.addorganization_id += u
  6092. } else {
  6093. m.addorganization_id = &u
  6094. }
  6095. }
  6096. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6097. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6098. v := m.addorganization_id
  6099. if v == nil {
  6100. return
  6101. }
  6102. return *v, true
  6103. }
  6104. // ResetOrganizationID resets all changes to the "organization_id" field.
  6105. func (m *BatchMsgMutation) ResetOrganizationID() {
  6106. m.organization_id = nil
  6107. m.addorganization_id = nil
  6108. }
  6109. // SetCtype sets the "ctype" field.
  6110. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6111. m.ctype = &u
  6112. m.addctype = nil
  6113. }
  6114. // Ctype returns the value of the "ctype" field in the mutation.
  6115. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6116. v := m.ctype
  6117. if v == nil {
  6118. return
  6119. }
  6120. return *v, true
  6121. }
  6122. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6123. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6125. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6126. if !m.op.Is(OpUpdateOne) {
  6127. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6128. }
  6129. if m.id == nil || m.oldValue == nil {
  6130. return v, errors.New("OldCtype requires an ID field in the mutation")
  6131. }
  6132. oldValue, err := m.oldValue(ctx)
  6133. if err != nil {
  6134. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6135. }
  6136. return oldValue.Ctype, nil
  6137. }
  6138. // AddCtype adds u to the "ctype" field.
  6139. func (m *BatchMsgMutation) AddCtype(u int64) {
  6140. if m.addctype != nil {
  6141. *m.addctype += u
  6142. } else {
  6143. m.addctype = &u
  6144. }
  6145. }
  6146. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6147. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6148. v := m.addctype
  6149. if v == nil {
  6150. return
  6151. }
  6152. return *v, true
  6153. }
  6154. // ResetCtype resets all changes to the "ctype" field.
  6155. func (m *BatchMsgMutation) ResetCtype() {
  6156. m.ctype = nil
  6157. m.addctype = nil
  6158. }
  6159. // SetCc sets the "cc" field.
  6160. func (m *BatchMsgMutation) SetCc(s string) {
  6161. m.cc = &s
  6162. }
  6163. // Cc returns the value of the "cc" field in the mutation.
  6164. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6165. v := m.cc
  6166. if v == nil {
  6167. return
  6168. }
  6169. return *v, true
  6170. }
  6171. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6172. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6174. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6175. if !m.op.Is(OpUpdateOne) {
  6176. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6177. }
  6178. if m.id == nil || m.oldValue == nil {
  6179. return v, errors.New("OldCc requires an ID field in the mutation")
  6180. }
  6181. oldValue, err := m.oldValue(ctx)
  6182. if err != nil {
  6183. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6184. }
  6185. return oldValue.Cc, nil
  6186. }
  6187. // ClearCc clears the value of the "cc" field.
  6188. func (m *BatchMsgMutation) ClearCc() {
  6189. m.cc = nil
  6190. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6191. }
  6192. // CcCleared returns if the "cc" field was cleared in this mutation.
  6193. func (m *BatchMsgMutation) CcCleared() bool {
  6194. _, ok := m.clearedFields[batchmsg.FieldCc]
  6195. return ok
  6196. }
  6197. // ResetCc resets all changes to the "cc" field.
  6198. func (m *BatchMsgMutation) ResetCc() {
  6199. m.cc = nil
  6200. delete(m.clearedFields, batchmsg.FieldCc)
  6201. }
  6202. // SetPhone sets the "phone" field.
  6203. func (m *BatchMsgMutation) SetPhone(s string) {
  6204. m.phone = &s
  6205. }
  6206. // Phone returns the value of the "phone" field in the mutation.
  6207. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6208. v := m.phone
  6209. if v == nil {
  6210. return
  6211. }
  6212. return *v, true
  6213. }
  6214. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6215. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6217. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6218. if !m.op.Is(OpUpdateOne) {
  6219. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6220. }
  6221. if m.id == nil || m.oldValue == nil {
  6222. return v, errors.New("OldPhone requires an ID field in the mutation")
  6223. }
  6224. oldValue, err := m.oldValue(ctx)
  6225. if err != nil {
  6226. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6227. }
  6228. return oldValue.Phone, nil
  6229. }
  6230. // ClearPhone clears the value of the "phone" field.
  6231. func (m *BatchMsgMutation) ClearPhone() {
  6232. m.phone = nil
  6233. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6234. }
  6235. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6236. func (m *BatchMsgMutation) PhoneCleared() bool {
  6237. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6238. return ok
  6239. }
  6240. // ResetPhone resets all changes to the "phone" field.
  6241. func (m *BatchMsgMutation) ResetPhone() {
  6242. m.phone = nil
  6243. delete(m.clearedFields, batchmsg.FieldPhone)
  6244. }
  6245. // SetTemplateName sets the "template_name" field.
  6246. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6247. m.template_name = &s
  6248. }
  6249. // TemplateName returns the value of the "template_name" field in the mutation.
  6250. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6251. v := m.template_name
  6252. if v == nil {
  6253. return
  6254. }
  6255. return *v, true
  6256. }
  6257. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6258. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6260. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6261. if !m.op.Is(OpUpdateOne) {
  6262. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6263. }
  6264. if m.id == nil || m.oldValue == nil {
  6265. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6266. }
  6267. oldValue, err := m.oldValue(ctx)
  6268. if err != nil {
  6269. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6270. }
  6271. return oldValue.TemplateName, nil
  6272. }
  6273. // ClearTemplateName clears the value of the "template_name" field.
  6274. func (m *BatchMsgMutation) ClearTemplateName() {
  6275. m.template_name = nil
  6276. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6277. }
  6278. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6279. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6280. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6281. return ok
  6282. }
  6283. // ResetTemplateName resets all changes to the "template_name" field.
  6284. func (m *BatchMsgMutation) ResetTemplateName() {
  6285. m.template_name = nil
  6286. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6287. }
  6288. // SetTemplateCode sets the "template_code" field.
  6289. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6290. m.template_code = &s
  6291. }
  6292. // TemplateCode returns the value of the "template_code" field in the mutation.
  6293. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6294. v := m.template_code
  6295. if v == nil {
  6296. return
  6297. }
  6298. return *v, true
  6299. }
  6300. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6301. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6303. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6304. if !m.op.Is(OpUpdateOne) {
  6305. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6306. }
  6307. if m.id == nil || m.oldValue == nil {
  6308. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6309. }
  6310. oldValue, err := m.oldValue(ctx)
  6311. if err != nil {
  6312. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6313. }
  6314. return oldValue.TemplateCode, nil
  6315. }
  6316. // ClearTemplateCode clears the value of the "template_code" field.
  6317. func (m *BatchMsgMutation) ClearTemplateCode() {
  6318. m.template_code = nil
  6319. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6320. }
  6321. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6322. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6323. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6324. return ok
  6325. }
  6326. // ResetTemplateCode resets all changes to the "template_code" field.
  6327. func (m *BatchMsgMutation) ResetTemplateCode() {
  6328. m.template_code = nil
  6329. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6330. }
  6331. // SetLang sets the "lang" field.
  6332. func (m *BatchMsgMutation) SetLang(s string) {
  6333. m.lang = &s
  6334. }
  6335. // Lang returns the value of the "lang" field in the mutation.
  6336. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6337. v := m.lang
  6338. if v == nil {
  6339. return
  6340. }
  6341. return *v, true
  6342. }
  6343. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6344. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6346. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6347. if !m.op.Is(OpUpdateOne) {
  6348. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6349. }
  6350. if m.id == nil || m.oldValue == nil {
  6351. return v, errors.New("OldLang requires an ID field in the mutation")
  6352. }
  6353. oldValue, err := m.oldValue(ctx)
  6354. if err != nil {
  6355. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6356. }
  6357. return oldValue.Lang, nil
  6358. }
  6359. // ClearLang clears the value of the "lang" field.
  6360. func (m *BatchMsgMutation) ClearLang() {
  6361. m.lang = nil
  6362. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6363. }
  6364. // LangCleared returns if the "lang" field was cleared in this mutation.
  6365. func (m *BatchMsgMutation) LangCleared() bool {
  6366. _, ok := m.clearedFields[batchmsg.FieldLang]
  6367. return ok
  6368. }
  6369. // ResetLang resets all changes to the "lang" field.
  6370. func (m *BatchMsgMutation) ResetLang() {
  6371. m.lang = nil
  6372. delete(m.clearedFields, batchmsg.FieldLang)
  6373. }
  6374. // Where appends a list predicates to the BatchMsgMutation builder.
  6375. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6376. m.predicates = append(m.predicates, ps...)
  6377. }
  6378. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6379. // users can use type-assertion to append predicates that do not depend on any generated package.
  6380. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6381. p := make([]predicate.BatchMsg, len(ps))
  6382. for i := range ps {
  6383. p[i] = ps[i]
  6384. }
  6385. m.Where(p...)
  6386. }
  6387. // Op returns the operation name.
  6388. func (m *BatchMsgMutation) Op() Op {
  6389. return m.op
  6390. }
  6391. // SetOp allows setting the mutation operation.
  6392. func (m *BatchMsgMutation) SetOp(op Op) {
  6393. m.op = op
  6394. }
  6395. // Type returns the node type of this mutation (BatchMsg).
  6396. func (m *BatchMsgMutation) Type() string {
  6397. return m.typ
  6398. }
  6399. // Fields returns all fields that were changed during this mutation. Note that in
  6400. // order to get all numeric fields that were incremented/decremented, call
  6401. // AddedFields().
  6402. func (m *BatchMsgMutation) Fields() []string {
  6403. fields := make([]string, 0, 24)
  6404. if m.created_at != nil {
  6405. fields = append(fields, batchmsg.FieldCreatedAt)
  6406. }
  6407. if m.updated_at != nil {
  6408. fields = append(fields, batchmsg.FieldUpdatedAt)
  6409. }
  6410. if m.deleted_at != nil {
  6411. fields = append(fields, batchmsg.FieldDeletedAt)
  6412. }
  6413. if m.status != nil {
  6414. fields = append(fields, batchmsg.FieldStatus)
  6415. }
  6416. if m.batch_no != nil {
  6417. fields = append(fields, batchmsg.FieldBatchNo)
  6418. }
  6419. if m.task_name != nil {
  6420. fields = append(fields, batchmsg.FieldTaskName)
  6421. }
  6422. if m.fromwxid != nil {
  6423. fields = append(fields, batchmsg.FieldFromwxid)
  6424. }
  6425. if m.msg != nil {
  6426. fields = append(fields, batchmsg.FieldMsg)
  6427. }
  6428. if m.tag != nil {
  6429. fields = append(fields, batchmsg.FieldTag)
  6430. }
  6431. if m.tagids != nil {
  6432. fields = append(fields, batchmsg.FieldTagids)
  6433. }
  6434. if m.total != nil {
  6435. fields = append(fields, batchmsg.FieldTotal)
  6436. }
  6437. if m.success != nil {
  6438. fields = append(fields, batchmsg.FieldSuccess)
  6439. }
  6440. if m.fail != nil {
  6441. fields = append(fields, batchmsg.FieldFail)
  6442. }
  6443. if m.start_time != nil {
  6444. fields = append(fields, batchmsg.FieldStartTime)
  6445. }
  6446. if m.stop_time != nil {
  6447. fields = append(fields, batchmsg.FieldStopTime)
  6448. }
  6449. if m.send_time != nil {
  6450. fields = append(fields, batchmsg.FieldSendTime)
  6451. }
  6452. if m._type != nil {
  6453. fields = append(fields, batchmsg.FieldType)
  6454. }
  6455. if m.organization_id != nil {
  6456. fields = append(fields, batchmsg.FieldOrganizationID)
  6457. }
  6458. if m.ctype != nil {
  6459. fields = append(fields, batchmsg.FieldCtype)
  6460. }
  6461. if m.cc != nil {
  6462. fields = append(fields, batchmsg.FieldCc)
  6463. }
  6464. if m.phone != nil {
  6465. fields = append(fields, batchmsg.FieldPhone)
  6466. }
  6467. if m.template_name != nil {
  6468. fields = append(fields, batchmsg.FieldTemplateName)
  6469. }
  6470. if m.template_code != nil {
  6471. fields = append(fields, batchmsg.FieldTemplateCode)
  6472. }
  6473. if m.lang != nil {
  6474. fields = append(fields, batchmsg.FieldLang)
  6475. }
  6476. return fields
  6477. }
  6478. // Field returns the value of a field with the given name. The second boolean
  6479. // return value indicates that this field was not set, or was not defined in the
  6480. // schema.
  6481. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6482. switch name {
  6483. case batchmsg.FieldCreatedAt:
  6484. return m.CreatedAt()
  6485. case batchmsg.FieldUpdatedAt:
  6486. return m.UpdatedAt()
  6487. case batchmsg.FieldDeletedAt:
  6488. return m.DeletedAt()
  6489. case batchmsg.FieldStatus:
  6490. return m.Status()
  6491. case batchmsg.FieldBatchNo:
  6492. return m.BatchNo()
  6493. case batchmsg.FieldTaskName:
  6494. return m.TaskName()
  6495. case batchmsg.FieldFromwxid:
  6496. return m.Fromwxid()
  6497. case batchmsg.FieldMsg:
  6498. return m.Msg()
  6499. case batchmsg.FieldTag:
  6500. return m.Tag()
  6501. case batchmsg.FieldTagids:
  6502. return m.Tagids()
  6503. case batchmsg.FieldTotal:
  6504. return m.Total()
  6505. case batchmsg.FieldSuccess:
  6506. return m.Success()
  6507. case batchmsg.FieldFail:
  6508. return m.Fail()
  6509. case batchmsg.FieldStartTime:
  6510. return m.StartTime()
  6511. case batchmsg.FieldStopTime:
  6512. return m.StopTime()
  6513. case batchmsg.FieldSendTime:
  6514. return m.SendTime()
  6515. case batchmsg.FieldType:
  6516. return m.GetType()
  6517. case batchmsg.FieldOrganizationID:
  6518. return m.OrganizationID()
  6519. case batchmsg.FieldCtype:
  6520. return m.Ctype()
  6521. case batchmsg.FieldCc:
  6522. return m.Cc()
  6523. case batchmsg.FieldPhone:
  6524. return m.Phone()
  6525. case batchmsg.FieldTemplateName:
  6526. return m.TemplateName()
  6527. case batchmsg.FieldTemplateCode:
  6528. return m.TemplateCode()
  6529. case batchmsg.FieldLang:
  6530. return m.Lang()
  6531. }
  6532. return nil, false
  6533. }
  6534. // OldField returns the old value of the field from the database. An error is
  6535. // returned if the mutation operation is not UpdateOne, or the query to the
  6536. // database failed.
  6537. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6538. switch name {
  6539. case batchmsg.FieldCreatedAt:
  6540. return m.OldCreatedAt(ctx)
  6541. case batchmsg.FieldUpdatedAt:
  6542. return m.OldUpdatedAt(ctx)
  6543. case batchmsg.FieldDeletedAt:
  6544. return m.OldDeletedAt(ctx)
  6545. case batchmsg.FieldStatus:
  6546. return m.OldStatus(ctx)
  6547. case batchmsg.FieldBatchNo:
  6548. return m.OldBatchNo(ctx)
  6549. case batchmsg.FieldTaskName:
  6550. return m.OldTaskName(ctx)
  6551. case batchmsg.FieldFromwxid:
  6552. return m.OldFromwxid(ctx)
  6553. case batchmsg.FieldMsg:
  6554. return m.OldMsg(ctx)
  6555. case batchmsg.FieldTag:
  6556. return m.OldTag(ctx)
  6557. case batchmsg.FieldTagids:
  6558. return m.OldTagids(ctx)
  6559. case batchmsg.FieldTotal:
  6560. return m.OldTotal(ctx)
  6561. case batchmsg.FieldSuccess:
  6562. return m.OldSuccess(ctx)
  6563. case batchmsg.FieldFail:
  6564. return m.OldFail(ctx)
  6565. case batchmsg.FieldStartTime:
  6566. return m.OldStartTime(ctx)
  6567. case batchmsg.FieldStopTime:
  6568. return m.OldStopTime(ctx)
  6569. case batchmsg.FieldSendTime:
  6570. return m.OldSendTime(ctx)
  6571. case batchmsg.FieldType:
  6572. return m.OldType(ctx)
  6573. case batchmsg.FieldOrganizationID:
  6574. return m.OldOrganizationID(ctx)
  6575. case batchmsg.FieldCtype:
  6576. return m.OldCtype(ctx)
  6577. case batchmsg.FieldCc:
  6578. return m.OldCc(ctx)
  6579. case batchmsg.FieldPhone:
  6580. return m.OldPhone(ctx)
  6581. case batchmsg.FieldTemplateName:
  6582. return m.OldTemplateName(ctx)
  6583. case batchmsg.FieldTemplateCode:
  6584. return m.OldTemplateCode(ctx)
  6585. case batchmsg.FieldLang:
  6586. return m.OldLang(ctx)
  6587. }
  6588. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6589. }
  6590. // SetField sets the value of a field with the given name. It returns an error if
  6591. // the field is not defined in the schema, or if the type mismatched the field
  6592. // type.
  6593. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6594. switch name {
  6595. case batchmsg.FieldCreatedAt:
  6596. v, ok := value.(time.Time)
  6597. if !ok {
  6598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6599. }
  6600. m.SetCreatedAt(v)
  6601. return nil
  6602. case batchmsg.FieldUpdatedAt:
  6603. v, ok := value.(time.Time)
  6604. if !ok {
  6605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6606. }
  6607. m.SetUpdatedAt(v)
  6608. return nil
  6609. case batchmsg.FieldDeletedAt:
  6610. v, ok := value.(time.Time)
  6611. if !ok {
  6612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6613. }
  6614. m.SetDeletedAt(v)
  6615. return nil
  6616. case batchmsg.FieldStatus:
  6617. v, ok := value.(uint8)
  6618. if !ok {
  6619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6620. }
  6621. m.SetStatus(v)
  6622. return nil
  6623. case batchmsg.FieldBatchNo:
  6624. v, ok := value.(string)
  6625. if !ok {
  6626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6627. }
  6628. m.SetBatchNo(v)
  6629. return nil
  6630. case batchmsg.FieldTaskName:
  6631. v, ok := value.(string)
  6632. if !ok {
  6633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6634. }
  6635. m.SetTaskName(v)
  6636. return nil
  6637. case batchmsg.FieldFromwxid:
  6638. v, ok := value.(string)
  6639. if !ok {
  6640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6641. }
  6642. m.SetFromwxid(v)
  6643. return nil
  6644. case batchmsg.FieldMsg:
  6645. v, ok := value.(string)
  6646. if !ok {
  6647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6648. }
  6649. m.SetMsg(v)
  6650. return nil
  6651. case batchmsg.FieldTag:
  6652. v, ok := value.(string)
  6653. if !ok {
  6654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6655. }
  6656. m.SetTag(v)
  6657. return nil
  6658. case batchmsg.FieldTagids:
  6659. v, ok := value.(string)
  6660. if !ok {
  6661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6662. }
  6663. m.SetTagids(v)
  6664. return nil
  6665. case batchmsg.FieldTotal:
  6666. v, ok := value.(int32)
  6667. if !ok {
  6668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6669. }
  6670. m.SetTotal(v)
  6671. return nil
  6672. case batchmsg.FieldSuccess:
  6673. v, ok := value.(int32)
  6674. if !ok {
  6675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6676. }
  6677. m.SetSuccess(v)
  6678. return nil
  6679. case batchmsg.FieldFail:
  6680. v, ok := value.(int32)
  6681. if !ok {
  6682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6683. }
  6684. m.SetFail(v)
  6685. return nil
  6686. case batchmsg.FieldStartTime:
  6687. v, ok := value.(time.Time)
  6688. if !ok {
  6689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6690. }
  6691. m.SetStartTime(v)
  6692. return nil
  6693. case batchmsg.FieldStopTime:
  6694. v, ok := value.(time.Time)
  6695. if !ok {
  6696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6697. }
  6698. m.SetStopTime(v)
  6699. return nil
  6700. case batchmsg.FieldSendTime:
  6701. v, ok := value.(time.Time)
  6702. if !ok {
  6703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6704. }
  6705. m.SetSendTime(v)
  6706. return nil
  6707. case batchmsg.FieldType:
  6708. v, ok := value.(int32)
  6709. if !ok {
  6710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6711. }
  6712. m.SetType(v)
  6713. return nil
  6714. case batchmsg.FieldOrganizationID:
  6715. v, ok := value.(uint64)
  6716. if !ok {
  6717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6718. }
  6719. m.SetOrganizationID(v)
  6720. return nil
  6721. case batchmsg.FieldCtype:
  6722. v, ok := value.(uint64)
  6723. if !ok {
  6724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6725. }
  6726. m.SetCtype(v)
  6727. return nil
  6728. case batchmsg.FieldCc:
  6729. v, ok := value.(string)
  6730. if !ok {
  6731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6732. }
  6733. m.SetCc(v)
  6734. return nil
  6735. case batchmsg.FieldPhone:
  6736. v, ok := value.(string)
  6737. if !ok {
  6738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6739. }
  6740. m.SetPhone(v)
  6741. return nil
  6742. case batchmsg.FieldTemplateName:
  6743. v, ok := value.(string)
  6744. if !ok {
  6745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6746. }
  6747. m.SetTemplateName(v)
  6748. return nil
  6749. case batchmsg.FieldTemplateCode:
  6750. v, ok := value.(string)
  6751. if !ok {
  6752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6753. }
  6754. m.SetTemplateCode(v)
  6755. return nil
  6756. case batchmsg.FieldLang:
  6757. v, ok := value.(string)
  6758. if !ok {
  6759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6760. }
  6761. m.SetLang(v)
  6762. return nil
  6763. }
  6764. return fmt.Errorf("unknown BatchMsg field %s", name)
  6765. }
  6766. // AddedFields returns all numeric fields that were incremented/decremented during
  6767. // this mutation.
  6768. func (m *BatchMsgMutation) AddedFields() []string {
  6769. var fields []string
  6770. if m.addstatus != nil {
  6771. fields = append(fields, batchmsg.FieldStatus)
  6772. }
  6773. if m.addtotal != nil {
  6774. fields = append(fields, batchmsg.FieldTotal)
  6775. }
  6776. if m.addsuccess != nil {
  6777. fields = append(fields, batchmsg.FieldSuccess)
  6778. }
  6779. if m.addfail != nil {
  6780. fields = append(fields, batchmsg.FieldFail)
  6781. }
  6782. if m.add_type != nil {
  6783. fields = append(fields, batchmsg.FieldType)
  6784. }
  6785. if m.addorganization_id != nil {
  6786. fields = append(fields, batchmsg.FieldOrganizationID)
  6787. }
  6788. if m.addctype != nil {
  6789. fields = append(fields, batchmsg.FieldCtype)
  6790. }
  6791. return fields
  6792. }
  6793. // AddedField returns the numeric value that was incremented/decremented on a field
  6794. // with the given name. The second boolean return value indicates that this field
  6795. // was not set, or was not defined in the schema.
  6796. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6797. switch name {
  6798. case batchmsg.FieldStatus:
  6799. return m.AddedStatus()
  6800. case batchmsg.FieldTotal:
  6801. return m.AddedTotal()
  6802. case batchmsg.FieldSuccess:
  6803. return m.AddedSuccess()
  6804. case batchmsg.FieldFail:
  6805. return m.AddedFail()
  6806. case batchmsg.FieldType:
  6807. return m.AddedType()
  6808. case batchmsg.FieldOrganizationID:
  6809. return m.AddedOrganizationID()
  6810. case batchmsg.FieldCtype:
  6811. return m.AddedCtype()
  6812. }
  6813. return nil, false
  6814. }
  6815. // AddField adds the value to the field with the given name. It returns an error if
  6816. // the field is not defined in the schema, or if the type mismatched the field
  6817. // type.
  6818. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6819. switch name {
  6820. case batchmsg.FieldStatus:
  6821. v, ok := value.(int8)
  6822. if !ok {
  6823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6824. }
  6825. m.AddStatus(v)
  6826. return nil
  6827. case batchmsg.FieldTotal:
  6828. v, ok := value.(int32)
  6829. if !ok {
  6830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6831. }
  6832. m.AddTotal(v)
  6833. return nil
  6834. case batchmsg.FieldSuccess:
  6835. v, ok := value.(int32)
  6836. if !ok {
  6837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6838. }
  6839. m.AddSuccess(v)
  6840. return nil
  6841. case batchmsg.FieldFail:
  6842. v, ok := value.(int32)
  6843. if !ok {
  6844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6845. }
  6846. m.AddFail(v)
  6847. return nil
  6848. case batchmsg.FieldType:
  6849. v, ok := value.(int32)
  6850. if !ok {
  6851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6852. }
  6853. m.AddType(v)
  6854. return nil
  6855. case batchmsg.FieldOrganizationID:
  6856. v, ok := value.(int64)
  6857. if !ok {
  6858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6859. }
  6860. m.AddOrganizationID(v)
  6861. return nil
  6862. case batchmsg.FieldCtype:
  6863. v, ok := value.(int64)
  6864. if !ok {
  6865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6866. }
  6867. m.AddCtype(v)
  6868. return nil
  6869. }
  6870. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6871. }
  6872. // ClearedFields returns all nullable fields that were cleared during this
  6873. // mutation.
  6874. func (m *BatchMsgMutation) ClearedFields() []string {
  6875. var fields []string
  6876. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6877. fields = append(fields, batchmsg.FieldDeletedAt)
  6878. }
  6879. if m.FieldCleared(batchmsg.FieldStatus) {
  6880. fields = append(fields, batchmsg.FieldStatus)
  6881. }
  6882. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6883. fields = append(fields, batchmsg.FieldBatchNo)
  6884. }
  6885. if m.FieldCleared(batchmsg.FieldTaskName) {
  6886. fields = append(fields, batchmsg.FieldTaskName)
  6887. }
  6888. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6889. fields = append(fields, batchmsg.FieldFromwxid)
  6890. }
  6891. if m.FieldCleared(batchmsg.FieldMsg) {
  6892. fields = append(fields, batchmsg.FieldMsg)
  6893. }
  6894. if m.FieldCleared(batchmsg.FieldTag) {
  6895. fields = append(fields, batchmsg.FieldTag)
  6896. }
  6897. if m.FieldCleared(batchmsg.FieldTagids) {
  6898. fields = append(fields, batchmsg.FieldTagids)
  6899. }
  6900. if m.FieldCleared(batchmsg.FieldTotal) {
  6901. fields = append(fields, batchmsg.FieldTotal)
  6902. }
  6903. if m.FieldCleared(batchmsg.FieldSuccess) {
  6904. fields = append(fields, batchmsg.FieldSuccess)
  6905. }
  6906. if m.FieldCleared(batchmsg.FieldFail) {
  6907. fields = append(fields, batchmsg.FieldFail)
  6908. }
  6909. if m.FieldCleared(batchmsg.FieldStartTime) {
  6910. fields = append(fields, batchmsg.FieldStartTime)
  6911. }
  6912. if m.FieldCleared(batchmsg.FieldStopTime) {
  6913. fields = append(fields, batchmsg.FieldStopTime)
  6914. }
  6915. if m.FieldCleared(batchmsg.FieldSendTime) {
  6916. fields = append(fields, batchmsg.FieldSendTime)
  6917. }
  6918. if m.FieldCleared(batchmsg.FieldType) {
  6919. fields = append(fields, batchmsg.FieldType)
  6920. }
  6921. if m.FieldCleared(batchmsg.FieldCc) {
  6922. fields = append(fields, batchmsg.FieldCc)
  6923. }
  6924. if m.FieldCleared(batchmsg.FieldPhone) {
  6925. fields = append(fields, batchmsg.FieldPhone)
  6926. }
  6927. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6928. fields = append(fields, batchmsg.FieldTemplateName)
  6929. }
  6930. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6931. fields = append(fields, batchmsg.FieldTemplateCode)
  6932. }
  6933. if m.FieldCleared(batchmsg.FieldLang) {
  6934. fields = append(fields, batchmsg.FieldLang)
  6935. }
  6936. return fields
  6937. }
  6938. // FieldCleared returns a boolean indicating if a field with the given name was
  6939. // cleared in this mutation.
  6940. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6941. _, ok := m.clearedFields[name]
  6942. return ok
  6943. }
  6944. // ClearField clears the value of the field with the given name. It returns an
  6945. // error if the field is not defined in the schema.
  6946. func (m *BatchMsgMutation) ClearField(name string) error {
  6947. switch name {
  6948. case batchmsg.FieldDeletedAt:
  6949. m.ClearDeletedAt()
  6950. return nil
  6951. case batchmsg.FieldStatus:
  6952. m.ClearStatus()
  6953. return nil
  6954. case batchmsg.FieldBatchNo:
  6955. m.ClearBatchNo()
  6956. return nil
  6957. case batchmsg.FieldTaskName:
  6958. m.ClearTaskName()
  6959. return nil
  6960. case batchmsg.FieldFromwxid:
  6961. m.ClearFromwxid()
  6962. return nil
  6963. case batchmsg.FieldMsg:
  6964. m.ClearMsg()
  6965. return nil
  6966. case batchmsg.FieldTag:
  6967. m.ClearTag()
  6968. return nil
  6969. case batchmsg.FieldTagids:
  6970. m.ClearTagids()
  6971. return nil
  6972. case batchmsg.FieldTotal:
  6973. m.ClearTotal()
  6974. return nil
  6975. case batchmsg.FieldSuccess:
  6976. m.ClearSuccess()
  6977. return nil
  6978. case batchmsg.FieldFail:
  6979. m.ClearFail()
  6980. return nil
  6981. case batchmsg.FieldStartTime:
  6982. m.ClearStartTime()
  6983. return nil
  6984. case batchmsg.FieldStopTime:
  6985. m.ClearStopTime()
  6986. return nil
  6987. case batchmsg.FieldSendTime:
  6988. m.ClearSendTime()
  6989. return nil
  6990. case batchmsg.FieldType:
  6991. m.ClearType()
  6992. return nil
  6993. case batchmsg.FieldCc:
  6994. m.ClearCc()
  6995. return nil
  6996. case batchmsg.FieldPhone:
  6997. m.ClearPhone()
  6998. return nil
  6999. case batchmsg.FieldTemplateName:
  7000. m.ClearTemplateName()
  7001. return nil
  7002. case batchmsg.FieldTemplateCode:
  7003. m.ClearTemplateCode()
  7004. return nil
  7005. case batchmsg.FieldLang:
  7006. m.ClearLang()
  7007. return nil
  7008. }
  7009. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7010. }
  7011. // ResetField resets all changes in the mutation for the field with the given name.
  7012. // It returns an error if the field is not defined in the schema.
  7013. func (m *BatchMsgMutation) ResetField(name string) error {
  7014. switch name {
  7015. case batchmsg.FieldCreatedAt:
  7016. m.ResetCreatedAt()
  7017. return nil
  7018. case batchmsg.FieldUpdatedAt:
  7019. m.ResetUpdatedAt()
  7020. return nil
  7021. case batchmsg.FieldDeletedAt:
  7022. m.ResetDeletedAt()
  7023. return nil
  7024. case batchmsg.FieldStatus:
  7025. m.ResetStatus()
  7026. return nil
  7027. case batchmsg.FieldBatchNo:
  7028. m.ResetBatchNo()
  7029. return nil
  7030. case batchmsg.FieldTaskName:
  7031. m.ResetTaskName()
  7032. return nil
  7033. case batchmsg.FieldFromwxid:
  7034. m.ResetFromwxid()
  7035. return nil
  7036. case batchmsg.FieldMsg:
  7037. m.ResetMsg()
  7038. return nil
  7039. case batchmsg.FieldTag:
  7040. m.ResetTag()
  7041. return nil
  7042. case batchmsg.FieldTagids:
  7043. m.ResetTagids()
  7044. return nil
  7045. case batchmsg.FieldTotal:
  7046. m.ResetTotal()
  7047. return nil
  7048. case batchmsg.FieldSuccess:
  7049. m.ResetSuccess()
  7050. return nil
  7051. case batchmsg.FieldFail:
  7052. m.ResetFail()
  7053. return nil
  7054. case batchmsg.FieldStartTime:
  7055. m.ResetStartTime()
  7056. return nil
  7057. case batchmsg.FieldStopTime:
  7058. m.ResetStopTime()
  7059. return nil
  7060. case batchmsg.FieldSendTime:
  7061. m.ResetSendTime()
  7062. return nil
  7063. case batchmsg.FieldType:
  7064. m.ResetType()
  7065. return nil
  7066. case batchmsg.FieldOrganizationID:
  7067. m.ResetOrganizationID()
  7068. return nil
  7069. case batchmsg.FieldCtype:
  7070. m.ResetCtype()
  7071. return nil
  7072. case batchmsg.FieldCc:
  7073. m.ResetCc()
  7074. return nil
  7075. case batchmsg.FieldPhone:
  7076. m.ResetPhone()
  7077. return nil
  7078. case batchmsg.FieldTemplateName:
  7079. m.ResetTemplateName()
  7080. return nil
  7081. case batchmsg.FieldTemplateCode:
  7082. m.ResetTemplateCode()
  7083. return nil
  7084. case batchmsg.FieldLang:
  7085. m.ResetLang()
  7086. return nil
  7087. }
  7088. return fmt.Errorf("unknown BatchMsg field %s", name)
  7089. }
  7090. // AddedEdges returns all edge names that were set/added in this mutation.
  7091. func (m *BatchMsgMutation) AddedEdges() []string {
  7092. edges := make([]string, 0, 0)
  7093. return edges
  7094. }
  7095. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7096. // name in this mutation.
  7097. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7098. return nil
  7099. }
  7100. // RemovedEdges returns all edge names that were removed in this mutation.
  7101. func (m *BatchMsgMutation) RemovedEdges() []string {
  7102. edges := make([]string, 0, 0)
  7103. return edges
  7104. }
  7105. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7106. // the given name in this mutation.
  7107. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7108. return nil
  7109. }
  7110. // ClearedEdges returns all edge names that were cleared in this mutation.
  7111. func (m *BatchMsgMutation) ClearedEdges() []string {
  7112. edges := make([]string, 0, 0)
  7113. return edges
  7114. }
  7115. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7116. // was cleared in this mutation.
  7117. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7118. return false
  7119. }
  7120. // ClearEdge clears the value of the edge with the given name. It returns an error
  7121. // if that edge is not defined in the schema.
  7122. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7123. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7124. }
  7125. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7126. // It returns an error if the edge is not defined in the schema.
  7127. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7128. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7129. }
  7130. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7131. type CategoryMutation struct {
  7132. config
  7133. op Op
  7134. typ string
  7135. id *uint64
  7136. created_at *time.Time
  7137. updated_at *time.Time
  7138. deleted_at *time.Time
  7139. name *string
  7140. organization_id *uint64
  7141. addorganization_id *int64
  7142. clearedFields map[string]struct{}
  7143. done bool
  7144. oldValue func(context.Context) (*Category, error)
  7145. predicates []predicate.Category
  7146. }
  7147. var _ ent.Mutation = (*CategoryMutation)(nil)
  7148. // categoryOption allows management of the mutation configuration using functional options.
  7149. type categoryOption func(*CategoryMutation)
  7150. // newCategoryMutation creates new mutation for the Category entity.
  7151. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7152. m := &CategoryMutation{
  7153. config: c,
  7154. op: op,
  7155. typ: TypeCategory,
  7156. clearedFields: make(map[string]struct{}),
  7157. }
  7158. for _, opt := range opts {
  7159. opt(m)
  7160. }
  7161. return m
  7162. }
  7163. // withCategoryID sets the ID field of the mutation.
  7164. func withCategoryID(id uint64) categoryOption {
  7165. return func(m *CategoryMutation) {
  7166. var (
  7167. err error
  7168. once sync.Once
  7169. value *Category
  7170. )
  7171. m.oldValue = func(ctx context.Context) (*Category, error) {
  7172. once.Do(func() {
  7173. if m.done {
  7174. err = errors.New("querying old values post mutation is not allowed")
  7175. } else {
  7176. value, err = m.Client().Category.Get(ctx, id)
  7177. }
  7178. })
  7179. return value, err
  7180. }
  7181. m.id = &id
  7182. }
  7183. }
  7184. // withCategory sets the old Category of the mutation.
  7185. func withCategory(node *Category) categoryOption {
  7186. return func(m *CategoryMutation) {
  7187. m.oldValue = func(context.Context) (*Category, error) {
  7188. return node, nil
  7189. }
  7190. m.id = &node.ID
  7191. }
  7192. }
  7193. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7194. // executed in a transaction (ent.Tx), a transactional client is returned.
  7195. func (m CategoryMutation) Client() *Client {
  7196. client := &Client{config: m.config}
  7197. client.init()
  7198. return client
  7199. }
  7200. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7201. // it returns an error otherwise.
  7202. func (m CategoryMutation) Tx() (*Tx, error) {
  7203. if _, ok := m.driver.(*txDriver); !ok {
  7204. return nil, errors.New("ent: mutation is not running in a transaction")
  7205. }
  7206. tx := &Tx{config: m.config}
  7207. tx.init()
  7208. return tx, nil
  7209. }
  7210. // SetID sets the value of the id field. Note that this
  7211. // operation is only accepted on creation of Category entities.
  7212. func (m *CategoryMutation) SetID(id uint64) {
  7213. m.id = &id
  7214. }
  7215. // ID returns the ID value in the mutation. Note that the ID is only available
  7216. // if it was provided to the builder or after it was returned from the database.
  7217. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7218. if m.id == nil {
  7219. return
  7220. }
  7221. return *m.id, true
  7222. }
  7223. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7224. // That means, if the mutation is applied within a transaction with an isolation level such
  7225. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7226. // or updated by the mutation.
  7227. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7228. switch {
  7229. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7230. id, exists := m.ID()
  7231. if exists {
  7232. return []uint64{id}, nil
  7233. }
  7234. fallthrough
  7235. case m.op.Is(OpUpdate | OpDelete):
  7236. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7237. default:
  7238. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7239. }
  7240. }
  7241. // SetCreatedAt sets the "created_at" field.
  7242. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7243. m.created_at = &t
  7244. }
  7245. // CreatedAt returns the value of the "created_at" field in the mutation.
  7246. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7247. v := m.created_at
  7248. if v == nil {
  7249. return
  7250. }
  7251. return *v, true
  7252. }
  7253. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7254. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7256. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7257. if !m.op.Is(OpUpdateOne) {
  7258. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7259. }
  7260. if m.id == nil || m.oldValue == nil {
  7261. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7262. }
  7263. oldValue, err := m.oldValue(ctx)
  7264. if err != nil {
  7265. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7266. }
  7267. return oldValue.CreatedAt, nil
  7268. }
  7269. // ResetCreatedAt resets all changes to the "created_at" field.
  7270. func (m *CategoryMutation) ResetCreatedAt() {
  7271. m.created_at = nil
  7272. }
  7273. // SetUpdatedAt sets the "updated_at" field.
  7274. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7275. m.updated_at = &t
  7276. }
  7277. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7278. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7279. v := m.updated_at
  7280. if v == nil {
  7281. return
  7282. }
  7283. return *v, true
  7284. }
  7285. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7286. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7288. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7289. if !m.op.Is(OpUpdateOne) {
  7290. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7291. }
  7292. if m.id == nil || m.oldValue == nil {
  7293. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7294. }
  7295. oldValue, err := m.oldValue(ctx)
  7296. if err != nil {
  7297. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7298. }
  7299. return oldValue.UpdatedAt, nil
  7300. }
  7301. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7302. func (m *CategoryMutation) ResetUpdatedAt() {
  7303. m.updated_at = nil
  7304. }
  7305. // SetDeletedAt sets the "deleted_at" field.
  7306. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7307. m.deleted_at = &t
  7308. }
  7309. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7310. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7311. v := m.deleted_at
  7312. if v == nil {
  7313. return
  7314. }
  7315. return *v, true
  7316. }
  7317. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7318. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7320. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7321. if !m.op.Is(OpUpdateOne) {
  7322. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7323. }
  7324. if m.id == nil || m.oldValue == nil {
  7325. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7326. }
  7327. oldValue, err := m.oldValue(ctx)
  7328. if err != nil {
  7329. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7330. }
  7331. return oldValue.DeletedAt, nil
  7332. }
  7333. // ClearDeletedAt clears the value of the "deleted_at" field.
  7334. func (m *CategoryMutation) ClearDeletedAt() {
  7335. m.deleted_at = nil
  7336. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7337. }
  7338. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7339. func (m *CategoryMutation) DeletedAtCleared() bool {
  7340. _, ok := m.clearedFields[category.FieldDeletedAt]
  7341. return ok
  7342. }
  7343. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7344. func (m *CategoryMutation) ResetDeletedAt() {
  7345. m.deleted_at = nil
  7346. delete(m.clearedFields, category.FieldDeletedAt)
  7347. }
  7348. // SetName sets the "name" field.
  7349. func (m *CategoryMutation) SetName(s string) {
  7350. m.name = &s
  7351. }
  7352. // Name returns the value of the "name" field in the mutation.
  7353. func (m *CategoryMutation) Name() (r string, exists bool) {
  7354. v := m.name
  7355. if v == nil {
  7356. return
  7357. }
  7358. return *v, true
  7359. }
  7360. // OldName returns the old "name" field's value of the Category entity.
  7361. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7363. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7364. if !m.op.Is(OpUpdateOne) {
  7365. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7366. }
  7367. if m.id == nil || m.oldValue == nil {
  7368. return v, errors.New("OldName requires an ID field in the mutation")
  7369. }
  7370. oldValue, err := m.oldValue(ctx)
  7371. if err != nil {
  7372. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7373. }
  7374. return oldValue.Name, nil
  7375. }
  7376. // ResetName resets all changes to the "name" field.
  7377. func (m *CategoryMutation) ResetName() {
  7378. m.name = nil
  7379. }
  7380. // SetOrganizationID sets the "organization_id" field.
  7381. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7382. m.organization_id = &u
  7383. m.addorganization_id = nil
  7384. }
  7385. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7386. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7387. v := m.organization_id
  7388. if v == nil {
  7389. return
  7390. }
  7391. return *v, true
  7392. }
  7393. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7394. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7396. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7397. if !m.op.Is(OpUpdateOne) {
  7398. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7399. }
  7400. if m.id == nil || m.oldValue == nil {
  7401. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7402. }
  7403. oldValue, err := m.oldValue(ctx)
  7404. if err != nil {
  7405. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7406. }
  7407. return oldValue.OrganizationID, nil
  7408. }
  7409. // AddOrganizationID adds u to the "organization_id" field.
  7410. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7411. if m.addorganization_id != nil {
  7412. *m.addorganization_id += u
  7413. } else {
  7414. m.addorganization_id = &u
  7415. }
  7416. }
  7417. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7418. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7419. v := m.addorganization_id
  7420. if v == nil {
  7421. return
  7422. }
  7423. return *v, true
  7424. }
  7425. // ResetOrganizationID resets all changes to the "organization_id" field.
  7426. func (m *CategoryMutation) ResetOrganizationID() {
  7427. m.organization_id = nil
  7428. m.addorganization_id = nil
  7429. }
  7430. // Where appends a list predicates to the CategoryMutation builder.
  7431. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7432. m.predicates = append(m.predicates, ps...)
  7433. }
  7434. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7435. // users can use type-assertion to append predicates that do not depend on any generated package.
  7436. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7437. p := make([]predicate.Category, len(ps))
  7438. for i := range ps {
  7439. p[i] = ps[i]
  7440. }
  7441. m.Where(p...)
  7442. }
  7443. // Op returns the operation name.
  7444. func (m *CategoryMutation) Op() Op {
  7445. return m.op
  7446. }
  7447. // SetOp allows setting the mutation operation.
  7448. func (m *CategoryMutation) SetOp(op Op) {
  7449. m.op = op
  7450. }
  7451. // Type returns the node type of this mutation (Category).
  7452. func (m *CategoryMutation) Type() string {
  7453. return m.typ
  7454. }
  7455. // Fields returns all fields that were changed during this mutation. Note that in
  7456. // order to get all numeric fields that were incremented/decremented, call
  7457. // AddedFields().
  7458. func (m *CategoryMutation) Fields() []string {
  7459. fields := make([]string, 0, 5)
  7460. if m.created_at != nil {
  7461. fields = append(fields, category.FieldCreatedAt)
  7462. }
  7463. if m.updated_at != nil {
  7464. fields = append(fields, category.FieldUpdatedAt)
  7465. }
  7466. if m.deleted_at != nil {
  7467. fields = append(fields, category.FieldDeletedAt)
  7468. }
  7469. if m.name != nil {
  7470. fields = append(fields, category.FieldName)
  7471. }
  7472. if m.organization_id != nil {
  7473. fields = append(fields, category.FieldOrganizationID)
  7474. }
  7475. return fields
  7476. }
  7477. // Field returns the value of a field with the given name. The second boolean
  7478. // return value indicates that this field was not set, or was not defined in the
  7479. // schema.
  7480. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7481. switch name {
  7482. case category.FieldCreatedAt:
  7483. return m.CreatedAt()
  7484. case category.FieldUpdatedAt:
  7485. return m.UpdatedAt()
  7486. case category.FieldDeletedAt:
  7487. return m.DeletedAt()
  7488. case category.FieldName:
  7489. return m.Name()
  7490. case category.FieldOrganizationID:
  7491. return m.OrganizationID()
  7492. }
  7493. return nil, false
  7494. }
  7495. // OldField returns the old value of the field from the database. An error is
  7496. // returned if the mutation operation is not UpdateOne, or the query to the
  7497. // database failed.
  7498. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7499. switch name {
  7500. case category.FieldCreatedAt:
  7501. return m.OldCreatedAt(ctx)
  7502. case category.FieldUpdatedAt:
  7503. return m.OldUpdatedAt(ctx)
  7504. case category.FieldDeletedAt:
  7505. return m.OldDeletedAt(ctx)
  7506. case category.FieldName:
  7507. return m.OldName(ctx)
  7508. case category.FieldOrganizationID:
  7509. return m.OldOrganizationID(ctx)
  7510. }
  7511. return nil, fmt.Errorf("unknown Category field %s", name)
  7512. }
  7513. // SetField sets the value of a field with the given name. It returns an error if
  7514. // the field is not defined in the schema, or if the type mismatched the field
  7515. // type.
  7516. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7517. switch name {
  7518. case category.FieldCreatedAt:
  7519. v, ok := value.(time.Time)
  7520. if !ok {
  7521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7522. }
  7523. m.SetCreatedAt(v)
  7524. return nil
  7525. case category.FieldUpdatedAt:
  7526. v, ok := value.(time.Time)
  7527. if !ok {
  7528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7529. }
  7530. m.SetUpdatedAt(v)
  7531. return nil
  7532. case category.FieldDeletedAt:
  7533. v, ok := value.(time.Time)
  7534. if !ok {
  7535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7536. }
  7537. m.SetDeletedAt(v)
  7538. return nil
  7539. case category.FieldName:
  7540. v, ok := value.(string)
  7541. if !ok {
  7542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7543. }
  7544. m.SetName(v)
  7545. return nil
  7546. case category.FieldOrganizationID:
  7547. v, ok := value.(uint64)
  7548. if !ok {
  7549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7550. }
  7551. m.SetOrganizationID(v)
  7552. return nil
  7553. }
  7554. return fmt.Errorf("unknown Category field %s", name)
  7555. }
  7556. // AddedFields returns all numeric fields that were incremented/decremented during
  7557. // this mutation.
  7558. func (m *CategoryMutation) AddedFields() []string {
  7559. var fields []string
  7560. if m.addorganization_id != nil {
  7561. fields = append(fields, category.FieldOrganizationID)
  7562. }
  7563. return fields
  7564. }
  7565. // AddedField returns the numeric value that was incremented/decremented on a field
  7566. // with the given name. The second boolean return value indicates that this field
  7567. // was not set, or was not defined in the schema.
  7568. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7569. switch name {
  7570. case category.FieldOrganizationID:
  7571. return m.AddedOrganizationID()
  7572. }
  7573. return nil, false
  7574. }
  7575. // AddField adds the value to the field with the given name. It returns an error if
  7576. // the field is not defined in the schema, or if the type mismatched the field
  7577. // type.
  7578. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7579. switch name {
  7580. case category.FieldOrganizationID:
  7581. v, ok := value.(int64)
  7582. if !ok {
  7583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7584. }
  7585. m.AddOrganizationID(v)
  7586. return nil
  7587. }
  7588. return fmt.Errorf("unknown Category numeric field %s", name)
  7589. }
  7590. // ClearedFields returns all nullable fields that were cleared during this
  7591. // mutation.
  7592. func (m *CategoryMutation) ClearedFields() []string {
  7593. var fields []string
  7594. if m.FieldCleared(category.FieldDeletedAt) {
  7595. fields = append(fields, category.FieldDeletedAt)
  7596. }
  7597. return fields
  7598. }
  7599. // FieldCleared returns a boolean indicating if a field with the given name was
  7600. // cleared in this mutation.
  7601. func (m *CategoryMutation) FieldCleared(name string) bool {
  7602. _, ok := m.clearedFields[name]
  7603. return ok
  7604. }
  7605. // ClearField clears the value of the field with the given name. It returns an
  7606. // error if the field is not defined in the schema.
  7607. func (m *CategoryMutation) ClearField(name string) error {
  7608. switch name {
  7609. case category.FieldDeletedAt:
  7610. m.ClearDeletedAt()
  7611. return nil
  7612. }
  7613. return fmt.Errorf("unknown Category nullable field %s", name)
  7614. }
  7615. // ResetField resets all changes in the mutation for the field with the given name.
  7616. // It returns an error if the field is not defined in the schema.
  7617. func (m *CategoryMutation) ResetField(name string) error {
  7618. switch name {
  7619. case category.FieldCreatedAt:
  7620. m.ResetCreatedAt()
  7621. return nil
  7622. case category.FieldUpdatedAt:
  7623. m.ResetUpdatedAt()
  7624. return nil
  7625. case category.FieldDeletedAt:
  7626. m.ResetDeletedAt()
  7627. return nil
  7628. case category.FieldName:
  7629. m.ResetName()
  7630. return nil
  7631. case category.FieldOrganizationID:
  7632. m.ResetOrganizationID()
  7633. return nil
  7634. }
  7635. return fmt.Errorf("unknown Category field %s", name)
  7636. }
  7637. // AddedEdges returns all edge names that were set/added in this mutation.
  7638. func (m *CategoryMutation) AddedEdges() []string {
  7639. edges := make([]string, 0, 0)
  7640. return edges
  7641. }
  7642. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7643. // name in this mutation.
  7644. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7645. return nil
  7646. }
  7647. // RemovedEdges returns all edge names that were removed in this mutation.
  7648. func (m *CategoryMutation) RemovedEdges() []string {
  7649. edges := make([]string, 0, 0)
  7650. return edges
  7651. }
  7652. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7653. // the given name in this mutation.
  7654. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7655. return nil
  7656. }
  7657. // ClearedEdges returns all edge names that were cleared in this mutation.
  7658. func (m *CategoryMutation) ClearedEdges() []string {
  7659. edges := make([]string, 0, 0)
  7660. return edges
  7661. }
  7662. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7663. // was cleared in this mutation.
  7664. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7665. return false
  7666. }
  7667. // ClearEdge clears the value of the edge with the given name. It returns an error
  7668. // if that edge is not defined in the schema.
  7669. func (m *CategoryMutation) ClearEdge(name string) error {
  7670. return fmt.Errorf("unknown Category unique edge %s", name)
  7671. }
  7672. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7673. // It returns an error if the edge is not defined in the schema.
  7674. func (m *CategoryMutation) ResetEdge(name string) error {
  7675. return fmt.Errorf("unknown Category edge %s", name)
  7676. }
  7677. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7678. type ChatRecordsMutation struct {
  7679. config
  7680. op Op
  7681. typ string
  7682. id *uint64
  7683. created_at *time.Time
  7684. updated_at *time.Time
  7685. deleted_at *time.Time
  7686. content *string
  7687. content_type *uint8
  7688. addcontent_type *int8
  7689. session_id *uint64
  7690. addsession_id *int64
  7691. user_id *uint64
  7692. adduser_id *int64
  7693. bot_id *uint64
  7694. addbot_id *int64
  7695. bot_type *uint8
  7696. addbot_type *int8
  7697. clearedFields map[string]struct{}
  7698. done bool
  7699. oldValue func(context.Context) (*ChatRecords, error)
  7700. predicates []predicate.ChatRecords
  7701. }
  7702. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7703. // chatrecordsOption allows management of the mutation configuration using functional options.
  7704. type chatrecordsOption func(*ChatRecordsMutation)
  7705. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7706. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7707. m := &ChatRecordsMutation{
  7708. config: c,
  7709. op: op,
  7710. typ: TypeChatRecords,
  7711. clearedFields: make(map[string]struct{}),
  7712. }
  7713. for _, opt := range opts {
  7714. opt(m)
  7715. }
  7716. return m
  7717. }
  7718. // withChatRecordsID sets the ID field of the mutation.
  7719. func withChatRecordsID(id uint64) chatrecordsOption {
  7720. return func(m *ChatRecordsMutation) {
  7721. var (
  7722. err error
  7723. once sync.Once
  7724. value *ChatRecords
  7725. )
  7726. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7727. once.Do(func() {
  7728. if m.done {
  7729. err = errors.New("querying old values post mutation is not allowed")
  7730. } else {
  7731. value, err = m.Client().ChatRecords.Get(ctx, id)
  7732. }
  7733. })
  7734. return value, err
  7735. }
  7736. m.id = &id
  7737. }
  7738. }
  7739. // withChatRecords sets the old ChatRecords of the mutation.
  7740. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7741. return func(m *ChatRecordsMutation) {
  7742. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7743. return node, nil
  7744. }
  7745. m.id = &node.ID
  7746. }
  7747. }
  7748. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7749. // executed in a transaction (ent.Tx), a transactional client is returned.
  7750. func (m ChatRecordsMutation) Client() *Client {
  7751. client := &Client{config: m.config}
  7752. client.init()
  7753. return client
  7754. }
  7755. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7756. // it returns an error otherwise.
  7757. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7758. if _, ok := m.driver.(*txDriver); !ok {
  7759. return nil, errors.New("ent: mutation is not running in a transaction")
  7760. }
  7761. tx := &Tx{config: m.config}
  7762. tx.init()
  7763. return tx, nil
  7764. }
  7765. // SetID sets the value of the id field. Note that this
  7766. // operation is only accepted on creation of ChatRecords entities.
  7767. func (m *ChatRecordsMutation) SetID(id uint64) {
  7768. m.id = &id
  7769. }
  7770. // ID returns the ID value in the mutation. Note that the ID is only available
  7771. // if it was provided to the builder or after it was returned from the database.
  7772. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7773. if m.id == nil {
  7774. return
  7775. }
  7776. return *m.id, true
  7777. }
  7778. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7779. // That means, if the mutation is applied within a transaction with an isolation level such
  7780. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7781. // or updated by the mutation.
  7782. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7783. switch {
  7784. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7785. id, exists := m.ID()
  7786. if exists {
  7787. return []uint64{id}, nil
  7788. }
  7789. fallthrough
  7790. case m.op.Is(OpUpdate | OpDelete):
  7791. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7792. default:
  7793. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7794. }
  7795. }
  7796. // SetCreatedAt sets the "created_at" field.
  7797. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7798. m.created_at = &t
  7799. }
  7800. // CreatedAt returns the value of the "created_at" field in the mutation.
  7801. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7802. v := m.created_at
  7803. if v == nil {
  7804. return
  7805. }
  7806. return *v, true
  7807. }
  7808. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7809. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7811. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7812. if !m.op.Is(OpUpdateOne) {
  7813. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7814. }
  7815. if m.id == nil || m.oldValue == nil {
  7816. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7817. }
  7818. oldValue, err := m.oldValue(ctx)
  7819. if err != nil {
  7820. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7821. }
  7822. return oldValue.CreatedAt, nil
  7823. }
  7824. // ResetCreatedAt resets all changes to the "created_at" field.
  7825. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7826. m.created_at = nil
  7827. }
  7828. // SetUpdatedAt sets the "updated_at" field.
  7829. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7830. m.updated_at = &t
  7831. }
  7832. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7833. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7834. v := m.updated_at
  7835. if v == nil {
  7836. return
  7837. }
  7838. return *v, true
  7839. }
  7840. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7841. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7843. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7844. if !m.op.Is(OpUpdateOne) {
  7845. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7846. }
  7847. if m.id == nil || m.oldValue == nil {
  7848. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7849. }
  7850. oldValue, err := m.oldValue(ctx)
  7851. if err != nil {
  7852. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7853. }
  7854. return oldValue.UpdatedAt, nil
  7855. }
  7856. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7857. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7858. m.updated_at = nil
  7859. }
  7860. // SetDeletedAt sets the "deleted_at" field.
  7861. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7862. m.deleted_at = &t
  7863. }
  7864. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7865. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7866. v := m.deleted_at
  7867. if v == nil {
  7868. return
  7869. }
  7870. return *v, true
  7871. }
  7872. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7873. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7875. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7876. if !m.op.Is(OpUpdateOne) {
  7877. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7878. }
  7879. if m.id == nil || m.oldValue == nil {
  7880. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7881. }
  7882. oldValue, err := m.oldValue(ctx)
  7883. if err != nil {
  7884. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7885. }
  7886. return oldValue.DeletedAt, nil
  7887. }
  7888. // ClearDeletedAt clears the value of the "deleted_at" field.
  7889. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7890. m.deleted_at = nil
  7891. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7892. }
  7893. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7894. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7895. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7896. return ok
  7897. }
  7898. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7899. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7900. m.deleted_at = nil
  7901. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7902. }
  7903. // SetContent sets the "content" field.
  7904. func (m *ChatRecordsMutation) SetContent(s string) {
  7905. m.content = &s
  7906. }
  7907. // Content returns the value of the "content" field in the mutation.
  7908. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7909. v := m.content
  7910. if v == nil {
  7911. return
  7912. }
  7913. return *v, true
  7914. }
  7915. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7916. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7918. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7919. if !m.op.Is(OpUpdateOne) {
  7920. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7921. }
  7922. if m.id == nil || m.oldValue == nil {
  7923. return v, errors.New("OldContent requires an ID field in the mutation")
  7924. }
  7925. oldValue, err := m.oldValue(ctx)
  7926. if err != nil {
  7927. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7928. }
  7929. return oldValue.Content, nil
  7930. }
  7931. // ResetContent resets all changes to the "content" field.
  7932. func (m *ChatRecordsMutation) ResetContent() {
  7933. m.content = nil
  7934. }
  7935. // SetContentType sets the "content_type" field.
  7936. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7937. m.content_type = &u
  7938. m.addcontent_type = nil
  7939. }
  7940. // ContentType returns the value of the "content_type" field in the mutation.
  7941. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7942. v := m.content_type
  7943. if v == nil {
  7944. return
  7945. }
  7946. return *v, true
  7947. }
  7948. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7949. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7951. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7952. if !m.op.Is(OpUpdateOne) {
  7953. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7954. }
  7955. if m.id == nil || m.oldValue == nil {
  7956. return v, errors.New("OldContentType requires an ID field in the mutation")
  7957. }
  7958. oldValue, err := m.oldValue(ctx)
  7959. if err != nil {
  7960. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7961. }
  7962. return oldValue.ContentType, nil
  7963. }
  7964. // AddContentType adds u to the "content_type" field.
  7965. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7966. if m.addcontent_type != nil {
  7967. *m.addcontent_type += u
  7968. } else {
  7969. m.addcontent_type = &u
  7970. }
  7971. }
  7972. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7973. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7974. v := m.addcontent_type
  7975. if v == nil {
  7976. return
  7977. }
  7978. return *v, true
  7979. }
  7980. // ResetContentType resets all changes to the "content_type" field.
  7981. func (m *ChatRecordsMutation) ResetContentType() {
  7982. m.content_type = nil
  7983. m.addcontent_type = nil
  7984. }
  7985. // SetSessionID sets the "session_id" field.
  7986. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7987. m.session_id = &u
  7988. m.addsession_id = nil
  7989. }
  7990. // SessionID returns the value of the "session_id" field in the mutation.
  7991. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7992. v := m.session_id
  7993. if v == nil {
  7994. return
  7995. }
  7996. return *v, true
  7997. }
  7998. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7999. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8001. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8002. if !m.op.Is(OpUpdateOne) {
  8003. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8004. }
  8005. if m.id == nil || m.oldValue == nil {
  8006. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8007. }
  8008. oldValue, err := m.oldValue(ctx)
  8009. if err != nil {
  8010. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8011. }
  8012. return oldValue.SessionID, nil
  8013. }
  8014. // AddSessionID adds u to the "session_id" field.
  8015. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8016. if m.addsession_id != nil {
  8017. *m.addsession_id += u
  8018. } else {
  8019. m.addsession_id = &u
  8020. }
  8021. }
  8022. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8023. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8024. v := m.addsession_id
  8025. if v == nil {
  8026. return
  8027. }
  8028. return *v, true
  8029. }
  8030. // ResetSessionID resets all changes to the "session_id" field.
  8031. func (m *ChatRecordsMutation) ResetSessionID() {
  8032. m.session_id = nil
  8033. m.addsession_id = nil
  8034. }
  8035. // SetUserID sets the "user_id" field.
  8036. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8037. m.user_id = &u
  8038. m.adduser_id = nil
  8039. }
  8040. // UserID returns the value of the "user_id" field in the mutation.
  8041. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8042. v := m.user_id
  8043. if v == nil {
  8044. return
  8045. }
  8046. return *v, true
  8047. }
  8048. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8049. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8051. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8052. if !m.op.Is(OpUpdateOne) {
  8053. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8054. }
  8055. if m.id == nil || m.oldValue == nil {
  8056. return v, errors.New("OldUserID requires an ID field in the mutation")
  8057. }
  8058. oldValue, err := m.oldValue(ctx)
  8059. if err != nil {
  8060. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8061. }
  8062. return oldValue.UserID, nil
  8063. }
  8064. // AddUserID adds u to the "user_id" field.
  8065. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8066. if m.adduser_id != nil {
  8067. *m.adduser_id += u
  8068. } else {
  8069. m.adduser_id = &u
  8070. }
  8071. }
  8072. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8073. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8074. v := m.adduser_id
  8075. if v == nil {
  8076. return
  8077. }
  8078. return *v, true
  8079. }
  8080. // ResetUserID resets all changes to the "user_id" field.
  8081. func (m *ChatRecordsMutation) ResetUserID() {
  8082. m.user_id = nil
  8083. m.adduser_id = nil
  8084. }
  8085. // SetBotID sets the "bot_id" field.
  8086. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8087. m.bot_id = &u
  8088. m.addbot_id = nil
  8089. }
  8090. // BotID returns the value of the "bot_id" field in the mutation.
  8091. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8092. v := m.bot_id
  8093. if v == nil {
  8094. return
  8095. }
  8096. return *v, true
  8097. }
  8098. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8099. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8101. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8102. if !m.op.Is(OpUpdateOne) {
  8103. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8104. }
  8105. if m.id == nil || m.oldValue == nil {
  8106. return v, errors.New("OldBotID requires an ID field in the mutation")
  8107. }
  8108. oldValue, err := m.oldValue(ctx)
  8109. if err != nil {
  8110. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8111. }
  8112. return oldValue.BotID, nil
  8113. }
  8114. // AddBotID adds u to the "bot_id" field.
  8115. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8116. if m.addbot_id != nil {
  8117. *m.addbot_id += u
  8118. } else {
  8119. m.addbot_id = &u
  8120. }
  8121. }
  8122. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8123. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8124. v := m.addbot_id
  8125. if v == nil {
  8126. return
  8127. }
  8128. return *v, true
  8129. }
  8130. // ResetBotID resets all changes to the "bot_id" field.
  8131. func (m *ChatRecordsMutation) ResetBotID() {
  8132. m.bot_id = nil
  8133. m.addbot_id = nil
  8134. }
  8135. // SetBotType sets the "bot_type" field.
  8136. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8137. m.bot_type = &u
  8138. m.addbot_type = nil
  8139. }
  8140. // BotType returns the value of the "bot_type" field in the mutation.
  8141. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8142. v := m.bot_type
  8143. if v == nil {
  8144. return
  8145. }
  8146. return *v, true
  8147. }
  8148. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8149. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8151. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8152. if !m.op.Is(OpUpdateOne) {
  8153. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8154. }
  8155. if m.id == nil || m.oldValue == nil {
  8156. return v, errors.New("OldBotType requires an ID field in the mutation")
  8157. }
  8158. oldValue, err := m.oldValue(ctx)
  8159. if err != nil {
  8160. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8161. }
  8162. return oldValue.BotType, nil
  8163. }
  8164. // AddBotType adds u to the "bot_type" field.
  8165. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8166. if m.addbot_type != nil {
  8167. *m.addbot_type += u
  8168. } else {
  8169. m.addbot_type = &u
  8170. }
  8171. }
  8172. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8173. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8174. v := m.addbot_type
  8175. if v == nil {
  8176. return
  8177. }
  8178. return *v, true
  8179. }
  8180. // ResetBotType resets all changes to the "bot_type" field.
  8181. func (m *ChatRecordsMutation) ResetBotType() {
  8182. m.bot_type = nil
  8183. m.addbot_type = nil
  8184. }
  8185. // Where appends a list predicates to the ChatRecordsMutation builder.
  8186. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8187. m.predicates = append(m.predicates, ps...)
  8188. }
  8189. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8190. // users can use type-assertion to append predicates that do not depend on any generated package.
  8191. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8192. p := make([]predicate.ChatRecords, len(ps))
  8193. for i := range ps {
  8194. p[i] = ps[i]
  8195. }
  8196. m.Where(p...)
  8197. }
  8198. // Op returns the operation name.
  8199. func (m *ChatRecordsMutation) Op() Op {
  8200. return m.op
  8201. }
  8202. // SetOp allows setting the mutation operation.
  8203. func (m *ChatRecordsMutation) SetOp(op Op) {
  8204. m.op = op
  8205. }
  8206. // Type returns the node type of this mutation (ChatRecords).
  8207. func (m *ChatRecordsMutation) Type() string {
  8208. return m.typ
  8209. }
  8210. // Fields returns all fields that were changed during this mutation. Note that in
  8211. // order to get all numeric fields that were incremented/decremented, call
  8212. // AddedFields().
  8213. func (m *ChatRecordsMutation) Fields() []string {
  8214. fields := make([]string, 0, 9)
  8215. if m.created_at != nil {
  8216. fields = append(fields, chatrecords.FieldCreatedAt)
  8217. }
  8218. if m.updated_at != nil {
  8219. fields = append(fields, chatrecords.FieldUpdatedAt)
  8220. }
  8221. if m.deleted_at != nil {
  8222. fields = append(fields, chatrecords.FieldDeletedAt)
  8223. }
  8224. if m.content != nil {
  8225. fields = append(fields, chatrecords.FieldContent)
  8226. }
  8227. if m.content_type != nil {
  8228. fields = append(fields, chatrecords.FieldContentType)
  8229. }
  8230. if m.session_id != nil {
  8231. fields = append(fields, chatrecords.FieldSessionID)
  8232. }
  8233. if m.user_id != nil {
  8234. fields = append(fields, chatrecords.FieldUserID)
  8235. }
  8236. if m.bot_id != nil {
  8237. fields = append(fields, chatrecords.FieldBotID)
  8238. }
  8239. if m.bot_type != nil {
  8240. fields = append(fields, chatrecords.FieldBotType)
  8241. }
  8242. return fields
  8243. }
  8244. // Field returns the value of a field with the given name. The second boolean
  8245. // return value indicates that this field was not set, or was not defined in the
  8246. // schema.
  8247. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8248. switch name {
  8249. case chatrecords.FieldCreatedAt:
  8250. return m.CreatedAt()
  8251. case chatrecords.FieldUpdatedAt:
  8252. return m.UpdatedAt()
  8253. case chatrecords.FieldDeletedAt:
  8254. return m.DeletedAt()
  8255. case chatrecords.FieldContent:
  8256. return m.Content()
  8257. case chatrecords.FieldContentType:
  8258. return m.ContentType()
  8259. case chatrecords.FieldSessionID:
  8260. return m.SessionID()
  8261. case chatrecords.FieldUserID:
  8262. return m.UserID()
  8263. case chatrecords.FieldBotID:
  8264. return m.BotID()
  8265. case chatrecords.FieldBotType:
  8266. return m.BotType()
  8267. }
  8268. return nil, false
  8269. }
  8270. // OldField returns the old value of the field from the database. An error is
  8271. // returned if the mutation operation is not UpdateOne, or the query to the
  8272. // database failed.
  8273. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8274. switch name {
  8275. case chatrecords.FieldCreatedAt:
  8276. return m.OldCreatedAt(ctx)
  8277. case chatrecords.FieldUpdatedAt:
  8278. return m.OldUpdatedAt(ctx)
  8279. case chatrecords.FieldDeletedAt:
  8280. return m.OldDeletedAt(ctx)
  8281. case chatrecords.FieldContent:
  8282. return m.OldContent(ctx)
  8283. case chatrecords.FieldContentType:
  8284. return m.OldContentType(ctx)
  8285. case chatrecords.FieldSessionID:
  8286. return m.OldSessionID(ctx)
  8287. case chatrecords.FieldUserID:
  8288. return m.OldUserID(ctx)
  8289. case chatrecords.FieldBotID:
  8290. return m.OldBotID(ctx)
  8291. case chatrecords.FieldBotType:
  8292. return m.OldBotType(ctx)
  8293. }
  8294. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8295. }
  8296. // SetField sets the value of a field with the given name. It returns an error if
  8297. // the field is not defined in the schema, or if the type mismatched the field
  8298. // type.
  8299. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8300. switch name {
  8301. case chatrecords.FieldCreatedAt:
  8302. v, ok := value.(time.Time)
  8303. if !ok {
  8304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8305. }
  8306. m.SetCreatedAt(v)
  8307. return nil
  8308. case chatrecords.FieldUpdatedAt:
  8309. v, ok := value.(time.Time)
  8310. if !ok {
  8311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8312. }
  8313. m.SetUpdatedAt(v)
  8314. return nil
  8315. case chatrecords.FieldDeletedAt:
  8316. v, ok := value.(time.Time)
  8317. if !ok {
  8318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8319. }
  8320. m.SetDeletedAt(v)
  8321. return nil
  8322. case chatrecords.FieldContent:
  8323. v, ok := value.(string)
  8324. if !ok {
  8325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8326. }
  8327. m.SetContent(v)
  8328. return nil
  8329. case chatrecords.FieldContentType:
  8330. v, ok := value.(uint8)
  8331. if !ok {
  8332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8333. }
  8334. m.SetContentType(v)
  8335. return nil
  8336. case chatrecords.FieldSessionID:
  8337. v, ok := value.(uint64)
  8338. if !ok {
  8339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8340. }
  8341. m.SetSessionID(v)
  8342. return nil
  8343. case chatrecords.FieldUserID:
  8344. v, ok := value.(uint64)
  8345. if !ok {
  8346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8347. }
  8348. m.SetUserID(v)
  8349. return nil
  8350. case chatrecords.FieldBotID:
  8351. v, ok := value.(uint64)
  8352. if !ok {
  8353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8354. }
  8355. m.SetBotID(v)
  8356. return nil
  8357. case chatrecords.FieldBotType:
  8358. v, ok := value.(uint8)
  8359. if !ok {
  8360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8361. }
  8362. m.SetBotType(v)
  8363. return nil
  8364. }
  8365. return fmt.Errorf("unknown ChatRecords field %s", name)
  8366. }
  8367. // AddedFields returns all numeric fields that were incremented/decremented during
  8368. // this mutation.
  8369. func (m *ChatRecordsMutation) AddedFields() []string {
  8370. var fields []string
  8371. if m.addcontent_type != nil {
  8372. fields = append(fields, chatrecords.FieldContentType)
  8373. }
  8374. if m.addsession_id != nil {
  8375. fields = append(fields, chatrecords.FieldSessionID)
  8376. }
  8377. if m.adduser_id != nil {
  8378. fields = append(fields, chatrecords.FieldUserID)
  8379. }
  8380. if m.addbot_id != nil {
  8381. fields = append(fields, chatrecords.FieldBotID)
  8382. }
  8383. if m.addbot_type != nil {
  8384. fields = append(fields, chatrecords.FieldBotType)
  8385. }
  8386. return fields
  8387. }
  8388. // AddedField returns the numeric value that was incremented/decremented on a field
  8389. // with the given name. The second boolean return value indicates that this field
  8390. // was not set, or was not defined in the schema.
  8391. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8392. switch name {
  8393. case chatrecords.FieldContentType:
  8394. return m.AddedContentType()
  8395. case chatrecords.FieldSessionID:
  8396. return m.AddedSessionID()
  8397. case chatrecords.FieldUserID:
  8398. return m.AddedUserID()
  8399. case chatrecords.FieldBotID:
  8400. return m.AddedBotID()
  8401. case chatrecords.FieldBotType:
  8402. return m.AddedBotType()
  8403. }
  8404. return nil, false
  8405. }
  8406. // AddField adds the value to the field with the given name. It returns an error if
  8407. // the field is not defined in the schema, or if the type mismatched the field
  8408. // type.
  8409. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8410. switch name {
  8411. case chatrecords.FieldContentType:
  8412. v, ok := value.(int8)
  8413. if !ok {
  8414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8415. }
  8416. m.AddContentType(v)
  8417. return nil
  8418. case chatrecords.FieldSessionID:
  8419. v, ok := value.(int64)
  8420. if !ok {
  8421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8422. }
  8423. m.AddSessionID(v)
  8424. return nil
  8425. case chatrecords.FieldUserID:
  8426. v, ok := value.(int64)
  8427. if !ok {
  8428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8429. }
  8430. m.AddUserID(v)
  8431. return nil
  8432. case chatrecords.FieldBotID:
  8433. v, ok := value.(int64)
  8434. if !ok {
  8435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8436. }
  8437. m.AddBotID(v)
  8438. return nil
  8439. case chatrecords.FieldBotType:
  8440. v, ok := value.(int8)
  8441. if !ok {
  8442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8443. }
  8444. m.AddBotType(v)
  8445. return nil
  8446. }
  8447. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8448. }
  8449. // ClearedFields returns all nullable fields that were cleared during this
  8450. // mutation.
  8451. func (m *ChatRecordsMutation) ClearedFields() []string {
  8452. var fields []string
  8453. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8454. fields = append(fields, chatrecords.FieldDeletedAt)
  8455. }
  8456. return fields
  8457. }
  8458. // FieldCleared returns a boolean indicating if a field with the given name was
  8459. // cleared in this mutation.
  8460. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8461. _, ok := m.clearedFields[name]
  8462. return ok
  8463. }
  8464. // ClearField clears the value of the field with the given name. It returns an
  8465. // error if the field is not defined in the schema.
  8466. func (m *ChatRecordsMutation) ClearField(name string) error {
  8467. switch name {
  8468. case chatrecords.FieldDeletedAt:
  8469. m.ClearDeletedAt()
  8470. return nil
  8471. }
  8472. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8473. }
  8474. // ResetField resets all changes in the mutation for the field with the given name.
  8475. // It returns an error if the field is not defined in the schema.
  8476. func (m *ChatRecordsMutation) ResetField(name string) error {
  8477. switch name {
  8478. case chatrecords.FieldCreatedAt:
  8479. m.ResetCreatedAt()
  8480. return nil
  8481. case chatrecords.FieldUpdatedAt:
  8482. m.ResetUpdatedAt()
  8483. return nil
  8484. case chatrecords.FieldDeletedAt:
  8485. m.ResetDeletedAt()
  8486. return nil
  8487. case chatrecords.FieldContent:
  8488. m.ResetContent()
  8489. return nil
  8490. case chatrecords.FieldContentType:
  8491. m.ResetContentType()
  8492. return nil
  8493. case chatrecords.FieldSessionID:
  8494. m.ResetSessionID()
  8495. return nil
  8496. case chatrecords.FieldUserID:
  8497. m.ResetUserID()
  8498. return nil
  8499. case chatrecords.FieldBotID:
  8500. m.ResetBotID()
  8501. return nil
  8502. case chatrecords.FieldBotType:
  8503. m.ResetBotType()
  8504. return nil
  8505. }
  8506. return fmt.Errorf("unknown ChatRecords field %s", name)
  8507. }
  8508. // AddedEdges returns all edge names that were set/added in this mutation.
  8509. func (m *ChatRecordsMutation) AddedEdges() []string {
  8510. edges := make([]string, 0, 0)
  8511. return edges
  8512. }
  8513. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8514. // name in this mutation.
  8515. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8516. return nil
  8517. }
  8518. // RemovedEdges returns all edge names that were removed in this mutation.
  8519. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8520. edges := make([]string, 0, 0)
  8521. return edges
  8522. }
  8523. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8524. // the given name in this mutation.
  8525. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8526. return nil
  8527. }
  8528. // ClearedEdges returns all edge names that were cleared in this mutation.
  8529. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8530. edges := make([]string, 0, 0)
  8531. return edges
  8532. }
  8533. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8534. // was cleared in this mutation.
  8535. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8536. return false
  8537. }
  8538. // ClearEdge clears the value of the edge with the given name. It returns an error
  8539. // if that edge is not defined in the schema.
  8540. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8541. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8542. }
  8543. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8544. // It returns an error if the edge is not defined in the schema.
  8545. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8546. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8547. }
  8548. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8549. type ChatSessionMutation struct {
  8550. config
  8551. op Op
  8552. typ string
  8553. id *uint64
  8554. created_at *time.Time
  8555. updated_at *time.Time
  8556. deleted_at *time.Time
  8557. name *string
  8558. user_id *uint64
  8559. adduser_id *int64
  8560. bot_id *uint64
  8561. addbot_id *int64
  8562. bot_type *uint8
  8563. addbot_type *int8
  8564. clearedFields map[string]struct{}
  8565. done bool
  8566. oldValue func(context.Context) (*ChatSession, error)
  8567. predicates []predicate.ChatSession
  8568. }
  8569. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8570. // chatsessionOption allows management of the mutation configuration using functional options.
  8571. type chatsessionOption func(*ChatSessionMutation)
  8572. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8573. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8574. m := &ChatSessionMutation{
  8575. config: c,
  8576. op: op,
  8577. typ: TypeChatSession,
  8578. clearedFields: make(map[string]struct{}),
  8579. }
  8580. for _, opt := range opts {
  8581. opt(m)
  8582. }
  8583. return m
  8584. }
  8585. // withChatSessionID sets the ID field of the mutation.
  8586. func withChatSessionID(id uint64) chatsessionOption {
  8587. return func(m *ChatSessionMutation) {
  8588. var (
  8589. err error
  8590. once sync.Once
  8591. value *ChatSession
  8592. )
  8593. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8594. once.Do(func() {
  8595. if m.done {
  8596. err = errors.New("querying old values post mutation is not allowed")
  8597. } else {
  8598. value, err = m.Client().ChatSession.Get(ctx, id)
  8599. }
  8600. })
  8601. return value, err
  8602. }
  8603. m.id = &id
  8604. }
  8605. }
  8606. // withChatSession sets the old ChatSession of the mutation.
  8607. func withChatSession(node *ChatSession) chatsessionOption {
  8608. return func(m *ChatSessionMutation) {
  8609. m.oldValue = func(context.Context) (*ChatSession, error) {
  8610. return node, nil
  8611. }
  8612. m.id = &node.ID
  8613. }
  8614. }
  8615. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8616. // executed in a transaction (ent.Tx), a transactional client is returned.
  8617. func (m ChatSessionMutation) Client() *Client {
  8618. client := &Client{config: m.config}
  8619. client.init()
  8620. return client
  8621. }
  8622. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8623. // it returns an error otherwise.
  8624. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8625. if _, ok := m.driver.(*txDriver); !ok {
  8626. return nil, errors.New("ent: mutation is not running in a transaction")
  8627. }
  8628. tx := &Tx{config: m.config}
  8629. tx.init()
  8630. return tx, nil
  8631. }
  8632. // SetID sets the value of the id field. Note that this
  8633. // operation is only accepted on creation of ChatSession entities.
  8634. func (m *ChatSessionMutation) SetID(id uint64) {
  8635. m.id = &id
  8636. }
  8637. // ID returns the ID value in the mutation. Note that the ID is only available
  8638. // if it was provided to the builder or after it was returned from the database.
  8639. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8640. if m.id == nil {
  8641. return
  8642. }
  8643. return *m.id, true
  8644. }
  8645. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8646. // That means, if the mutation is applied within a transaction with an isolation level such
  8647. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8648. // or updated by the mutation.
  8649. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8650. switch {
  8651. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8652. id, exists := m.ID()
  8653. if exists {
  8654. return []uint64{id}, nil
  8655. }
  8656. fallthrough
  8657. case m.op.Is(OpUpdate | OpDelete):
  8658. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8659. default:
  8660. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8661. }
  8662. }
  8663. // SetCreatedAt sets the "created_at" field.
  8664. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8665. m.created_at = &t
  8666. }
  8667. // CreatedAt returns the value of the "created_at" field in the mutation.
  8668. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8669. v := m.created_at
  8670. if v == nil {
  8671. return
  8672. }
  8673. return *v, true
  8674. }
  8675. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8676. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8678. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8679. if !m.op.Is(OpUpdateOne) {
  8680. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8681. }
  8682. if m.id == nil || m.oldValue == nil {
  8683. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8684. }
  8685. oldValue, err := m.oldValue(ctx)
  8686. if err != nil {
  8687. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8688. }
  8689. return oldValue.CreatedAt, nil
  8690. }
  8691. // ResetCreatedAt resets all changes to the "created_at" field.
  8692. func (m *ChatSessionMutation) ResetCreatedAt() {
  8693. m.created_at = nil
  8694. }
  8695. // SetUpdatedAt sets the "updated_at" field.
  8696. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8697. m.updated_at = &t
  8698. }
  8699. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8700. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8701. v := m.updated_at
  8702. if v == nil {
  8703. return
  8704. }
  8705. return *v, true
  8706. }
  8707. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8708. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8710. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8711. if !m.op.Is(OpUpdateOne) {
  8712. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8713. }
  8714. if m.id == nil || m.oldValue == nil {
  8715. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8716. }
  8717. oldValue, err := m.oldValue(ctx)
  8718. if err != nil {
  8719. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8720. }
  8721. return oldValue.UpdatedAt, nil
  8722. }
  8723. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8724. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8725. m.updated_at = nil
  8726. }
  8727. // SetDeletedAt sets the "deleted_at" field.
  8728. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8729. m.deleted_at = &t
  8730. }
  8731. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8732. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8733. v := m.deleted_at
  8734. if v == nil {
  8735. return
  8736. }
  8737. return *v, true
  8738. }
  8739. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8740. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8742. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8743. if !m.op.Is(OpUpdateOne) {
  8744. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8745. }
  8746. if m.id == nil || m.oldValue == nil {
  8747. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8748. }
  8749. oldValue, err := m.oldValue(ctx)
  8750. if err != nil {
  8751. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8752. }
  8753. return oldValue.DeletedAt, nil
  8754. }
  8755. // ClearDeletedAt clears the value of the "deleted_at" field.
  8756. func (m *ChatSessionMutation) ClearDeletedAt() {
  8757. m.deleted_at = nil
  8758. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8759. }
  8760. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8761. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8762. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8763. return ok
  8764. }
  8765. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8766. func (m *ChatSessionMutation) ResetDeletedAt() {
  8767. m.deleted_at = nil
  8768. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8769. }
  8770. // SetName sets the "name" field.
  8771. func (m *ChatSessionMutation) SetName(s string) {
  8772. m.name = &s
  8773. }
  8774. // Name returns the value of the "name" field in the mutation.
  8775. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8776. v := m.name
  8777. if v == nil {
  8778. return
  8779. }
  8780. return *v, true
  8781. }
  8782. // OldName returns the old "name" field's value of the ChatSession entity.
  8783. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8785. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8786. if !m.op.Is(OpUpdateOne) {
  8787. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8788. }
  8789. if m.id == nil || m.oldValue == nil {
  8790. return v, errors.New("OldName requires an ID field in the mutation")
  8791. }
  8792. oldValue, err := m.oldValue(ctx)
  8793. if err != nil {
  8794. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8795. }
  8796. return oldValue.Name, nil
  8797. }
  8798. // ResetName resets all changes to the "name" field.
  8799. func (m *ChatSessionMutation) ResetName() {
  8800. m.name = nil
  8801. }
  8802. // SetUserID sets the "user_id" field.
  8803. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8804. m.user_id = &u
  8805. m.adduser_id = nil
  8806. }
  8807. // UserID returns the value of the "user_id" field in the mutation.
  8808. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8809. v := m.user_id
  8810. if v == nil {
  8811. return
  8812. }
  8813. return *v, true
  8814. }
  8815. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8816. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8818. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8819. if !m.op.Is(OpUpdateOne) {
  8820. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8821. }
  8822. if m.id == nil || m.oldValue == nil {
  8823. return v, errors.New("OldUserID requires an ID field in the mutation")
  8824. }
  8825. oldValue, err := m.oldValue(ctx)
  8826. if err != nil {
  8827. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8828. }
  8829. return oldValue.UserID, nil
  8830. }
  8831. // AddUserID adds u to the "user_id" field.
  8832. func (m *ChatSessionMutation) AddUserID(u int64) {
  8833. if m.adduser_id != nil {
  8834. *m.adduser_id += u
  8835. } else {
  8836. m.adduser_id = &u
  8837. }
  8838. }
  8839. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8840. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8841. v := m.adduser_id
  8842. if v == nil {
  8843. return
  8844. }
  8845. return *v, true
  8846. }
  8847. // ResetUserID resets all changes to the "user_id" field.
  8848. func (m *ChatSessionMutation) ResetUserID() {
  8849. m.user_id = nil
  8850. m.adduser_id = nil
  8851. }
  8852. // SetBotID sets the "bot_id" field.
  8853. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8854. m.bot_id = &u
  8855. m.addbot_id = nil
  8856. }
  8857. // BotID returns the value of the "bot_id" field in the mutation.
  8858. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8859. v := m.bot_id
  8860. if v == nil {
  8861. return
  8862. }
  8863. return *v, true
  8864. }
  8865. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8866. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8868. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8869. if !m.op.Is(OpUpdateOne) {
  8870. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8871. }
  8872. if m.id == nil || m.oldValue == nil {
  8873. return v, errors.New("OldBotID requires an ID field in the mutation")
  8874. }
  8875. oldValue, err := m.oldValue(ctx)
  8876. if err != nil {
  8877. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8878. }
  8879. return oldValue.BotID, nil
  8880. }
  8881. // AddBotID adds u to the "bot_id" field.
  8882. func (m *ChatSessionMutation) AddBotID(u int64) {
  8883. if m.addbot_id != nil {
  8884. *m.addbot_id += u
  8885. } else {
  8886. m.addbot_id = &u
  8887. }
  8888. }
  8889. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8890. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8891. v := m.addbot_id
  8892. if v == nil {
  8893. return
  8894. }
  8895. return *v, true
  8896. }
  8897. // ResetBotID resets all changes to the "bot_id" field.
  8898. func (m *ChatSessionMutation) ResetBotID() {
  8899. m.bot_id = nil
  8900. m.addbot_id = nil
  8901. }
  8902. // SetBotType sets the "bot_type" field.
  8903. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8904. m.bot_type = &u
  8905. m.addbot_type = nil
  8906. }
  8907. // BotType returns the value of the "bot_type" field in the mutation.
  8908. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8909. v := m.bot_type
  8910. if v == nil {
  8911. return
  8912. }
  8913. return *v, true
  8914. }
  8915. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8916. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8918. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8919. if !m.op.Is(OpUpdateOne) {
  8920. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8921. }
  8922. if m.id == nil || m.oldValue == nil {
  8923. return v, errors.New("OldBotType requires an ID field in the mutation")
  8924. }
  8925. oldValue, err := m.oldValue(ctx)
  8926. if err != nil {
  8927. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8928. }
  8929. return oldValue.BotType, nil
  8930. }
  8931. // AddBotType adds u to the "bot_type" field.
  8932. func (m *ChatSessionMutation) AddBotType(u int8) {
  8933. if m.addbot_type != nil {
  8934. *m.addbot_type += u
  8935. } else {
  8936. m.addbot_type = &u
  8937. }
  8938. }
  8939. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8940. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8941. v := m.addbot_type
  8942. if v == nil {
  8943. return
  8944. }
  8945. return *v, true
  8946. }
  8947. // ResetBotType resets all changes to the "bot_type" field.
  8948. func (m *ChatSessionMutation) ResetBotType() {
  8949. m.bot_type = nil
  8950. m.addbot_type = nil
  8951. }
  8952. // Where appends a list predicates to the ChatSessionMutation builder.
  8953. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8954. m.predicates = append(m.predicates, ps...)
  8955. }
  8956. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8957. // users can use type-assertion to append predicates that do not depend on any generated package.
  8958. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8959. p := make([]predicate.ChatSession, len(ps))
  8960. for i := range ps {
  8961. p[i] = ps[i]
  8962. }
  8963. m.Where(p...)
  8964. }
  8965. // Op returns the operation name.
  8966. func (m *ChatSessionMutation) Op() Op {
  8967. return m.op
  8968. }
  8969. // SetOp allows setting the mutation operation.
  8970. func (m *ChatSessionMutation) SetOp(op Op) {
  8971. m.op = op
  8972. }
  8973. // Type returns the node type of this mutation (ChatSession).
  8974. func (m *ChatSessionMutation) Type() string {
  8975. return m.typ
  8976. }
  8977. // Fields returns all fields that were changed during this mutation. Note that in
  8978. // order to get all numeric fields that were incremented/decremented, call
  8979. // AddedFields().
  8980. func (m *ChatSessionMutation) Fields() []string {
  8981. fields := make([]string, 0, 7)
  8982. if m.created_at != nil {
  8983. fields = append(fields, chatsession.FieldCreatedAt)
  8984. }
  8985. if m.updated_at != nil {
  8986. fields = append(fields, chatsession.FieldUpdatedAt)
  8987. }
  8988. if m.deleted_at != nil {
  8989. fields = append(fields, chatsession.FieldDeletedAt)
  8990. }
  8991. if m.name != nil {
  8992. fields = append(fields, chatsession.FieldName)
  8993. }
  8994. if m.user_id != nil {
  8995. fields = append(fields, chatsession.FieldUserID)
  8996. }
  8997. if m.bot_id != nil {
  8998. fields = append(fields, chatsession.FieldBotID)
  8999. }
  9000. if m.bot_type != nil {
  9001. fields = append(fields, chatsession.FieldBotType)
  9002. }
  9003. return fields
  9004. }
  9005. // Field returns the value of a field with the given name. The second boolean
  9006. // return value indicates that this field was not set, or was not defined in the
  9007. // schema.
  9008. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9009. switch name {
  9010. case chatsession.FieldCreatedAt:
  9011. return m.CreatedAt()
  9012. case chatsession.FieldUpdatedAt:
  9013. return m.UpdatedAt()
  9014. case chatsession.FieldDeletedAt:
  9015. return m.DeletedAt()
  9016. case chatsession.FieldName:
  9017. return m.Name()
  9018. case chatsession.FieldUserID:
  9019. return m.UserID()
  9020. case chatsession.FieldBotID:
  9021. return m.BotID()
  9022. case chatsession.FieldBotType:
  9023. return m.BotType()
  9024. }
  9025. return nil, false
  9026. }
  9027. // OldField returns the old value of the field from the database. An error is
  9028. // returned if the mutation operation is not UpdateOne, or the query to the
  9029. // database failed.
  9030. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9031. switch name {
  9032. case chatsession.FieldCreatedAt:
  9033. return m.OldCreatedAt(ctx)
  9034. case chatsession.FieldUpdatedAt:
  9035. return m.OldUpdatedAt(ctx)
  9036. case chatsession.FieldDeletedAt:
  9037. return m.OldDeletedAt(ctx)
  9038. case chatsession.FieldName:
  9039. return m.OldName(ctx)
  9040. case chatsession.FieldUserID:
  9041. return m.OldUserID(ctx)
  9042. case chatsession.FieldBotID:
  9043. return m.OldBotID(ctx)
  9044. case chatsession.FieldBotType:
  9045. return m.OldBotType(ctx)
  9046. }
  9047. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9048. }
  9049. // SetField sets the value of a field with the given name. It returns an error if
  9050. // the field is not defined in the schema, or if the type mismatched the field
  9051. // type.
  9052. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9053. switch name {
  9054. case chatsession.FieldCreatedAt:
  9055. v, ok := value.(time.Time)
  9056. if !ok {
  9057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9058. }
  9059. m.SetCreatedAt(v)
  9060. return nil
  9061. case chatsession.FieldUpdatedAt:
  9062. v, ok := value.(time.Time)
  9063. if !ok {
  9064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9065. }
  9066. m.SetUpdatedAt(v)
  9067. return nil
  9068. case chatsession.FieldDeletedAt:
  9069. v, ok := value.(time.Time)
  9070. if !ok {
  9071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9072. }
  9073. m.SetDeletedAt(v)
  9074. return nil
  9075. case chatsession.FieldName:
  9076. v, ok := value.(string)
  9077. if !ok {
  9078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9079. }
  9080. m.SetName(v)
  9081. return nil
  9082. case chatsession.FieldUserID:
  9083. v, ok := value.(uint64)
  9084. if !ok {
  9085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9086. }
  9087. m.SetUserID(v)
  9088. return nil
  9089. case chatsession.FieldBotID:
  9090. v, ok := value.(uint64)
  9091. if !ok {
  9092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9093. }
  9094. m.SetBotID(v)
  9095. return nil
  9096. case chatsession.FieldBotType:
  9097. v, ok := value.(uint8)
  9098. if !ok {
  9099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9100. }
  9101. m.SetBotType(v)
  9102. return nil
  9103. }
  9104. return fmt.Errorf("unknown ChatSession field %s", name)
  9105. }
  9106. // AddedFields returns all numeric fields that were incremented/decremented during
  9107. // this mutation.
  9108. func (m *ChatSessionMutation) AddedFields() []string {
  9109. var fields []string
  9110. if m.adduser_id != nil {
  9111. fields = append(fields, chatsession.FieldUserID)
  9112. }
  9113. if m.addbot_id != nil {
  9114. fields = append(fields, chatsession.FieldBotID)
  9115. }
  9116. if m.addbot_type != nil {
  9117. fields = append(fields, chatsession.FieldBotType)
  9118. }
  9119. return fields
  9120. }
  9121. // AddedField returns the numeric value that was incremented/decremented on a field
  9122. // with the given name. The second boolean return value indicates that this field
  9123. // was not set, or was not defined in the schema.
  9124. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9125. switch name {
  9126. case chatsession.FieldUserID:
  9127. return m.AddedUserID()
  9128. case chatsession.FieldBotID:
  9129. return m.AddedBotID()
  9130. case chatsession.FieldBotType:
  9131. return m.AddedBotType()
  9132. }
  9133. return nil, false
  9134. }
  9135. // AddField adds the value to the field with the given name. It returns an error if
  9136. // the field is not defined in the schema, or if the type mismatched the field
  9137. // type.
  9138. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9139. switch name {
  9140. case chatsession.FieldUserID:
  9141. v, ok := value.(int64)
  9142. if !ok {
  9143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9144. }
  9145. m.AddUserID(v)
  9146. return nil
  9147. case chatsession.FieldBotID:
  9148. v, ok := value.(int64)
  9149. if !ok {
  9150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9151. }
  9152. m.AddBotID(v)
  9153. return nil
  9154. case chatsession.FieldBotType:
  9155. v, ok := value.(int8)
  9156. if !ok {
  9157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9158. }
  9159. m.AddBotType(v)
  9160. return nil
  9161. }
  9162. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9163. }
  9164. // ClearedFields returns all nullable fields that were cleared during this
  9165. // mutation.
  9166. func (m *ChatSessionMutation) ClearedFields() []string {
  9167. var fields []string
  9168. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9169. fields = append(fields, chatsession.FieldDeletedAt)
  9170. }
  9171. return fields
  9172. }
  9173. // FieldCleared returns a boolean indicating if a field with the given name was
  9174. // cleared in this mutation.
  9175. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9176. _, ok := m.clearedFields[name]
  9177. return ok
  9178. }
  9179. // ClearField clears the value of the field with the given name. It returns an
  9180. // error if the field is not defined in the schema.
  9181. func (m *ChatSessionMutation) ClearField(name string) error {
  9182. switch name {
  9183. case chatsession.FieldDeletedAt:
  9184. m.ClearDeletedAt()
  9185. return nil
  9186. }
  9187. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9188. }
  9189. // ResetField resets all changes in the mutation for the field with the given name.
  9190. // It returns an error if the field is not defined in the schema.
  9191. func (m *ChatSessionMutation) ResetField(name string) error {
  9192. switch name {
  9193. case chatsession.FieldCreatedAt:
  9194. m.ResetCreatedAt()
  9195. return nil
  9196. case chatsession.FieldUpdatedAt:
  9197. m.ResetUpdatedAt()
  9198. return nil
  9199. case chatsession.FieldDeletedAt:
  9200. m.ResetDeletedAt()
  9201. return nil
  9202. case chatsession.FieldName:
  9203. m.ResetName()
  9204. return nil
  9205. case chatsession.FieldUserID:
  9206. m.ResetUserID()
  9207. return nil
  9208. case chatsession.FieldBotID:
  9209. m.ResetBotID()
  9210. return nil
  9211. case chatsession.FieldBotType:
  9212. m.ResetBotType()
  9213. return nil
  9214. }
  9215. return fmt.Errorf("unknown ChatSession field %s", name)
  9216. }
  9217. // AddedEdges returns all edge names that were set/added in this mutation.
  9218. func (m *ChatSessionMutation) AddedEdges() []string {
  9219. edges := make([]string, 0, 0)
  9220. return edges
  9221. }
  9222. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9223. // name in this mutation.
  9224. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9225. return nil
  9226. }
  9227. // RemovedEdges returns all edge names that were removed in this mutation.
  9228. func (m *ChatSessionMutation) RemovedEdges() []string {
  9229. edges := make([]string, 0, 0)
  9230. return edges
  9231. }
  9232. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9233. // the given name in this mutation.
  9234. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9235. return nil
  9236. }
  9237. // ClearedEdges returns all edge names that were cleared in this mutation.
  9238. func (m *ChatSessionMutation) ClearedEdges() []string {
  9239. edges := make([]string, 0, 0)
  9240. return edges
  9241. }
  9242. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9243. // was cleared in this mutation.
  9244. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9245. return false
  9246. }
  9247. // ClearEdge clears the value of the edge with the given name. It returns an error
  9248. // if that edge is not defined in the schema.
  9249. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9250. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9251. }
  9252. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9253. // It returns an error if the edge is not defined in the schema.
  9254. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9255. return fmt.Errorf("unknown ChatSession edge %s", name)
  9256. }
  9257. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9258. type ContactMutation struct {
  9259. config
  9260. op Op
  9261. typ string
  9262. id *uint64
  9263. created_at *time.Time
  9264. updated_at *time.Time
  9265. status *uint8
  9266. addstatus *int8
  9267. deleted_at *time.Time
  9268. wx_wxid *string
  9269. _type *int
  9270. add_type *int
  9271. wxid *string
  9272. account *string
  9273. nickname *string
  9274. markname *string
  9275. headimg *string
  9276. sex *int
  9277. addsex *int
  9278. starrole *string
  9279. dontseeit *int
  9280. adddontseeit *int
  9281. dontseeme *int
  9282. adddontseeme *int
  9283. lag *string
  9284. gid *string
  9285. gname *string
  9286. v3 *string
  9287. organization_id *uint64
  9288. addorganization_id *int64
  9289. ctype *uint64
  9290. addctype *int64
  9291. cage *int
  9292. addcage *int
  9293. cname *string
  9294. carea *string
  9295. cbirthday *string
  9296. cbirtharea *string
  9297. cidcard_no *string
  9298. ctitle *string
  9299. cc *string
  9300. phone *string
  9301. clearedFields map[string]struct{}
  9302. contact_relationships map[uint64]struct{}
  9303. removedcontact_relationships map[uint64]struct{}
  9304. clearedcontact_relationships bool
  9305. contact_fields map[uint64]struct{}
  9306. removedcontact_fields map[uint64]struct{}
  9307. clearedcontact_fields bool
  9308. contact_messages map[uint64]struct{}
  9309. removedcontact_messages map[uint64]struct{}
  9310. clearedcontact_messages bool
  9311. done bool
  9312. oldValue func(context.Context) (*Contact, error)
  9313. predicates []predicate.Contact
  9314. }
  9315. var _ ent.Mutation = (*ContactMutation)(nil)
  9316. // contactOption allows management of the mutation configuration using functional options.
  9317. type contactOption func(*ContactMutation)
  9318. // newContactMutation creates new mutation for the Contact entity.
  9319. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9320. m := &ContactMutation{
  9321. config: c,
  9322. op: op,
  9323. typ: TypeContact,
  9324. clearedFields: make(map[string]struct{}),
  9325. }
  9326. for _, opt := range opts {
  9327. opt(m)
  9328. }
  9329. return m
  9330. }
  9331. // withContactID sets the ID field of the mutation.
  9332. func withContactID(id uint64) contactOption {
  9333. return func(m *ContactMutation) {
  9334. var (
  9335. err error
  9336. once sync.Once
  9337. value *Contact
  9338. )
  9339. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9340. once.Do(func() {
  9341. if m.done {
  9342. err = errors.New("querying old values post mutation is not allowed")
  9343. } else {
  9344. value, err = m.Client().Contact.Get(ctx, id)
  9345. }
  9346. })
  9347. return value, err
  9348. }
  9349. m.id = &id
  9350. }
  9351. }
  9352. // withContact sets the old Contact of the mutation.
  9353. func withContact(node *Contact) contactOption {
  9354. return func(m *ContactMutation) {
  9355. m.oldValue = func(context.Context) (*Contact, error) {
  9356. return node, nil
  9357. }
  9358. m.id = &node.ID
  9359. }
  9360. }
  9361. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9362. // executed in a transaction (ent.Tx), a transactional client is returned.
  9363. func (m ContactMutation) Client() *Client {
  9364. client := &Client{config: m.config}
  9365. client.init()
  9366. return client
  9367. }
  9368. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9369. // it returns an error otherwise.
  9370. func (m ContactMutation) Tx() (*Tx, error) {
  9371. if _, ok := m.driver.(*txDriver); !ok {
  9372. return nil, errors.New("ent: mutation is not running in a transaction")
  9373. }
  9374. tx := &Tx{config: m.config}
  9375. tx.init()
  9376. return tx, nil
  9377. }
  9378. // SetID sets the value of the id field. Note that this
  9379. // operation is only accepted on creation of Contact entities.
  9380. func (m *ContactMutation) SetID(id uint64) {
  9381. m.id = &id
  9382. }
  9383. // ID returns the ID value in the mutation. Note that the ID is only available
  9384. // if it was provided to the builder or after it was returned from the database.
  9385. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9386. if m.id == nil {
  9387. return
  9388. }
  9389. return *m.id, true
  9390. }
  9391. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9392. // That means, if the mutation is applied within a transaction with an isolation level such
  9393. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9394. // or updated by the mutation.
  9395. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9396. switch {
  9397. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9398. id, exists := m.ID()
  9399. if exists {
  9400. return []uint64{id}, nil
  9401. }
  9402. fallthrough
  9403. case m.op.Is(OpUpdate | OpDelete):
  9404. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9405. default:
  9406. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9407. }
  9408. }
  9409. // SetCreatedAt sets the "created_at" field.
  9410. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9411. m.created_at = &t
  9412. }
  9413. // CreatedAt returns the value of the "created_at" field in the mutation.
  9414. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9415. v := m.created_at
  9416. if v == nil {
  9417. return
  9418. }
  9419. return *v, true
  9420. }
  9421. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9422. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9424. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9425. if !m.op.Is(OpUpdateOne) {
  9426. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9427. }
  9428. if m.id == nil || m.oldValue == nil {
  9429. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9430. }
  9431. oldValue, err := m.oldValue(ctx)
  9432. if err != nil {
  9433. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9434. }
  9435. return oldValue.CreatedAt, nil
  9436. }
  9437. // ResetCreatedAt resets all changes to the "created_at" field.
  9438. func (m *ContactMutation) ResetCreatedAt() {
  9439. m.created_at = nil
  9440. }
  9441. // SetUpdatedAt sets the "updated_at" field.
  9442. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9443. m.updated_at = &t
  9444. }
  9445. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9446. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9447. v := m.updated_at
  9448. if v == nil {
  9449. return
  9450. }
  9451. return *v, true
  9452. }
  9453. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9454. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9456. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9457. if !m.op.Is(OpUpdateOne) {
  9458. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9459. }
  9460. if m.id == nil || m.oldValue == nil {
  9461. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9462. }
  9463. oldValue, err := m.oldValue(ctx)
  9464. if err != nil {
  9465. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9466. }
  9467. return oldValue.UpdatedAt, nil
  9468. }
  9469. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9470. func (m *ContactMutation) ResetUpdatedAt() {
  9471. m.updated_at = nil
  9472. }
  9473. // SetStatus sets the "status" field.
  9474. func (m *ContactMutation) SetStatus(u uint8) {
  9475. m.status = &u
  9476. m.addstatus = nil
  9477. }
  9478. // Status returns the value of the "status" field in the mutation.
  9479. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9480. v := m.status
  9481. if v == nil {
  9482. return
  9483. }
  9484. return *v, true
  9485. }
  9486. // OldStatus returns the old "status" field's value of the Contact entity.
  9487. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9489. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9490. if !m.op.Is(OpUpdateOne) {
  9491. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9492. }
  9493. if m.id == nil || m.oldValue == nil {
  9494. return v, errors.New("OldStatus requires an ID field in the mutation")
  9495. }
  9496. oldValue, err := m.oldValue(ctx)
  9497. if err != nil {
  9498. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9499. }
  9500. return oldValue.Status, nil
  9501. }
  9502. // AddStatus adds u to the "status" field.
  9503. func (m *ContactMutation) AddStatus(u int8) {
  9504. if m.addstatus != nil {
  9505. *m.addstatus += u
  9506. } else {
  9507. m.addstatus = &u
  9508. }
  9509. }
  9510. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9511. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9512. v := m.addstatus
  9513. if v == nil {
  9514. return
  9515. }
  9516. return *v, true
  9517. }
  9518. // ClearStatus clears the value of the "status" field.
  9519. func (m *ContactMutation) ClearStatus() {
  9520. m.status = nil
  9521. m.addstatus = nil
  9522. m.clearedFields[contact.FieldStatus] = struct{}{}
  9523. }
  9524. // StatusCleared returns if the "status" field was cleared in this mutation.
  9525. func (m *ContactMutation) StatusCleared() bool {
  9526. _, ok := m.clearedFields[contact.FieldStatus]
  9527. return ok
  9528. }
  9529. // ResetStatus resets all changes to the "status" field.
  9530. func (m *ContactMutation) ResetStatus() {
  9531. m.status = nil
  9532. m.addstatus = nil
  9533. delete(m.clearedFields, contact.FieldStatus)
  9534. }
  9535. // SetDeletedAt sets the "deleted_at" field.
  9536. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9537. m.deleted_at = &t
  9538. }
  9539. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9540. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9541. v := m.deleted_at
  9542. if v == nil {
  9543. return
  9544. }
  9545. return *v, true
  9546. }
  9547. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9548. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9550. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9551. if !m.op.Is(OpUpdateOne) {
  9552. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9553. }
  9554. if m.id == nil || m.oldValue == nil {
  9555. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9556. }
  9557. oldValue, err := m.oldValue(ctx)
  9558. if err != nil {
  9559. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9560. }
  9561. return oldValue.DeletedAt, nil
  9562. }
  9563. // ClearDeletedAt clears the value of the "deleted_at" field.
  9564. func (m *ContactMutation) ClearDeletedAt() {
  9565. m.deleted_at = nil
  9566. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9567. }
  9568. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9569. func (m *ContactMutation) DeletedAtCleared() bool {
  9570. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9571. return ok
  9572. }
  9573. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9574. func (m *ContactMutation) ResetDeletedAt() {
  9575. m.deleted_at = nil
  9576. delete(m.clearedFields, contact.FieldDeletedAt)
  9577. }
  9578. // SetWxWxid sets the "wx_wxid" field.
  9579. func (m *ContactMutation) SetWxWxid(s string) {
  9580. m.wx_wxid = &s
  9581. }
  9582. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9583. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9584. v := m.wx_wxid
  9585. if v == nil {
  9586. return
  9587. }
  9588. return *v, true
  9589. }
  9590. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9591. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9593. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9594. if !m.op.Is(OpUpdateOne) {
  9595. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9596. }
  9597. if m.id == nil || m.oldValue == nil {
  9598. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9599. }
  9600. oldValue, err := m.oldValue(ctx)
  9601. if err != nil {
  9602. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9603. }
  9604. return oldValue.WxWxid, nil
  9605. }
  9606. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9607. func (m *ContactMutation) ResetWxWxid() {
  9608. m.wx_wxid = nil
  9609. }
  9610. // SetType sets the "type" field.
  9611. func (m *ContactMutation) SetType(i int) {
  9612. m._type = &i
  9613. m.add_type = nil
  9614. }
  9615. // GetType returns the value of the "type" field in the mutation.
  9616. func (m *ContactMutation) GetType() (r int, exists bool) {
  9617. v := m._type
  9618. if v == nil {
  9619. return
  9620. }
  9621. return *v, true
  9622. }
  9623. // OldType returns the old "type" field's value of the Contact entity.
  9624. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9626. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9627. if !m.op.Is(OpUpdateOne) {
  9628. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9629. }
  9630. if m.id == nil || m.oldValue == nil {
  9631. return v, errors.New("OldType requires an ID field in the mutation")
  9632. }
  9633. oldValue, err := m.oldValue(ctx)
  9634. if err != nil {
  9635. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9636. }
  9637. return oldValue.Type, nil
  9638. }
  9639. // AddType adds i to the "type" field.
  9640. func (m *ContactMutation) AddType(i int) {
  9641. if m.add_type != nil {
  9642. *m.add_type += i
  9643. } else {
  9644. m.add_type = &i
  9645. }
  9646. }
  9647. // AddedType returns the value that was added to the "type" field in this mutation.
  9648. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9649. v := m.add_type
  9650. if v == nil {
  9651. return
  9652. }
  9653. return *v, true
  9654. }
  9655. // ClearType clears the value of the "type" field.
  9656. func (m *ContactMutation) ClearType() {
  9657. m._type = nil
  9658. m.add_type = nil
  9659. m.clearedFields[contact.FieldType] = struct{}{}
  9660. }
  9661. // TypeCleared returns if the "type" field was cleared in this mutation.
  9662. func (m *ContactMutation) TypeCleared() bool {
  9663. _, ok := m.clearedFields[contact.FieldType]
  9664. return ok
  9665. }
  9666. // ResetType resets all changes to the "type" field.
  9667. func (m *ContactMutation) ResetType() {
  9668. m._type = nil
  9669. m.add_type = nil
  9670. delete(m.clearedFields, contact.FieldType)
  9671. }
  9672. // SetWxid sets the "wxid" field.
  9673. func (m *ContactMutation) SetWxid(s string) {
  9674. m.wxid = &s
  9675. }
  9676. // Wxid returns the value of the "wxid" field in the mutation.
  9677. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9678. v := m.wxid
  9679. if v == nil {
  9680. return
  9681. }
  9682. return *v, true
  9683. }
  9684. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9685. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9687. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9688. if !m.op.Is(OpUpdateOne) {
  9689. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9690. }
  9691. if m.id == nil || m.oldValue == nil {
  9692. return v, errors.New("OldWxid requires an ID field in the mutation")
  9693. }
  9694. oldValue, err := m.oldValue(ctx)
  9695. if err != nil {
  9696. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9697. }
  9698. return oldValue.Wxid, nil
  9699. }
  9700. // ResetWxid resets all changes to the "wxid" field.
  9701. func (m *ContactMutation) ResetWxid() {
  9702. m.wxid = nil
  9703. }
  9704. // SetAccount sets the "account" field.
  9705. func (m *ContactMutation) SetAccount(s string) {
  9706. m.account = &s
  9707. }
  9708. // Account returns the value of the "account" field in the mutation.
  9709. func (m *ContactMutation) Account() (r string, exists bool) {
  9710. v := m.account
  9711. if v == nil {
  9712. return
  9713. }
  9714. return *v, true
  9715. }
  9716. // OldAccount returns the old "account" field's value of the Contact entity.
  9717. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9719. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9720. if !m.op.Is(OpUpdateOne) {
  9721. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9722. }
  9723. if m.id == nil || m.oldValue == nil {
  9724. return v, errors.New("OldAccount requires an ID field in the mutation")
  9725. }
  9726. oldValue, err := m.oldValue(ctx)
  9727. if err != nil {
  9728. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9729. }
  9730. return oldValue.Account, nil
  9731. }
  9732. // ResetAccount resets all changes to the "account" field.
  9733. func (m *ContactMutation) ResetAccount() {
  9734. m.account = nil
  9735. }
  9736. // SetNickname sets the "nickname" field.
  9737. func (m *ContactMutation) SetNickname(s string) {
  9738. m.nickname = &s
  9739. }
  9740. // Nickname returns the value of the "nickname" field in the mutation.
  9741. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9742. v := m.nickname
  9743. if v == nil {
  9744. return
  9745. }
  9746. return *v, true
  9747. }
  9748. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9749. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9751. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9752. if !m.op.Is(OpUpdateOne) {
  9753. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9754. }
  9755. if m.id == nil || m.oldValue == nil {
  9756. return v, errors.New("OldNickname requires an ID field in the mutation")
  9757. }
  9758. oldValue, err := m.oldValue(ctx)
  9759. if err != nil {
  9760. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9761. }
  9762. return oldValue.Nickname, nil
  9763. }
  9764. // ResetNickname resets all changes to the "nickname" field.
  9765. func (m *ContactMutation) ResetNickname() {
  9766. m.nickname = nil
  9767. }
  9768. // SetMarkname sets the "markname" field.
  9769. func (m *ContactMutation) SetMarkname(s string) {
  9770. m.markname = &s
  9771. }
  9772. // Markname returns the value of the "markname" field in the mutation.
  9773. func (m *ContactMutation) Markname() (r string, exists bool) {
  9774. v := m.markname
  9775. if v == nil {
  9776. return
  9777. }
  9778. return *v, true
  9779. }
  9780. // OldMarkname returns the old "markname" field's value of the Contact entity.
  9781. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9783. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  9784. if !m.op.Is(OpUpdateOne) {
  9785. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  9786. }
  9787. if m.id == nil || m.oldValue == nil {
  9788. return v, errors.New("OldMarkname requires an ID field in the mutation")
  9789. }
  9790. oldValue, err := m.oldValue(ctx)
  9791. if err != nil {
  9792. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  9793. }
  9794. return oldValue.Markname, nil
  9795. }
  9796. // ResetMarkname resets all changes to the "markname" field.
  9797. func (m *ContactMutation) ResetMarkname() {
  9798. m.markname = nil
  9799. }
  9800. // SetHeadimg sets the "headimg" field.
  9801. func (m *ContactMutation) SetHeadimg(s string) {
  9802. m.headimg = &s
  9803. }
  9804. // Headimg returns the value of the "headimg" field in the mutation.
  9805. func (m *ContactMutation) Headimg() (r string, exists bool) {
  9806. v := m.headimg
  9807. if v == nil {
  9808. return
  9809. }
  9810. return *v, true
  9811. }
  9812. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  9813. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9815. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  9816. if !m.op.Is(OpUpdateOne) {
  9817. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  9818. }
  9819. if m.id == nil || m.oldValue == nil {
  9820. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  9821. }
  9822. oldValue, err := m.oldValue(ctx)
  9823. if err != nil {
  9824. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  9825. }
  9826. return oldValue.Headimg, nil
  9827. }
  9828. // ResetHeadimg resets all changes to the "headimg" field.
  9829. func (m *ContactMutation) ResetHeadimg() {
  9830. m.headimg = nil
  9831. }
  9832. // SetSex sets the "sex" field.
  9833. func (m *ContactMutation) SetSex(i int) {
  9834. m.sex = &i
  9835. m.addsex = nil
  9836. }
  9837. // Sex returns the value of the "sex" field in the mutation.
  9838. func (m *ContactMutation) Sex() (r int, exists bool) {
  9839. v := m.sex
  9840. if v == nil {
  9841. return
  9842. }
  9843. return *v, true
  9844. }
  9845. // OldSex returns the old "sex" field's value of the Contact entity.
  9846. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9848. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  9849. if !m.op.Is(OpUpdateOne) {
  9850. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  9851. }
  9852. if m.id == nil || m.oldValue == nil {
  9853. return v, errors.New("OldSex requires an ID field in the mutation")
  9854. }
  9855. oldValue, err := m.oldValue(ctx)
  9856. if err != nil {
  9857. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  9858. }
  9859. return oldValue.Sex, nil
  9860. }
  9861. // AddSex adds i to the "sex" field.
  9862. func (m *ContactMutation) AddSex(i int) {
  9863. if m.addsex != nil {
  9864. *m.addsex += i
  9865. } else {
  9866. m.addsex = &i
  9867. }
  9868. }
  9869. // AddedSex returns the value that was added to the "sex" field in this mutation.
  9870. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  9871. v := m.addsex
  9872. if v == nil {
  9873. return
  9874. }
  9875. return *v, true
  9876. }
  9877. // ResetSex resets all changes to the "sex" field.
  9878. func (m *ContactMutation) ResetSex() {
  9879. m.sex = nil
  9880. m.addsex = nil
  9881. }
  9882. // SetStarrole sets the "starrole" field.
  9883. func (m *ContactMutation) SetStarrole(s string) {
  9884. m.starrole = &s
  9885. }
  9886. // Starrole returns the value of the "starrole" field in the mutation.
  9887. func (m *ContactMutation) Starrole() (r string, exists bool) {
  9888. v := m.starrole
  9889. if v == nil {
  9890. return
  9891. }
  9892. return *v, true
  9893. }
  9894. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  9895. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9897. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  9898. if !m.op.Is(OpUpdateOne) {
  9899. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  9900. }
  9901. if m.id == nil || m.oldValue == nil {
  9902. return v, errors.New("OldStarrole requires an ID field in the mutation")
  9903. }
  9904. oldValue, err := m.oldValue(ctx)
  9905. if err != nil {
  9906. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  9907. }
  9908. return oldValue.Starrole, nil
  9909. }
  9910. // ResetStarrole resets all changes to the "starrole" field.
  9911. func (m *ContactMutation) ResetStarrole() {
  9912. m.starrole = nil
  9913. }
  9914. // SetDontseeit sets the "dontseeit" field.
  9915. func (m *ContactMutation) SetDontseeit(i int) {
  9916. m.dontseeit = &i
  9917. m.adddontseeit = nil
  9918. }
  9919. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  9920. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  9921. v := m.dontseeit
  9922. if v == nil {
  9923. return
  9924. }
  9925. return *v, true
  9926. }
  9927. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  9928. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9930. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  9931. if !m.op.Is(OpUpdateOne) {
  9932. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  9933. }
  9934. if m.id == nil || m.oldValue == nil {
  9935. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  9936. }
  9937. oldValue, err := m.oldValue(ctx)
  9938. if err != nil {
  9939. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  9940. }
  9941. return oldValue.Dontseeit, nil
  9942. }
  9943. // AddDontseeit adds i to the "dontseeit" field.
  9944. func (m *ContactMutation) AddDontseeit(i int) {
  9945. if m.adddontseeit != nil {
  9946. *m.adddontseeit += i
  9947. } else {
  9948. m.adddontseeit = &i
  9949. }
  9950. }
  9951. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  9952. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  9953. v := m.adddontseeit
  9954. if v == nil {
  9955. return
  9956. }
  9957. return *v, true
  9958. }
  9959. // ResetDontseeit resets all changes to the "dontseeit" field.
  9960. func (m *ContactMutation) ResetDontseeit() {
  9961. m.dontseeit = nil
  9962. m.adddontseeit = nil
  9963. }
  9964. // SetDontseeme sets the "dontseeme" field.
  9965. func (m *ContactMutation) SetDontseeme(i int) {
  9966. m.dontseeme = &i
  9967. m.adddontseeme = nil
  9968. }
  9969. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  9970. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  9971. v := m.dontseeme
  9972. if v == nil {
  9973. return
  9974. }
  9975. return *v, true
  9976. }
  9977. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  9978. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9980. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  9981. if !m.op.Is(OpUpdateOne) {
  9982. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  9983. }
  9984. if m.id == nil || m.oldValue == nil {
  9985. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  9986. }
  9987. oldValue, err := m.oldValue(ctx)
  9988. if err != nil {
  9989. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  9990. }
  9991. return oldValue.Dontseeme, nil
  9992. }
  9993. // AddDontseeme adds i to the "dontseeme" field.
  9994. func (m *ContactMutation) AddDontseeme(i int) {
  9995. if m.adddontseeme != nil {
  9996. *m.adddontseeme += i
  9997. } else {
  9998. m.adddontseeme = &i
  9999. }
  10000. }
  10001. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  10002. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  10003. v := m.adddontseeme
  10004. if v == nil {
  10005. return
  10006. }
  10007. return *v, true
  10008. }
  10009. // ResetDontseeme resets all changes to the "dontseeme" field.
  10010. func (m *ContactMutation) ResetDontseeme() {
  10011. m.dontseeme = nil
  10012. m.adddontseeme = nil
  10013. }
  10014. // SetLag sets the "lag" field.
  10015. func (m *ContactMutation) SetLag(s string) {
  10016. m.lag = &s
  10017. }
  10018. // Lag returns the value of the "lag" field in the mutation.
  10019. func (m *ContactMutation) Lag() (r string, exists bool) {
  10020. v := m.lag
  10021. if v == nil {
  10022. return
  10023. }
  10024. return *v, true
  10025. }
  10026. // OldLag returns the old "lag" field's value of the Contact entity.
  10027. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10029. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  10030. if !m.op.Is(OpUpdateOne) {
  10031. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  10032. }
  10033. if m.id == nil || m.oldValue == nil {
  10034. return v, errors.New("OldLag requires an ID field in the mutation")
  10035. }
  10036. oldValue, err := m.oldValue(ctx)
  10037. if err != nil {
  10038. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  10039. }
  10040. return oldValue.Lag, nil
  10041. }
  10042. // ResetLag resets all changes to the "lag" field.
  10043. func (m *ContactMutation) ResetLag() {
  10044. m.lag = nil
  10045. }
  10046. // SetGid sets the "gid" field.
  10047. func (m *ContactMutation) SetGid(s string) {
  10048. m.gid = &s
  10049. }
  10050. // Gid returns the value of the "gid" field in the mutation.
  10051. func (m *ContactMutation) Gid() (r string, exists bool) {
  10052. v := m.gid
  10053. if v == nil {
  10054. return
  10055. }
  10056. return *v, true
  10057. }
  10058. // OldGid returns the old "gid" field's value of the Contact entity.
  10059. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10061. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  10062. if !m.op.Is(OpUpdateOne) {
  10063. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  10064. }
  10065. if m.id == nil || m.oldValue == nil {
  10066. return v, errors.New("OldGid requires an ID field in the mutation")
  10067. }
  10068. oldValue, err := m.oldValue(ctx)
  10069. if err != nil {
  10070. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  10071. }
  10072. return oldValue.Gid, nil
  10073. }
  10074. // ResetGid resets all changes to the "gid" field.
  10075. func (m *ContactMutation) ResetGid() {
  10076. m.gid = nil
  10077. }
  10078. // SetGname sets the "gname" field.
  10079. func (m *ContactMutation) SetGname(s string) {
  10080. m.gname = &s
  10081. }
  10082. // Gname returns the value of the "gname" field in the mutation.
  10083. func (m *ContactMutation) Gname() (r string, exists bool) {
  10084. v := m.gname
  10085. if v == nil {
  10086. return
  10087. }
  10088. return *v, true
  10089. }
  10090. // OldGname returns the old "gname" field's value of the Contact entity.
  10091. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10093. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10094. if !m.op.Is(OpUpdateOne) {
  10095. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10096. }
  10097. if m.id == nil || m.oldValue == nil {
  10098. return v, errors.New("OldGname requires an ID field in the mutation")
  10099. }
  10100. oldValue, err := m.oldValue(ctx)
  10101. if err != nil {
  10102. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10103. }
  10104. return oldValue.Gname, nil
  10105. }
  10106. // ResetGname resets all changes to the "gname" field.
  10107. func (m *ContactMutation) ResetGname() {
  10108. m.gname = nil
  10109. }
  10110. // SetV3 sets the "v3" field.
  10111. func (m *ContactMutation) SetV3(s string) {
  10112. m.v3 = &s
  10113. }
  10114. // V3 returns the value of the "v3" field in the mutation.
  10115. func (m *ContactMutation) V3() (r string, exists bool) {
  10116. v := m.v3
  10117. if v == nil {
  10118. return
  10119. }
  10120. return *v, true
  10121. }
  10122. // OldV3 returns the old "v3" field's value of the Contact entity.
  10123. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10125. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10126. if !m.op.Is(OpUpdateOne) {
  10127. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10128. }
  10129. if m.id == nil || m.oldValue == nil {
  10130. return v, errors.New("OldV3 requires an ID field in the mutation")
  10131. }
  10132. oldValue, err := m.oldValue(ctx)
  10133. if err != nil {
  10134. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10135. }
  10136. return oldValue.V3, nil
  10137. }
  10138. // ResetV3 resets all changes to the "v3" field.
  10139. func (m *ContactMutation) ResetV3() {
  10140. m.v3 = nil
  10141. }
  10142. // SetOrganizationID sets the "organization_id" field.
  10143. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10144. m.organization_id = &u
  10145. m.addorganization_id = nil
  10146. }
  10147. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10148. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10149. v := m.organization_id
  10150. if v == nil {
  10151. return
  10152. }
  10153. return *v, true
  10154. }
  10155. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10156. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10158. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10159. if !m.op.Is(OpUpdateOne) {
  10160. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10161. }
  10162. if m.id == nil || m.oldValue == nil {
  10163. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10164. }
  10165. oldValue, err := m.oldValue(ctx)
  10166. if err != nil {
  10167. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10168. }
  10169. return oldValue.OrganizationID, nil
  10170. }
  10171. // AddOrganizationID adds u to the "organization_id" field.
  10172. func (m *ContactMutation) AddOrganizationID(u int64) {
  10173. if m.addorganization_id != nil {
  10174. *m.addorganization_id += u
  10175. } else {
  10176. m.addorganization_id = &u
  10177. }
  10178. }
  10179. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10180. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10181. v := m.addorganization_id
  10182. if v == nil {
  10183. return
  10184. }
  10185. return *v, true
  10186. }
  10187. // ClearOrganizationID clears the value of the "organization_id" field.
  10188. func (m *ContactMutation) ClearOrganizationID() {
  10189. m.organization_id = nil
  10190. m.addorganization_id = nil
  10191. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10192. }
  10193. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10194. func (m *ContactMutation) OrganizationIDCleared() bool {
  10195. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10196. return ok
  10197. }
  10198. // ResetOrganizationID resets all changes to the "organization_id" field.
  10199. func (m *ContactMutation) ResetOrganizationID() {
  10200. m.organization_id = nil
  10201. m.addorganization_id = nil
  10202. delete(m.clearedFields, contact.FieldOrganizationID)
  10203. }
  10204. // SetCtype sets the "ctype" field.
  10205. func (m *ContactMutation) SetCtype(u uint64) {
  10206. m.ctype = &u
  10207. m.addctype = nil
  10208. }
  10209. // Ctype returns the value of the "ctype" field in the mutation.
  10210. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10211. v := m.ctype
  10212. if v == nil {
  10213. return
  10214. }
  10215. return *v, true
  10216. }
  10217. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10218. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10220. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10221. if !m.op.Is(OpUpdateOne) {
  10222. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10223. }
  10224. if m.id == nil || m.oldValue == nil {
  10225. return v, errors.New("OldCtype requires an ID field in the mutation")
  10226. }
  10227. oldValue, err := m.oldValue(ctx)
  10228. if err != nil {
  10229. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10230. }
  10231. return oldValue.Ctype, nil
  10232. }
  10233. // AddCtype adds u to the "ctype" field.
  10234. func (m *ContactMutation) AddCtype(u int64) {
  10235. if m.addctype != nil {
  10236. *m.addctype += u
  10237. } else {
  10238. m.addctype = &u
  10239. }
  10240. }
  10241. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10242. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10243. v := m.addctype
  10244. if v == nil {
  10245. return
  10246. }
  10247. return *v, true
  10248. }
  10249. // ResetCtype resets all changes to the "ctype" field.
  10250. func (m *ContactMutation) ResetCtype() {
  10251. m.ctype = nil
  10252. m.addctype = nil
  10253. }
  10254. // SetCage sets the "cage" field.
  10255. func (m *ContactMutation) SetCage(i int) {
  10256. m.cage = &i
  10257. m.addcage = nil
  10258. }
  10259. // Cage returns the value of the "cage" field in the mutation.
  10260. func (m *ContactMutation) Cage() (r int, exists bool) {
  10261. v := m.cage
  10262. if v == nil {
  10263. return
  10264. }
  10265. return *v, true
  10266. }
  10267. // OldCage returns the old "cage" field's value of the Contact entity.
  10268. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10270. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10271. if !m.op.Is(OpUpdateOne) {
  10272. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10273. }
  10274. if m.id == nil || m.oldValue == nil {
  10275. return v, errors.New("OldCage requires an ID field in the mutation")
  10276. }
  10277. oldValue, err := m.oldValue(ctx)
  10278. if err != nil {
  10279. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10280. }
  10281. return oldValue.Cage, nil
  10282. }
  10283. // AddCage adds i to the "cage" field.
  10284. func (m *ContactMutation) AddCage(i int) {
  10285. if m.addcage != nil {
  10286. *m.addcage += i
  10287. } else {
  10288. m.addcage = &i
  10289. }
  10290. }
  10291. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10292. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10293. v := m.addcage
  10294. if v == nil {
  10295. return
  10296. }
  10297. return *v, true
  10298. }
  10299. // ResetCage resets all changes to the "cage" field.
  10300. func (m *ContactMutation) ResetCage() {
  10301. m.cage = nil
  10302. m.addcage = nil
  10303. }
  10304. // SetCname sets the "cname" field.
  10305. func (m *ContactMutation) SetCname(s string) {
  10306. m.cname = &s
  10307. }
  10308. // Cname returns the value of the "cname" field in the mutation.
  10309. func (m *ContactMutation) Cname() (r string, exists bool) {
  10310. v := m.cname
  10311. if v == nil {
  10312. return
  10313. }
  10314. return *v, true
  10315. }
  10316. // OldCname returns the old "cname" field's value of the Contact entity.
  10317. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10319. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10320. if !m.op.Is(OpUpdateOne) {
  10321. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10322. }
  10323. if m.id == nil || m.oldValue == nil {
  10324. return v, errors.New("OldCname requires an ID field in the mutation")
  10325. }
  10326. oldValue, err := m.oldValue(ctx)
  10327. if err != nil {
  10328. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10329. }
  10330. return oldValue.Cname, nil
  10331. }
  10332. // ResetCname resets all changes to the "cname" field.
  10333. func (m *ContactMutation) ResetCname() {
  10334. m.cname = nil
  10335. }
  10336. // SetCarea sets the "carea" field.
  10337. func (m *ContactMutation) SetCarea(s string) {
  10338. m.carea = &s
  10339. }
  10340. // Carea returns the value of the "carea" field in the mutation.
  10341. func (m *ContactMutation) Carea() (r string, exists bool) {
  10342. v := m.carea
  10343. if v == nil {
  10344. return
  10345. }
  10346. return *v, true
  10347. }
  10348. // OldCarea returns the old "carea" field's value of the Contact entity.
  10349. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10351. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10352. if !m.op.Is(OpUpdateOne) {
  10353. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10354. }
  10355. if m.id == nil || m.oldValue == nil {
  10356. return v, errors.New("OldCarea requires an ID field in the mutation")
  10357. }
  10358. oldValue, err := m.oldValue(ctx)
  10359. if err != nil {
  10360. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10361. }
  10362. return oldValue.Carea, nil
  10363. }
  10364. // ResetCarea resets all changes to the "carea" field.
  10365. func (m *ContactMutation) ResetCarea() {
  10366. m.carea = nil
  10367. }
  10368. // SetCbirthday sets the "cbirthday" field.
  10369. func (m *ContactMutation) SetCbirthday(s string) {
  10370. m.cbirthday = &s
  10371. }
  10372. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10373. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10374. v := m.cbirthday
  10375. if v == nil {
  10376. return
  10377. }
  10378. return *v, true
  10379. }
  10380. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10381. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10383. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10384. if !m.op.Is(OpUpdateOne) {
  10385. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10386. }
  10387. if m.id == nil || m.oldValue == nil {
  10388. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10389. }
  10390. oldValue, err := m.oldValue(ctx)
  10391. if err != nil {
  10392. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10393. }
  10394. return oldValue.Cbirthday, nil
  10395. }
  10396. // ResetCbirthday resets all changes to the "cbirthday" field.
  10397. func (m *ContactMutation) ResetCbirthday() {
  10398. m.cbirthday = nil
  10399. }
  10400. // SetCbirtharea sets the "cbirtharea" field.
  10401. func (m *ContactMutation) SetCbirtharea(s string) {
  10402. m.cbirtharea = &s
  10403. }
  10404. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10405. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10406. v := m.cbirtharea
  10407. if v == nil {
  10408. return
  10409. }
  10410. return *v, true
  10411. }
  10412. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10413. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10415. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10416. if !m.op.Is(OpUpdateOne) {
  10417. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10418. }
  10419. if m.id == nil || m.oldValue == nil {
  10420. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10421. }
  10422. oldValue, err := m.oldValue(ctx)
  10423. if err != nil {
  10424. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10425. }
  10426. return oldValue.Cbirtharea, nil
  10427. }
  10428. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10429. func (m *ContactMutation) ResetCbirtharea() {
  10430. m.cbirtharea = nil
  10431. }
  10432. // SetCidcardNo sets the "cidcard_no" field.
  10433. func (m *ContactMutation) SetCidcardNo(s string) {
  10434. m.cidcard_no = &s
  10435. }
  10436. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10437. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10438. v := m.cidcard_no
  10439. if v == nil {
  10440. return
  10441. }
  10442. return *v, true
  10443. }
  10444. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10445. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10447. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10448. if !m.op.Is(OpUpdateOne) {
  10449. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10450. }
  10451. if m.id == nil || m.oldValue == nil {
  10452. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10453. }
  10454. oldValue, err := m.oldValue(ctx)
  10455. if err != nil {
  10456. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10457. }
  10458. return oldValue.CidcardNo, nil
  10459. }
  10460. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10461. func (m *ContactMutation) ResetCidcardNo() {
  10462. m.cidcard_no = nil
  10463. }
  10464. // SetCtitle sets the "ctitle" field.
  10465. func (m *ContactMutation) SetCtitle(s string) {
  10466. m.ctitle = &s
  10467. }
  10468. // Ctitle returns the value of the "ctitle" field in the mutation.
  10469. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10470. v := m.ctitle
  10471. if v == nil {
  10472. return
  10473. }
  10474. return *v, true
  10475. }
  10476. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10477. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10479. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10480. if !m.op.Is(OpUpdateOne) {
  10481. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10482. }
  10483. if m.id == nil || m.oldValue == nil {
  10484. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10485. }
  10486. oldValue, err := m.oldValue(ctx)
  10487. if err != nil {
  10488. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10489. }
  10490. return oldValue.Ctitle, nil
  10491. }
  10492. // ResetCtitle resets all changes to the "ctitle" field.
  10493. func (m *ContactMutation) ResetCtitle() {
  10494. m.ctitle = nil
  10495. }
  10496. // SetCc sets the "cc" field.
  10497. func (m *ContactMutation) SetCc(s string) {
  10498. m.cc = &s
  10499. }
  10500. // Cc returns the value of the "cc" field in the mutation.
  10501. func (m *ContactMutation) Cc() (r string, exists bool) {
  10502. v := m.cc
  10503. if v == nil {
  10504. return
  10505. }
  10506. return *v, true
  10507. }
  10508. // OldCc returns the old "cc" field's value of the Contact entity.
  10509. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10511. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10512. if !m.op.Is(OpUpdateOne) {
  10513. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10514. }
  10515. if m.id == nil || m.oldValue == nil {
  10516. return v, errors.New("OldCc requires an ID field in the mutation")
  10517. }
  10518. oldValue, err := m.oldValue(ctx)
  10519. if err != nil {
  10520. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10521. }
  10522. return oldValue.Cc, nil
  10523. }
  10524. // ResetCc resets all changes to the "cc" field.
  10525. func (m *ContactMutation) ResetCc() {
  10526. m.cc = nil
  10527. }
  10528. // SetPhone sets the "phone" field.
  10529. func (m *ContactMutation) SetPhone(s string) {
  10530. m.phone = &s
  10531. }
  10532. // Phone returns the value of the "phone" field in the mutation.
  10533. func (m *ContactMutation) Phone() (r string, exists bool) {
  10534. v := m.phone
  10535. if v == nil {
  10536. return
  10537. }
  10538. return *v, true
  10539. }
  10540. // OldPhone returns the old "phone" field's value of the Contact entity.
  10541. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10543. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10544. if !m.op.Is(OpUpdateOne) {
  10545. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10546. }
  10547. if m.id == nil || m.oldValue == nil {
  10548. return v, errors.New("OldPhone requires an ID field in the mutation")
  10549. }
  10550. oldValue, err := m.oldValue(ctx)
  10551. if err != nil {
  10552. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10553. }
  10554. return oldValue.Phone, nil
  10555. }
  10556. // ResetPhone resets all changes to the "phone" field.
  10557. func (m *ContactMutation) ResetPhone() {
  10558. m.phone = nil
  10559. }
  10560. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10561. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10562. if m.contact_relationships == nil {
  10563. m.contact_relationships = make(map[uint64]struct{})
  10564. }
  10565. for i := range ids {
  10566. m.contact_relationships[ids[i]] = struct{}{}
  10567. }
  10568. }
  10569. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10570. func (m *ContactMutation) ClearContactRelationships() {
  10571. m.clearedcontact_relationships = true
  10572. }
  10573. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10574. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10575. return m.clearedcontact_relationships
  10576. }
  10577. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10578. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10579. if m.removedcontact_relationships == nil {
  10580. m.removedcontact_relationships = make(map[uint64]struct{})
  10581. }
  10582. for i := range ids {
  10583. delete(m.contact_relationships, ids[i])
  10584. m.removedcontact_relationships[ids[i]] = struct{}{}
  10585. }
  10586. }
  10587. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10588. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10589. for id := range m.removedcontact_relationships {
  10590. ids = append(ids, id)
  10591. }
  10592. return
  10593. }
  10594. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10595. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10596. for id := range m.contact_relationships {
  10597. ids = append(ids, id)
  10598. }
  10599. return
  10600. }
  10601. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10602. func (m *ContactMutation) ResetContactRelationships() {
  10603. m.contact_relationships = nil
  10604. m.clearedcontact_relationships = false
  10605. m.removedcontact_relationships = nil
  10606. }
  10607. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  10608. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  10609. if m.contact_fields == nil {
  10610. m.contact_fields = make(map[uint64]struct{})
  10611. }
  10612. for i := range ids {
  10613. m.contact_fields[ids[i]] = struct{}{}
  10614. }
  10615. }
  10616. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  10617. func (m *ContactMutation) ClearContactFields() {
  10618. m.clearedcontact_fields = true
  10619. }
  10620. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  10621. func (m *ContactMutation) ContactFieldsCleared() bool {
  10622. return m.clearedcontact_fields
  10623. }
  10624. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  10625. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  10626. if m.removedcontact_fields == nil {
  10627. m.removedcontact_fields = make(map[uint64]struct{})
  10628. }
  10629. for i := range ids {
  10630. delete(m.contact_fields, ids[i])
  10631. m.removedcontact_fields[ids[i]] = struct{}{}
  10632. }
  10633. }
  10634. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  10635. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  10636. for id := range m.removedcontact_fields {
  10637. ids = append(ids, id)
  10638. }
  10639. return
  10640. }
  10641. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  10642. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  10643. for id := range m.contact_fields {
  10644. ids = append(ids, id)
  10645. }
  10646. return
  10647. }
  10648. // ResetContactFields resets all changes to the "contact_fields" edge.
  10649. func (m *ContactMutation) ResetContactFields() {
  10650. m.contact_fields = nil
  10651. m.clearedcontact_fields = false
  10652. m.removedcontact_fields = nil
  10653. }
  10654. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10655. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10656. if m.contact_messages == nil {
  10657. m.contact_messages = make(map[uint64]struct{})
  10658. }
  10659. for i := range ids {
  10660. m.contact_messages[ids[i]] = struct{}{}
  10661. }
  10662. }
  10663. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10664. func (m *ContactMutation) ClearContactMessages() {
  10665. m.clearedcontact_messages = true
  10666. }
  10667. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10668. func (m *ContactMutation) ContactMessagesCleared() bool {
  10669. return m.clearedcontact_messages
  10670. }
  10671. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10672. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10673. if m.removedcontact_messages == nil {
  10674. m.removedcontact_messages = make(map[uint64]struct{})
  10675. }
  10676. for i := range ids {
  10677. delete(m.contact_messages, ids[i])
  10678. m.removedcontact_messages[ids[i]] = struct{}{}
  10679. }
  10680. }
  10681. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10682. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10683. for id := range m.removedcontact_messages {
  10684. ids = append(ids, id)
  10685. }
  10686. return
  10687. }
  10688. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10689. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10690. for id := range m.contact_messages {
  10691. ids = append(ids, id)
  10692. }
  10693. return
  10694. }
  10695. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10696. func (m *ContactMutation) ResetContactMessages() {
  10697. m.contact_messages = nil
  10698. m.clearedcontact_messages = false
  10699. m.removedcontact_messages = nil
  10700. }
  10701. // Where appends a list predicates to the ContactMutation builder.
  10702. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10703. m.predicates = append(m.predicates, ps...)
  10704. }
  10705. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10706. // users can use type-assertion to append predicates that do not depend on any generated package.
  10707. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10708. p := make([]predicate.Contact, len(ps))
  10709. for i := range ps {
  10710. p[i] = ps[i]
  10711. }
  10712. m.Where(p...)
  10713. }
  10714. // Op returns the operation name.
  10715. func (m *ContactMutation) Op() Op {
  10716. return m.op
  10717. }
  10718. // SetOp allows setting the mutation operation.
  10719. func (m *ContactMutation) SetOp(op Op) {
  10720. m.op = op
  10721. }
  10722. // Type returns the node type of this mutation (Contact).
  10723. func (m *ContactMutation) Type() string {
  10724. return m.typ
  10725. }
  10726. // Fields returns all fields that were changed during this mutation. Note that in
  10727. // order to get all numeric fields that were incremented/decremented, call
  10728. // AddedFields().
  10729. func (m *ContactMutation) Fields() []string {
  10730. fields := make([]string, 0, 30)
  10731. if m.created_at != nil {
  10732. fields = append(fields, contact.FieldCreatedAt)
  10733. }
  10734. if m.updated_at != nil {
  10735. fields = append(fields, contact.FieldUpdatedAt)
  10736. }
  10737. if m.status != nil {
  10738. fields = append(fields, contact.FieldStatus)
  10739. }
  10740. if m.deleted_at != nil {
  10741. fields = append(fields, contact.FieldDeletedAt)
  10742. }
  10743. if m.wx_wxid != nil {
  10744. fields = append(fields, contact.FieldWxWxid)
  10745. }
  10746. if m._type != nil {
  10747. fields = append(fields, contact.FieldType)
  10748. }
  10749. if m.wxid != nil {
  10750. fields = append(fields, contact.FieldWxid)
  10751. }
  10752. if m.account != nil {
  10753. fields = append(fields, contact.FieldAccount)
  10754. }
  10755. if m.nickname != nil {
  10756. fields = append(fields, contact.FieldNickname)
  10757. }
  10758. if m.markname != nil {
  10759. fields = append(fields, contact.FieldMarkname)
  10760. }
  10761. if m.headimg != nil {
  10762. fields = append(fields, contact.FieldHeadimg)
  10763. }
  10764. if m.sex != nil {
  10765. fields = append(fields, contact.FieldSex)
  10766. }
  10767. if m.starrole != nil {
  10768. fields = append(fields, contact.FieldStarrole)
  10769. }
  10770. if m.dontseeit != nil {
  10771. fields = append(fields, contact.FieldDontseeit)
  10772. }
  10773. if m.dontseeme != nil {
  10774. fields = append(fields, contact.FieldDontseeme)
  10775. }
  10776. if m.lag != nil {
  10777. fields = append(fields, contact.FieldLag)
  10778. }
  10779. if m.gid != nil {
  10780. fields = append(fields, contact.FieldGid)
  10781. }
  10782. if m.gname != nil {
  10783. fields = append(fields, contact.FieldGname)
  10784. }
  10785. if m.v3 != nil {
  10786. fields = append(fields, contact.FieldV3)
  10787. }
  10788. if m.organization_id != nil {
  10789. fields = append(fields, contact.FieldOrganizationID)
  10790. }
  10791. if m.ctype != nil {
  10792. fields = append(fields, contact.FieldCtype)
  10793. }
  10794. if m.cage != nil {
  10795. fields = append(fields, contact.FieldCage)
  10796. }
  10797. if m.cname != nil {
  10798. fields = append(fields, contact.FieldCname)
  10799. }
  10800. if m.carea != nil {
  10801. fields = append(fields, contact.FieldCarea)
  10802. }
  10803. if m.cbirthday != nil {
  10804. fields = append(fields, contact.FieldCbirthday)
  10805. }
  10806. if m.cbirtharea != nil {
  10807. fields = append(fields, contact.FieldCbirtharea)
  10808. }
  10809. if m.cidcard_no != nil {
  10810. fields = append(fields, contact.FieldCidcardNo)
  10811. }
  10812. if m.ctitle != nil {
  10813. fields = append(fields, contact.FieldCtitle)
  10814. }
  10815. if m.cc != nil {
  10816. fields = append(fields, contact.FieldCc)
  10817. }
  10818. if m.phone != nil {
  10819. fields = append(fields, contact.FieldPhone)
  10820. }
  10821. return fields
  10822. }
  10823. // Field returns the value of a field with the given name. The second boolean
  10824. // return value indicates that this field was not set, or was not defined in the
  10825. // schema.
  10826. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  10827. switch name {
  10828. case contact.FieldCreatedAt:
  10829. return m.CreatedAt()
  10830. case contact.FieldUpdatedAt:
  10831. return m.UpdatedAt()
  10832. case contact.FieldStatus:
  10833. return m.Status()
  10834. case contact.FieldDeletedAt:
  10835. return m.DeletedAt()
  10836. case contact.FieldWxWxid:
  10837. return m.WxWxid()
  10838. case contact.FieldType:
  10839. return m.GetType()
  10840. case contact.FieldWxid:
  10841. return m.Wxid()
  10842. case contact.FieldAccount:
  10843. return m.Account()
  10844. case contact.FieldNickname:
  10845. return m.Nickname()
  10846. case contact.FieldMarkname:
  10847. return m.Markname()
  10848. case contact.FieldHeadimg:
  10849. return m.Headimg()
  10850. case contact.FieldSex:
  10851. return m.Sex()
  10852. case contact.FieldStarrole:
  10853. return m.Starrole()
  10854. case contact.FieldDontseeit:
  10855. return m.Dontseeit()
  10856. case contact.FieldDontseeme:
  10857. return m.Dontseeme()
  10858. case contact.FieldLag:
  10859. return m.Lag()
  10860. case contact.FieldGid:
  10861. return m.Gid()
  10862. case contact.FieldGname:
  10863. return m.Gname()
  10864. case contact.FieldV3:
  10865. return m.V3()
  10866. case contact.FieldOrganizationID:
  10867. return m.OrganizationID()
  10868. case contact.FieldCtype:
  10869. return m.Ctype()
  10870. case contact.FieldCage:
  10871. return m.Cage()
  10872. case contact.FieldCname:
  10873. return m.Cname()
  10874. case contact.FieldCarea:
  10875. return m.Carea()
  10876. case contact.FieldCbirthday:
  10877. return m.Cbirthday()
  10878. case contact.FieldCbirtharea:
  10879. return m.Cbirtharea()
  10880. case contact.FieldCidcardNo:
  10881. return m.CidcardNo()
  10882. case contact.FieldCtitle:
  10883. return m.Ctitle()
  10884. case contact.FieldCc:
  10885. return m.Cc()
  10886. case contact.FieldPhone:
  10887. return m.Phone()
  10888. }
  10889. return nil, false
  10890. }
  10891. // OldField returns the old value of the field from the database. An error is
  10892. // returned if the mutation operation is not UpdateOne, or the query to the
  10893. // database failed.
  10894. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10895. switch name {
  10896. case contact.FieldCreatedAt:
  10897. return m.OldCreatedAt(ctx)
  10898. case contact.FieldUpdatedAt:
  10899. return m.OldUpdatedAt(ctx)
  10900. case contact.FieldStatus:
  10901. return m.OldStatus(ctx)
  10902. case contact.FieldDeletedAt:
  10903. return m.OldDeletedAt(ctx)
  10904. case contact.FieldWxWxid:
  10905. return m.OldWxWxid(ctx)
  10906. case contact.FieldType:
  10907. return m.OldType(ctx)
  10908. case contact.FieldWxid:
  10909. return m.OldWxid(ctx)
  10910. case contact.FieldAccount:
  10911. return m.OldAccount(ctx)
  10912. case contact.FieldNickname:
  10913. return m.OldNickname(ctx)
  10914. case contact.FieldMarkname:
  10915. return m.OldMarkname(ctx)
  10916. case contact.FieldHeadimg:
  10917. return m.OldHeadimg(ctx)
  10918. case contact.FieldSex:
  10919. return m.OldSex(ctx)
  10920. case contact.FieldStarrole:
  10921. return m.OldStarrole(ctx)
  10922. case contact.FieldDontseeit:
  10923. return m.OldDontseeit(ctx)
  10924. case contact.FieldDontseeme:
  10925. return m.OldDontseeme(ctx)
  10926. case contact.FieldLag:
  10927. return m.OldLag(ctx)
  10928. case contact.FieldGid:
  10929. return m.OldGid(ctx)
  10930. case contact.FieldGname:
  10931. return m.OldGname(ctx)
  10932. case contact.FieldV3:
  10933. return m.OldV3(ctx)
  10934. case contact.FieldOrganizationID:
  10935. return m.OldOrganizationID(ctx)
  10936. case contact.FieldCtype:
  10937. return m.OldCtype(ctx)
  10938. case contact.FieldCage:
  10939. return m.OldCage(ctx)
  10940. case contact.FieldCname:
  10941. return m.OldCname(ctx)
  10942. case contact.FieldCarea:
  10943. return m.OldCarea(ctx)
  10944. case contact.FieldCbirthday:
  10945. return m.OldCbirthday(ctx)
  10946. case contact.FieldCbirtharea:
  10947. return m.OldCbirtharea(ctx)
  10948. case contact.FieldCidcardNo:
  10949. return m.OldCidcardNo(ctx)
  10950. case contact.FieldCtitle:
  10951. return m.OldCtitle(ctx)
  10952. case contact.FieldCc:
  10953. return m.OldCc(ctx)
  10954. case contact.FieldPhone:
  10955. return m.OldPhone(ctx)
  10956. }
  10957. return nil, fmt.Errorf("unknown Contact field %s", name)
  10958. }
  10959. // SetField sets the value of a field with the given name. It returns an error if
  10960. // the field is not defined in the schema, or if the type mismatched the field
  10961. // type.
  10962. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  10963. switch name {
  10964. case contact.FieldCreatedAt:
  10965. v, ok := value.(time.Time)
  10966. if !ok {
  10967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10968. }
  10969. m.SetCreatedAt(v)
  10970. return nil
  10971. case contact.FieldUpdatedAt:
  10972. v, ok := value.(time.Time)
  10973. if !ok {
  10974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10975. }
  10976. m.SetUpdatedAt(v)
  10977. return nil
  10978. case contact.FieldStatus:
  10979. v, ok := value.(uint8)
  10980. if !ok {
  10981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10982. }
  10983. m.SetStatus(v)
  10984. return nil
  10985. case contact.FieldDeletedAt:
  10986. v, ok := value.(time.Time)
  10987. if !ok {
  10988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10989. }
  10990. m.SetDeletedAt(v)
  10991. return nil
  10992. case contact.FieldWxWxid:
  10993. v, ok := value.(string)
  10994. if !ok {
  10995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10996. }
  10997. m.SetWxWxid(v)
  10998. return nil
  10999. case contact.FieldType:
  11000. v, ok := value.(int)
  11001. if !ok {
  11002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11003. }
  11004. m.SetType(v)
  11005. return nil
  11006. case contact.FieldWxid:
  11007. v, ok := value.(string)
  11008. if !ok {
  11009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11010. }
  11011. m.SetWxid(v)
  11012. return nil
  11013. case contact.FieldAccount:
  11014. v, ok := value.(string)
  11015. if !ok {
  11016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11017. }
  11018. m.SetAccount(v)
  11019. return nil
  11020. case contact.FieldNickname:
  11021. v, ok := value.(string)
  11022. if !ok {
  11023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11024. }
  11025. m.SetNickname(v)
  11026. return nil
  11027. case contact.FieldMarkname:
  11028. v, ok := value.(string)
  11029. if !ok {
  11030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11031. }
  11032. m.SetMarkname(v)
  11033. return nil
  11034. case contact.FieldHeadimg:
  11035. v, ok := value.(string)
  11036. if !ok {
  11037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11038. }
  11039. m.SetHeadimg(v)
  11040. return nil
  11041. case contact.FieldSex:
  11042. v, ok := value.(int)
  11043. if !ok {
  11044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11045. }
  11046. m.SetSex(v)
  11047. return nil
  11048. case contact.FieldStarrole:
  11049. v, ok := value.(string)
  11050. if !ok {
  11051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11052. }
  11053. m.SetStarrole(v)
  11054. return nil
  11055. case contact.FieldDontseeit:
  11056. v, ok := value.(int)
  11057. if !ok {
  11058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11059. }
  11060. m.SetDontseeit(v)
  11061. return nil
  11062. case contact.FieldDontseeme:
  11063. v, ok := value.(int)
  11064. if !ok {
  11065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11066. }
  11067. m.SetDontseeme(v)
  11068. return nil
  11069. case contact.FieldLag:
  11070. v, ok := value.(string)
  11071. if !ok {
  11072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11073. }
  11074. m.SetLag(v)
  11075. return nil
  11076. case contact.FieldGid:
  11077. v, ok := value.(string)
  11078. if !ok {
  11079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11080. }
  11081. m.SetGid(v)
  11082. return nil
  11083. case contact.FieldGname:
  11084. v, ok := value.(string)
  11085. if !ok {
  11086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11087. }
  11088. m.SetGname(v)
  11089. return nil
  11090. case contact.FieldV3:
  11091. v, ok := value.(string)
  11092. if !ok {
  11093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11094. }
  11095. m.SetV3(v)
  11096. return nil
  11097. case contact.FieldOrganizationID:
  11098. v, ok := value.(uint64)
  11099. if !ok {
  11100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11101. }
  11102. m.SetOrganizationID(v)
  11103. return nil
  11104. case contact.FieldCtype:
  11105. v, ok := value.(uint64)
  11106. if !ok {
  11107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11108. }
  11109. m.SetCtype(v)
  11110. return nil
  11111. case contact.FieldCage:
  11112. v, ok := value.(int)
  11113. if !ok {
  11114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11115. }
  11116. m.SetCage(v)
  11117. return nil
  11118. case contact.FieldCname:
  11119. v, ok := value.(string)
  11120. if !ok {
  11121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11122. }
  11123. m.SetCname(v)
  11124. return nil
  11125. case contact.FieldCarea:
  11126. v, ok := value.(string)
  11127. if !ok {
  11128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11129. }
  11130. m.SetCarea(v)
  11131. return nil
  11132. case contact.FieldCbirthday:
  11133. v, ok := value.(string)
  11134. if !ok {
  11135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11136. }
  11137. m.SetCbirthday(v)
  11138. return nil
  11139. case contact.FieldCbirtharea:
  11140. v, ok := value.(string)
  11141. if !ok {
  11142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11143. }
  11144. m.SetCbirtharea(v)
  11145. return nil
  11146. case contact.FieldCidcardNo:
  11147. v, ok := value.(string)
  11148. if !ok {
  11149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11150. }
  11151. m.SetCidcardNo(v)
  11152. return nil
  11153. case contact.FieldCtitle:
  11154. v, ok := value.(string)
  11155. if !ok {
  11156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11157. }
  11158. m.SetCtitle(v)
  11159. return nil
  11160. case contact.FieldCc:
  11161. v, ok := value.(string)
  11162. if !ok {
  11163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11164. }
  11165. m.SetCc(v)
  11166. return nil
  11167. case contact.FieldPhone:
  11168. v, ok := value.(string)
  11169. if !ok {
  11170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11171. }
  11172. m.SetPhone(v)
  11173. return nil
  11174. }
  11175. return fmt.Errorf("unknown Contact field %s", name)
  11176. }
  11177. // AddedFields returns all numeric fields that were incremented/decremented during
  11178. // this mutation.
  11179. func (m *ContactMutation) AddedFields() []string {
  11180. var fields []string
  11181. if m.addstatus != nil {
  11182. fields = append(fields, contact.FieldStatus)
  11183. }
  11184. if m.add_type != nil {
  11185. fields = append(fields, contact.FieldType)
  11186. }
  11187. if m.addsex != nil {
  11188. fields = append(fields, contact.FieldSex)
  11189. }
  11190. if m.adddontseeit != nil {
  11191. fields = append(fields, contact.FieldDontseeit)
  11192. }
  11193. if m.adddontseeme != nil {
  11194. fields = append(fields, contact.FieldDontseeme)
  11195. }
  11196. if m.addorganization_id != nil {
  11197. fields = append(fields, contact.FieldOrganizationID)
  11198. }
  11199. if m.addctype != nil {
  11200. fields = append(fields, contact.FieldCtype)
  11201. }
  11202. if m.addcage != nil {
  11203. fields = append(fields, contact.FieldCage)
  11204. }
  11205. return fields
  11206. }
  11207. // AddedField returns the numeric value that was incremented/decremented on a field
  11208. // with the given name. The second boolean return value indicates that this field
  11209. // was not set, or was not defined in the schema.
  11210. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11211. switch name {
  11212. case contact.FieldStatus:
  11213. return m.AddedStatus()
  11214. case contact.FieldType:
  11215. return m.AddedType()
  11216. case contact.FieldSex:
  11217. return m.AddedSex()
  11218. case contact.FieldDontseeit:
  11219. return m.AddedDontseeit()
  11220. case contact.FieldDontseeme:
  11221. return m.AddedDontseeme()
  11222. case contact.FieldOrganizationID:
  11223. return m.AddedOrganizationID()
  11224. case contact.FieldCtype:
  11225. return m.AddedCtype()
  11226. case contact.FieldCage:
  11227. return m.AddedCage()
  11228. }
  11229. return nil, false
  11230. }
  11231. // AddField adds the value to the field with the given name. It returns an error if
  11232. // the field is not defined in the schema, or if the type mismatched the field
  11233. // type.
  11234. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11235. switch name {
  11236. case contact.FieldStatus:
  11237. v, ok := value.(int8)
  11238. if !ok {
  11239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11240. }
  11241. m.AddStatus(v)
  11242. return nil
  11243. case contact.FieldType:
  11244. v, ok := value.(int)
  11245. if !ok {
  11246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11247. }
  11248. m.AddType(v)
  11249. return nil
  11250. case contact.FieldSex:
  11251. v, ok := value.(int)
  11252. if !ok {
  11253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11254. }
  11255. m.AddSex(v)
  11256. return nil
  11257. case contact.FieldDontseeit:
  11258. v, ok := value.(int)
  11259. if !ok {
  11260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11261. }
  11262. m.AddDontseeit(v)
  11263. return nil
  11264. case contact.FieldDontseeme:
  11265. v, ok := value.(int)
  11266. if !ok {
  11267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11268. }
  11269. m.AddDontseeme(v)
  11270. return nil
  11271. case contact.FieldOrganizationID:
  11272. v, ok := value.(int64)
  11273. if !ok {
  11274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11275. }
  11276. m.AddOrganizationID(v)
  11277. return nil
  11278. case contact.FieldCtype:
  11279. v, ok := value.(int64)
  11280. if !ok {
  11281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11282. }
  11283. m.AddCtype(v)
  11284. return nil
  11285. case contact.FieldCage:
  11286. v, ok := value.(int)
  11287. if !ok {
  11288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11289. }
  11290. m.AddCage(v)
  11291. return nil
  11292. }
  11293. return fmt.Errorf("unknown Contact numeric field %s", name)
  11294. }
  11295. // ClearedFields returns all nullable fields that were cleared during this
  11296. // mutation.
  11297. func (m *ContactMutation) ClearedFields() []string {
  11298. var fields []string
  11299. if m.FieldCleared(contact.FieldStatus) {
  11300. fields = append(fields, contact.FieldStatus)
  11301. }
  11302. if m.FieldCleared(contact.FieldDeletedAt) {
  11303. fields = append(fields, contact.FieldDeletedAt)
  11304. }
  11305. if m.FieldCleared(contact.FieldType) {
  11306. fields = append(fields, contact.FieldType)
  11307. }
  11308. if m.FieldCleared(contact.FieldOrganizationID) {
  11309. fields = append(fields, contact.FieldOrganizationID)
  11310. }
  11311. return fields
  11312. }
  11313. // FieldCleared returns a boolean indicating if a field with the given name was
  11314. // cleared in this mutation.
  11315. func (m *ContactMutation) FieldCleared(name string) bool {
  11316. _, ok := m.clearedFields[name]
  11317. return ok
  11318. }
  11319. // ClearField clears the value of the field with the given name. It returns an
  11320. // error if the field is not defined in the schema.
  11321. func (m *ContactMutation) ClearField(name string) error {
  11322. switch name {
  11323. case contact.FieldStatus:
  11324. m.ClearStatus()
  11325. return nil
  11326. case contact.FieldDeletedAt:
  11327. m.ClearDeletedAt()
  11328. return nil
  11329. case contact.FieldType:
  11330. m.ClearType()
  11331. return nil
  11332. case contact.FieldOrganizationID:
  11333. m.ClearOrganizationID()
  11334. return nil
  11335. }
  11336. return fmt.Errorf("unknown Contact nullable field %s", name)
  11337. }
  11338. // ResetField resets all changes in the mutation for the field with the given name.
  11339. // It returns an error if the field is not defined in the schema.
  11340. func (m *ContactMutation) ResetField(name string) error {
  11341. switch name {
  11342. case contact.FieldCreatedAt:
  11343. m.ResetCreatedAt()
  11344. return nil
  11345. case contact.FieldUpdatedAt:
  11346. m.ResetUpdatedAt()
  11347. return nil
  11348. case contact.FieldStatus:
  11349. m.ResetStatus()
  11350. return nil
  11351. case contact.FieldDeletedAt:
  11352. m.ResetDeletedAt()
  11353. return nil
  11354. case contact.FieldWxWxid:
  11355. m.ResetWxWxid()
  11356. return nil
  11357. case contact.FieldType:
  11358. m.ResetType()
  11359. return nil
  11360. case contact.FieldWxid:
  11361. m.ResetWxid()
  11362. return nil
  11363. case contact.FieldAccount:
  11364. m.ResetAccount()
  11365. return nil
  11366. case contact.FieldNickname:
  11367. m.ResetNickname()
  11368. return nil
  11369. case contact.FieldMarkname:
  11370. m.ResetMarkname()
  11371. return nil
  11372. case contact.FieldHeadimg:
  11373. m.ResetHeadimg()
  11374. return nil
  11375. case contact.FieldSex:
  11376. m.ResetSex()
  11377. return nil
  11378. case contact.FieldStarrole:
  11379. m.ResetStarrole()
  11380. return nil
  11381. case contact.FieldDontseeit:
  11382. m.ResetDontseeit()
  11383. return nil
  11384. case contact.FieldDontseeme:
  11385. m.ResetDontseeme()
  11386. return nil
  11387. case contact.FieldLag:
  11388. m.ResetLag()
  11389. return nil
  11390. case contact.FieldGid:
  11391. m.ResetGid()
  11392. return nil
  11393. case contact.FieldGname:
  11394. m.ResetGname()
  11395. return nil
  11396. case contact.FieldV3:
  11397. m.ResetV3()
  11398. return nil
  11399. case contact.FieldOrganizationID:
  11400. m.ResetOrganizationID()
  11401. return nil
  11402. case contact.FieldCtype:
  11403. m.ResetCtype()
  11404. return nil
  11405. case contact.FieldCage:
  11406. m.ResetCage()
  11407. return nil
  11408. case contact.FieldCname:
  11409. m.ResetCname()
  11410. return nil
  11411. case contact.FieldCarea:
  11412. m.ResetCarea()
  11413. return nil
  11414. case contact.FieldCbirthday:
  11415. m.ResetCbirthday()
  11416. return nil
  11417. case contact.FieldCbirtharea:
  11418. m.ResetCbirtharea()
  11419. return nil
  11420. case contact.FieldCidcardNo:
  11421. m.ResetCidcardNo()
  11422. return nil
  11423. case contact.FieldCtitle:
  11424. m.ResetCtitle()
  11425. return nil
  11426. case contact.FieldCc:
  11427. m.ResetCc()
  11428. return nil
  11429. case contact.FieldPhone:
  11430. m.ResetPhone()
  11431. return nil
  11432. }
  11433. return fmt.Errorf("unknown Contact field %s", name)
  11434. }
  11435. // AddedEdges returns all edge names that were set/added in this mutation.
  11436. func (m *ContactMutation) AddedEdges() []string {
  11437. edges := make([]string, 0, 3)
  11438. if m.contact_relationships != nil {
  11439. edges = append(edges, contact.EdgeContactRelationships)
  11440. }
  11441. if m.contact_fields != nil {
  11442. edges = append(edges, contact.EdgeContactFields)
  11443. }
  11444. if m.contact_messages != nil {
  11445. edges = append(edges, contact.EdgeContactMessages)
  11446. }
  11447. return edges
  11448. }
  11449. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11450. // name in this mutation.
  11451. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11452. switch name {
  11453. case contact.EdgeContactRelationships:
  11454. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11455. for id := range m.contact_relationships {
  11456. ids = append(ids, id)
  11457. }
  11458. return ids
  11459. case contact.EdgeContactFields:
  11460. ids := make([]ent.Value, 0, len(m.contact_fields))
  11461. for id := range m.contact_fields {
  11462. ids = append(ids, id)
  11463. }
  11464. return ids
  11465. case contact.EdgeContactMessages:
  11466. ids := make([]ent.Value, 0, len(m.contact_messages))
  11467. for id := range m.contact_messages {
  11468. ids = append(ids, id)
  11469. }
  11470. return ids
  11471. }
  11472. return nil
  11473. }
  11474. // RemovedEdges returns all edge names that were removed in this mutation.
  11475. func (m *ContactMutation) RemovedEdges() []string {
  11476. edges := make([]string, 0, 3)
  11477. if m.removedcontact_relationships != nil {
  11478. edges = append(edges, contact.EdgeContactRelationships)
  11479. }
  11480. if m.removedcontact_fields != nil {
  11481. edges = append(edges, contact.EdgeContactFields)
  11482. }
  11483. if m.removedcontact_messages != nil {
  11484. edges = append(edges, contact.EdgeContactMessages)
  11485. }
  11486. return edges
  11487. }
  11488. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11489. // the given name in this mutation.
  11490. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11491. switch name {
  11492. case contact.EdgeContactRelationships:
  11493. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11494. for id := range m.removedcontact_relationships {
  11495. ids = append(ids, id)
  11496. }
  11497. return ids
  11498. case contact.EdgeContactFields:
  11499. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  11500. for id := range m.removedcontact_fields {
  11501. ids = append(ids, id)
  11502. }
  11503. return ids
  11504. case contact.EdgeContactMessages:
  11505. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11506. for id := range m.removedcontact_messages {
  11507. ids = append(ids, id)
  11508. }
  11509. return ids
  11510. }
  11511. return nil
  11512. }
  11513. // ClearedEdges returns all edge names that were cleared in this mutation.
  11514. func (m *ContactMutation) ClearedEdges() []string {
  11515. edges := make([]string, 0, 3)
  11516. if m.clearedcontact_relationships {
  11517. edges = append(edges, contact.EdgeContactRelationships)
  11518. }
  11519. if m.clearedcontact_fields {
  11520. edges = append(edges, contact.EdgeContactFields)
  11521. }
  11522. if m.clearedcontact_messages {
  11523. edges = append(edges, contact.EdgeContactMessages)
  11524. }
  11525. return edges
  11526. }
  11527. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11528. // was cleared in this mutation.
  11529. func (m *ContactMutation) EdgeCleared(name string) bool {
  11530. switch name {
  11531. case contact.EdgeContactRelationships:
  11532. return m.clearedcontact_relationships
  11533. case contact.EdgeContactFields:
  11534. return m.clearedcontact_fields
  11535. case contact.EdgeContactMessages:
  11536. return m.clearedcontact_messages
  11537. }
  11538. return false
  11539. }
  11540. // ClearEdge clears the value of the edge with the given name. It returns an error
  11541. // if that edge is not defined in the schema.
  11542. func (m *ContactMutation) ClearEdge(name string) error {
  11543. switch name {
  11544. }
  11545. return fmt.Errorf("unknown Contact unique edge %s", name)
  11546. }
  11547. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11548. // It returns an error if the edge is not defined in the schema.
  11549. func (m *ContactMutation) ResetEdge(name string) error {
  11550. switch name {
  11551. case contact.EdgeContactRelationships:
  11552. m.ResetContactRelationships()
  11553. return nil
  11554. case contact.EdgeContactFields:
  11555. m.ResetContactFields()
  11556. return nil
  11557. case contact.EdgeContactMessages:
  11558. m.ResetContactMessages()
  11559. return nil
  11560. }
  11561. return fmt.Errorf("unknown Contact edge %s", name)
  11562. }
  11563. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  11564. type ContactFieldMutation struct {
  11565. config
  11566. op Op
  11567. typ string
  11568. id *uint64
  11569. created_at *time.Time
  11570. updated_at *time.Time
  11571. status *uint8
  11572. addstatus *int8
  11573. deleted_at *time.Time
  11574. form_id *string
  11575. value *[]string
  11576. appendvalue []string
  11577. clearedFields map[string]struct{}
  11578. field_contact *uint64
  11579. clearedfield_contact bool
  11580. done bool
  11581. oldValue func(context.Context) (*ContactField, error)
  11582. predicates []predicate.ContactField
  11583. }
  11584. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  11585. // contactfieldOption allows management of the mutation configuration using functional options.
  11586. type contactfieldOption func(*ContactFieldMutation)
  11587. // newContactFieldMutation creates new mutation for the ContactField entity.
  11588. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  11589. m := &ContactFieldMutation{
  11590. config: c,
  11591. op: op,
  11592. typ: TypeContactField,
  11593. clearedFields: make(map[string]struct{}),
  11594. }
  11595. for _, opt := range opts {
  11596. opt(m)
  11597. }
  11598. return m
  11599. }
  11600. // withContactFieldID sets the ID field of the mutation.
  11601. func withContactFieldID(id uint64) contactfieldOption {
  11602. return func(m *ContactFieldMutation) {
  11603. var (
  11604. err error
  11605. once sync.Once
  11606. value *ContactField
  11607. )
  11608. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  11609. once.Do(func() {
  11610. if m.done {
  11611. err = errors.New("querying old values post mutation is not allowed")
  11612. } else {
  11613. value, err = m.Client().ContactField.Get(ctx, id)
  11614. }
  11615. })
  11616. return value, err
  11617. }
  11618. m.id = &id
  11619. }
  11620. }
  11621. // withContactField sets the old ContactField of the mutation.
  11622. func withContactField(node *ContactField) contactfieldOption {
  11623. return func(m *ContactFieldMutation) {
  11624. m.oldValue = func(context.Context) (*ContactField, error) {
  11625. return node, nil
  11626. }
  11627. m.id = &node.ID
  11628. }
  11629. }
  11630. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11631. // executed in a transaction (ent.Tx), a transactional client is returned.
  11632. func (m ContactFieldMutation) Client() *Client {
  11633. client := &Client{config: m.config}
  11634. client.init()
  11635. return client
  11636. }
  11637. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11638. // it returns an error otherwise.
  11639. func (m ContactFieldMutation) Tx() (*Tx, error) {
  11640. if _, ok := m.driver.(*txDriver); !ok {
  11641. return nil, errors.New("ent: mutation is not running in a transaction")
  11642. }
  11643. tx := &Tx{config: m.config}
  11644. tx.init()
  11645. return tx, nil
  11646. }
  11647. // SetID sets the value of the id field. Note that this
  11648. // operation is only accepted on creation of ContactField entities.
  11649. func (m *ContactFieldMutation) SetID(id uint64) {
  11650. m.id = &id
  11651. }
  11652. // ID returns the ID value in the mutation. Note that the ID is only available
  11653. // if it was provided to the builder or after it was returned from the database.
  11654. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  11655. if m.id == nil {
  11656. return
  11657. }
  11658. return *m.id, true
  11659. }
  11660. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11661. // That means, if the mutation is applied within a transaction with an isolation level such
  11662. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11663. // or updated by the mutation.
  11664. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  11665. switch {
  11666. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11667. id, exists := m.ID()
  11668. if exists {
  11669. return []uint64{id}, nil
  11670. }
  11671. fallthrough
  11672. case m.op.Is(OpUpdate | OpDelete):
  11673. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  11674. default:
  11675. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11676. }
  11677. }
  11678. // SetCreatedAt sets the "created_at" field.
  11679. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  11680. m.created_at = &t
  11681. }
  11682. // CreatedAt returns the value of the "created_at" field in the mutation.
  11683. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  11684. v := m.created_at
  11685. if v == nil {
  11686. return
  11687. }
  11688. return *v, true
  11689. }
  11690. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  11691. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11693. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11694. if !m.op.Is(OpUpdateOne) {
  11695. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11696. }
  11697. if m.id == nil || m.oldValue == nil {
  11698. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11699. }
  11700. oldValue, err := m.oldValue(ctx)
  11701. if err != nil {
  11702. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11703. }
  11704. return oldValue.CreatedAt, nil
  11705. }
  11706. // ResetCreatedAt resets all changes to the "created_at" field.
  11707. func (m *ContactFieldMutation) ResetCreatedAt() {
  11708. m.created_at = nil
  11709. }
  11710. // SetUpdatedAt sets the "updated_at" field.
  11711. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  11712. m.updated_at = &t
  11713. }
  11714. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11715. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  11716. v := m.updated_at
  11717. if v == nil {
  11718. return
  11719. }
  11720. return *v, true
  11721. }
  11722. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  11723. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11725. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11726. if !m.op.Is(OpUpdateOne) {
  11727. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11728. }
  11729. if m.id == nil || m.oldValue == nil {
  11730. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11731. }
  11732. oldValue, err := m.oldValue(ctx)
  11733. if err != nil {
  11734. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11735. }
  11736. return oldValue.UpdatedAt, nil
  11737. }
  11738. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11739. func (m *ContactFieldMutation) ResetUpdatedAt() {
  11740. m.updated_at = nil
  11741. }
  11742. // SetStatus sets the "status" field.
  11743. func (m *ContactFieldMutation) SetStatus(u uint8) {
  11744. m.status = &u
  11745. m.addstatus = nil
  11746. }
  11747. // Status returns the value of the "status" field in the mutation.
  11748. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  11749. v := m.status
  11750. if v == nil {
  11751. return
  11752. }
  11753. return *v, true
  11754. }
  11755. // OldStatus returns the old "status" field's value of the ContactField entity.
  11756. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11758. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11759. if !m.op.Is(OpUpdateOne) {
  11760. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11761. }
  11762. if m.id == nil || m.oldValue == nil {
  11763. return v, errors.New("OldStatus requires an ID field in the mutation")
  11764. }
  11765. oldValue, err := m.oldValue(ctx)
  11766. if err != nil {
  11767. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11768. }
  11769. return oldValue.Status, nil
  11770. }
  11771. // AddStatus adds u to the "status" field.
  11772. func (m *ContactFieldMutation) AddStatus(u int8) {
  11773. if m.addstatus != nil {
  11774. *m.addstatus += u
  11775. } else {
  11776. m.addstatus = &u
  11777. }
  11778. }
  11779. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11780. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  11781. v := m.addstatus
  11782. if v == nil {
  11783. return
  11784. }
  11785. return *v, true
  11786. }
  11787. // ClearStatus clears the value of the "status" field.
  11788. func (m *ContactFieldMutation) ClearStatus() {
  11789. m.status = nil
  11790. m.addstatus = nil
  11791. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  11792. }
  11793. // StatusCleared returns if the "status" field was cleared in this mutation.
  11794. func (m *ContactFieldMutation) StatusCleared() bool {
  11795. _, ok := m.clearedFields[contactfield.FieldStatus]
  11796. return ok
  11797. }
  11798. // ResetStatus resets all changes to the "status" field.
  11799. func (m *ContactFieldMutation) ResetStatus() {
  11800. m.status = nil
  11801. m.addstatus = nil
  11802. delete(m.clearedFields, contactfield.FieldStatus)
  11803. }
  11804. // SetDeletedAt sets the "deleted_at" field.
  11805. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  11806. m.deleted_at = &t
  11807. }
  11808. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11809. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  11810. v := m.deleted_at
  11811. if v == nil {
  11812. return
  11813. }
  11814. return *v, true
  11815. }
  11816. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  11817. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11819. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11820. if !m.op.Is(OpUpdateOne) {
  11821. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11822. }
  11823. if m.id == nil || m.oldValue == nil {
  11824. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11825. }
  11826. oldValue, err := m.oldValue(ctx)
  11827. if err != nil {
  11828. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11829. }
  11830. return oldValue.DeletedAt, nil
  11831. }
  11832. // ClearDeletedAt clears the value of the "deleted_at" field.
  11833. func (m *ContactFieldMutation) ClearDeletedAt() {
  11834. m.deleted_at = nil
  11835. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  11836. }
  11837. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11838. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  11839. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  11840. return ok
  11841. }
  11842. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11843. func (m *ContactFieldMutation) ResetDeletedAt() {
  11844. m.deleted_at = nil
  11845. delete(m.clearedFields, contactfield.FieldDeletedAt)
  11846. }
  11847. // SetContactID sets the "contact_id" field.
  11848. func (m *ContactFieldMutation) SetContactID(u uint64) {
  11849. m.field_contact = &u
  11850. }
  11851. // ContactID returns the value of the "contact_id" field in the mutation.
  11852. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  11853. v := m.field_contact
  11854. if v == nil {
  11855. return
  11856. }
  11857. return *v, true
  11858. }
  11859. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  11860. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11862. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  11863. if !m.op.Is(OpUpdateOne) {
  11864. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  11865. }
  11866. if m.id == nil || m.oldValue == nil {
  11867. return v, errors.New("OldContactID requires an ID field in the mutation")
  11868. }
  11869. oldValue, err := m.oldValue(ctx)
  11870. if err != nil {
  11871. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  11872. }
  11873. return oldValue.ContactID, nil
  11874. }
  11875. // ResetContactID resets all changes to the "contact_id" field.
  11876. func (m *ContactFieldMutation) ResetContactID() {
  11877. m.field_contact = nil
  11878. }
  11879. // SetFormID sets the "form_id" field.
  11880. func (m *ContactFieldMutation) SetFormID(s string) {
  11881. m.form_id = &s
  11882. }
  11883. // FormID returns the value of the "form_id" field in the mutation.
  11884. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  11885. v := m.form_id
  11886. if v == nil {
  11887. return
  11888. }
  11889. return *v, true
  11890. }
  11891. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  11892. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11894. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  11895. if !m.op.Is(OpUpdateOne) {
  11896. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  11897. }
  11898. if m.id == nil || m.oldValue == nil {
  11899. return v, errors.New("OldFormID requires an ID field in the mutation")
  11900. }
  11901. oldValue, err := m.oldValue(ctx)
  11902. if err != nil {
  11903. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  11904. }
  11905. return oldValue.FormID, nil
  11906. }
  11907. // ResetFormID resets all changes to the "form_id" field.
  11908. func (m *ContactFieldMutation) ResetFormID() {
  11909. m.form_id = nil
  11910. }
  11911. // SetValue sets the "value" field.
  11912. func (m *ContactFieldMutation) SetValue(s []string) {
  11913. m.value = &s
  11914. m.appendvalue = nil
  11915. }
  11916. // Value returns the value of the "value" field in the mutation.
  11917. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  11918. v := m.value
  11919. if v == nil {
  11920. return
  11921. }
  11922. return *v, true
  11923. }
  11924. // OldValue returns the old "value" field's value of the ContactField entity.
  11925. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11927. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  11928. if !m.op.Is(OpUpdateOne) {
  11929. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  11930. }
  11931. if m.id == nil || m.oldValue == nil {
  11932. return v, errors.New("OldValue requires an ID field in the mutation")
  11933. }
  11934. oldValue, err := m.oldValue(ctx)
  11935. if err != nil {
  11936. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  11937. }
  11938. return oldValue.Value, nil
  11939. }
  11940. // AppendValue adds s to the "value" field.
  11941. func (m *ContactFieldMutation) AppendValue(s []string) {
  11942. m.appendvalue = append(m.appendvalue, s...)
  11943. }
  11944. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  11945. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  11946. if len(m.appendvalue) == 0 {
  11947. return nil, false
  11948. }
  11949. return m.appendvalue, true
  11950. }
  11951. // ResetValue resets all changes to the "value" field.
  11952. func (m *ContactFieldMutation) ResetValue() {
  11953. m.value = nil
  11954. m.appendvalue = nil
  11955. }
  11956. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  11957. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  11958. m.field_contact = &id
  11959. }
  11960. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  11961. func (m *ContactFieldMutation) ClearFieldContact() {
  11962. m.clearedfield_contact = true
  11963. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  11964. }
  11965. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  11966. func (m *ContactFieldMutation) FieldContactCleared() bool {
  11967. return m.clearedfield_contact
  11968. }
  11969. // FieldContactID returns the "field_contact" edge ID in the mutation.
  11970. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  11971. if m.field_contact != nil {
  11972. return *m.field_contact, true
  11973. }
  11974. return
  11975. }
  11976. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  11977. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11978. // FieldContactID instead. It exists only for internal usage by the builders.
  11979. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  11980. if id := m.field_contact; id != nil {
  11981. ids = append(ids, *id)
  11982. }
  11983. return
  11984. }
  11985. // ResetFieldContact resets all changes to the "field_contact" edge.
  11986. func (m *ContactFieldMutation) ResetFieldContact() {
  11987. m.field_contact = nil
  11988. m.clearedfield_contact = false
  11989. }
  11990. // Where appends a list predicates to the ContactFieldMutation builder.
  11991. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  11992. m.predicates = append(m.predicates, ps...)
  11993. }
  11994. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  11995. // users can use type-assertion to append predicates that do not depend on any generated package.
  11996. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  11997. p := make([]predicate.ContactField, len(ps))
  11998. for i := range ps {
  11999. p[i] = ps[i]
  12000. }
  12001. m.Where(p...)
  12002. }
  12003. // Op returns the operation name.
  12004. func (m *ContactFieldMutation) Op() Op {
  12005. return m.op
  12006. }
  12007. // SetOp allows setting the mutation operation.
  12008. func (m *ContactFieldMutation) SetOp(op Op) {
  12009. m.op = op
  12010. }
  12011. // Type returns the node type of this mutation (ContactField).
  12012. func (m *ContactFieldMutation) Type() string {
  12013. return m.typ
  12014. }
  12015. // Fields returns all fields that were changed during this mutation. Note that in
  12016. // order to get all numeric fields that were incremented/decremented, call
  12017. // AddedFields().
  12018. func (m *ContactFieldMutation) Fields() []string {
  12019. fields := make([]string, 0, 7)
  12020. if m.created_at != nil {
  12021. fields = append(fields, contactfield.FieldCreatedAt)
  12022. }
  12023. if m.updated_at != nil {
  12024. fields = append(fields, contactfield.FieldUpdatedAt)
  12025. }
  12026. if m.status != nil {
  12027. fields = append(fields, contactfield.FieldStatus)
  12028. }
  12029. if m.deleted_at != nil {
  12030. fields = append(fields, contactfield.FieldDeletedAt)
  12031. }
  12032. if m.field_contact != nil {
  12033. fields = append(fields, contactfield.FieldContactID)
  12034. }
  12035. if m.form_id != nil {
  12036. fields = append(fields, contactfield.FieldFormID)
  12037. }
  12038. if m.value != nil {
  12039. fields = append(fields, contactfield.FieldValue)
  12040. }
  12041. return fields
  12042. }
  12043. // Field returns the value of a field with the given name. The second boolean
  12044. // return value indicates that this field was not set, or was not defined in the
  12045. // schema.
  12046. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  12047. switch name {
  12048. case contactfield.FieldCreatedAt:
  12049. return m.CreatedAt()
  12050. case contactfield.FieldUpdatedAt:
  12051. return m.UpdatedAt()
  12052. case contactfield.FieldStatus:
  12053. return m.Status()
  12054. case contactfield.FieldDeletedAt:
  12055. return m.DeletedAt()
  12056. case contactfield.FieldContactID:
  12057. return m.ContactID()
  12058. case contactfield.FieldFormID:
  12059. return m.FormID()
  12060. case contactfield.FieldValue:
  12061. return m.Value()
  12062. }
  12063. return nil, false
  12064. }
  12065. // OldField returns the old value of the field from the database. An error is
  12066. // returned if the mutation operation is not UpdateOne, or the query to the
  12067. // database failed.
  12068. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12069. switch name {
  12070. case contactfield.FieldCreatedAt:
  12071. return m.OldCreatedAt(ctx)
  12072. case contactfield.FieldUpdatedAt:
  12073. return m.OldUpdatedAt(ctx)
  12074. case contactfield.FieldStatus:
  12075. return m.OldStatus(ctx)
  12076. case contactfield.FieldDeletedAt:
  12077. return m.OldDeletedAt(ctx)
  12078. case contactfield.FieldContactID:
  12079. return m.OldContactID(ctx)
  12080. case contactfield.FieldFormID:
  12081. return m.OldFormID(ctx)
  12082. case contactfield.FieldValue:
  12083. return m.OldValue(ctx)
  12084. }
  12085. return nil, fmt.Errorf("unknown ContactField field %s", name)
  12086. }
  12087. // SetField sets the value of a field with the given name. It returns an error if
  12088. // the field is not defined in the schema, or if the type mismatched the field
  12089. // type.
  12090. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  12091. switch name {
  12092. case contactfield.FieldCreatedAt:
  12093. v, ok := value.(time.Time)
  12094. if !ok {
  12095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12096. }
  12097. m.SetCreatedAt(v)
  12098. return nil
  12099. case contactfield.FieldUpdatedAt:
  12100. v, ok := value.(time.Time)
  12101. if !ok {
  12102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12103. }
  12104. m.SetUpdatedAt(v)
  12105. return nil
  12106. case contactfield.FieldStatus:
  12107. v, ok := value.(uint8)
  12108. if !ok {
  12109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12110. }
  12111. m.SetStatus(v)
  12112. return nil
  12113. case contactfield.FieldDeletedAt:
  12114. v, ok := value.(time.Time)
  12115. if !ok {
  12116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12117. }
  12118. m.SetDeletedAt(v)
  12119. return nil
  12120. case contactfield.FieldContactID:
  12121. v, ok := value.(uint64)
  12122. if !ok {
  12123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12124. }
  12125. m.SetContactID(v)
  12126. return nil
  12127. case contactfield.FieldFormID:
  12128. v, ok := value.(string)
  12129. if !ok {
  12130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12131. }
  12132. m.SetFormID(v)
  12133. return nil
  12134. case contactfield.FieldValue:
  12135. v, ok := value.([]string)
  12136. if !ok {
  12137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12138. }
  12139. m.SetValue(v)
  12140. return nil
  12141. }
  12142. return fmt.Errorf("unknown ContactField field %s", name)
  12143. }
  12144. // AddedFields returns all numeric fields that were incremented/decremented during
  12145. // this mutation.
  12146. func (m *ContactFieldMutation) AddedFields() []string {
  12147. var fields []string
  12148. if m.addstatus != nil {
  12149. fields = append(fields, contactfield.FieldStatus)
  12150. }
  12151. return fields
  12152. }
  12153. // AddedField returns the numeric value that was incremented/decremented on a field
  12154. // with the given name. The second boolean return value indicates that this field
  12155. // was not set, or was not defined in the schema.
  12156. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  12157. switch name {
  12158. case contactfield.FieldStatus:
  12159. return m.AddedStatus()
  12160. }
  12161. return nil, false
  12162. }
  12163. // AddField adds the value to the field with the given name. It returns an error if
  12164. // the field is not defined in the schema, or if the type mismatched the field
  12165. // type.
  12166. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  12167. switch name {
  12168. case contactfield.FieldStatus:
  12169. v, ok := value.(int8)
  12170. if !ok {
  12171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12172. }
  12173. m.AddStatus(v)
  12174. return nil
  12175. }
  12176. return fmt.Errorf("unknown ContactField numeric field %s", name)
  12177. }
  12178. // ClearedFields returns all nullable fields that were cleared during this
  12179. // mutation.
  12180. func (m *ContactFieldMutation) ClearedFields() []string {
  12181. var fields []string
  12182. if m.FieldCleared(contactfield.FieldStatus) {
  12183. fields = append(fields, contactfield.FieldStatus)
  12184. }
  12185. if m.FieldCleared(contactfield.FieldDeletedAt) {
  12186. fields = append(fields, contactfield.FieldDeletedAt)
  12187. }
  12188. return fields
  12189. }
  12190. // FieldCleared returns a boolean indicating if a field with the given name was
  12191. // cleared in this mutation.
  12192. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  12193. _, ok := m.clearedFields[name]
  12194. return ok
  12195. }
  12196. // ClearField clears the value of the field with the given name. It returns an
  12197. // error if the field is not defined in the schema.
  12198. func (m *ContactFieldMutation) ClearField(name string) error {
  12199. switch name {
  12200. case contactfield.FieldStatus:
  12201. m.ClearStatus()
  12202. return nil
  12203. case contactfield.FieldDeletedAt:
  12204. m.ClearDeletedAt()
  12205. return nil
  12206. }
  12207. return fmt.Errorf("unknown ContactField nullable field %s", name)
  12208. }
  12209. // ResetField resets all changes in the mutation for the field with the given name.
  12210. // It returns an error if the field is not defined in the schema.
  12211. func (m *ContactFieldMutation) ResetField(name string) error {
  12212. switch name {
  12213. case contactfield.FieldCreatedAt:
  12214. m.ResetCreatedAt()
  12215. return nil
  12216. case contactfield.FieldUpdatedAt:
  12217. m.ResetUpdatedAt()
  12218. return nil
  12219. case contactfield.FieldStatus:
  12220. m.ResetStatus()
  12221. return nil
  12222. case contactfield.FieldDeletedAt:
  12223. m.ResetDeletedAt()
  12224. return nil
  12225. case contactfield.FieldContactID:
  12226. m.ResetContactID()
  12227. return nil
  12228. case contactfield.FieldFormID:
  12229. m.ResetFormID()
  12230. return nil
  12231. case contactfield.FieldValue:
  12232. m.ResetValue()
  12233. return nil
  12234. }
  12235. return fmt.Errorf("unknown ContactField field %s", name)
  12236. }
  12237. // AddedEdges returns all edge names that were set/added in this mutation.
  12238. func (m *ContactFieldMutation) AddedEdges() []string {
  12239. edges := make([]string, 0, 1)
  12240. if m.field_contact != nil {
  12241. edges = append(edges, contactfield.EdgeFieldContact)
  12242. }
  12243. return edges
  12244. }
  12245. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12246. // name in this mutation.
  12247. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  12248. switch name {
  12249. case contactfield.EdgeFieldContact:
  12250. if id := m.field_contact; id != nil {
  12251. return []ent.Value{*id}
  12252. }
  12253. }
  12254. return nil
  12255. }
  12256. // RemovedEdges returns all edge names that were removed in this mutation.
  12257. func (m *ContactFieldMutation) RemovedEdges() []string {
  12258. edges := make([]string, 0, 1)
  12259. return edges
  12260. }
  12261. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12262. // the given name in this mutation.
  12263. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  12264. return nil
  12265. }
  12266. // ClearedEdges returns all edge names that were cleared in this mutation.
  12267. func (m *ContactFieldMutation) ClearedEdges() []string {
  12268. edges := make([]string, 0, 1)
  12269. if m.clearedfield_contact {
  12270. edges = append(edges, contactfield.EdgeFieldContact)
  12271. }
  12272. return edges
  12273. }
  12274. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12275. // was cleared in this mutation.
  12276. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  12277. switch name {
  12278. case contactfield.EdgeFieldContact:
  12279. return m.clearedfield_contact
  12280. }
  12281. return false
  12282. }
  12283. // ClearEdge clears the value of the edge with the given name. It returns an error
  12284. // if that edge is not defined in the schema.
  12285. func (m *ContactFieldMutation) ClearEdge(name string) error {
  12286. switch name {
  12287. case contactfield.EdgeFieldContact:
  12288. m.ClearFieldContact()
  12289. return nil
  12290. }
  12291. return fmt.Errorf("unknown ContactField unique edge %s", name)
  12292. }
  12293. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12294. // It returns an error if the edge is not defined in the schema.
  12295. func (m *ContactFieldMutation) ResetEdge(name string) error {
  12296. switch name {
  12297. case contactfield.EdgeFieldContact:
  12298. m.ResetFieldContact()
  12299. return nil
  12300. }
  12301. return fmt.Errorf("unknown ContactField edge %s", name)
  12302. }
  12303. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  12304. type ContactFieldTemplateMutation struct {
  12305. config
  12306. op Op
  12307. typ string
  12308. id *uint64
  12309. created_at *time.Time
  12310. updated_at *time.Time
  12311. status *uint8
  12312. addstatus *int8
  12313. deleted_at *time.Time
  12314. organization_id *uint64
  12315. addorganization_id *int64
  12316. template *[]custom_types.ContactFieldTemplate
  12317. appendtemplate []custom_types.ContactFieldTemplate
  12318. clearedFields map[string]struct{}
  12319. done bool
  12320. oldValue func(context.Context) (*ContactFieldTemplate, error)
  12321. predicates []predicate.ContactFieldTemplate
  12322. }
  12323. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  12324. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  12325. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  12326. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  12327. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  12328. m := &ContactFieldTemplateMutation{
  12329. config: c,
  12330. op: op,
  12331. typ: TypeContactFieldTemplate,
  12332. clearedFields: make(map[string]struct{}),
  12333. }
  12334. for _, opt := range opts {
  12335. opt(m)
  12336. }
  12337. return m
  12338. }
  12339. // withContactFieldTemplateID sets the ID field of the mutation.
  12340. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  12341. return func(m *ContactFieldTemplateMutation) {
  12342. var (
  12343. err error
  12344. once sync.Once
  12345. value *ContactFieldTemplate
  12346. )
  12347. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  12348. once.Do(func() {
  12349. if m.done {
  12350. err = errors.New("querying old values post mutation is not allowed")
  12351. } else {
  12352. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  12353. }
  12354. })
  12355. return value, err
  12356. }
  12357. m.id = &id
  12358. }
  12359. }
  12360. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  12361. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  12362. return func(m *ContactFieldTemplateMutation) {
  12363. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  12364. return node, nil
  12365. }
  12366. m.id = &node.ID
  12367. }
  12368. }
  12369. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12370. // executed in a transaction (ent.Tx), a transactional client is returned.
  12371. func (m ContactFieldTemplateMutation) Client() *Client {
  12372. client := &Client{config: m.config}
  12373. client.init()
  12374. return client
  12375. }
  12376. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12377. // it returns an error otherwise.
  12378. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  12379. if _, ok := m.driver.(*txDriver); !ok {
  12380. return nil, errors.New("ent: mutation is not running in a transaction")
  12381. }
  12382. tx := &Tx{config: m.config}
  12383. tx.init()
  12384. return tx, nil
  12385. }
  12386. // SetID sets the value of the id field. Note that this
  12387. // operation is only accepted on creation of ContactFieldTemplate entities.
  12388. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  12389. m.id = &id
  12390. }
  12391. // ID returns the ID value in the mutation. Note that the ID is only available
  12392. // if it was provided to the builder or after it was returned from the database.
  12393. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  12394. if m.id == nil {
  12395. return
  12396. }
  12397. return *m.id, true
  12398. }
  12399. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12400. // That means, if the mutation is applied within a transaction with an isolation level such
  12401. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12402. // or updated by the mutation.
  12403. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  12404. switch {
  12405. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12406. id, exists := m.ID()
  12407. if exists {
  12408. return []uint64{id}, nil
  12409. }
  12410. fallthrough
  12411. case m.op.Is(OpUpdate | OpDelete):
  12412. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  12413. default:
  12414. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12415. }
  12416. }
  12417. // SetCreatedAt sets the "created_at" field.
  12418. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  12419. m.created_at = &t
  12420. }
  12421. // CreatedAt returns the value of the "created_at" field in the mutation.
  12422. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  12423. v := m.created_at
  12424. if v == nil {
  12425. return
  12426. }
  12427. return *v, true
  12428. }
  12429. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  12430. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12432. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12433. if !m.op.Is(OpUpdateOne) {
  12434. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12435. }
  12436. if m.id == nil || m.oldValue == nil {
  12437. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12438. }
  12439. oldValue, err := m.oldValue(ctx)
  12440. if err != nil {
  12441. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12442. }
  12443. return oldValue.CreatedAt, nil
  12444. }
  12445. // ResetCreatedAt resets all changes to the "created_at" field.
  12446. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  12447. m.created_at = nil
  12448. }
  12449. // SetUpdatedAt sets the "updated_at" field.
  12450. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  12451. m.updated_at = &t
  12452. }
  12453. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12454. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  12455. v := m.updated_at
  12456. if v == nil {
  12457. return
  12458. }
  12459. return *v, true
  12460. }
  12461. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  12462. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12464. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12465. if !m.op.Is(OpUpdateOne) {
  12466. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12467. }
  12468. if m.id == nil || m.oldValue == nil {
  12469. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12470. }
  12471. oldValue, err := m.oldValue(ctx)
  12472. if err != nil {
  12473. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12474. }
  12475. return oldValue.UpdatedAt, nil
  12476. }
  12477. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12478. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  12479. m.updated_at = nil
  12480. }
  12481. // SetStatus sets the "status" field.
  12482. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  12483. m.status = &u
  12484. m.addstatus = nil
  12485. }
  12486. // Status returns the value of the "status" field in the mutation.
  12487. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  12488. v := m.status
  12489. if v == nil {
  12490. return
  12491. }
  12492. return *v, true
  12493. }
  12494. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  12495. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12497. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12498. if !m.op.Is(OpUpdateOne) {
  12499. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12500. }
  12501. if m.id == nil || m.oldValue == nil {
  12502. return v, errors.New("OldStatus requires an ID field in the mutation")
  12503. }
  12504. oldValue, err := m.oldValue(ctx)
  12505. if err != nil {
  12506. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12507. }
  12508. return oldValue.Status, nil
  12509. }
  12510. // AddStatus adds u to the "status" field.
  12511. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  12512. if m.addstatus != nil {
  12513. *m.addstatus += u
  12514. } else {
  12515. m.addstatus = &u
  12516. }
  12517. }
  12518. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12519. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  12520. v := m.addstatus
  12521. if v == nil {
  12522. return
  12523. }
  12524. return *v, true
  12525. }
  12526. // ClearStatus clears the value of the "status" field.
  12527. func (m *ContactFieldTemplateMutation) ClearStatus() {
  12528. m.status = nil
  12529. m.addstatus = nil
  12530. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  12531. }
  12532. // StatusCleared returns if the "status" field was cleared in this mutation.
  12533. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  12534. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  12535. return ok
  12536. }
  12537. // ResetStatus resets all changes to the "status" field.
  12538. func (m *ContactFieldTemplateMutation) ResetStatus() {
  12539. m.status = nil
  12540. m.addstatus = nil
  12541. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  12542. }
  12543. // SetDeletedAt sets the "deleted_at" field.
  12544. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  12545. m.deleted_at = &t
  12546. }
  12547. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12548. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  12549. v := m.deleted_at
  12550. if v == nil {
  12551. return
  12552. }
  12553. return *v, true
  12554. }
  12555. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  12556. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12558. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12559. if !m.op.Is(OpUpdateOne) {
  12560. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12561. }
  12562. if m.id == nil || m.oldValue == nil {
  12563. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12564. }
  12565. oldValue, err := m.oldValue(ctx)
  12566. if err != nil {
  12567. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12568. }
  12569. return oldValue.DeletedAt, nil
  12570. }
  12571. // ClearDeletedAt clears the value of the "deleted_at" field.
  12572. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  12573. m.deleted_at = nil
  12574. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  12575. }
  12576. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12577. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  12578. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  12579. return ok
  12580. }
  12581. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12582. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  12583. m.deleted_at = nil
  12584. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  12585. }
  12586. // SetOrganizationID sets the "organization_id" field.
  12587. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  12588. m.organization_id = &u
  12589. m.addorganization_id = nil
  12590. }
  12591. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12592. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  12593. v := m.organization_id
  12594. if v == nil {
  12595. return
  12596. }
  12597. return *v, true
  12598. }
  12599. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  12600. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12602. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12603. if !m.op.Is(OpUpdateOne) {
  12604. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12605. }
  12606. if m.id == nil || m.oldValue == nil {
  12607. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12608. }
  12609. oldValue, err := m.oldValue(ctx)
  12610. if err != nil {
  12611. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12612. }
  12613. return oldValue.OrganizationID, nil
  12614. }
  12615. // AddOrganizationID adds u to the "organization_id" field.
  12616. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  12617. if m.addorganization_id != nil {
  12618. *m.addorganization_id += u
  12619. } else {
  12620. m.addorganization_id = &u
  12621. }
  12622. }
  12623. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12624. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  12625. v := m.addorganization_id
  12626. if v == nil {
  12627. return
  12628. }
  12629. return *v, true
  12630. }
  12631. // ResetOrganizationID resets all changes to the "organization_id" field.
  12632. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  12633. m.organization_id = nil
  12634. m.addorganization_id = nil
  12635. }
  12636. // SetTemplate sets the "template" field.
  12637. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  12638. m.template = &ctft
  12639. m.appendtemplate = nil
  12640. }
  12641. // Template returns the value of the "template" field in the mutation.
  12642. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  12643. v := m.template
  12644. if v == nil {
  12645. return
  12646. }
  12647. return *v, true
  12648. }
  12649. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  12650. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12652. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  12653. if !m.op.Is(OpUpdateOne) {
  12654. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  12655. }
  12656. if m.id == nil || m.oldValue == nil {
  12657. return v, errors.New("OldTemplate requires an ID field in the mutation")
  12658. }
  12659. oldValue, err := m.oldValue(ctx)
  12660. if err != nil {
  12661. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  12662. }
  12663. return oldValue.Template, nil
  12664. }
  12665. // AppendTemplate adds ctft to the "template" field.
  12666. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  12667. m.appendtemplate = append(m.appendtemplate, ctft...)
  12668. }
  12669. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  12670. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  12671. if len(m.appendtemplate) == 0 {
  12672. return nil, false
  12673. }
  12674. return m.appendtemplate, true
  12675. }
  12676. // ResetTemplate resets all changes to the "template" field.
  12677. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  12678. m.template = nil
  12679. m.appendtemplate = nil
  12680. }
  12681. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  12682. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  12683. m.predicates = append(m.predicates, ps...)
  12684. }
  12685. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  12686. // users can use type-assertion to append predicates that do not depend on any generated package.
  12687. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  12688. p := make([]predicate.ContactFieldTemplate, len(ps))
  12689. for i := range ps {
  12690. p[i] = ps[i]
  12691. }
  12692. m.Where(p...)
  12693. }
  12694. // Op returns the operation name.
  12695. func (m *ContactFieldTemplateMutation) Op() Op {
  12696. return m.op
  12697. }
  12698. // SetOp allows setting the mutation operation.
  12699. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  12700. m.op = op
  12701. }
  12702. // Type returns the node type of this mutation (ContactFieldTemplate).
  12703. func (m *ContactFieldTemplateMutation) Type() string {
  12704. return m.typ
  12705. }
  12706. // Fields returns all fields that were changed during this mutation. Note that in
  12707. // order to get all numeric fields that were incremented/decremented, call
  12708. // AddedFields().
  12709. func (m *ContactFieldTemplateMutation) Fields() []string {
  12710. fields := make([]string, 0, 6)
  12711. if m.created_at != nil {
  12712. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  12713. }
  12714. if m.updated_at != nil {
  12715. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  12716. }
  12717. if m.status != nil {
  12718. fields = append(fields, contactfieldtemplate.FieldStatus)
  12719. }
  12720. if m.deleted_at != nil {
  12721. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  12722. }
  12723. if m.organization_id != nil {
  12724. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  12725. }
  12726. if m.template != nil {
  12727. fields = append(fields, contactfieldtemplate.FieldTemplate)
  12728. }
  12729. return fields
  12730. }
  12731. // Field returns the value of a field with the given name. The second boolean
  12732. // return value indicates that this field was not set, or was not defined in the
  12733. // schema.
  12734. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  12735. switch name {
  12736. case contactfieldtemplate.FieldCreatedAt:
  12737. return m.CreatedAt()
  12738. case contactfieldtemplate.FieldUpdatedAt:
  12739. return m.UpdatedAt()
  12740. case contactfieldtemplate.FieldStatus:
  12741. return m.Status()
  12742. case contactfieldtemplate.FieldDeletedAt:
  12743. return m.DeletedAt()
  12744. case contactfieldtemplate.FieldOrganizationID:
  12745. return m.OrganizationID()
  12746. case contactfieldtemplate.FieldTemplate:
  12747. return m.Template()
  12748. }
  12749. return nil, false
  12750. }
  12751. // OldField returns the old value of the field from the database. An error is
  12752. // returned if the mutation operation is not UpdateOne, or the query to the
  12753. // database failed.
  12754. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12755. switch name {
  12756. case contactfieldtemplate.FieldCreatedAt:
  12757. return m.OldCreatedAt(ctx)
  12758. case contactfieldtemplate.FieldUpdatedAt:
  12759. return m.OldUpdatedAt(ctx)
  12760. case contactfieldtemplate.FieldStatus:
  12761. return m.OldStatus(ctx)
  12762. case contactfieldtemplate.FieldDeletedAt:
  12763. return m.OldDeletedAt(ctx)
  12764. case contactfieldtemplate.FieldOrganizationID:
  12765. return m.OldOrganizationID(ctx)
  12766. case contactfieldtemplate.FieldTemplate:
  12767. return m.OldTemplate(ctx)
  12768. }
  12769. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  12770. }
  12771. // SetField sets the value of a field with the given name. It returns an error if
  12772. // the field is not defined in the schema, or if the type mismatched the field
  12773. // type.
  12774. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  12775. switch name {
  12776. case contactfieldtemplate.FieldCreatedAt:
  12777. v, ok := value.(time.Time)
  12778. if !ok {
  12779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12780. }
  12781. m.SetCreatedAt(v)
  12782. return nil
  12783. case contactfieldtemplate.FieldUpdatedAt:
  12784. v, ok := value.(time.Time)
  12785. if !ok {
  12786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12787. }
  12788. m.SetUpdatedAt(v)
  12789. return nil
  12790. case contactfieldtemplate.FieldStatus:
  12791. v, ok := value.(uint8)
  12792. if !ok {
  12793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12794. }
  12795. m.SetStatus(v)
  12796. return nil
  12797. case contactfieldtemplate.FieldDeletedAt:
  12798. v, ok := value.(time.Time)
  12799. if !ok {
  12800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12801. }
  12802. m.SetDeletedAt(v)
  12803. return nil
  12804. case contactfieldtemplate.FieldOrganizationID:
  12805. v, ok := value.(uint64)
  12806. if !ok {
  12807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12808. }
  12809. m.SetOrganizationID(v)
  12810. return nil
  12811. case contactfieldtemplate.FieldTemplate:
  12812. v, ok := value.([]custom_types.ContactFieldTemplate)
  12813. if !ok {
  12814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12815. }
  12816. m.SetTemplate(v)
  12817. return nil
  12818. }
  12819. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  12820. }
  12821. // AddedFields returns all numeric fields that were incremented/decremented during
  12822. // this mutation.
  12823. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  12824. var fields []string
  12825. if m.addstatus != nil {
  12826. fields = append(fields, contactfieldtemplate.FieldStatus)
  12827. }
  12828. if m.addorganization_id != nil {
  12829. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  12830. }
  12831. return fields
  12832. }
  12833. // AddedField returns the numeric value that was incremented/decremented on a field
  12834. // with the given name. The second boolean return value indicates that this field
  12835. // was not set, or was not defined in the schema.
  12836. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  12837. switch name {
  12838. case contactfieldtemplate.FieldStatus:
  12839. return m.AddedStatus()
  12840. case contactfieldtemplate.FieldOrganizationID:
  12841. return m.AddedOrganizationID()
  12842. }
  12843. return nil, false
  12844. }
  12845. // AddField adds the value to the field with the given name. It returns an error if
  12846. // the field is not defined in the schema, or if the type mismatched the field
  12847. // type.
  12848. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  12849. switch name {
  12850. case contactfieldtemplate.FieldStatus:
  12851. v, ok := value.(int8)
  12852. if !ok {
  12853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12854. }
  12855. m.AddStatus(v)
  12856. return nil
  12857. case contactfieldtemplate.FieldOrganizationID:
  12858. v, ok := value.(int64)
  12859. if !ok {
  12860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12861. }
  12862. m.AddOrganizationID(v)
  12863. return nil
  12864. }
  12865. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  12866. }
  12867. // ClearedFields returns all nullable fields that were cleared during this
  12868. // mutation.
  12869. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  12870. var fields []string
  12871. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  12872. fields = append(fields, contactfieldtemplate.FieldStatus)
  12873. }
  12874. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  12875. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  12876. }
  12877. return fields
  12878. }
  12879. // FieldCleared returns a boolean indicating if a field with the given name was
  12880. // cleared in this mutation.
  12881. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  12882. _, ok := m.clearedFields[name]
  12883. return ok
  12884. }
  12885. // ClearField clears the value of the field with the given name. It returns an
  12886. // error if the field is not defined in the schema.
  12887. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  12888. switch name {
  12889. case contactfieldtemplate.FieldStatus:
  12890. m.ClearStatus()
  12891. return nil
  12892. case contactfieldtemplate.FieldDeletedAt:
  12893. m.ClearDeletedAt()
  12894. return nil
  12895. }
  12896. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  12897. }
  12898. // ResetField resets all changes in the mutation for the field with the given name.
  12899. // It returns an error if the field is not defined in the schema.
  12900. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  12901. switch name {
  12902. case contactfieldtemplate.FieldCreatedAt:
  12903. m.ResetCreatedAt()
  12904. return nil
  12905. case contactfieldtemplate.FieldUpdatedAt:
  12906. m.ResetUpdatedAt()
  12907. return nil
  12908. case contactfieldtemplate.FieldStatus:
  12909. m.ResetStatus()
  12910. return nil
  12911. case contactfieldtemplate.FieldDeletedAt:
  12912. m.ResetDeletedAt()
  12913. return nil
  12914. case contactfieldtemplate.FieldOrganizationID:
  12915. m.ResetOrganizationID()
  12916. return nil
  12917. case contactfieldtemplate.FieldTemplate:
  12918. m.ResetTemplate()
  12919. return nil
  12920. }
  12921. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  12922. }
  12923. // AddedEdges returns all edge names that were set/added in this mutation.
  12924. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  12925. edges := make([]string, 0, 0)
  12926. return edges
  12927. }
  12928. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12929. // name in this mutation.
  12930. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  12931. return nil
  12932. }
  12933. // RemovedEdges returns all edge names that were removed in this mutation.
  12934. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  12935. edges := make([]string, 0, 0)
  12936. return edges
  12937. }
  12938. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12939. // the given name in this mutation.
  12940. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  12941. return nil
  12942. }
  12943. // ClearedEdges returns all edge names that were cleared in this mutation.
  12944. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  12945. edges := make([]string, 0, 0)
  12946. return edges
  12947. }
  12948. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12949. // was cleared in this mutation.
  12950. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  12951. return false
  12952. }
  12953. // ClearEdge clears the value of the edge with the given name. It returns an error
  12954. // if that edge is not defined in the schema.
  12955. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  12956. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  12957. }
  12958. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12959. // It returns an error if the edge is not defined in the schema.
  12960. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  12961. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  12962. }
  12963. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  12964. type CreditBalanceMutation struct {
  12965. config
  12966. op Op
  12967. typ string
  12968. id *uint64
  12969. created_at *time.Time
  12970. updated_at *time.Time
  12971. deleted_at *time.Time
  12972. user_id *string
  12973. balance *float64
  12974. addbalance *float64
  12975. status *int
  12976. addstatus *int
  12977. organization_id *uint64
  12978. addorganization_id *int64
  12979. clearedFields map[string]struct{}
  12980. done bool
  12981. oldValue func(context.Context) (*CreditBalance, error)
  12982. predicates []predicate.CreditBalance
  12983. }
  12984. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  12985. // creditbalanceOption allows management of the mutation configuration using functional options.
  12986. type creditbalanceOption func(*CreditBalanceMutation)
  12987. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  12988. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  12989. m := &CreditBalanceMutation{
  12990. config: c,
  12991. op: op,
  12992. typ: TypeCreditBalance,
  12993. clearedFields: make(map[string]struct{}),
  12994. }
  12995. for _, opt := range opts {
  12996. opt(m)
  12997. }
  12998. return m
  12999. }
  13000. // withCreditBalanceID sets the ID field of the mutation.
  13001. func withCreditBalanceID(id uint64) creditbalanceOption {
  13002. return func(m *CreditBalanceMutation) {
  13003. var (
  13004. err error
  13005. once sync.Once
  13006. value *CreditBalance
  13007. )
  13008. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  13009. once.Do(func() {
  13010. if m.done {
  13011. err = errors.New("querying old values post mutation is not allowed")
  13012. } else {
  13013. value, err = m.Client().CreditBalance.Get(ctx, id)
  13014. }
  13015. })
  13016. return value, err
  13017. }
  13018. m.id = &id
  13019. }
  13020. }
  13021. // withCreditBalance sets the old CreditBalance of the mutation.
  13022. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  13023. return func(m *CreditBalanceMutation) {
  13024. m.oldValue = func(context.Context) (*CreditBalance, error) {
  13025. return node, nil
  13026. }
  13027. m.id = &node.ID
  13028. }
  13029. }
  13030. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13031. // executed in a transaction (ent.Tx), a transactional client is returned.
  13032. func (m CreditBalanceMutation) Client() *Client {
  13033. client := &Client{config: m.config}
  13034. client.init()
  13035. return client
  13036. }
  13037. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13038. // it returns an error otherwise.
  13039. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  13040. if _, ok := m.driver.(*txDriver); !ok {
  13041. return nil, errors.New("ent: mutation is not running in a transaction")
  13042. }
  13043. tx := &Tx{config: m.config}
  13044. tx.init()
  13045. return tx, nil
  13046. }
  13047. // SetID sets the value of the id field. Note that this
  13048. // operation is only accepted on creation of CreditBalance entities.
  13049. func (m *CreditBalanceMutation) SetID(id uint64) {
  13050. m.id = &id
  13051. }
  13052. // ID returns the ID value in the mutation. Note that the ID is only available
  13053. // if it was provided to the builder or after it was returned from the database.
  13054. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  13055. if m.id == nil {
  13056. return
  13057. }
  13058. return *m.id, true
  13059. }
  13060. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13061. // That means, if the mutation is applied within a transaction with an isolation level such
  13062. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13063. // or updated by the mutation.
  13064. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  13065. switch {
  13066. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13067. id, exists := m.ID()
  13068. if exists {
  13069. return []uint64{id}, nil
  13070. }
  13071. fallthrough
  13072. case m.op.Is(OpUpdate | OpDelete):
  13073. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  13074. default:
  13075. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13076. }
  13077. }
  13078. // SetCreatedAt sets the "created_at" field.
  13079. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  13080. m.created_at = &t
  13081. }
  13082. // CreatedAt returns the value of the "created_at" field in the mutation.
  13083. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  13084. v := m.created_at
  13085. if v == nil {
  13086. return
  13087. }
  13088. return *v, true
  13089. }
  13090. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  13091. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13093. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13094. if !m.op.Is(OpUpdateOne) {
  13095. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13096. }
  13097. if m.id == nil || m.oldValue == nil {
  13098. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13099. }
  13100. oldValue, err := m.oldValue(ctx)
  13101. if err != nil {
  13102. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13103. }
  13104. return oldValue.CreatedAt, nil
  13105. }
  13106. // ResetCreatedAt resets all changes to the "created_at" field.
  13107. func (m *CreditBalanceMutation) ResetCreatedAt() {
  13108. m.created_at = nil
  13109. }
  13110. // SetUpdatedAt sets the "updated_at" field.
  13111. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  13112. m.updated_at = &t
  13113. }
  13114. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13115. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  13116. v := m.updated_at
  13117. if v == nil {
  13118. return
  13119. }
  13120. return *v, true
  13121. }
  13122. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  13123. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13125. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13126. if !m.op.Is(OpUpdateOne) {
  13127. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13128. }
  13129. if m.id == nil || m.oldValue == nil {
  13130. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13131. }
  13132. oldValue, err := m.oldValue(ctx)
  13133. if err != nil {
  13134. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13135. }
  13136. return oldValue.UpdatedAt, nil
  13137. }
  13138. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13139. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  13140. m.updated_at = nil
  13141. }
  13142. // SetDeletedAt sets the "deleted_at" field.
  13143. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  13144. m.deleted_at = &t
  13145. }
  13146. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13147. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  13148. v := m.deleted_at
  13149. if v == nil {
  13150. return
  13151. }
  13152. return *v, true
  13153. }
  13154. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  13155. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13157. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13158. if !m.op.Is(OpUpdateOne) {
  13159. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13160. }
  13161. if m.id == nil || m.oldValue == nil {
  13162. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13163. }
  13164. oldValue, err := m.oldValue(ctx)
  13165. if err != nil {
  13166. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13167. }
  13168. return oldValue.DeletedAt, nil
  13169. }
  13170. // ClearDeletedAt clears the value of the "deleted_at" field.
  13171. func (m *CreditBalanceMutation) ClearDeletedAt() {
  13172. m.deleted_at = nil
  13173. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  13174. }
  13175. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13176. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  13177. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  13178. return ok
  13179. }
  13180. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13181. func (m *CreditBalanceMutation) ResetDeletedAt() {
  13182. m.deleted_at = nil
  13183. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  13184. }
  13185. // SetUserID sets the "user_id" field.
  13186. func (m *CreditBalanceMutation) SetUserID(s string) {
  13187. m.user_id = &s
  13188. }
  13189. // UserID returns the value of the "user_id" field in the mutation.
  13190. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  13191. v := m.user_id
  13192. if v == nil {
  13193. return
  13194. }
  13195. return *v, true
  13196. }
  13197. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  13198. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13200. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  13201. if !m.op.Is(OpUpdateOne) {
  13202. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  13203. }
  13204. if m.id == nil || m.oldValue == nil {
  13205. return v, errors.New("OldUserID requires an ID field in the mutation")
  13206. }
  13207. oldValue, err := m.oldValue(ctx)
  13208. if err != nil {
  13209. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  13210. }
  13211. return oldValue.UserID, nil
  13212. }
  13213. // ClearUserID clears the value of the "user_id" field.
  13214. func (m *CreditBalanceMutation) ClearUserID() {
  13215. m.user_id = nil
  13216. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  13217. }
  13218. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  13219. func (m *CreditBalanceMutation) UserIDCleared() bool {
  13220. _, ok := m.clearedFields[creditbalance.FieldUserID]
  13221. return ok
  13222. }
  13223. // ResetUserID resets all changes to the "user_id" field.
  13224. func (m *CreditBalanceMutation) ResetUserID() {
  13225. m.user_id = nil
  13226. delete(m.clearedFields, creditbalance.FieldUserID)
  13227. }
  13228. // SetBalance sets the "balance" field.
  13229. func (m *CreditBalanceMutation) SetBalance(f float64) {
  13230. m.balance = &f
  13231. m.addbalance = nil
  13232. }
  13233. // Balance returns the value of the "balance" field in the mutation.
  13234. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  13235. v := m.balance
  13236. if v == nil {
  13237. return
  13238. }
  13239. return *v, true
  13240. }
  13241. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  13242. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13244. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  13245. if !m.op.Is(OpUpdateOne) {
  13246. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  13247. }
  13248. if m.id == nil || m.oldValue == nil {
  13249. return v, errors.New("OldBalance requires an ID field in the mutation")
  13250. }
  13251. oldValue, err := m.oldValue(ctx)
  13252. if err != nil {
  13253. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  13254. }
  13255. return oldValue.Balance, nil
  13256. }
  13257. // AddBalance adds f to the "balance" field.
  13258. func (m *CreditBalanceMutation) AddBalance(f float64) {
  13259. if m.addbalance != nil {
  13260. *m.addbalance += f
  13261. } else {
  13262. m.addbalance = &f
  13263. }
  13264. }
  13265. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  13266. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  13267. v := m.addbalance
  13268. if v == nil {
  13269. return
  13270. }
  13271. return *v, true
  13272. }
  13273. // ResetBalance resets all changes to the "balance" field.
  13274. func (m *CreditBalanceMutation) ResetBalance() {
  13275. m.balance = nil
  13276. m.addbalance = nil
  13277. }
  13278. // SetStatus sets the "status" field.
  13279. func (m *CreditBalanceMutation) SetStatus(i int) {
  13280. m.status = &i
  13281. m.addstatus = nil
  13282. }
  13283. // Status returns the value of the "status" field in the mutation.
  13284. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  13285. v := m.status
  13286. if v == nil {
  13287. return
  13288. }
  13289. return *v, true
  13290. }
  13291. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  13292. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13294. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  13295. if !m.op.Is(OpUpdateOne) {
  13296. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13297. }
  13298. if m.id == nil || m.oldValue == nil {
  13299. return v, errors.New("OldStatus requires an ID field in the mutation")
  13300. }
  13301. oldValue, err := m.oldValue(ctx)
  13302. if err != nil {
  13303. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13304. }
  13305. return oldValue.Status, nil
  13306. }
  13307. // AddStatus adds i to the "status" field.
  13308. func (m *CreditBalanceMutation) AddStatus(i int) {
  13309. if m.addstatus != nil {
  13310. *m.addstatus += i
  13311. } else {
  13312. m.addstatus = &i
  13313. }
  13314. }
  13315. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13316. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  13317. v := m.addstatus
  13318. if v == nil {
  13319. return
  13320. }
  13321. return *v, true
  13322. }
  13323. // ClearStatus clears the value of the "status" field.
  13324. func (m *CreditBalanceMutation) ClearStatus() {
  13325. m.status = nil
  13326. m.addstatus = nil
  13327. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  13328. }
  13329. // StatusCleared returns if the "status" field was cleared in this mutation.
  13330. func (m *CreditBalanceMutation) StatusCleared() bool {
  13331. _, ok := m.clearedFields[creditbalance.FieldStatus]
  13332. return ok
  13333. }
  13334. // ResetStatus resets all changes to the "status" field.
  13335. func (m *CreditBalanceMutation) ResetStatus() {
  13336. m.status = nil
  13337. m.addstatus = nil
  13338. delete(m.clearedFields, creditbalance.FieldStatus)
  13339. }
  13340. // SetOrganizationID sets the "organization_id" field.
  13341. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  13342. m.organization_id = &u
  13343. m.addorganization_id = nil
  13344. }
  13345. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13346. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  13347. v := m.organization_id
  13348. if v == nil {
  13349. return
  13350. }
  13351. return *v, true
  13352. }
  13353. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  13354. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13356. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13357. if !m.op.Is(OpUpdateOne) {
  13358. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13359. }
  13360. if m.id == nil || m.oldValue == nil {
  13361. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13362. }
  13363. oldValue, err := m.oldValue(ctx)
  13364. if err != nil {
  13365. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13366. }
  13367. return oldValue.OrganizationID, nil
  13368. }
  13369. // AddOrganizationID adds u to the "organization_id" field.
  13370. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  13371. if m.addorganization_id != nil {
  13372. *m.addorganization_id += u
  13373. } else {
  13374. m.addorganization_id = &u
  13375. }
  13376. }
  13377. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13378. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  13379. v := m.addorganization_id
  13380. if v == nil {
  13381. return
  13382. }
  13383. return *v, true
  13384. }
  13385. // ClearOrganizationID clears the value of the "organization_id" field.
  13386. func (m *CreditBalanceMutation) ClearOrganizationID() {
  13387. m.organization_id = nil
  13388. m.addorganization_id = nil
  13389. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  13390. }
  13391. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13392. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  13393. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  13394. return ok
  13395. }
  13396. // ResetOrganizationID resets all changes to the "organization_id" field.
  13397. func (m *CreditBalanceMutation) ResetOrganizationID() {
  13398. m.organization_id = nil
  13399. m.addorganization_id = nil
  13400. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  13401. }
  13402. // Where appends a list predicates to the CreditBalanceMutation builder.
  13403. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  13404. m.predicates = append(m.predicates, ps...)
  13405. }
  13406. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  13407. // users can use type-assertion to append predicates that do not depend on any generated package.
  13408. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  13409. p := make([]predicate.CreditBalance, len(ps))
  13410. for i := range ps {
  13411. p[i] = ps[i]
  13412. }
  13413. m.Where(p...)
  13414. }
  13415. // Op returns the operation name.
  13416. func (m *CreditBalanceMutation) Op() Op {
  13417. return m.op
  13418. }
  13419. // SetOp allows setting the mutation operation.
  13420. func (m *CreditBalanceMutation) SetOp(op Op) {
  13421. m.op = op
  13422. }
  13423. // Type returns the node type of this mutation (CreditBalance).
  13424. func (m *CreditBalanceMutation) Type() string {
  13425. return m.typ
  13426. }
  13427. // Fields returns all fields that were changed during this mutation. Note that in
  13428. // order to get all numeric fields that were incremented/decremented, call
  13429. // AddedFields().
  13430. func (m *CreditBalanceMutation) Fields() []string {
  13431. fields := make([]string, 0, 7)
  13432. if m.created_at != nil {
  13433. fields = append(fields, creditbalance.FieldCreatedAt)
  13434. }
  13435. if m.updated_at != nil {
  13436. fields = append(fields, creditbalance.FieldUpdatedAt)
  13437. }
  13438. if m.deleted_at != nil {
  13439. fields = append(fields, creditbalance.FieldDeletedAt)
  13440. }
  13441. if m.user_id != nil {
  13442. fields = append(fields, creditbalance.FieldUserID)
  13443. }
  13444. if m.balance != nil {
  13445. fields = append(fields, creditbalance.FieldBalance)
  13446. }
  13447. if m.status != nil {
  13448. fields = append(fields, creditbalance.FieldStatus)
  13449. }
  13450. if m.organization_id != nil {
  13451. fields = append(fields, creditbalance.FieldOrganizationID)
  13452. }
  13453. return fields
  13454. }
  13455. // Field returns the value of a field with the given name. The second boolean
  13456. // return value indicates that this field was not set, or was not defined in the
  13457. // schema.
  13458. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  13459. switch name {
  13460. case creditbalance.FieldCreatedAt:
  13461. return m.CreatedAt()
  13462. case creditbalance.FieldUpdatedAt:
  13463. return m.UpdatedAt()
  13464. case creditbalance.FieldDeletedAt:
  13465. return m.DeletedAt()
  13466. case creditbalance.FieldUserID:
  13467. return m.UserID()
  13468. case creditbalance.FieldBalance:
  13469. return m.Balance()
  13470. case creditbalance.FieldStatus:
  13471. return m.Status()
  13472. case creditbalance.FieldOrganizationID:
  13473. return m.OrganizationID()
  13474. }
  13475. return nil, false
  13476. }
  13477. // OldField returns the old value of the field from the database. An error is
  13478. // returned if the mutation operation is not UpdateOne, or the query to the
  13479. // database failed.
  13480. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13481. switch name {
  13482. case creditbalance.FieldCreatedAt:
  13483. return m.OldCreatedAt(ctx)
  13484. case creditbalance.FieldUpdatedAt:
  13485. return m.OldUpdatedAt(ctx)
  13486. case creditbalance.FieldDeletedAt:
  13487. return m.OldDeletedAt(ctx)
  13488. case creditbalance.FieldUserID:
  13489. return m.OldUserID(ctx)
  13490. case creditbalance.FieldBalance:
  13491. return m.OldBalance(ctx)
  13492. case creditbalance.FieldStatus:
  13493. return m.OldStatus(ctx)
  13494. case creditbalance.FieldOrganizationID:
  13495. return m.OldOrganizationID(ctx)
  13496. }
  13497. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  13498. }
  13499. // SetField sets the value of a field with the given name. It returns an error if
  13500. // the field is not defined in the schema, or if the type mismatched the field
  13501. // type.
  13502. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  13503. switch name {
  13504. case creditbalance.FieldCreatedAt:
  13505. v, ok := value.(time.Time)
  13506. if !ok {
  13507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13508. }
  13509. m.SetCreatedAt(v)
  13510. return nil
  13511. case creditbalance.FieldUpdatedAt:
  13512. v, ok := value.(time.Time)
  13513. if !ok {
  13514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13515. }
  13516. m.SetUpdatedAt(v)
  13517. return nil
  13518. case creditbalance.FieldDeletedAt:
  13519. v, ok := value.(time.Time)
  13520. if !ok {
  13521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13522. }
  13523. m.SetDeletedAt(v)
  13524. return nil
  13525. case creditbalance.FieldUserID:
  13526. v, ok := value.(string)
  13527. if !ok {
  13528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13529. }
  13530. m.SetUserID(v)
  13531. return nil
  13532. case creditbalance.FieldBalance:
  13533. v, ok := value.(float64)
  13534. if !ok {
  13535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13536. }
  13537. m.SetBalance(v)
  13538. return nil
  13539. case creditbalance.FieldStatus:
  13540. v, ok := value.(int)
  13541. if !ok {
  13542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13543. }
  13544. m.SetStatus(v)
  13545. return nil
  13546. case creditbalance.FieldOrganizationID:
  13547. v, ok := value.(uint64)
  13548. if !ok {
  13549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13550. }
  13551. m.SetOrganizationID(v)
  13552. return nil
  13553. }
  13554. return fmt.Errorf("unknown CreditBalance field %s", name)
  13555. }
  13556. // AddedFields returns all numeric fields that were incremented/decremented during
  13557. // this mutation.
  13558. func (m *CreditBalanceMutation) AddedFields() []string {
  13559. var fields []string
  13560. if m.addbalance != nil {
  13561. fields = append(fields, creditbalance.FieldBalance)
  13562. }
  13563. if m.addstatus != nil {
  13564. fields = append(fields, creditbalance.FieldStatus)
  13565. }
  13566. if m.addorganization_id != nil {
  13567. fields = append(fields, creditbalance.FieldOrganizationID)
  13568. }
  13569. return fields
  13570. }
  13571. // AddedField returns the numeric value that was incremented/decremented on a field
  13572. // with the given name. The second boolean return value indicates that this field
  13573. // was not set, or was not defined in the schema.
  13574. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  13575. switch name {
  13576. case creditbalance.FieldBalance:
  13577. return m.AddedBalance()
  13578. case creditbalance.FieldStatus:
  13579. return m.AddedStatus()
  13580. case creditbalance.FieldOrganizationID:
  13581. return m.AddedOrganizationID()
  13582. }
  13583. return nil, false
  13584. }
  13585. // AddField adds the value to the field with the given name. It returns an error if
  13586. // the field is not defined in the schema, or if the type mismatched the field
  13587. // type.
  13588. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  13589. switch name {
  13590. case creditbalance.FieldBalance:
  13591. v, ok := value.(float64)
  13592. if !ok {
  13593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13594. }
  13595. m.AddBalance(v)
  13596. return nil
  13597. case creditbalance.FieldStatus:
  13598. v, ok := value.(int)
  13599. if !ok {
  13600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13601. }
  13602. m.AddStatus(v)
  13603. return nil
  13604. case creditbalance.FieldOrganizationID:
  13605. v, ok := value.(int64)
  13606. if !ok {
  13607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13608. }
  13609. m.AddOrganizationID(v)
  13610. return nil
  13611. }
  13612. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  13613. }
  13614. // ClearedFields returns all nullable fields that were cleared during this
  13615. // mutation.
  13616. func (m *CreditBalanceMutation) ClearedFields() []string {
  13617. var fields []string
  13618. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  13619. fields = append(fields, creditbalance.FieldDeletedAt)
  13620. }
  13621. if m.FieldCleared(creditbalance.FieldUserID) {
  13622. fields = append(fields, creditbalance.FieldUserID)
  13623. }
  13624. if m.FieldCleared(creditbalance.FieldStatus) {
  13625. fields = append(fields, creditbalance.FieldStatus)
  13626. }
  13627. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  13628. fields = append(fields, creditbalance.FieldOrganizationID)
  13629. }
  13630. return fields
  13631. }
  13632. // FieldCleared returns a boolean indicating if a field with the given name was
  13633. // cleared in this mutation.
  13634. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  13635. _, ok := m.clearedFields[name]
  13636. return ok
  13637. }
  13638. // ClearField clears the value of the field with the given name. It returns an
  13639. // error if the field is not defined in the schema.
  13640. func (m *CreditBalanceMutation) ClearField(name string) error {
  13641. switch name {
  13642. case creditbalance.FieldDeletedAt:
  13643. m.ClearDeletedAt()
  13644. return nil
  13645. case creditbalance.FieldUserID:
  13646. m.ClearUserID()
  13647. return nil
  13648. case creditbalance.FieldStatus:
  13649. m.ClearStatus()
  13650. return nil
  13651. case creditbalance.FieldOrganizationID:
  13652. m.ClearOrganizationID()
  13653. return nil
  13654. }
  13655. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  13656. }
  13657. // ResetField resets all changes in the mutation for the field with the given name.
  13658. // It returns an error if the field is not defined in the schema.
  13659. func (m *CreditBalanceMutation) ResetField(name string) error {
  13660. switch name {
  13661. case creditbalance.FieldCreatedAt:
  13662. m.ResetCreatedAt()
  13663. return nil
  13664. case creditbalance.FieldUpdatedAt:
  13665. m.ResetUpdatedAt()
  13666. return nil
  13667. case creditbalance.FieldDeletedAt:
  13668. m.ResetDeletedAt()
  13669. return nil
  13670. case creditbalance.FieldUserID:
  13671. m.ResetUserID()
  13672. return nil
  13673. case creditbalance.FieldBalance:
  13674. m.ResetBalance()
  13675. return nil
  13676. case creditbalance.FieldStatus:
  13677. m.ResetStatus()
  13678. return nil
  13679. case creditbalance.FieldOrganizationID:
  13680. m.ResetOrganizationID()
  13681. return nil
  13682. }
  13683. return fmt.Errorf("unknown CreditBalance field %s", name)
  13684. }
  13685. // AddedEdges returns all edge names that were set/added in this mutation.
  13686. func (m *CreditBalanceMutation) AddedEdges() []string {
  13687. edges := make([]string, 0, 0)
  13688. return edges
  13689. }
  13690. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13691. // name in this mutation.
  13692. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  13693. return nil
  13694. }
  13695. // RemovedEdges returns all edge names that were removed in this mutation.
  13696. func (m *CreditBalanceMutation) RemovedEdges() []string {
  13697. edges := make([]string, 0, 0)
  13698. return edges
  13699. }
  13700. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13701. // the given name in this mutation.
  13702. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  13703. return nil
  13704. }
  13705. // ClearedEdges returns all edge names that were cleared in this mutation.
  13706. func (m *CreditBalanceMutation) ClearedEdges() []string {
  13707. edges := make([]string, 0, 0)
  13708. return edges
  13709. }
  13710. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13711. // was cleared in this mutation.
  13712. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  13713. return false
  13714. }
  13715. // ClearEdge clears the value of the edge with the given name. It returns an error
  13716. // if that edge is not defined in the schema.
  13717. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  13718. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  13719. }
  13720. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13721. // It returns an error if the edge is not defined in the schema.
  13722. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  13723. return fmt.Errorf("unknown CreditBalance edge %s", name)
  13724. }
  13725. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  13726. type CreditUsageMutation struct {
  13727. config
  13728. op Op
  13729. typ string
  13730. id *uint64
  13731. created_at *time.Time
  13732. updated_at *time.Time
  13733. deleted_at *time.Time
  13734. user_id *string
  13735. number *float64
  13736. addnumber *float64
  13737. pay_number *float64
  13738. addpay_number *float64
  13739. before_number *float64
  13740. addbefore_number *float64
  13741. after_number *float64
  13742. addafter_number *float64
  13743. pay_method *int
  13744. addpay_method *int
  13745. status *int
  13746. addstatus *int
  13747. ntype *int
  13748. addntype *int
  13749. table *string
  13750. organization_id *uint64
  13751. addorganization_id *int64
  13752. nid *uint64
  13753. addnid *int64
  13754. reason *string
  13755. operator *string
  13756. clearedFields map[string]struct{}
  13757. done bool
  13758. oldValue func(context.Context) (*CreditUsage, error)
  13759. predicates []predicate.CreditUsage
  13760. }
  13761. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  13762. // creditusageOption allows management of the mutation configuration using functional options.
  13763. type creditusageOption func(*CreditUsageMutation)
  13764. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  13765. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  13766. m := &CreditUsageMutation{
  13767. config: c,
  13768. op: op,
  13769. typ: TypeCreditUsage,
  13770. clearedFields: make(map[string]struct{}),
  13771. }
  13772. for _, opt := range opts {
  13773. opt(m)
  13774. }
  13775. return m
  13776. }
  13777. // withCreditUsageID sets the ID field of the mutation.
  13778. func withCreditUsageID(id uint64) creditusageOption {
  13779. return func(m *CreditUsageMutation) {
  13780. var (
  13781. err error
  13782. once sync.Once
  13783. value *CreditUsage
  13784. )
  13785. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  13786. once.Do(func() {
  13787. if m.done {
  13788. err = errors.New("querying old values post mutation is not allowed")
  13789. } else {
  13790. value, err = m.Client().CreditUsage.Get(ctx, id)
  13791. }
  13792. })
  13793. return value, err
  13794. }
  13795. m.id = &id
  13796. }
  13797. }
  13798. // withCreditUsage sets the old CreditUsage of the mutation.
  13799. func withCreditUsage(node *CreditUsage) creditusageOption {
  13800. return func(m *CreditUsageMutation) {
  13801. m.oldValue = func(context.Context) (*CreditUsage, error) {
  13802. return node, nil
  13803. }
  13804. m.id = &node.ID
  13805. }
  13806. }
  13807. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13808. // executed in a transaction (ent.Tx), a transactional client is returned.
  13809. func (m CreditUsageMutation) Client() *Client {
  13810. client := &Client{config: m.config}
  13811. client.init()
  13812. return client
  13813. }
  13814. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13815. // it returns an error otherwise.
  13816. func (m CreditUsageMutation) Tx() (*Tx, error) {
  13817. if _, ok := m.driver.(*txDriver); !ok {
  13818. return nil, errors.New("ent: mutation is not running in a transaction")
  13819. }
  13820. tx := &Tx{config: m.config}
  13821. tx.init()
  13822. return tx, nil
  13823. }
  13824. // SetID sets the value of the id field. Note that this
  13825. // operation is only accepted on creation of CreditUsage entities.
  13826. func (m *CreditUsageMutation) SetID(id uint64) {
  13827. m.id = &id
  13828. }
  13829. // ID returns the ID value in the mutation. Note that the ID is only available
  13830. // if it was provided to the builder or after it was returned from the database.
  13831. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  13832. if m.id == nil {
  13833. return
  13834. }
  13835. return *m.id, true
  13836. }
  13837. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13838. // That means, if the mutation is applied within a transaction with an isolation level such
  13839. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13840. // or updated by the mutation.
  13841. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13842. switch {
  13843. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13844. id, exists := m.ID()
  13845. if exists {
  13846. return []uint64{id}, nil
  13847. }
  13848. fallthrough
  13849. case m.op.Is(OpUpdate | OpDelete):
  13850. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  13851. default:
  13852. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13853. }
  13854. }
  13855. // SetCreatedAt sets the "created_at" field.
  13856. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  13857. m.created_at = &t
  13858. }
  13859. // CreatedAt returns the value of the "created_at" field in the mutation.
  13860. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  13861. v := m.created_at
  13862. if v == nil {
  13863. return
  13864. }
  13865. return *v, true
  13866. }
  13867. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  13868. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13870. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13871. if !m.op.Is(OpUpdateOne) {
  13872. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13873. }
  13874. if m.id == nil || m.oldValue == nil {
  13875. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13876. }
  13877. oldValue, err := m.oldValue(ctx)
  13878. if err != nil {
  13879. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13880. }
  13881. return oldValue.CreatedAt, nil
  13882. }
  13883. // ResetCreatedAt resets all changes to the "created_at" field.
  13884. func (m *CreditUsageMutation) ResetCreatedAt() {
  13885. m.created_at = nil
  13886. }
  13887. // SetUpdatedAt sets the "updated_at" field.
  13888. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  13889. m.updated_at = &t
  13890. }
  13891. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13892. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  13893. v := m.updated_at
  13894. if v == nil {
  13895. return
  13896. }
  13897. return *v, true
  13898. }
  13899. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  13900. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13902. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13903. if !m.op.Is(OpUpdateOne) {
  13904. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13905. }
  13906. if m.id == nil || m.oldValue == nil {
  13907. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13908. }
  13909. oldValue, err := m.oldValue(ctx)
  13910. if err != nil {
  13911. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13912. }
  13913. return oldValue.UpdatedAt, nil
  13914. }
  13915. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13916. func (m *CreditUsageMutation) ResetUpdatedAt() {
  13917. m.updated_at = nil
  13918. }
  13919. // SetDeletedAt sets the "deleted_at" field.
  13920. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  13921. m.deleted_at = &t
  13922. }
  13923. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13924. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  13925. v := m.deleted_at
  13926. if v == nil {
  13927. return
  13928. }
  13929. return *v, true
  13930. }
  13931. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  13932. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13934. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13935. if !m.op.Is(OpUpdateOne) {
  13936. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13937. }
  13938. if m.id == nil || m.oldValue == nil {
  13939. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13940. }
  13941. oldValue, err := m.oldValue(ctx)
  13942. if err != nil {
  13943. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13944. }
  13945. return oldValue.DeletedAt, nil
  13946. }
  13947. // ClearDeletedAt clears the value of the "deleted_at" field.
  13948. func (m *CreditUsageMutation) ClearDeletedAt() {
  13949. m.deleted_at = nil
  13950. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  13951. }
  13952. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13953. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  13954. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  13955. return ok
  13956. }
  13957. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13958. func (m *CreditUsageMutation) ResetDeletedAt() {
  13959. m.deleted_at = nil
  13960. delete(m.clearedFields, creditusage.FieldDeletedAt)
  13961. }
  13962. // SetUserID sets the "user_id" field.
  13963. func (m *CreditUsageMutation) SetUserID(s string) {
  13964. m.user_id = &s
  13965. }
  13966. // UserID returns the value of the "user_id" field in the mutation.
  13967. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  13968. v := m.user_id
  13969. if v == nil {
  13970. return
  13971. }
  13972. return *v, true
  13973. }
  13974. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  13975. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13977. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  13978. if !m.op.Is(OpUpdateOne) {
  13979. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  13980. }
  13981. if m.id == nil || m.oldValue == nil {
  13982. return v, errors.New("OldUserID requires an ID field in the mutation")
  13983. }
  13984. oldValue, err := m.oldValue(ctx)
  13985. if err != nil {
  13986. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  13987. }
  13988. return oldValue.UserID, nil
  13989. }
  13990. // ClearUserID clears the value of the "user_id" field.
  13991. func (m *CreditUsageMutation) ClearUserID() {
  13992. m.user_id = nil
  13993. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  13994. }
  13995. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  13996. func (m *CreditUsageMutation) UserIDCleared() bool {
  13997. _, ok := m.clearedFields[creditusage.FieldUserID]
  13998. return ok
  13999. }
  14000. // ResetUserID resets all changes to the "user_id" field.
  14001. func (m *CreditUsageMutation) ResetUserID() {
  14002. m.user_id = nil
  14003. delete(m.clearedFields, creditusage.FieldUserID)
  14004. }
  14005. // SetNumber sets the "number" field.
  14006. func (m *CreditUsageMutation) SetNumber(f float64) {
  14007. m.number = &f
  14008. m.addnumber = nil
  14009. }
  14010. // Number returns the value of the "number" field in the mutation.
  14011. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  14012. v := m.number
  14013. if v == nil {
  14014. return
  14015. }
  14016. return *v, true
  14017. }
  14018. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  14019. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14021. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  14022. if !m.op.Is(OpUpdateOne) {
  14023. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  14024. }
  14025. if m.id == nil || m.oldValue == nil {
  14026. return v, errors.New("OldNumber requires an ID field in the mutation")
  14027. }
  14028. oldValue, err := m.oldValue(ctx)
  14029. if err != nil {
  14030. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  14031. }
  14032. return oldValue.Number, nil
  14033. }
  14034. // AddNumber adds f to the "number" field.
  14035. func (m *CreditUsageMutation) AddNumber(f float64) {
  14036. if m.addnumber != nil {
  14037. *m.addnumber += f
  14038. } else {
  14039. m.addnumber = &f
  14040. }
  14041. }
  14042. // AddedNumber returns the value that was added to the "number" field in this mutation.
  14043. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  14044. v := m.addnumber
  14045. if v == nil {
  14046. return
  14047. }
  14048. return *v, true
  14049. }
  14050. // ResetNumber resets all changes to the "number" field.
  14051. func (m *CreditUsageMutation) ResetNumber() {
  14052. m.number = nil
  14053. m.addnumber = nil
  14054. }
  14055. // SetPayNumber sets the "pay_number" field.
  14056. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  14057. m.pay_number = &f
  14058. m.addpay_number = nil
  14059. }
  14060. // PayNumber returns the value of the "pay_number" field in the mutation.
  14061. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  14062. v := m.pay_number
  14063. if v == nil {
  14064. return
  14065. }
  14066. return *v, true
  14067. }
  14068. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  14069. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14071. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  14072. if !m.op.Is(OpUpdateOne) {
  14073. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  14074. }
  14075. if m.id == nil || m.oldValue == nil {
  14076. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  14077. }
  14078. oldValue, err := m.oldValue(ctx)
  14079. if err != nil {
  14080. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  14081. }
  14082. return oldValue.PayNumber, nil
  14083. }
  14084. // AddPayNumber adds f to the "pay_number" field.
  14085. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  14086. if m.addpay_number != nil {
  14087. *m.addpay_number += f
  14088. } else {
  14089. m.addpay_number = &f
  14090. }
  14091. }
  14092. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  14093. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  14094. v := m.addpay_number
  14095. if v == nil {
  14096. return
  14097. }
  14098. return *v, true
  14099. }
  14100. // ClearPayNumber clears the value of the "pay_number" field.
  14101. func (m *CreditUsageMutation) ClearPayNumber() {
  14102. m.pay_number = nil
  14103. m.addpay_number = nil
  14104. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  14105. }
  14106. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  14107. func (m *CreditUsageMutation) PayNumberCleared() bool {
  14108. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  14109. return ok
  14110. }
  14111. // ResetPayNumber resets all changes to the "pay_number" field.
  14112. func (m *CreditUsageMutation) ResetPayNumber() {
  14113. m.pay_number = nil
  14114. m.addpay_number = nil
  14115. delete(m.clearedFields, creditusage.FieldPayNumber)
  14116. }
  14117. // SetBeforeNumber sets the "before_number" field.
  14118. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  14119. m.before_number = &f
  14120. m.addbefore_number = nil
  14121. }
  14122. // BeforeNumber returns the value of the "before_number" field in the mutation.
  14123. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  14124. v := m.before_number
  14125. if v == nil {
  14126. return
  14127. }
  14128. return *v, true
  14129. }
  14130. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  14131. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14133. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  14134. if !m.op.Is(OpUpdateOne) {
  14135. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  14136. }
  14137. if m.id == nil || m.oldValue == nil {
  14138. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  14139. }
  14140. oldValue, err := m.oldValue(ctx)
  14141. if err != nil {
  14142. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  14143. }
  14144. return oldValue.BeforeNumber, nil
  14145. }
  14146. // AddBeforeNumber adds f to the "before_number" field.
  14147. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  14148. if m.addbefore_number != nil {
  14149. *m.addbefore_number += f
  14150. } else {
  14151. m.addbefore_number = &f
  14152. }
  14153. }
  14154. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  14155. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  14156. v := m.addbefore_number
  14157. if v == nil {
  14158. return
  14159. }
  14160. return *v, true
  14161. }
  14162. // ClearBeforeNumber clears the value of the "before_number" field.
  14163. func (m *CreditUsageMutation) ClearBeforeNumber() {
  14164. m.before_number = nil
  14165. m.addbefore_number = nil
  14166. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  14167. }
  14168. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  14169. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  14170. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  14171. return ok
  14172. }
  14173. // ResetBeforeNumber resets all changes to the "before_number" field.
  14174. func (m *CreditUsageMutation) ResetBeforeNumber() {
  14175. m.before_number = nil
  14176. m.addbefore_number = nil
  14177. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  14178. }
  14179. // SetAfterNumber sets the "after_number" field.
  14180. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  14181. m.after_number = &f
  14182. m.addafter_number = nil
  14183. }
  14184. // AfterNumber returns the value of the "after_number" field in the mutation.
  14185. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  14186. v := m.after_number
  14187. if v == nil {
  14188. return
  14189. }
  14190. return *v, true
  14191. }
  14192. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  14193. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14195. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  14196. if !m.op.Is(OpUpdateOne) {
  14197. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  14198. }
  14199. if m.id == nil || m.oldValue == nil {
  14200. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  14201. }
  14202. oldValue, err := m.oldValue(ctx)
  14203. if err != nil {
  14204. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  14205. }
  14206. return oldValue.AfterNumber, nil
  14207. }
  14208. // AddAfterNumber adds f to the "after_number" field.
  14209. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  14210. if m.addafter_number != nil {
  14211. *m.addafter_number += f
  14212. } else {
  14213. m.addafter_number = &f
  14214. }
  14215. }
  14216. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  14217. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  14218. v := m.addafter_number
  14219. if v == nil {
  14220. return
  14221. }
  14222. return *v, true
  14223. }
  14224. // ClearAfterNumber clears the value of the "after_number" field.
  14225. func (m *CreditUsageMutation) ClearAfterNumber() {
  14226. m.after_number = nil
  14227. m.addafter_number = nil
  14228. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  14229. }
  14230. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  14231. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  14232. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  14233. return ok
  14234. }
  14235. // ResetAfterNumber resets all changes to the "after_number" field.
  14236. func (m *CreditUsageMutation) ResetAfterNumber() {
  14237. m.after_number = nil
  14238. m.addafter_number = nil
  14239. delete(m.clearedFields, creditusage.FieldAfterNumber)
  14240. }
  14241. // SetPayMethod sets the "pay_method" field.
  14242. func (m *CreditUsageMutation) SetPayMethod(i int) {
  14243. m.pay_method = &i
  14244. m.addpay_method = nil
  14245. }
  14246. // PayMethod returns the value of the "pay_method" field in the mutation.
  14247. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  14248. v := m.pay_method
  14249. if v == nil {
  14250. return
  14251. }
  14252. return *v, true
  14253. }
  14254. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  14255. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14257. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  14258. if !m.op.Is(OpUpdateOne) {
  14259. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  14260. }
  14261. if m.id == nil || m.oldValue == nil {
  14262. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  14263. }
  14264. oldValue, err := m.oldValue(ctx)
  14265. if err != nil {
  14266. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  14267. }
  14268. return oldValue.PayMethod, nil
  14269. }
  14270. // AddPayMethod adds i to the "pay_method" field.
  14271. func (m *CreditUsageMutation) AddPayMethod(i int) {
  14272. if m.addpay_method != nil {
  14273. *m.addpay_method += i
  14274. } else {
  14275. m.addpay_method = &i
  14276. }
  14277. }
  14278. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  14279. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  14280. v := m.addpay_method
  14281. if v == nil {
  14282. return
  14283. }
  14284. return *v, true
  14285. }
  14286. // ClearPayMethod clears the value of the "pay_method" field.
  14287. func (m *CreditUsageMutation) ClearPayMethod() {
  14288. m.pay_method = nil
  14289. m.addpay_method = nil
  14290. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  14291. }
  14292. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  14293. func (m *CreditUsageMutation) PayMethodCleared() bool {
  14294. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  14295. return ok
  14296. }
  14297. // ResetPayMethod resets all changes to the "pay_method" field.
  14298. func (m *CreditUsageMutation) ResetPayMethod() {
  14299. m.pay_method = nil
  14300. m.addpay_method = nil
  14301. delete(m.clearedFields, creditusage.FieldPayMethod)
  14302. }
  14303. // SetStatus sets the "status" field.
  14304. func (m *CreditUsageMutation) SetStatus(i int) {
  14305. m.status = &i
  14306. m.addstatus = nil
  14307. }
  14308. // Status returns the value of the "status" field in the mutation.
  14309. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  14310. v := m.status
  14311. if v == nil {
  14312. return
  14313. }
  14314. return *v, true
  14315. }
  14316. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  14317. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14319. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  14320. if !m.op.Is(OpUpdateOne) {
  14321. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14322. }
  14323. if m.id == nil || m.oldValue == nil {
  14324. return v, errors.New("OldStatus requires an ID field in the mutation")
  14325. }
  14326. oldValue, err := m.oldValue(ctx)
  14327. if err != nil {
  14328. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14329. }
  14330. return oldValue.Status, nil
  14331. }
  14332. // AddStatus adds i to the "status" field.
  14333. func (m *CreditUsageMutation) AddStatus(i int) {
  14334. if m.addstatus != nil {
  14335. *m.addstatus += i
  14336. } else {
  14337. m.addstatus = &i
  14338. }
  14339. }
  14340. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14341. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  14342. v := m.addstatus
  14343. if v == nil {
  14344. return
  14345. }
  14346. return *v, true
  14347. }
  14348. // ClearStatus clears the value of the "status" field.
  14349. func (m *CreditUsageMutation) ClearStatus() {
  14350. m.status = nil
  14351. m.addstatus = nil
  14352. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  14353. }
  14354. // StatusCleared returns if the "status" field was cleared in this mutation.
  14355. func (m *CreditUsageMutation) StatusCleared() bool {
  14356. _, ok := m.clearedFields[creditusage.FieldStatus]
  14357. return ok
  14358. }
  14359. // ResetStatus resets all changes to the "status" field.
  14360. func (m *CreditUsageMutation) ResetStatus() {
  14361. m.status = nil
  14362. m.addstatus = nil
  14363. delete(m.clearedFields, creditusage.FieldStatus)
  14364. }
  14365. // SetNtype sets the "ntype" field.
  14366. func (m *CreditUsageMutation) SetNtype(i int) {
  14367. m.ntype = &i
  14368. m.addntype = nil
  14369. }
  14370. // Ntype returns the value of the "ntype" field in the mutation.
  14371. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  14372. v := m.ntype
  14373. if v == nil {
  14374. return
  14375. }
  14376. return *v, true
  14377. }
  14378. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  14379. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14381. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  14382. if !m.op.Is(OpUpdateOne) {
  14383. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  14384. }
  14385. if m.id == nil || m.oldValue == nil {
  14386. return v, errors.New("OldNtype requires an ID field in the mutation")
  14387. }
  14388. oldValue, err := m.oldValue(ctx)
  14389. if err != nil {
  14390. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  14391. }
  14392. return oldValue.Ntype, nil
  14393. }
  14394. // AddNtype adds i to the "ntype" field.
  14395. func (m *CreditUsageMutation) AddNtype(i int) {
  14396. if m.addntype != nil {
  14397. *m.addntype += i
  14398. } else {
  14399. m.addntype = &i
  14400. }
  14401. }
  14402. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  14403. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  14404. v := m.addntype
  14405. if v == nil {
  14406. return
  14407. }
  14408. return *v, true
  14409. }
  14410. // ResetNtype resets all changes to the "ntype" field.
  14411. func (m *CreditUsageMutation) ResetNtype() {
  14412. m.ntype = nil
  14413. m.addntype = nil
  14414. }
  14415. // SetTable sets the "table" field.
  14416. func (m *CreditUsageMutation) SetTable(s string) {
  14417. m.table = &s
  14418. }
  14419. // Table returns the value of the "table" field in the mutation.
  14420. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  14421. v := m.table
  14422. if v == nil {
  14423. return
  14424. }
  14425. return *v, true
  14426. }
  14427. // OldTable returns the old "table" field's value of the CreditUsage entity.
  14428. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14430. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  14431. if !m.op.Is(OpUpdateOne) {
  14432. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  14433. }
  14434. if m.id == nil || m.oldValue == nil {
  14435. return v, errors.New("OldTable requires an ID field in the mutation")
  14436. }
  14437. oldValue, err := m.oldValue(ctx)
  14438. if err != nil {
  14439. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  14440. }
  14441. return oldValue.Table, nil
  14442. }
  14443. // ResetTable resets all changes to the "table" field.
  14444. func (m *CreditUsageMutation) ResetTable() {
  14445. m.table = nil
  14446. }
  14447. // SetOrganizationID sets the "organization_id" field.
  14448. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  14449. m.organization_id = &u
  14450. m.addorganization_id = nil
  14451. }
  14452. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14453. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  14454. v := m.organization_id
  14455. if v == nil {
  14456. return
  14457. }
  14458. return *v, true
  14459. }
  14460. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  14461. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14463. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14464. if !m.op.Is(OpUpdateOne) {
  14465. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14466. }
  14467. if m.id == nil || m.oldValue == nil {
  14468. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14469. }
  14470. oldValue, err := m.oldValue(ctx)
  14471. if err != nil {
  14472. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14473. }
  14474. return oldValue.OrganizationID, nil
  14475. }
  14476. // AddOrganizationID adds u to the "organization_id" field.
  14477. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  14478. if m.addorganization_id != nil {
  14479. *m.addorganization_id += u
  14480. } else {
  14481. m.addorganization_id = &u
  14482. }
  14483. }
  14484. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14485. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  14486. v := m.addorganization_id
  14487. if v == nil {
  14488. return
  14489. }
  14490. return *v, true
  14491. }
  14492. // ClearOrganizationID clears the value of the "organization_id" field.
  14493. func (m *CreditUsageMutation) ClearOrganizationID() {
  14494. m.organization_id = nil
  14495. m.addorganization_id = nil
  14496. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  14497. }
  14498. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14499. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  14500. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  14501. return ok
  14502. }
  14503. // ResetOrganizationID resets all changes to the "organization_id" field.
  14504. func (m *CreditUsageMutation) ResetOrganizationID() {
  14505. m.organization_id = nil
  14506. m.addorganization_id = nil
  14507. delete(m.clearedFields, creditusage.FieldOrganizationID)
  14508. }
  14509. // SetNid sets the "nid" field.
  14510. func (m *CreditUsageMutation) SetNid(u uint64) {
  14511. m.nid = &u
  14512. m.addnid = nil
  14513. }
  14514. // Nid returns the value of the "nid" field in the mutation.
  14515. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  14516. v := m.nid
  14517. if v == nil {
  14518. return
  14519. }
  14520. return *v, true
  14521. }
  14522. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  14523. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14525. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  14526. if !m.op.Is(OpUpdateOne) {
  14527. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  14528. }
  14529. if m.id == nil || m.oldValue == nil {
  14530. return v, errors.New("OldNid requires an ID field in the mutation")
  14531. }
  14532. oldValue, err := m.oldValue(ctx)
  14533. if err != nil {
  14534. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  14535. }
  14536. return oldValue.Nid, nil
  14537. }
  14538. // AddNid adds u to the "nid" field.
  14539. func (m *CreditUsageMutation) AddNid(u int64) {
  14540. if m.addnid != nil {
  14541. *m.addnid += u
  14542. } else {
  14543. m.addnid = &u
  14544. }
  14545. }
  14546. // AddedNid returns the value that was added to the "nid" field in this mutation.
  14547. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  14548. v := m.addnid
  14549. if v == nil {
  14550. return
  14551. }
  14552. return *v, true
  14553. }
  14554. // ResetNid resets all changes to the "nid" field.
  14555. func (m *CreditUsageMutation) ResetNid() {
  14556. m.nid = nil
  14557. m.addnid = nil
  14558. }
  14559. // SetReason sets the "reason" field.
  14560. func (m *CreditUsageMutation) SetReason(s string) {
  14561. m.reason = &s
  14562. }
  14563. // Reason returns the value of the "reason" field in the mutation.
  14564. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  14565. v := m.reason
  14566. if v == nil {
  14567. return
  14568. }
  14569. return *v, true
  14570. }
  14571. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  14572. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14574. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  14575. if !m.op.Is(OpUpdateOne) {
  14576. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  14577. }
  14578. if m.id == nil || m.oldValue == nil {
  14579. return v, errors.New("OldReason requires an ID field in the mutation")
  14580. }
  14581. oldValue, err := m.oldValue(ctx)
  14582. if err != nil {
  14583. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  14584. }
  14585. return oldValue.Reason, nil
  14586. }
  14587. // ResetReason resets all changes to the "reason" field.
  14588. func (m *CreditUsageMutation) ResetReason() {
  14589. m.reason = nil
  14590. }
  14591. // SetOperator sets the "operator" field.
  14592. func (m *CreditUsageMutation) SetOperator(s string) {
  14593. m.operator = &s
  14594. }
  14595. // Operator returns the value of the "operator" field in the mutation.
  14596. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  14597. v := m.operator
  14598. if v == nil {
  14599. return
  14600. }
  14601. return *v, true
  14602. }
  14603. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  14604. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14606. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  14607. if !m.op.Is(OpUpdateOne) {
  14608. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  14609. }
  14610. if m.id == nil || m.oldValue == nil {
  14611. return v, errors.New("OldOperator requires an ID field in the mutation")
  14612. }
  14613. oldValue, err := m.oldValue(ctx)
  14614. if err != nil {
  14615. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  14616. }
  14617. return oldValue.Operator, nil
  14618. }
  14619. // ResetOperator resets all changes to the "operator" field.
  14620. func (m *CreditUsageMutation) ResetOperator() {
  14621. m.operator = nil
  14622. }
  14623. // Where appends a list predicates to the CreditUsageMutation builder.
  14624. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  14625. m.predicates = append(m.predicates, ps...)
  14626. }
  14627. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  14628. // users can use type-assertion to append predicates that do not depend on any generated package.
  14629. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  14630. p := make([]predicate.CreditUsage, len(ps))
  14631. for i := range ps {
  14632. p[i] = ps[i]
  14633. }
  14634. m.Where(p...)
  14635. }
  14636. // Op returns the operation name.
  14637. func (m *CreditUsageMutation) Op() Op {
  14638. return m.op
  14639. }
  14640. // SetOp allows setting the mutation operation.
  14641. func (m *CreditUsageMutation) SetOp(op Op) {
  14642. m.op = op
  14643. }
  14644. // Type returns the node type of this mutation (CreditUsage).
  14645. func (m *CreditUsageMutation) Type() string {
  14646. return m.typ
  14647. }
  14648. // Fields returns all fields that were changed during this mutation. Note that in
  14649. // order to get all numeric fields that were incremented/decremented, call
  14650. // AddedFields().
  14651. func (m *CreditUsageMutation) Fields() []string {
  14652. fields := make([]string, 0, 16)
  14653. if m.created_at != nil {
  14654. fields = append(fields, creditusage.FieldCreatedAt)
  14655. }
  14656. if m.updated_at != nil {
  14657. fields = append(fields, creditusage.FieldUpdatedAt)
  14658. }
  14659. if m.deleted_at != nil {
  14660. fields = append(fields, creditusage.FieldDeletedAt)
  14661. }
  14662. if m.user_id != nil {
  14663. fields = append(fields, creditusage.FieldUserID)
  14664. }
  14665. if m.number != nil {
  14666. fields = append(fields, creditusage.FieldNumber)
  14667. }
  14668. if m.pay_number != nil {
  14669. fields = append(fields, creditusage.FieldPayNumber)
  14670. }
  14671. if m.before_number != nil {
  14672. fields = append(fields, creditusage.FieldBeforeNumber)
  14673. }
  14674. if m.after_number != nil {
  14675. fields = append(fields, creditusage.FieldAfterNumber)
  14676. }
  14677. if m.pay_method != nil {
  14678. fields = append(fields, creditusage.FieldPayMethod)
  14679. }
  14680. if m.status != nil {
  14681. fields = append(fields, creditusage.FieldStatus)
  14682. }
  14683. if m.ntype != nil {
  14684. fields = append(fields, creditusage.FieldNtype)
  14685. }
  14686. if m.table != nil {
  14687. fields = append(fields, creditusage.FieldTable)
  14688. }
  14689. if m.organization_id != nil {
  14690. fields = append(fields, creditusage.FieldOrganizationID)
  14691. }
  14692. if m.nid != nil {
  14693. fields = append(fields, creditusage.FieldNid)
  14694. }
  14695. if m.reason != nil {
  14696. fields = append(fields, creditusage.FieldReason)
  14697. }
  14698. if m.operator != nil {
  14699. fields = append(fields, creditusage.FieldOperator)
  14700. }
  14701. return fields
  14702. }
  14703. // Field returns the value of a field with the given name. The second boolean
  14704. // return value indicates that this field was not set, or was not defined in the
  14705. // schema.
  14706. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  14707. switch name {
  14708. case creditusage.FieldCreatedAt:
  14709. return m.CreatedAt()
  14710. case creditusage.FieldUpdatedAt:
  14711. return m.UpdatedAt()
  14712. case creditusage.FieldDeletedAt:
  14713. return m.DeletedAt()
  14714. case creditusage.FieldUserID:
  14715. return m.UserID()
  14716. case creditusage.FieldNumber:
  14717. return m.Number()
  14718. case creditusage.FieldPayNumber:
  14719. return m.PayNumber()
  14720. case creditusage.FieldBeforeNumber:
  14721. return m.BeforeNumber()
  14722. case creditusage.FieldAfterNumber:
  14723. return m.AfterNumber()
  14724. case creditusage.FieldPayMethod:
  14725. return m.PayMethod()
  14726. case creditusage.FieldStatus:
  14727. return m.Status()
  14728. case creditusage.FieldNtype:
  14729. return m.Ntype()
  14730. case creditusage.FieldTable:
  14731. return m.Table()
  14732. case creditusage.FieldOrganizationID:
  14733. return m.OrganizationID()
  14734. case creditusage.FieldNid:
  14735. return m.Nid()
  14736. case creditusage.FieldReason:
  14737. return m.Reason()
  14738. case creditusage.FieldOperator:
  14739. return m.Operator()
  14740. }
  14741. return nil, false
  14742. }
  14743. // OldField returns the old value of the field from the database. An error is
  14744. // returned if the mutation operation is not UpdateOne, or the query to the
  14745. // database failed.
  14746. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14747. switch name {
  14748. case creditusage.FieldCreatedAt:
  14749. return m.OldCreatedAt(ctx)
  14750. case creditusage.FieldUpdatedAt:
  14751. return m.OldUpdatedAt(ctx)
  14752. case creditusage.FieldDeletedAt:
  14753. return m.OldDeletedAt(ctx)
  14754. case creditusage.FieldUserID:
  14755. return m.OldUserID(ctx)
  14756. case creditusage.FieldNumber:
  14757. return m.OldNumber(ctx)
  14758. case creditusage.FieldPayNumber:
  14759. return m.OldPayNumber(ctx)
  14760. case creditusage.FieldBeforeNumber:
  14761. return m.OldBeforeNumber(ctx)
  14762. case creditusage.FieldAfterNumber:
  14763. return m.OldAfterNumber(ctx)
  14764. case creditusage.FieldPayMethod:
  14765. return m.OldPayMethod(ctx)
  14766. case creditusage.FieldStatus:
  14767. return m.OldStatus(ctx)
  14768. case creditusage.FieldNtype:
  14769. return m.OldNtype(ctx)
  14770. case creditusage.FieldTable:
  14771. return m.OldTable(ctx)
  14772. case creditusage.FieldOrganizationID:
  14773. return m.OldOrganizationID(ctx)
  14774. case creditusage.FieldNid:
  14775. return m.OldNid(ctx)
  14776. case creditusage.FieldReason:
  14777. return m.OldReason(ctx)
  14778. case creditusage.FieldOperator:
  14779. return m.OldOperator(ctx)
  14780. }
  14781. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  14782. }
  14783. // SetField sets the value of a field with the given name. It returns an error if
  14784. // the field is not defined in the schema, or if the type mismatched the field
  14785. // type.
  14786. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  14787. switch name {
  14788. case creditusage.FieldCreatedAt:
  14789. v, ok := value.(time.Time)
  14790. if !ok {
  14791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14792. }
  14793. m.SetCreatedAt(v)
  14794. return nil
  14795. case creditusage.FieldUpdatedAt:
  14796. v, ok := value.(time.Time)
  14797. if !ok {
  14798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14799. }
  14800. m.SetUpdatedAt(v)
  14801. return nil
  14802. case creditusage.FieldDeletedAt:
  14803. v, ok := value.(time.Time)
  14804. if !ok {
  14805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14806. }
  14807. m.SetDeletedAt(v)
  14808. return nil
  14809. case creditusage.FieldUserID:
  14810. v, ok := value.(string)
  14811. if !ok {
  14812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14813. }
  14814. m.SetUserID(v)
  14815. return nil
  14816. case creditusage.FieldNumber:
  14817. v, ok := value.(float64)
  14818. if !ok {
  14819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14820. }
  14821. m.SetNumber(v)
  14822. return nil
  14823. case creditusage.FieldPayNumber:
  14824. v, ok := value.(float64)
  14825. if !ok {
  14826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14827. }
  14828. m.SetPayNumber(v)
  14829. return nil
  14830. case creditusage.FieldBeforeNumber:
  14831. v, ok := value.(float64)
  14832. if !ok {
  14833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14834. }
  14835. m.SetBeforeNumber(v)
  14836. return nil
  14837. case creditusage.FieldAfterNumber:
  14838. v, ok := value.(float64)
  14839. if !ok {
  14840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14841. }
  14842. m.SetAfterNumber(v)
  14843. return nil
  14844. case creditusage.FieldPayMethod:
  14845. v, ok := value.(int)
  14846. if !ok {
  14847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14848. }
  14849. m.SetPayMethod(v)
  14850. return nil
  14851. case creditusage.FieldStatus:
  14852. v, ok := value.(int)
  14853. if !ok {
  14854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14855. }
  14856. m.SetStatus(v)
  14857. return nil
  14858. case creditusage.FieldNtype:
  14859. v, ok := value.(int)
  14860. if !ok {
  14861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14862. }
  14863. m.SetNtype(v)
  14864. return nil
  14865. case creditusage.FieldTable:
  14866. v, ok := value.(string)
  14867. if !ok {
  14868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14869. }
  14870. m.SetTable(v)
  14871. return nil
  14872. case creditusage.FieldOrganizationID:
  14873. v, ok := value.(uint64)
  14874. if !ok {
  14875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14876. }
  14877. m.SetOrganizationID(v)
  14878. return nil
  14879. case creditusage.FieldNid:
  14880. v, ok := value.(uint64)
  14881. if !ok {
  14882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14883. }
  14884. m.SetNid(v)
  14885. return nil
  14886. case creditusage.FieldReason:
  14887. v, ok := value.(string)
  14888. if !ok {
  14889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14890. }
  14891. m.SetReason(v)
  14892. return nil
  14893. case creditusage.FieldOperator:
  14894. v, ok := value.(string)
  14895. if !ok {
  14896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14897. }
  14898. m.SetOperator(v)
  14899. return nil
  14900. }
  14901. return fmt.Errorf("unknown CreditUsage field %s", name)
  14902. }
  14903. // AddedFields returns all numeric fields that were incremented/decremented during
  14904. // this mutation.
  14905. func (m *CreditUsageMutation) AddedFields() []string {
  14906. var fields []string
  14907. if m.addnumber != nil {
  14908. fields = append(fields, creditusage.FieldNumber)
  14909. }
  14910. if m.addpay_number != nil {
  14911. fields = append(fields, creditusage.FieldPayNumber)
  14912. }
  14913. if m.addbefore_number != nil {
  14914. fields = append(fields, creditusage.FieldBeforeNumber)
  14915. }
  14916. if m.addafter_number != nil {
  14917. fields = append(fields, creditusage.FieldAfterNumber)
  14918. }
  14919. if m.addpay_method != nil {
  14920. fields = append(fields, creditusage.FieldPayMethod)
  14921. }
  14922. if m.addstatus != nil {
  14923. fields = append(fields, creditusage.FieldStatus)
  14924. }
  14925. if m.addntype != nil {
  14926. fields = append(fields, creditusage.FieldNtype)
  14927. }
  14928. if m.addorganization_id != nil {
  14929. fields = append(fields, creditusage.FieldOrganizationID)
  14930. }
  14931. if m.addnid != nil {
  14932. fields = append(fields, creditusage.FieldNid)
  14933. }
  14934. return fields
  14935. }
  14936. // AddedField returns the numeric value that was incremented/decremented on a field
  14937. // with the given name. The second boolean return value indicates that this field
  14938. // was not set, or was not defined in the schema.
  14939. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  14940. switch name {
  14941. case creditusage.FieldNumber:
  14942. return m.AddedNumber()
  14943. case creditusage.FieldPayNumber:
  14944. return m.AddedPayNumber()
  14945. case creditusage.FieldBeforeNumber:
  14946. return m.AddedBeforeNumber()
  14947. case creditusage.FieldAfterNumber:
  14948. return m.AddedAfterNumber()
  14949. case creditusage.FieldPayMethod:
  14950. return m.AddedPayMethod()
  14951. case creditusage.FieldStatus:
  14952. return m.AddedStatus()
  14953. case creditusage.FieldNtype:
  14954. return m.AddedNtype()
  14955. case creditusage.FieldOrganizationID:
  14956. return m.AddedOrganizationID()
  14957. case creditusage.FieldNid:
  14958. return m.AddedNid()
  14959. }
  14960. return nil, false
  14961. }
  14962. // AddField adds the value to the field with the given name. It returns an error if
  14963. // the field is not defined in the schema, or if the type mismatched the field
  14964. // type.
  14965. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  14966. switch name {
  14967. case creditusage.FieldNumber:
  14968. v, ok := value.(float64)
  14969. if !ok {
  14970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14971. }
  14972. m.AddNumber(v)
  14973. return nil
  14974. case creditusage.FieldPayNumber:
  14975. v, ok := value.(float64)
  14976. if !ok {
  14977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14978. }
  14979. m.AddPayNumber(v)
  14980. return nil
  14981. case creditusage.FieldBeforeNumber:
  14982. v, ok := value.(float64)
  14983. if !ok {
  14984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14985. }
  14986. m.AddBeforeNumber(v)
  14987. return nil
  14988. case creditusage.FieldAfterNumber:
  14989. v, ok := value.(float64)
  14990. if !ok {
  14991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14992. }
  14993. m.AddAfterNumber(v)
  14994. return nil
  14995. case creditusage.FieldPayMethod:
  14996. v, ok := value.(int)
  14997. if !ok {
  14998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14999. }
  15000. m.AddPayMethod(v)
  15001. return nil
  15002. case creditusage.FieldStatus:
  15003. v, ok := value.(int)
  15004. if !ok {
  15005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15006. }
  15007. m.AddStatus(v)
  15008. return nil
  15009. case creditusage.FieldNtype:
  15010. v, ok := value.(int)
  15011. if !ok {
  15012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15013. }
  15014. m.AddNtype(v)
  15015. return nil
  15016. case creditusage.FieldOrganizationID:
  15017. v, ok := value.(int64)
  15018. if !ok {
  15019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15020. }
  15021. m.AddOrganizationID(v)
  15022. return nil
  15023. case creditusage.FieldNid:
  15024. v, ok := value.(int64)
  15025. if !ok {
  15026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15027. }
  15028. m.AddNid(v)
  15029. return nil
  15030. }
  15031. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  15032. }
  15033. // ClearedFields returns all nullable fields that were cleared during this
  15034. // mutation.
  15035. func (m *CreditUsageMutation) ClearedFields() []string {
  15036. var fields []string
  15037. if m.FieldCleared(creditusage.FieldDeletedAt) {
  15038. fields = append(fields, creditusage.FieldDeletedAt)
  15039. }
  15040. if m.FieldCleared(creditusage.FieldUserID) {
  15041. fields = append(fields, creditusage.FieldUserID)
  15042. }
  15043. if m.FieldCleared(creditusage.FieldPayNumber) {
  15044. fields = append(fields, creditusage.FieldPayNumber)
  15045. }
  15046. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  15047. fields = append(fields, creditusage.FieldBeforeNumber)
  15048. }
  15049. if m.FieldCleared(creditusage.FieldAfterNumber) {
  15050. fields = append(fields, creditusage.FieldAfterNumber)
  15051. }
  15052. if m.FieldCleared(creditusage.FieldPayMethod) {
  15053. fields = append(fields, creditusage.FieldPayMethod)
  15054. }
  15055. if m.FieldCleared(creditusage.FieldStatus) {
  15056. fields = append(fields, creditusage.FieldStatus)
  15057. }
  15058. if m.FieldCleared(creditusage.FieldOrganizationID) {
  15059. fields = append(fields, creditusage.FieldOrganizationID)
  15060. }
  15061. return fields
  15062. }
  15063. // FieldCleared returns a boolean indicating if a field with the given name was
  15064. // cleared in this mutation.
  15065. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  15066. _, ok := m.clearedFields[name]
  15067. return ok
  15068. }
  15069. // ClearField clears the value of the field with the given name. It returns an
  15070. // error if the field is not defined in the schema.
  15071. func (m *CreditUsageMutation) ClearField(name string) error {
  15072. switch name {
  15073. case creditusage.FieldDeletedAt:
  15074. m.ClearDeletedAt()
  15075. return nil
  15076. case creditusage.FieldUserID:
  15077. m.ClearUserID()
  15078. return nil
  15079. case creditusage.FieldPayNumber:
  15080. m.ClearPayNumber()
  15081. return nil
  15082. case creditusage.FieldBeforeNumber:
  15083. m.ClearBeforeNumber()
  15084. return nil
  15085. case creditusage.FieldAfterNumber:
  15086. m.ClearAfterNumber()
  15087. return nil
  15088. case creditusage.FieldPayMethod:
  15089. m.ClearPayMethod()
  15090. return nil
  15091. case creditusage.FieldStatus:
  15092. m.ClearStatus()
  15093. return nil
  15094. case creditusage.FieldOrganizationID:
  15095. m.ClearOrganizationID()
  15096. return nil
  15097. }
  15098. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  15099. }
  15100. // ResetField resets all changes in the mutation for the field with the given name.
  15101. // It returns an error if the field is not defined in the schema.
  15102. func (m *CreditUsageMutation) ResetField(name string) error {
  15103. switch name {
  15104. case creditusage.FieldCreatedAt:
  15105. m.ResetCreatedAt()
  15106. return nil
  15107. case creditusage.FieldUpdatedAt:
  15108. m.ResetUpdatedAt()
  15109. return nil
  15110. case creditusage.FieldDeletedAt:
  15111. m.ResetDeletedAt()
  15112. return nil
  15113. case creditusage.FieldUserID:
  15114. m.ResetUserID()
  15115. return nil
  15116. case creditusage.FieldNumber:
  15117. m.ResetNumber()
  15118. return nil
  15119. case creditusage.FieldPayNumber:
  15120. m.ResetPayNumber()
  15121. return nil
  15122. case creditusage.FieldBeforeNumber:
  15123. m.ResetBeforeNumber()
  15124. return nil
  15125. case creditusage.FieldAfterNumber:
  15126. m.ResetAfterNumber()
  15127. return nil
  15128. case creditusage.FieldPayMethod:
  15129. m.ResetPayMethod()
  15130. return nil
  15131. case creditusage.FieldStatus:
  15132. m.ResetStatus()
  15133. return nil
  15134. case creditusage.FieldNtype:
  15135. m.ResetNtype()
  15136. return nil
  15137. case creditusage.FieldTable:
  15138. m.ResetTable()
  15139. return nil
  15140. case creditusage.FieldOrganizationID:
  15141. m.ResetOrganizationID()
  15142. return nil
  15143. case creditusage.FieldNid:
  15144. m.ResetNid()
  15145. return nil
  15146. case creditusage.FieldReason:
  15147. m.ResetReason()
  15148. return nil
  15149. case creditusage.FieldOperator:
  15150. m.ResetOperator()
  15151. return nil
  15152. }
  15153. return fmt.Errorf("unknown CreditUsage field %s", name)
  15154. }
  15155. // AddedEdges returns all edge names that were set/added in this mutation.
  15156. func (m *CreditUsageMutation) AddedEdges() []string {
  15157. edges := make([]string, 0, 0)
  15158. return edges
  15159. }
  15160. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15161. // name in this mutation.
  15162. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  15163. return nil
  15164. }
  15165. // RemovedEdges returns all edge names that were removed in this mutation.
  15166. func (m *CreditUsageMutation) RemovedEdges() []string {
  15167. edges := make([]string, 0, 0)
  15168. return edges
  15169. }
  15170. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15171. // the given name in this mutation.
  15172. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  15173. return nil
  15174. }
  15175. // ClearedEdges returns all edge names that were cleared in this mutation.
  15176. func (m *CreditUsageMutation) ClearedEdges() []string {
  15177. edges := make([]string, 0, 0)
  15178. return edges
  15179. }
  15180. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15181. // was cleared in this mutation.
  15182. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  15183. return false
  15184. }
  15185. // ClearEdge clears the value of the edge with the given name. It returns an error
  15186. // if that edge is not defined in the schema.
  15187. func (m *CreditUsageMutation) ClearEdge(name string) error {
  15188. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  15189. }
  15190. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15191. // It returns an error if the edge is not defined in the schema.
  15192. func (m *CreditUsageMutation) ResetEdge(name string) error {
  15193. return fmt.Errorf("unknown CreditUsage edge %s", name)
  15194. }
  15195. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  15196. type EmployeeMutation struct {
  15197. config
  15198. op Op
  15199. typ string
  15200. id *uint64
  15201. created_at *time.Time
  15202. updated_at *time.Time
  15203. deleted_at *time.Time
  15204. title *string
  15205. avatar *string
  15206. tags *string
  15207. hire_count *int
  15208. addhire_count *int
  15209. service_count *int
  15210. addservice_count *int
  15211. achievement_count *int
  15212. addachievement_count *int
  15213. intro *string
  15214. estimate *string
  15215. skill *string
  15216. ability_type *string
  15217. scene *string
  15218. switch_in *string
  15219. video_url *string
  15220. organization_id *uint64
  15221. addorganization_id *int64
  15222. category_id *uint64
  15223. addcategory_id *int64
  15224. api_base *string
  15225. api_key *string
  15226. ai_info *string
  15227. is_vip *int
  15228. addis_vip *int
  15229. chat_url *string
  15230. clearedFields map[string]struct{}
  15231. em_work_experiences map[uint64]struct{}
  15232. removedem_work_experiences map[uint64]struct{}
  15233. clearedem_work_experiences bool
  15234. em_tutorial map[uint64]struct{}
  15235. removedem_tutorial map[uint64]struct{}
  15236. clearedem_tutorial bool
  15237. done bool
  15238. oldValue func(context.Context) (*Employee, error)
  15239. predicates []predicate.Employee
  15240. }
  15241. var _ ent.Mutation = (*EmployeeMutation)(nil)
  15242. // employeeOption allows management of the mutation configuration using functional options.
  15243. type employeeOption func(*EmployeeMutation)
  15244. // newEmployeeMutation creates new mutation for the Employee entity.
  15245. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  15246. m := &EmployeeMutation{
  15247. config: c,
  15248. op: op,
  15249. typ: TypeEmployee,
  15250. clearedFields: make(map[string]struct{}),
  15251. }
  15252. for _, opt := range opts {
  15253. opt(m)
  15254. }
  15255. return m
  15256. }
  15257. // withEmployeeID sets the ID field of the mutation.
  15258. func withEmployeeID(id uint64) employeeOption {
  15259. return func(m *EmployeeMutation) {
  15260. var (
  15261. err error
  15262. once sync.Once
  15263. value *Employee
  15264. )
  15265. m.oldValue = func(ctx context.Context) (*Employee, error) {
  15266. once.Do(func() {
  15267. if m.done {
  15268. err = errors.New("querying old values post mutation is not allowed")
  15269. } else {
  15270. value, err = m.Client().Employee.Get(ctx, id)
  15271. }
  15272. })
  15273. return value, err
  15274. }
  15275. m.id = &id
  15276. }
  15277. }
  15278. // withEmployee sets the old Employee of the mutation.
  15279. func withEmployee(node *Employee) employeeOption {
  15280. return func(m *EmployeeMutation) {
  15281. m.oldValue = func(context.Context) (*Employee, error) {
  15282. return node, nil
  15283. }
  15284. m.id = &node.ID
  15285. }
  15286. }
  15287. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15288. // executed in a transaction (ent.Tx), a transactional client is returned.
  15289. func (m EmployeeMutation) Client() *Client {
  15290. client := &Client{config: m.config}
  15291. client.init()
  15292. return client
  15293. }
  15294. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15295. // it returns an error otherwise.
  15296. func (m EmployeeMutation) Tx() (*Tx, error) {
  15297. if _, ok := m.driver.(*txDriver); !ok {
  15298. return nil, errors.New("ent: mutation is not running in a transaction")
  15299. }
  15300. tx := &Tx{config: m.config}
  15301. tx.init()
  15302. return tx, nil
  15303. }
  15304. // SetID sets the value of the id field. Note that this
  15305. // operation is only accepted on creation of Employee entities.
  15306. func (m *EmployeeMutation) SetID(id uint64) {
  15307. m.id = &id
  15308. }
  15309. // ID returns the ID value in the mutation. Note that the ID is only available
  15310. // if it was provided to the builder or after it was returned from the database.
  15311. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  15312. if m.id == nil {
  15313. return
  15314. }
  15315. return *m.id, true
  15316. }
  15317. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15318. // That means, if the mutation is applied within a transaction with an isolation level such
  15319. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15320. // or updated by the mutation.
  15321. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  15322. switch {
  15323. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15324. id, exists := m.ID()
  15325. if exists {
  15326. return []uint64{id}, nil
  15327. }
  15328. fallthrough
  15329. case m.op.Is(OpUpdate | OpDelete):
  15330. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  15331. default:
  15332. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15333. }
  15334. }
  15335. // SetCreatedAt sets the "created_at" field.
  15336. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  15337. m.created_at = &t
  15338. }
  15339. // CreatedAt returns the value of the "created_at" field in the mutation.
  15340. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  15341. v := m.created_at
  15342. if v == nil {
  15343. return
  15344. }
  15345. return *v, true
  15346. }
  15347. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  15348. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15350. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15351. if !m.op.Is(OpUpdateOne) {
  15352. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15353. }
  15354. if m.id == nil || m.oldValue == nil {
  15355. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15356. }
  15357. oldValue, err := m.oldValue(ctx)
  15358. if err != nil {
  15359. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15360. }
  15361. return oldValue.CreatedAt, nil
  15362. }
  15363. // ResetCreatedAt resets all changes to the "created_at" field.
  15364. func (m *EmployeeMutation) ResetCreatedAt() {
  15365. m.created_at = nil
  15366. }
  15367. // SetUpdatedAt sets the "updated_at" field.
  15368. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  15369. m.updated_at = &t
  15370. }
  15371. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15372. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  15373. v := m.updated_at
  15374. if v == nil {
  15375. return
  15376. }
  15377. return *v, true
  15378. }
  15379. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  15380. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15382. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15383. if !m.op.Is(OpUpdateOne) {
  15384. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15385. }
  15386. if m.id == nil || m.oldValue == nil {
  15387. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15388. }
  15389. oldValue, err := m.oldValue(ctx)
  15390. if err != nil {
  15391. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15392. }
  15393. return oldValue.UpdatedAt, nil
  15394. }
  15395. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15396. func (m *EmployeeMutation) ResetUpdatedAt() {
  15397. m.updated_at = nil
  15398. }
  15399. // SetDeletedAt sets the "deleted_at" field.
  15400. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  15401. m.deleted_at = &t
  15402. }
  15403. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15404. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  15405. v := m.deleted_at
  15406. if v == nil {
  15407. return
  15408. }
  15409. return *v, true
  15410. }
  15411. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  15412. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15414. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15415. if !m.op.Is(OpUpdateOne) {
  15416. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15417. }
  15418. if m.id == nil || m.oldValue == nil {
  15419. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15420. }
  15421. oldValue, err := m.oldValue(ctx)
  15422. if err != nil {
  15423. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15424. }
  15425. return oldValue.DeletedAt, nil
  15426. }
  15427. // ClearDeletedAt clears the value of the "deleted_at" field.
  15428. func (m *EmployeeMutation) ClearDeletedAt() {
  15429. m.deleted_at = nil
  15430. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  15431. }
  15432. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15433. func (m *EmployeeMutation) DeletedAtCleared() bool {
  15434. _, ok := m.clearedFields[employee.FieldDeletedAt]
  15435. return ok
  15436. }
  15437. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15438. func (m *EmployeeMutation) ResetDeletedAt() {
  15439. m.deleted_at = nil
  15440. delete(m.clearedFields, employee.FieldDeletedAt)
  15441. }
  15442. // SetTitle sets the "title" field.
  15443. func (m *EmployeeMutation) SetTitle(s string) {
  15444. m.title = &s
  15445. }
  15446. // Title returns the value of the "title" field in the mutation.
  15447. func (m *EmployeeMutation) Title() (r string, exists bool) {
  15448. v := m.title
  15449. if v == nil {
  15450. return
  15451. }
  15452. return *v, true
  15453. }
  15454. // OldTitle returns the old "title" field's value of the Employee entity.
  15455. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15457. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  15458. if !m.op.Is(OpUpdateOne) {
  15459. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15460. }
  15461. if m.id == nil || m.oldValue == nil {
  15462. return v, errors.New("OldTitle requires an ID field in the mutation")
  15463. }
  15464. oldValue, err := m.oldValue(ctx)
  15465. if err != nil {
  15466. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15467. }
  15468. return oldValue.Title, nil
  15469. }
  15470. // ResetTitle resets all changes to the "title" field.
  15471. func (m *EmployeeMutation) ResetTitle() {
  15472. m.title = nil
  15473. }
  15474. // SetAvatar sets the "avatar" field.
  15475. func (m *EmployeeMutation) SetAvatar(s string) {
  15476. m.avatar = &s
  15477. }
  15478. // Avatar returns the value of the "avatar" field in the mutation.
  15479. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  15480. v := m.avatar
  15481. if v == nil {
  15482. return
  15483. }
  15484. return *v, true
  15485. }
  15486. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  15487. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15489. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  15490. if !m.op.Is(OpUpdateOne) {
  15491. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  15492. }
  15493. if m.id == nil || m.oldValue == nil {
  15494. return v, errors.New("OldAvatar requires an ID field in the mutation")
  15495. }
  15496. oldValue, err := m.oldValue(ctx)
  15497. if err != nil {
  15498. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  15499. }
  15500. return oldValue.Avatar, nil
  15501. }
  15502. // ResetAvatar resets all changes to the "avatar" field.
  15503. func (m *EmployeeMutation) ResetAvatar() {
  15504. m.avatar = nil
  15505. }
  15506. // SetTags sets the "tags" field.
  15507. func (m *EmployeeMutation) SetTags(s string) {
  15508. m.tags = &s
  15509. }
  15510. // Tags returns the value of the "tags" field in the mutation.
  15511. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  15512. v := m.tags
  15513. if v == nil {
  15514. return
  15515. }
  15516. return *v, true
  15517. }
  15518. // OldTags returns the old "tags" field's value of the Employee entity.
  15519. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15521. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  15522. if !m.op.Is(OpUpdateOne) {
  15523. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  15524. }
  15525. if m.id == nil || m.oldValue == nil {
  15526. return v, errors.New("OldTags requires an ID field in the mutation")
  15527. }
  15528. oldValue, err := m.oldValue(ctx)
  15529. if err != nil {
  15530. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  15531. }
  15532. return oldValue.Tags, nil
  15533. }
  15534. // ResetTags resets all changes to the "tags" field.
  15535. func (m *EmployeeMutation) ResetTags() {
  15536. m.tags = nil
  15537. }
  15538. // SetHireCount sets the "hire_count" field.
  15539. func (m *EmployeeMutation) SetHireCount(i int) {
  15540. m.hire_count = &i
  15541. m.addhire_count = nil
  15542. }
  15543. // HireCount returns the value of the "hire_count" field in the mutation.
  15544. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  15545. v := m.hire_count
  15546. if v == nil {
  15547. return
  15548. }
  15549. return *v, true
  15550. }
  15551. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  15552. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15554. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  15555. if !m.op.Is(OpUpdateOne) {
  15556. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  15557. }
  15558. if m.id == nil || m.oldValue == nil {
  15559. return v, errors.New("OldHireCount requires an ID field in the mutation")
  15560. }
  15561. oldValue, err := m.oldValue(ctx)
  15562. if err != nil {
  15563. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  15564. }
  15565. return oldValue.HireCount, nil
  15566. }
  15567. // AddHireCount adds i to the "hire_count" field.
  15568. func (m *EmployeeMutation) AddHireCount(i int) {
  15569. if m.addhire_count != nil {
  15570. *m.addhire_count += i
  15571. } else {
  15572. m.addhire_count = &i
  15573. }
  15574. }
  15575. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  15576. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  15577. v := m.addhire_count
  15578. if v == nil {
  15579. return
  15580. }
  15581. return *v, true
  15582. }
  15583. // ResetHireCount resets all changes to the "hire_count" field.
  15584. func (m *EmployeeMutation) ResetHireCount() {
  15585. m.hire_count = nil
  15586. m.addhire_count = nil
  15587. }
  15588. // SetServiceCount sets the "service_count" field.
  15589. func (m *EmployeeMutation) SetServiceCount(i int) {
  15590. m.service_count = &i
  15591. m.addservice_count = nil
  15592. }
  15593. // ServiceCount returns the value of the "service_count" field in the mutation.
  15594. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  15595. v := m.service_count
  15596. if v == nil {
  15597. return
  15598. }
  15599. return *v, true
  15600. }
  15601. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  15602. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15604. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  15605. if !m.op.Is(OpUpdateOne) {
  15606. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  15607. }
  15608. if m.id == nil || m.oldValue == nil {
  15609. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  15610. }
  15611. oldValue, err := m.oldValue(ctx)
  15612. if err != nil {
  15613. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  15614. }
  15615. return oldValue.ServiceCount, nil
  15616. }
  15617. // AddServiceCount adds i to the "service_count" field.
  15618. func (m *EmployeeMutation) AddServiceCount(i int) {
  15619. if m.addservice_count != nil {
  15620. *m.addservice_count += i
  15621. } else {
  15622. m.addservice_count = &i
  15623. }
  15624. }
  15625. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  15626. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  15627. v := m.addservice_count
  15628. if v == nil {
  15629. return
  15630. }
  15631. return *v, true
  15632. }
  15633. // ResetServiceCount resets all changes to the "service_count" field.
  15634. func (m *EmployeeMutation) ResetServiceCount() {
  15635. m.service_count = nil
  15636. m.addservice_count = nil
  15637. }
  15638. // SetAchievementCount sets the "achievement_count" field.
  15639. func (m *EmployeeMutation) SetAchievementCount(i int) {
  15640. m.achievement_count = &i
  15641. m.addachievement_count = nil
  15642. }
  15643. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  15644. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  15645. v := m.achievement_count
  15646. if v == nil {
  15647. return
  15648. }
  15649. return *v, true
  15650. }
  15651. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  15652. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15654. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  15655. if !m.op.Is(OpUpdateOne) {
  15656. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  15657. }
  15658. if m.id == nil || m.oldValue == nil {
  15659. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  15660. }
  15661. oldValue, err := m.oldValue(ctx)
  15662. if err != nil {
  15663. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  15664. }
  15665. return oldValue.AchievementCount, nil
  15666. }
  15667. // AddAchievementCount adds i to the "achievement_count" field.
  15668. func (m *EmployeeMutation) AddAchievementCount(i int) {
  15669. if m.addachievement_count != nil {
  15670. *m.addachievement_count += i
  15671. } else {
  15672. m.addachievement_count = &i
  15673. }
  15674. }
  15675. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  15676. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  15677. v := m.addachievement_count
  15678. if v == nil {
  15679. return
  15680. }
  15681. return *v, true
  15682. }
  15683. // ResetAchievementCount resets all changes to the "achievement_count" field.
  15684. func (m *EmployeeMutation) ResetAchievementCount() {
  15685. m.achievement_count = nil
  15686. m.addachievement_count = nil
  15687. }
  15688. // SetIntro sets the "intro" field.
  15689. func (m *EmployeeMutation) SetIntro(s string) {
  15690. m.intro = &s
  15691. }
  15692. // Intro returns the value of the "intro" field in the mutation.
  15693. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  15694. v := m.intro
  15695. if v == nil {
  15696. return
  15697. }
  15698. return *v, true
  15699. }
  15700. // OldIntro returns the old "intro" field's value of the Employee entity.
  15701. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15703. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  15704. if !m.op.Is(OpUpdateOne) {
  15705. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  15706. }
  15707. if m.id == nil || m.oldValue == nil {
  15708. return v, errors.New("OldIntro requires an ID field in the mutation")
  15709. }
  15710. oldValue, err := m.oldValue(ctx)
  15711. if err != nil {
  15712. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  15713. }
  15714. return oldValue.Intro, nil
  15715. }
  15716. // ResetIntro resets all changes to the "intro" field.
  15717. func (m *EmployeeMutation) ResetIntro() {
  15718. m.intro = nil
  15719. }
  15720. // SetEstimate sets the "estimate" field.
  15721. func (m *EmployeeMutation) SetEstimate(s string) {
  15722. m.estimate = &s
  15723. }
  15724. // Estimate returns the value of the "estimate" field in the mutation.
  15725. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  15726. v := m.estimate
  15727. if v == nil {
  15728. return
  15729. }
  15730. return *v, true
  15731. }
  15732. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  15733. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15735. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  15736. if !m.op.Is(OpUpdateOne) {
  15737. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  15738. }
  15739. if m.id == nil || m.oldValue == nil {
  15740. return v, errors.New("OldEstimate requires an ID field in the mutation")
  15741. }
  15742. oldValue, err := m.oldValue(ctx)
  15743. if err != nil {
  15744. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  15745. }
  15746. return oldValue.Estimate, nil
  15747. }
  15748. // ResetEstimate resets all changes to the "estimate" field.
  15749. func (m *EmployeeMutation) ResetEstimate() {
  15750. m.estimate = nil
  15751. }
  15752. // SetSkill sets the "skill" field.
  15753. func (m *EmployeeMutation) SetSkill(s string) {
  15754. m.skill = &s
  15755. }
  15756. // Skill returns the value of the "skill" field in the mutation.
  15757. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  15758. v := m.skill
  15759. if v == nil {
  15760. return
  15761. }
  15762. return *v, true
  15763. }
  15764. // OldSkill returns the old "skill" field's value of the Employee entity.
  15765. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15767. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  15768. if !m.op.Is(OpUpdateOne) {
  15769. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  15770. }
  15771. if m.id == nil || m.oldValue == nil {
  15772. return v, errors.New("OldSkill requires an ID field in the mutation")
  15773. }
  15774. oldValue, err := m.oldValue(ctx)
  15775. if err != nil {
  15776. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  15777. }
  15778. return oldValue.Skill, nil
  15779. }
  15780. // ResetSkill resets all changes to the "skill" field.
  15781. func (m *EmployeeMutation) ResetSkill() {
  15782. m.skill = nil
  15783. }
  15784. // SetAbilityType sets the "ability_type" field.
  15785. func (m *EmployeeMutation) SetAbilityType(s string) {
  15786. m.ability_type = &s
  15787. }
  15788. // AbilityType returns the value of the "ability_type" field in the mutation.
  15789. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  15790. v := m.ability_type
  15791. if v == nil {
  15792. return
  15793. }
  15794. return *v, true
  15795. }
  15796. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  15797. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15799. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  15800. if !m.op.Is(OpUpdateOne) {
  15801. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  15802. }
  15803. if m.id == nil || m.oldValue == nil {
  15804. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  15805. }
  15806. oldValue, err := m.oldValue(ctx)
  15807. if err != nil {
  15808. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  15809. }
  15810. return oldValue.AbilityType, nil
  15811. }
  15812. // ResetAbilityType resets all changes to the "ability_type" field.
  15813. func (m *EmployeeMutation) ResetAbilityType() {
  15814. m.ability_type = nil
  15815. }
  15816. // SetScene sets the "scene" field.
  15817. func (m *EmployeeMutation) SetScene(s string) {
  15818. m.scene = &s
  15819. }
  15820. // Scene returns the value of the "scene" field in the mutation.
  15821. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  15822. v := m.scene
  15823. if v == nil {
  15824. return
  15825. }
  15826. return *v, true
  15827. }
  15828. // OldScene returns the old "scene" field's value of the Employee entity.
  15829. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15831. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  15832. if !m.op.Is(OpUpdateOne) {
  15833. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  15834. }
  15835. if m.id == nil || m.oldValue == nil {
  15836. return v, errors.New("OldScene requires an ID field in the mutation")
  15837. }
  15838. oldValue, err := m.oldValue(ctx)
  15839. if err != nil {
  15840. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  15841. }
  15842. return oldValue.Scene, nil
  15843. }
  15844. // ResetScene resets all changes to the "scene" field.
  15845. func (m *EmployeeMutation) ResetScene() {
  15846. m.scene = nil
  15847. }
  15848. // SetSwitchIn sets the "switch_in" field.
  15849. func (m *EmployeeMutation) SetSwitchIn(s string) {
  15850. m.switch_in = &s
  15851. }
  15852. // SwitchIn returns the value of the "switch_in" field in the mutation.
  15853. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  15854. v := m.switch_in
  15855. if v == nil {
  15856. return
  15857. }
  15858. return *v, true
  15859. }
  15860. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  15861. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15863. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  15864. if !m.op.Is(OpUpdateOne) {
  15865. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  15866. }
  15867. if m.id == nil || m.oldValue == nil {
  15868. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  15869. }
  15870. oldValue, err := m.oldValue(ctx)
  15871. if err != nil {
  15872. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  15873. }
  15874. return oldValue.SwitchIn, nil
  15875. }
  15876. // ResetSwitchIn resets all changes to the "switch_in" field.
  15877. func (m *EmployeeMutation) ResetSwitchIn() {
  15878. m.switch_in = nil
  15879. }
  15880. // SetVideoURL sets the "video_url" field.
  15881. func (m *EmployeeMutation) SetVideoURL(s string) {
  15882. m.video_url = &s
  15883. }
  15884. // VideoURL returns the value of the "video_url" field in the mutation.
  15885. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  15886. v := m.video_url
  15887. if v == nil {
  15888. return
  15889. }
  15890. return *v, true
  15891. }
  15892. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  15893. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15895. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  15896. if !m.op.Is(OpUpdateOne) {
  15897. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  15898. }
  15899. if m.id == nil || m.oldValue == nil {
  15900. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  15901. }
  15902. oldValue, err := m.oldValue(ctx)
  15903. if err != nil {
  15904. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  15905. }
  15906. return oldValue.VideoURL, nil
  15907. }
  15908. // ResetVideoURL resets all changes to the "video_url" field.
  15909. func (m *EmployeeMutation) ResetVideoURL() {
  15910. m.video_url = nil
  15911. }
  15912. // SetOrganizationID sets the "organization_id" field.
  15913. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  15914. m.organization_id = &u
  15915. m.addorganization_id = nil
  15916. }
  15917. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15918. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  15919. v := m.organization_id
  15920. if v == nil {
  15921. return
  15922. }
  15923. return *v, true
  15924. }
  15925. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  15926. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15928. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15929. if !m.op.Is(OpUpdateOne) {
  15930. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15931. }
  15932. if m.id == nil || m.oldValue == nil {
  15933. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15934. }
  15935. oldValue, err := m.oldValue(ctx)
  15936. if err != nil {
  15937. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15938. }
  15939. return oldValue.OrganizationID, nil
  15940. }
  15941. // AddOrganizationID adds u to the "organization_id" field.
  15942. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  15943. if m.addorganization_id != nil {
  15944. *m.addorganization_id += u
  15945. } else {
  15946. m.addorganization_id = &u
  15947. }
  15948. }
  15949. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15950. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  15951. v := m.addorganization_id
  15952. if v == nil {
  15953. return
  15954. }
  15955. return *v, true
  15956. }
  15957. // ResetOrganizationID resets all changes to the "organization_id" field.
  15958. func (m *EmployeeMutation) ResetOrganizationID() {
  15959. m.organization_id = nil
  15960. m.addorganization_id = nil
  15961. }
  15962. // SetCategoryID sets the "category_id" field.
  15963. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  15964. m.category_id = &u
  15965. m.addcategory_id = nil
  15966. }
  15967. // CategoryID returns the value of the "category_id" field in the mutation.
  15968. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  15969. v := m.category_id
  15970. if v == nil {
  15971. return
  15972. }
  15973. return *v, true
  15974. }
  15975. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  15976. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15978. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  15979. if !m.op.Is(OpUpdateOne) {
  15980. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  15981. }
  15982. if m.id == nil || m.oldValue == nil {
  15983. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  15984. }
  15985. oldValue, err := m.oldValue(ctx)
  15986. if err != nil {
  15987. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  15988. }
  15989. return oldValue.CategoryID, nil
  15990. }
  15991. // AddCategoryID adds u to the "category_id" field.
  15992. func (m *EmployeeMutation) AddCategoryID(u int64) {
  15993. if m.addcategory_id != nil {
  15994. *m.addcategory_id += u
  15995. } else {
  15996. m.addcategory_id = &u
  15997. }
  15998. }
  15999. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  16000. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  16001. v := m.addcategory_id
  16002. if v == nil {
  16003. return
  16004. }
  16005. return *v, true
  16006. }
  16007. // ResetCategoryID resets all changes to the "category_id" field.
  16008. func (m *EmployeeMutation) ResetCategoryID() {
  16009. m.category_id = nil
  16010. m.addcategory_id = nil
  16011. }
  16012. // SetAPIBase sets the "api_base" field.
  16013. func (m *EmployeeMutation) SetAPIBase(s string) {
  16014. m.api_base = &s
  16015. }
  16016. // APIBase returns the value of the "api_base" field in the mutation.
  16017. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  16018. v := m.api_base
  16019. if v == nil {
  16020. return
  16021. }
  16022. return *v, true
  16023. }
  16024. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  16025. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16027. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  16028. if !m.op.Is(OpUpdateOne) {
  16029. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  16030. }
  16031. if m.id == nil || m.oldValue == nil {
  16032. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  16033. }
  16034. oldValue, err := m.oldValue(ctx)
  16035. if err != nil {
  16036. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  16037. }
  16038. return oldValue.APIBase, nil
  16039. }
  16040. // ResetAPIBase resets all changes to the "api_base" field.
  16041. func (m *EmployeeMutation) ResetAPIBase() {
  16042. m.api_base = nil
  16043. }
  16044. // SetAPIKey sets the "api_key" field.
  16045. func (m *EmployeeMutation) SetAPIKey(s string) {
  16046. m.api_key = &s
  16047. }
  16048. // APIKey returns the value of the "api_key" field in the mutation.
  16049. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  16050. v := m.api_key
  16051. if v == nil {
  16052. return
  16053. }
  16054. return *v, true
  16055. }
  16056. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  16057. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16059. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  16060. if !m.op.Is(OpUpdateOne) {
  16061. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  16062. }
  16063. if m.id == nil || m.oldValue == nil {
  16064. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  16065. }
  16066. oldValue, err := m.oldValue(ctx)
  16067. if err != nil {
  16068. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  16069. }
  16070. return oldValue.APIKey, nil
  16071. }
  16072. // ResetAPIKey resets all changes to the "api_key" field.
  16073. func (m *EmployeeMutation) ResetAPIKey() {
  16074. m.api_key = nil
  16075. }
  16076. // SetAiInfo sets the "ai_info" field.
  16077. func (m *EmployeeMutation) SetAiInfo(s string) {
  16078. m.ai_info = &s
  16079. }
  16080. // AiInfo returns the value of the "ai_info" field in the mutation.
  16081. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  16082. v := m.ai_info
  16083. if v == nil {
  16084. return
  16085. }
  16086. return *v, true
  16087. }
  16088. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  16089. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16091. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  16092. if !m.op.Is(OpUpdateOne) {
  16093. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  16094. }
  16095. if m.id == nil || m.oldValue == nil {
  16096. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  16097. }
  16098. oldValue, err := m.oldValue(ctx)
  16099. if err != nil {
  16100. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  16101. }
  16102. return oldValue.AiInfo, nil
  16103. }
  16104. // ClearAiInfo clears the value of the "ai_info" field.
  16105. func (m *EmployeeMutation) ClearAiInfo() {
  16106. m.ai_info = nil
  16107. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  16108. }
  16109. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  16110. func (m *EmployeeMutation) AiInfoCleared() bool {
  16111. _, ok := m.clearedFields[employee.FieldAiInfo]
  16112. return ok
  16113. }
  16114. // ResetAiInfo resets all changes to the "ai_info" field.
  16115. func (m *EmployeeMutation) ResetAiInfo() {
  16116. m.ai_info = nil
  16117. delete(m.clearedFields, employee.FieldAiInfo)
  16118. }
  16119. // SetIsVip sets the "is_vip" field.
  16120. func (m *EmployeeMutation) SetIsVip(i int) {
  16121. m.is_vip = &i
  16122. m.addis_vip = nil
  16123. }
  16124. // IsVip returns the value of the "is_vip" field in the mutation.
  16125. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  16126. v := m.is_vip
  16127. if v == nil {
  16128. return
  16129. }
  16130. return *v, true
  16131. }
  16132. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  16133. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16135. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  16136. if !m.op.Is(OpUpdateOne) {
  16137. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  16138. }
  16139. if m.id == nil || m.oldValue == nil {
  16140. return v, errors.New("OldIsVip requires an ID field in the mutation")
  16141. }
  16142. oldValue, err := m.oldValue(ctx)
  16143. if err != nil {
  16144. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  16145. }
  16146. return oldValue.IsVip, nil
  16147. }
  16148. // AddIsVip adds i to the "is_vip" field.
  16149. func (m *EmployeeMutation) AddIsVip(i int) {
  16150. if m.addis_vip != nil {
  16151. *m.addis_vip += i
  16152. } else {
  16153. m.addis_vip = &i
  16154. }
  16155. }
  16156. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  16157. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  16158. v := m.addis_vip
  16159. if v == nil {
  16160. return
  16161. }
  16162. return *v, true
  16163. }
  16164. // ResetIsVip resets all changes to the "is_vip" field.
  16165. func (m *EmployeeMutation) ResetIsVip() {
  16166. m.is_vip = nil
  16167. m.addis_vip = nil
  16168. }
  16169. // SetChatURL sets the "chat_url" field.
  16170. func (m *EmployeeMutation) SetChatURL(s string) {
  16171. m.chat_url = &s
  16172. }
  16173. // ChatURL returns the value of the "chat_url" field in the mutation.
  16174. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  16175. v := m.chat_url
  16176. if v == nil {
  16177. return
  16178. }
  16179. return *v, true
  16180. }
  16181. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  16182. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16184. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  16185. if !m.op.Is(OpUpdateOne) {
  16186. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  16187. }
  16188. if m.id == nil || m.oldValue == nil {
  16189. return v, errors.New("OldChatURL requires an ID field in the mutation")
  16190. }
  16191. oldValue, err := m.oldValue(ctx)
  16192. if err != nil {
  16193. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  16194. }
  16195. return oldValue.ChatURL, nil
  16196. }
  16197. // ResetChatURL resets all changes to the "chat_url" field.
  16198. func (m *EmployeeMutation) ResetChatURL() {
  16199. m.chat_url = nil
  16200. }
  16201. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  16202. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  16203. if m.em_work_experiences == nil {
  16204. m.em_work_experiences = make(map[uint64]struct{})
  16205. }
  16206. for i := range ids {
  16207. m.em_work_experiences[ids[i]] = struct{}{}
  16208. }
  16209. }
  16210. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  16211. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  16212. m.clearedem_work_experiences = true
  16213. }
  16214. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  16215. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  16216. return m.clearedem_work_experiences
  16217. }
  16218. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  16219. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  16220. if m.removedem_work_experiences == nil {
  16221. m.removedem_work_experiences = make(map[uint64]struct{})
  16222. }
  16223. for i := range ids {
  16224. delete(m.em_work_experiences, ids[i])
  16225. m.removedem_work_experiences[ids[i]] = struct{}{}
  16226. }
  16227. }
  16228. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  16229. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  16230. for id := range m.removedem_work_experiences {
  16231. ids = append(ids, id)
  16232. }
  16233. return
  16234. }
  16235. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  16236. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  16237. for id := range m.em_work_experiences {
  16238. ids = append(ids, id)
  16239. }
  16240. return
  16241. }
  16242. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  16243. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  16244. m.em_work_experiences = nil
  16245. m.clearedem_work_experiences = false
  16246. m.removedem_work_experiences = nil
  16247. }
  16248. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  16249. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  16250. if m.em_tutorial == nil {
  16251. m.em_tutorial = make(map[uint64]struct{})
  16252. }
  16253. for i := range ids {
  16254. m.em_tutorial[ids[i]] = struct{}{}
  16255. }
  16256. }
  16257. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  16258. func (m *EmployeeMutation) ClearEmTutorial() {
  16259. m.clearedem_tutorial = true
  16260. }
  16261. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  16262. func (m *EmployeeMutation) EmTutorialCleared() bool {
  16263. return m.clearedem_tutorial
  16264. }
  16265. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  16266. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  16267. if m.removedem_tutorial == nil {
  16268. m.removedem_tutorial = make(map[uint64]struct{})
  16269. }
  16270. for i := range ids {
  16271. delete(m.em_tutorial, ids[i])
  16272. m.removedem_tutorial[ids[i]] = struct{}{}
  16273. }
  16274. }
  16275. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  16276. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  16277. for id := range m.removedem_tutorial {
  16278. ids = append(ids, id)
  16279. }
  16280. return
  16281. }
  16282. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  16283. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  16284. for id := range m.em_tutorial {
  16285. ids = append(ids, id)
  16286. }
  16287. return
  16288. }
  16289. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  16290. func (m *EmployeeMutation) ResetEmTutorial() {
  16291. m.em_tutorial = nil
  16292. m.clearedem_tutorial = false
  16293. m.removedem_tutorial = nil
  16294. }
  16295. // Where appends a list predicates to the EmployeeMutation builder.
  16296. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  16297. m.predicates = append(m.predicates, ps...)
  16298. }
  16299. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  16300. // users can use type-assertion to append predicates that do not depend on any generated package.
  16301. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  16302. p := make([]predicate.Employee, len(ps))
  16303. for i := range ps {
  16304. p[i] = ps[i]
  16305. }
  16306. m.Where(p...)
  16307. }
  16308. // Op returns the operation name.
  16309. func (m *EmployeeMutation) Op() Op {
  16310. return m.op
  16311. }
  16312. // SetOp allows setting the mutation operation.
  16313. func (m *EmployeeMutation) SetOp(op Op) {
  16314. m.op = op
  16315. }
  16316. // Type returns the node type of this mutation (Employee).
  16317. func (m *EmployeeMutation) Type() string {
  16318. return m.typ
  16319. }
  16320. // Fields returns all fields that were changed during this mutation. Note that in
  16321. // order to get all numeric fields that were incremented/decremented, call
  16322. // AddedFields().
  16323. func (m *EmployeeMutation) Fields() []string {
  16324. fields := make([]string, 0, 23)
  16325. if m.created_at != nil {
  16326. fields = append(fields, employee.FieldCreatedAt)
  16327. }
  16328. if m.updated_at != nil {
  16329. fields = append(fields, employee.FieldUpdatedAt)
  16330. }
  16331. if m.deleted_at != nil {
  16332. fields = append(fields, employee.FieldDeletedAt)
  16333. }
  16334. if m.title != nil {
  16335. fields = append(fields, employee.FieldTitle)
  16336. }
  16337. if m.avatar != nil {
  16338. fields = append(fields, employee.FieldAvatar)
  16339. }
  16340. if m.tags != nil {
  16341. fields = append(fields, employee.FieldTags)
  16342. }
  16343. if m.hire_count != nil {
  16344. fields = append(fields, employee.FieldHireCount)
  16345. }
  16346. if m.service_count != nil {
  16347. fields = append(fields, employee.FieldServiceCount)
  16348. }
  16349. if m.achievement_count != nil {
  16350. fields = append(fields, employee.FieldAchievementCount)
  16351. }
  16352. if m.intro != nil {
  16353. fields = append(fields, employee.FieldIntro)
  16354. }
  16355. if m.estimate != nil {
  16356. fields = append(fields, employee.FieldEstimate)
  16357. }
  16358. if m.skill != nil {
  16359. fields = append(fields, employee.FieldSkill)
  16360. }
  16361. if m.ability_type != nil {
  16362. fields = append(fields, employee.FieldAbilityType)
  16363. }
  16364. if m.scene != nil {
  16365. fields = append(fields, employee.FieldScene)
  16366. }
  16367. if m.switch_in != nil {
  16368. fields = append(fields, employee.FieldSwitchIn)
  16369. }
  16370. if m.video_url != nil {
  16371. fields = append(fields, employee.FieldVideoURL)
  16372. }
  16373. if m.organization_id != nil {
  16374. fields = append(fields, employee.FieldOrganizationID)
  16375. }
  16376. if m.category_id != nil {
  16377. fields = append(fields, employee.FieldCategoryID)
  16378. }
  16379. if m.api_base != nil {
  16380. fields = append(fields, employee.FieldAPIBase)
  16381. }
  16382. if m.api_key != nil {
  16383. fields = append(fields, employee.FieldAPIKey)
  16384. }
  16385. if m.ai_info != nil {
  16386. fields = append(fields, employee.FieldAiInfo)
  16387. }
  16388. if m.is_vip != nil {
  16389. fields = append(fields, employee.FieldIsVip)
  16390. }
  16391. if m.chat_url != nil {
  16392. fields = append(fields, employee.FieldChatURL)
  16393. }
  16394. return fields
  16395. }
  16396. // Field returns the value of a field with the given name. The second boolean
  16397. // return value indicates that this field was not set, or was not defined in the
  16398. // schema.
  16399. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  16400. switch name {
  16401. case employee.FieldCreatedAt:
  16402. return m.CreatedAt()
  16403. case employee.FieldUpdatedAt:
  16404. return m.UpdatedAt()
  16405. case employee.FieldDeletedAt:
  16406. return m.DeletedAt()
  16407. case employee.FieldTitle:
  16408. return m.Title()
  16409. case employee.FieldAvatar:
  16410. return m.Avatar()
  16411. case employee.FieldTags:
  16412. return m.Tags()
  16413. case employee.FieldHireCount:
  16414. return m.HireCount()
  16415. case employee.FieldServiceCount:
  16416. return m.ServiceCount()
  16417. case employee.FieldAchievementCount:
  16418. return m.AchievementCount()
  16419. case employee.FieldIntro:
  16420. return m.Intro()
  16421. case employee.FieldEstimate:
  16422. return m.Estimate()
  16423. case employee.FieldSkill:
  16424. return m.Skill()
  16425. case employee.FieldAbilityType:
  16426. return m.AbilityType()
  16427. case employee.FieldScene:
  16428. return m.Scene()
  16429. case employee.FieldSwitchIn:
  16430. return m.SwitchIn()
  16431. case employee.FieldVideoURL:
  16432. return m.VideoURL()
  16433. case employee.FieldOrganizationID:
  16434. return m.OrganizationID()
  16435. case employee.FieldCategoryID:
  16436. return m.CategoryID()
  16437. case employee.FieldAPIBase:
  16438. return m.APIBase()
  16439. case employee.FieldAPIKey:
  16440. return m.APIKey()
  16441. case employee.FieldAiInfo:
  16442. return m.AiInfo()
  16443. case employee.FieldIsVip:
  16444. return m.IsVip()
  16445. case employee.FieldChatURL:
  16446. return m.ChatURL()
  16447. }
  16448. return nil, false
  16449. }
  16450. // OldField returns the old value of the field from the database. An error is
  16451. // returned if the mutation operation is not UpdateOne, or the query to the
  16452. // database failed.
  16453. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16454. switch name {
  16455. case employee.FieldCreatedAt:
  16456. return m.OldCreatedAt(ctx)
  16457. case employee.FieldUpdatedAt:
  16458. return m.OldUpdatedAt(ctx)
  16459. case employee.FieldDeletedAt:
  16460. return m.OldDeletedAt(ctx)
  16461. case employee.FieldTitle:
  16462. return m.OldTitle(ctx)
  16463. case employee.FieldAvatar:
  16464. return m.OldAvatar(ctx)
  16465. case employee.FieldTags:
  16466. return m.OldTags(ctx)
  16467. case employee.FieldHireCount:
  16468. return m.OldHireCount(ctx)
  16469. case employee.FieldServiceCount:
  16470. return m.OldServiceCount(ctx)
  16471. case employee.FieldAchievementCount:
  16472. return m.OldAchievementCount(ctx)
  16473. case employee.FieldIntro:
  16474. return m.OldIntro(ctx)
  16475. case employee.FieldEstimate:
  16476. return m.OldEstimate(ctx)
  16477. case employee.FieldSkill:
  16478. return m.OldSkill(ctx)
  16479. case employee.FieldAbilityType:
  16480. return m.OldAbilityType(ctx)
  16481. case employee.FieldScene:
  16482. return m.OldScene(ctx)
  16483. case employee.FieldSwitchIn:
  16484. return m.OldSwitchIn(ctx)
  16485. case employee.FieldVideoURL:
  16486. return m.OldVideoURL(ctx)
  16487. case employee.FieldOrganizationID:
  16488. return m.OldOrganizationID(ctx)
  16489. case employee.FieldCategoryID:
  16490. return m.OldCategoryID(ctx)
  16491. case employee.FieldAPIBase:
  16492. return m.OldAPIBase(ctx)
  16493. case employee.FieldAPIKey:
  16494. return m.OldAPIKey(ctx)
  16495. case employee.FieldAiInfo:
  16496. return m.OldAiInfo(ctx)
  16497. case employee.FieldIsVip:
  16498. return m.OldIsVip(ctx)
  16499. case employee.FieldChatURL:
  16500. return m.OldChatURL(ctx)
  16501. }
  16502. return nil, fmt.Errorf("unknown Employee field %s", name)
  16503. }
  16504. // SetField sets the value of a field with the given name. It returns an error if
  16505. // the field is not defined in the schema, or if the type mismatched the field
  16506. // type.
  16507. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  16508. switch name {
  16509. case employee.FieldCreatedAt:
  16510. v, ok := value.(time.Time)
  16511. if !ok {
  16512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16513. }
  16514. m.SetCreatedAt(v)
  16515. return nil
  16516. case employee.FieldUpdatedAt:
  16517. v, ok := value.(time.Time)
  16518. if !ok {
  16519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16520. }
  16521. m.SetUpdatedAt(v)
  16522. return nil
  16523. case employee.FieldDeletedAt:
  16524. v, ok := value.(time.Time)
  16525. if !ok {
  16526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16527. }
  16528. m.SetDeletedAt(v)
  16529. return nil
  16530. case employee.FieldTitle:
  16531. v, ok := value.(string)
  16532. if !ok {
  16533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16534. }
  16535. m.SetTitle(v)
  16536. return nil
  16537. case employee.FieldAvatar:
  16538. v, ok := value.(string)
  16539. if !ok {
  16540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16541. }
  16542. m.SetAvatar(v)
  16543. return nil
  16544. case employee.FieldTags:
  16545. v, ok := value.(string)
  16546. if !ok {
  16547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16548. }
  16549. m.SetTags(v)
  16550. return nil
  16551. case employee.FieldHireCount:
  16552. v, ok := value.(int)
  16553. if !ok {
  16554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16555. }
  16556. m.SetHireCount(v)
  16557. return nil
  16558. case employee.FieldServiceCount:
  16559. v, ok := value.(int)
  16560. if !ok {
  16561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16562. }
  16563. m.SetServiceCount(v)
  16564. return nil
  16565. case employee.FieldAchievementCount:
  16566. v, ok := value.(int)
  16567. if !ok {
  16568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16569. }
  16570. m.SetAchievementCount(v)
  16571. return nil
  16572. case employee.FieldIntro:
  16573. v, ok := value.(string)
  16574. if !ok {
  16575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16576. }
  16577. m.SetIntro(v)
  16578. return nil
  16579. case employee.FieldEstimate:
  16580. v, ok := value.(string)
  16581. if !ok {
  16582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16583. }
  16584. m.SetEstimate(v)
  16585. return nil
  16586. case employee.FieldSkill:
  16587. v, ok := value.(string)
  16588. if !ok {
  16589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16590. }
  16591. m.SetSkill(v)
  16592. return nil
  16593. case employee.FieldAbilityType:
  16594. v, ok := value.(string)
  16595. if !ok {
  16596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16597. }
  16598. m.SetAbilityType(v)
  16599. return nil
  16600. case employee.FieldScene:
  16601. v, ok := value.(string)
  16602. if !ok {
  16603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16604. }
  16605. m.SetScene(v)
  16606. return nil
  16607. case employee.FieldSwitchIn:
  16608. v, ok := value.(string)
  16609. if !ok {
  16610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16611. }
  16612. m.SetSwitchIn(v)
  16613. return nil
  16614. case employee.FieldVideoURL:
  16615. v, ok := value.(string)
  16616. if !ok {
  16617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16618. }
  16619. m.SetVideoURL(v)
  16620. return nil
  16621. case employee.FieldOrganizationID:
  16622. v, ok := value.(uint64)
  16623. if !ok {
  16624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16625. }
  16626. m.SetOrganizationID(v)
  16627. return nil
  16628. case employee.FieldCategoryID:
  16629. v, ok := value.(uint64)
  16630. if !ok {
  16631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16632. }
  16633. m.SetCategoryID(v)
  16634. return nil
  16635. case employee.FieldAPIBase:
  16636. v, ok := value.(string)
  16637. if !ok {
  16638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16639. }
  16640. m.SetAPIBase(v)
  16641. return nil
  16642. case employee.FieldAPIKey:
  16643. v, ok := value.(string)
  16644. if !ok {
  16645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16646. }
  16647. m.SetAPIKey(v)
  16648. return nil
  16649. case employee.FieldAiInfo:
  16650. v, ok := value.(string)
  16651. if !ok {
  16652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16653. }
  16654. m.SetAiInfo(v)
  16655. return nil
  16656. case employee.FieldIsVip:
  16657. v, ok := value.(int)
  16658. if !ok {
  16659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16660. }
  16661. m.SetIsVip(v)
  16662. return nil
  16663. case employee.FieldChatURL:
  16664. v, ok := value.(string)
  16665. if !ok {
  16666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16667. }
  16668. m.SetChatURL(v)
  16669. return nil
  16670. }
  16671. return fmt.Errorf("unknown Employee field %s", name)
  16672. }
  16673. // AddedFields returns all numeric fields that were incremented/decremented during
  16674. // this mutation.
  16675. func (m *EmployeeMutation) AddedFields() []string {
  16676. var fields []string
  16677. if m.addhire_count != nil {
  16678. fields = append(fields, employee.FieldHireCount)
  16679. }
  16680. if m.addservice_count != nil {
  16681. fields = append(fields, employee.FieldServiceCount)
  16682. }
  16683. if m.addachievement_count != nil {
  16684. fields = append(fields, employee.FieldAchievementCount)
  16685. }
  16686. if m.addorganization_id != nil {
  16687. fields = append(fields, employee.FieldOrganizationID)
  16688. }
  16689. if m.addcategory_id != nil {
  16690. fields = append(fields, employee.FieldCategoryID)
  16691. }
  16692. if m.addis_vip != nil {
  16693. fields = append(fields, employee.FieldIsVip)
  16694. }
  16695. return fields
  16696. }
  16697. // AddedField returns the numeric value that was incremented/decremented on a field
  16698. // with the given name. The second boolean return value indicates that this field
  16699. // was not set, or was not defined in the schema.
  16700. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  16701. switch name {
  16702. case employee.FieldHireCount:
  16703. return m.AddedHireCount()
  16704. case employee.FieldServiceCount:
  16705. return m.AddedServiceCount()
  16706. case employee.FieldAchievementCount:
  16707. return m.AddedAchievementCount()
  16708. case employee.FieldOrganizationID:
  16709. return m.AddedOrganizationID()
  16710. case employee.FieldCategoryID:
  16711. return m.AddedCategoryID()
  16712. case employee.FieldIsVip:
  16713. return m.AddedIsVip()
  16714. }
  16715. return nil, false
  16716. }
  16717. // AddField adds the value to the field with the given name. It returns an error if
  16718. // the field is not defined in the schema, or if the type mismatched the field
  16719. // type.
  16720. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  16721. switch name {
  16722. case employee.FieldHireCount:
  16723. v, ok := value.(int)
  16724. if !ok {
  16725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16726. }
  16727. m.AddHireCount(v)
  16728. return nil
  16729. case employee.FieldServiceCount:
  16730. v, ok := value.(int)
  16731. if !ok {
  16732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16733. }
  16734. m.AddServiceCount(v)
  16735. return nil
  16736. case employee.FieldAchievementCount:
  16737. v, ok := value.(int)
  16738. if !ok {
  16739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16740. }
  16741. m.AddAchievementCount(v)
  16742. return nil
  16743. case employee.FieldOrganizationID:
  16744. v, ok := value.(int64)
  16745. if !ok {
  16746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16747. }
  16748. m.AddOrganizationID(v)
  16749. return nil
  16750. case employee.FieldCategoryID:
  16751. v, ok := value.(int64)
  16752. if !ok {
  16753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16754. }
  16755. m.AddCategoryID(v)
  16756. return nil
  16757. case employee.FieldIsVip:
  16758. v, ok := value.(int)
  16759. if !ok {
  16760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16761. }
  16762. m.AddIsVip(v)
  16763. return nil
  16764. }
  16765. return fmt.Errorf("unknown Employee numeric field %s", name)
  16766. }
  16767. // ClearedFields returns all nullable fields that were cleared during this
  16768. // mutation.
  16769. func (m *EmployeeMutation) ClearedFields() []string {
  16770. var fields []string
  16771. if m.FieldCleared(employee.FieldDeletedAt) {
  16772. fields = append(fields, employee.FieldDeletedAt)
  16773. }
  16774. if m.FieldCleared(employee.FieldAiInfo) {
  16775. fields = append(fields, employee.FieldAiInfo)
  16776. }
  16777. return fields
  16778. }
  16779. // FieldCleared returns a boolean indicating if a field with the given name was
  16780. // cleared in this mutation.
  16781. func (m *EmployeeMutation) FieldCleared(name string) bool {
  16782. _, ok := m.clearedFields[name]
  16783. return ok
  16784. }
  16785. // ClearField clears the value of the field with the given name. It returns an
  16786. // error if the field is not defined in the schema.
  16787. func (m *EmployeeMutation) ClearField(name string) error {
  16788. switch name {
  16789. case employee.FieldDeletedAt:
  16790. m.ClearDeletedAt()
  16791. return nil
  16792. case employee.FieldAiInfo:
  16793. m.ClearAiInfo()
  16794. return nil
  16795. }
  16796. return fmt.Errorf("unknown Employee nullable field %s", name)
  16797. }
  16798. // ResetField resets all changes in the mutation for the field with the given name.
  16799. // It returns an error if the field is not defined in the schema.
  16800. func (m *EmployeeMutation) ResetField(name string) error {
  16801. switch name {
  16802. case employee.FieldCreatedAt:
  16803. m.ResetCreatedAt()
  16804. return nil
  16805. case employee.FieldUpdatedAt:
  16806. m.ResetUpdatedAt()
  16807. return nil
  16808. case employee.FieldDeletedAt:
  16809. m.ResetDeletedAt()
  16810. return nil
  16811. case employee.FieldTitle:
  16812. m.ResetTitle()
  16813. return nil
  16814. case employee.FieldAvatar:
  16815. m.ResetAvatar()
  16816. return nil
  16817. case employee.FieldTags:
  16818. m.ResetTags()
  16819. return nil
  16820. case employee.FieldHireCount:
  16821. m.ResetHireCount()
  16822. return nil
  16823. case employee.FieldServiceCount:
  16824. m.ResetServiceCount()
  16825. return nil
  16826. case employee.FieldAchievementCount:
  16827. m.ResetAchievementCount()
  16828. return nil
  16829. case employee.FieldIntro:
  16830. m.ResetIntro()
  16831. return nil
  16832. case employee.FieldEstimate:
  16833. m.ResetEstimate()
  16834. return nil
  16835. case employee.FieldSkill:
  16836. m.ResetSkill()
  16837. return nil
  16838. case employee.FieldAbilityType:
  16839. m.ResetAbilityType()
  16840. return nil
  16841. case employee.FieldScene:
  16842. m.ResetScene()
  16843. return nil
  16844. case employee.FieldSwitchIn:
  16845. m.ResetSwitchIn()
  16846. return nil
  16847. case employee.FieldVideoURL:
  16848. m.ResetVideoURL()
  16849. return nil
  16850. case employee.FieldOrganizationID:
  16851. m.ResetOrganizationID()
  16852. return nil
  16853. case employee.FieldCategoryID:
  16854. m.ResetCategoryID()
  16855. return nil
  16856. case employee.FieldAPIBase:
  16857. m.ResetAPIBase()
  16858. return nil
  16859. case employee.FieldAPIKey:
  16860. m.ResetAPIKey()
  16861. return nil
  16862. case employee.FieldAiInfo:
  16863. m.ResetAiInfo()
  16864. return nil
  16865. case employee.FieldIsVip:
  16866. m.ResetIsVip()
  16867. return nil
  16868. case employee.FieldChatURL:
  16869. m.ResetChatURL()
  16870. return nil
  16871. }
  16872. return fmt.Errorf("unknown Employee field %s", name)
  16873. }
  16874. // AddedEdges returns all edge names that were set/added in this mutation.
  16875. func (m *EmployeeMutation) AddedEdges() []string {
  16876. edges := make([]string, 0, 2)
  16877. if m.em_work_experiences != nil {
  16878. edges = append(edges, employee.EdgeEmWorkExperiences)
  16879. }
  16880. if m.em_tutorial != nil {
  16881. edges = append(edges, employee.EdgeEmTutorial)
  16882. }
  16883. return edges
  16884. }
  16885. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16886. // name in this mutation.
  16887. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  16888. switch name {
  16889. case employee.EdgeEmWorkExperiences:
  16890. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  16891. for id := range m.em_work_experiences {
  16892. ids = append(ids, id)
  16893. }
  16894. return ids
  16895. case employee.EdgeEmTutorial:
  16896. ids := make([]ent.Value, 0, len(m.em_tutorial))
  16897. for id := range m.em_tutorial {
  16898. ids = append(ids, id)
  16899. }
  16900. return ids
  16901. }
  16902. return nil
  16903. }
  16904. // RemovedEdges returns all edge names that were removed in this mutation.
  16905. func (m *EmployeeMutation) RemovedEdges() []string {
  16906. edges := make([]string, 0, 2)
  16907. if m.removedem_work_experiences != nil {
  16908. edges = append(edges, employee.EdgeEmWorkExperiences)
  16909. }
  16910. if m.removedem_tutorial != nil {
  16911. edges = append(edges, employee.EdgeEmTutorial)
  16912. }
  16913. return edges
  16914. }
  16915. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16916. // the given name in this mutation.
  16917. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  16918. switch name {
  16919. case employee.EdgeEmWorkExperiences:
  16920. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  16921. for id := range m.removedem_work_experiences {
  16922. ids = append(ids, id)
  16923. }
  16924. return ids
  16925. case employee.EdgeEmTutorial:
  16926. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  16927. for id := range m.removedem_tutorial {
  16928. ids = append(ids, id)
  16929. }
  16930. return ids
  16931. }
  16932. return nil
  16933. }
  16934. // ClearedEdges returns all edge names that were cleared in this mutation.
  16935. func (m *EmployeeMutation) ClearedEdges() []string {
  16936. edges := make([]string, 0, 2)
  16937. if m.clearedem_work_experiences {
  16938. edges = append(edges, employee.EdgeEmWorkExperiences)
  16939. }
  16940. if m.clearedem_tutorial {
  16941. edges = append(edges, employee.EdgeEmTutorial)
  16942. }
  16943. return edges
  16944. }
  16945. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16946. // was cleared in this mutation.
  16947. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  16948. switch name {
  16949. case employee.EdgeEmWorkExperiences:
  16950. return m.clearedem_work_experiences
  16951. case employee.EdgeEmTutorial:
  16952. return m.clearedem_tutorial
  16953. }
  16954. return false
  16955. }
  16956. // ClearEdge clears the value of the edge with the given name. It returns an error
  16957. // if that edge is not defined in the schema.
  16958. func (m *EmployeeMutation) ClearEdge(name string) error {
  16959. switch name {
  16960. }
  16961. return fmt.Errorf("unknown Employee unique edge %s", name)
  16962. }
  16963. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16964. // It returns an error if the edge is not defined in the schema.
  16965. func (m *EmployeeMutation) ResetEdge(name string) error {
  16966. switch name {
  16967. case employee.EdgeEmWorkExperiences:
  16968. m.ResetEmWorkExperiences()
  16969. return nil
  16970. case employee.EdgeEmTutorial:
  16971. m.ResetEmTutorial()
  16972. return nil
  16973. }
  16974. return fmt.Errorf("unknown Employee edge %s", name)
  16975. }
  16976. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  16977. type EmployeeConfigMutation struct {
  16978. config
  16979. op Op
  16980. typ string
  16981. id *uint64
  16982. created_at *time.Time
  16983. updated_at *time.Time
  16984. deleted_at *time.Time
  16985. stype *string
  16986. title *string
  16987. photo *string
  16988. organization_id *uint64
  16989. addorganization_id *int64
  16990. clearedFields map[string]struct{}
  16991. done bool
  16992. oldValue func(context.Context) (*EmployeeConfig, error)
  16993. predicates []predicate.EmployeeConfig
  16994. }
  16995. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  16996. // employeeconfigOption allows management of the mutation configuration using functional options.
  16997. type employeeconfigOption func(*EmployeeConfigMutation)
  16998. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  16999. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  17000. m := &EmployeeConfigMutation{
  17001. config: c,
  17002. op: op,
  17003. typ: TypeEmployeeConfig,
  17004. clearedFields: make(map[string]struct{}),
  17005. }
  17006. for _, opt := range opts {
  17007. opt(m)
  17008. }
  17009. return m
  17010. }
  17011. // withEmployeeConfigID sets the ID field of the mutation.
  17012. func withEmployeeConfigID(id uint64) employeeconfigOption {
  17013. return func(m *EmployeeConfigMutation) {
  17014. var (
  17015. err error
  17016. once sync.Once
  17017. value *EmployeeConfig
  17018. )
  17019. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  17020. once.Do(func() {
  17021. if m.done {
  17022. err = errors.New("querying old values post mutation is not allowed")
  17023. } else {
  17024. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  17025. }
  17026. })
  17027. return value, err
  17028. }
  17029. m.id = &id
  17030. }
  17031. }
  17032. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  17033. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  17034. return func(m *EmployeeConfigMutation) {
  17035. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  17036. return node, nil
  17037. }
  17038. m.id = &node.ID
  17039. }
  17040. }
  17041. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17042. // executed in a transaction (ent.Tx), a transactional client is returned.
  17043. func (m EmployeeConfigMutation) Client() *Client {
  17044. client := &Client{config: m.config}
  17045. client.init()
  17046. return client
  17047. }
  17048. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17049. // it returns an error otherwise.
  17050. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  17051. if _, ok := m.driver.(*txDriver); !ok {
  17052. return nil, errors.New("ent: mutation is not running in a transaction")
  17053. }
  17054. tx := &Tx{config: m.config}
  17055. tx.init()
  17056. return tx, nil
  17057. }
  17058. // SetID sets the value of the id field. Note that this
  17059. // operation is only accepted on creation of EmployeeConfig entities.
  17060. func (m *EmployeeConfigMutation) SetID(id uint64) {
  17061. m.id = &id
  17062. }
  17063. // ID returns the ID value in the mutation. Note that the ID is only available
  17064. // if it was provided to the builder or after it was returned from the database.
  17065. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  17066. if m.id == nil {
  17067. return
  17068. }
  17069. return *m.id, true
  17070. }
  17071. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17072. // That means, if the mutation is applied within a transaction with an isolation level such
  17073. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17074. // or updated by the mutation.
  17075. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  17076. switch {
  17077. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17078. id, exists := m.ID()
  17079. if exists {
  17080. return []uint64{id}, nil
  17081. }
  17082. fallthrough
  17083. case m.op.Is(OpUpdate | OpDelete):
  17084. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  17085. default:
  17086. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17087. }
  17088. }
  17089. // SetCreatedAt sets the "created_at" field.
  17090. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  17091. m.created_at = &t
  17092. }
  17093. // CreatedAt returns the value of the "created_at" field in the mutation.
  17094. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  17095. v := m.created_at
  17096. if v == nil {
  17097. return
  17098. }
  17099. return *v, true
  17100. }
  17101. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  17102. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17104. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17105. if !m.op.Is(OpUpdateOne) {
  17106. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17107. }
  17108. if m.id == nil || m.oldValue == nil {
  17109. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17110. }
  17111. oldValue, err := m.oldValue(ctx)
  17112. if err != nil {
  17113. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17114. }
  17115. return oldValue.CreatedAt, nil
  17116. }
  17117. // ResetCreatedAt resets all changes to the "created_at" field.
  17118. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  17119. m.created_at = nil
  17120. }
  17121. // SetUpdatedAt sets the "updated_at" field.
  17122. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  17123. m.updated_at = &t
  17124. }
  17125. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17126. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  17127. v := m.updated_at
  17128. if v == nil {
  17129. return
  17130. }
  17131. return *v, true
  17132. }
  17133. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  17134. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17136. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17137. if !m.op.Is(OpUpdateOne) {
  17138. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17139. }
  17140. if m.id == nil || m.oldValue == nil {
  17141. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17142. }
  17143. oldValue, err := m.oldValue(ctx)
  17144. if err != nil {
  17145. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17146. }
  17147. return oldValue.UpdatedAt, nil
  17148. }
  17149. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17150. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  17151. m.updated_at = nil
  17152. }
  17153. // SetDeletedAt sets the "deleted_at" field.
  17154. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  17155. m.deleted_at = &t
  17156. }
  17157. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17158. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  17159. v := m.deleted_at
  17160. if v == nil {
  17161. return
  17162. }
  17163. return *v, true
  17164. }
  17165. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  17166. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17168. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17169. if !m.op.Is(OpUpdateOne) {
  17170. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17171. }
  17172. if m.id == nil || m.oldValue == nil {
  17173. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17174. }
  17175. oldValue, err := m.oldValue(ctx)
  17176. if err != nil {
  17177. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17178. }
  17179. return oldValue.DeletedAt, nil
  17180. }
  17181. // ClearDeletedAt clears the value of the "deleted_at" field.
  17182. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  17183. m.deleted_at = nil
  17184. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  17185. }
  17186. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17187. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  17188. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  17189. return ok
  17190. }
  17191. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17192. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  17193. m.deleted_at = nil
  17194. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  17195. }
  17196. // SetStype sets the "stype" field.
  17197. func (m *EmployeeConfigMutation) SetStype(s string) {
  17198. m.stype = &s
  17199. }
  17200. // Stype returns the value of the "stype" field in the mutation.
  17201. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  17202. v := m.stype
  17203. if v == nil {
  17204. return
  17205. }
  17206. return *v, true
  17207. }
  17208. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  17209. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17211. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  17212. if !m.op.Is(OpUpdateOne) {
  17213. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  17214. }
  17215. if m.id == nil || m.oldValue == nil {
  17216. return v, errors.New("OldStype requires an ID field in the mutation")
  17217. }
  17218. oldValue, err := m.oldValue(ctx)
  17219. if err != nil {
  17220. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  17221. }
  17222. return oldValue.Stype, nil
  17223. }
  17224. // ResetStype resets all changes to the "stype" field.
  17225. func (m *EmployeeConfigMutation) ResetStype() {
  17226. m.stype = nil
  17227. }
  17228. // SetTitle sets the "title" field.
  17229. func (m *EmployeeConfigMutation) SetTitle(s string) {
  17230. m.title = &s
  17231. }
  17232. // Title returns the value of the "title" field in the mutation.
  17233. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  17234. v := m.title
  17235. if v == nil {
  17236. return
  17237. }
  17238. return *v, true
  17239. }
  17240. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  17241. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17243. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  17244. if !m.op.Is(OpUpdateOne) {
  17245. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  17246. }
  17247. if m.id == nil || m.oldValue == nil {
  17248. return v, errors.New("OldTitle requires an ID field in the mutation")
  17249. }
  17250. oldValue, err := m.oldValue(ctx)
  17251. if err != nil {
  17252. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  17253. }
  17254. return oldValue.Title, nil
  17255. }
  17256. // ResetTitle resets all changes to the "title" field.
  17257. func (m *EmployeeConfigMutation) ResetTitle() {
  17258. m.title = nil
  17259. }
  17260. // SetPhoto sets the "photo" field.
  17261. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  17262. m.photo = &s
  17263. }
  17264. // Photo returns the value of the "photo" field in the mutation.
  17265. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  17266. v := m.photo
  17267. if v == nil {
  17268. return
  17269. }
  17270. return *v, true
  17271. }
  17272. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  17273. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17275. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  17276. if !m.op.Is(OpUpdateOne) {
  17277. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  17278. }
  17279. if m.id == nil || m.oldValue == nil {
  17280. return v, errors.New("OldPhoto requires an ID field in the mutation")
  17281. }
  17282. oldValue, err := m.oldValue(ctx)
  17283. if err != nil {
  17284. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  17285. }
  17286. return oldValue.Photo, nil
  17287. }
  17288. // ResetPhoto resets all changes to the "photo" field.
  17289. func (m *EmployeeConfigMutation) ResetPhoto() {
  17290. m.photo = nil
  17291. }
  17292. // SetOrganizationID sets the "organization_id" field.
  17293. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  17294. m.organization_id = &u
  17295. m.addorganization_id = nil
  17296. }
  17297. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17298. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  17299. v := m.organization_id
  17300. if v == nil {
  17301. return
  17302. }
  17303. return *v, true
  17304. }
  17305. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  17306. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17308. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17309. if !m.op.Is(OpUpdateOne) {
  17310. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17311. }
  17312. if m.id == nil || m.oldValue == nil {
  17313. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17314. }
  17315. oldValue, err := m.oldValue(ctx)
  17316. if err != nil {
  17317. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17318. }
  17319. return oldValue.OrganizationID, nil
  17320. }
  17321. // AddOrganizationID adds u to the "organization_id" field.
  17322. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  17323. if m.addorganization_id != nil {
  17324. *m.addorganization_id += u
  17325. } else {
  17326. m.addorganization_id = &u
  17327. }
  17328. }
  17329. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17330. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  17331. v := m.addorganization_id
  17332. if v == nil {
  17333. return
  17334. }
  17335. return *v, true
  17336. }
  17337. // ClearOrganizationID clears the value of the "organization_id" field.
  17338. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  17339. m.organization_id = nil
  17340. m.addorganization_id = nil
  17341. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  17342. }
  17343. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17344. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  17345. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  17346. return ok
  17347. }
  17348. // ResetOrganizationID resets all changes to the "organization_id" field.
  17349. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  17350. m.organization_id = nil
  17351. m.addorganization_id = nil
  17352. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  17353. }
  17354. // Where appends a list predicates to the EmployeeConfigMutation builder.
  17355. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  17356. m.predicates = append(m.predicates, ps...)
  17357. }
  17358. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  17359. // users can use type-assertion to append predicates that do not depend on any generated package.
  17360. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  17361. p := make([]predicate.EmployeeConfig, len(ps))
  17362. for i := range ps {
  17363. p[i] = ps[i]
  17364. }
  17365. m.Where(p...)
  17366. }
  17367. // Op returns the operation name.
  17368. func (m *EmployeeConfigMutation) Op() Op {
  17369. return m.op
  17370. }
  17371. // SetOp allows setting the mutation operation.
  17372. func (m *EmployeeConfigMutation) SetOp(op Op) {
  17373. m.op = op
  17374. }
  17375. // Type returns the node type of this mutation (EmployeeConfig).
  17376. func (m *EmployeeConfigMutation) Type() string {
  17377. return m.typ
  17378. }
  17379. // Fields returns all fields that were changed during this mutation. Note that in
  17380. // order to get all numeric fields that were incremented/decremented, call
  17381. // AddedFields().
  17382. func (m *EmployeeConfigMutation) Fields() []string {
  17383. fields := make([]string, 0, 7)
  17384. if m.created_at != nil {
  17385. fields = append(fields, employeeconfig.FieldCreatedAt)
  17386. }
  17387. if m.updated_at != nil {
  17388. fields = append(fields, employeeconfig.FieldUpdatedAt)
  17389. }
  17390. if m.deleted_at != nil {
  17391. fields = append(fields, employeeconfig.FieldDeletedAt)
  17392. }
  17393. if m.stype != nil {
  17394. fields = append(fields, employeeconfig.FieldStype)
  17395. }
  17396. if m.title != nil {
  17397. fields = append(fields, employeeconfig.FieldTitle)
  17398. }
  17399. if m.photo != nil {
  17400. fields = append(fields, employeeconfig.FieldPhoto)
  17401. }
  17402. if m.organization_id != nil {
  17403. fields = append(fields, employeeconfig.FieldOrganizationID)
  17404. }
  17405. return fields
  17406. }
  17407. // Field returns the value of a field with the given name. The second boolean
  17408. // return value indicates that this field was not set, or was not defined in the
  17409. // schema.
  17410. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  17411. switch name {
  17412. case employeeconfig.FieldCreatedAt:
  17413. return m.CreatedAt()
  17414. case employeeconfig.FieldUpdatedAt:
  17415. return m.UpdatedAt()
  17416. case employeeconfig.FieldDeletedAt:
  17417. return m.DeletedAt()
  17418. case employeeconfig.FieldStype:
  17419. return m.Stype()
  17420. case employeeconfig.FieldTitle:
  17421. return m.Title()
  17422. case employeeconfig.FieldPhoto:
  17423. return m.Photo()
  17424. case employeeconfig.FieldOrganizationID:
  17425. return m.OrganizationID()
  17426. }
  17427. return nil, false
  17428. }
  17429. // OldField returns the old value of the field from the database. An error is
  17430. // returned if the mutation operation is not UpdateOne, or the query to the
  17431. // database failed.
  17432. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17433. switch name {
  17434. case employeeconfig.FieldCreatedAt:
  17435. return m.OldCreatedAt(ctx)
  17436. case employeeconfig.FieldUpdatedAt:
  17437. return m.OldUpdatedAt(ctx)
  17438. case employeeconfig.FieldDeletedAt:
  17439. return m.OldDeletedAt(ctx)
  17440. case employeeconfig.FieldStype:
  17441. return m.OldStype(ctx)
  17442. case employeeconfig.FieldTitle:
  17443. return m.OldTitle(ctx)
  17444. case employeeconfig.FieldPhoto:
  17445. return m.OldPhoto(ctx)
  17446. case employeeconfig.FieldOrganizationID:
  17447. return m.OldOrganizationID(ctx)
  17448. }
  17449. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  17450. }
  17451. // SetField sets the value of a field with the given name. It returns an error if
  17452. // the field is not defined in the schema, or if the type mismatched the field
  17453. // type.
  17454. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  17455. switch name {
  17456. case employeeconfig.FieldCreatedAt:
  17457. v, ok := value.(time.Time)
  17458. if !ok {
  17459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17460. }
  17461. m.SetCreatedAt(v)
  17462. return nil
  17463. case employeeconfig.FieldUpdatedAt:
  17464. v, ok := value.(time.Time)
  17465. if !ok {
  17466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17467. }
  17468. m.SetUpdatedAt(v)
  17469. return nil
  17470. case employeeconfig.FieldDeletedAt:
  17471. v, ok := value.(time.Time)
  17472. if !ok {
  17473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17474. }
  17475. m.SetDeletedAt(v)
  17476. return nil
  17477. case employeeconfig.FieldStype:
  17478. v, ok := value.(string)
  17479. if !ok {
  17480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17481. }
  17482. m.SetStype(v)
  17483. return nil
  17484. case employeeconfig.FieldTitle:
  17485. v, ok := value.(string)
  17486. if !ok {
  17487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17488. }
  17489. m.SetTitle(v)
  17490. return nil
  17491. case employeeconfig.FieldPhoto:
  17492. v, ok := value.(string)
  17493. if !ok {
  17494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17495. }
  17496. m.SetPhoto(v)
  17497. return nil
  17498. case employeeconfig.FieldOrganizationID:
  17499. v, ok := value.(uint64)
  17500. if !ok {
  17501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17502. }
  17503. m.SetOrganizationID(v)
  17504. return nil
  17505. }
  17506. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17507. }
  17508. // AddedFields returns all numeric fields that were incremented/decremented during
  17509. // this mutation.
  17510. func (m *EmployeeConfigMutation) AddedFields() []string {
  17511. var fields []string
  17512. if m.addorganization_id != nil {
  17513. fields = append(fields, employeeconfig.FieldOrganizationID)
  17514. }
  17515. return fields
  17516. }
  17517. // AddedField returns the numeric value that was incremented/decremented on a field
  17518. // with the given name. The second boolean return value indicates that this field
  17519. // was not set, or was not defined in the schema.
  17520. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  17521. switch name {
  17522. case employeeconfig.FieldOrganizationID:
  17523. return m.AddedOrganizationID()
  17524. }
  17525. return nil, false
  17526. }
  17527. // AddField adds the value to the field with the given name. It returns an error if
  17528. // the field is not defined in the schema, or if the type mismatched the field
  17529. // type.
  17530. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  17531. switch name {
  17532. case employeeconfig.FieldOrganizationID:
  17533. v, ok := value.(int64)
  17534. if !ok {
  17535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17536. }
  17537. m.AddOrganizationID(v)
  17538. return nil
  17539. }
  17540. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  17541. }
  17542. // ClearedFields returns all nullable fields that were cleared during this
  17543. // mutation.
  17544. func (m *EmployeeConfigMutation) ClearedFields() []string {
  17545. var fields []string
  17546. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  17547. fields = append(fields, employeeconfig.FieldDeletedAt)
  17548. }
  17549. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  17550. fields = append(fields, employeeconfig.FieldOrganizationID)
  17551. }
  17552. return fields
  17553. }
  17554. // FieldCleared returns a boolean indicating if a field with the given name was
  17555. // cleared in this mutation.
  17556. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  17557. _, ok := m.clearedFields[name]
  17558. return ok
  17559. }
  17560. // ClearField clears the value of the field with the given name. It returns an
  17561. // error if the field is not defined in the schema.
  17562. func (m *EmployeeConfigMutation) ClearField(name string) error {
  17563. switch name {
  17564. case employeeconfig.FieldDeletedAt:
  17565. m.ClearDeletedAt()
  17566. return nil
  17567. case employeeconfig.FieldOrganizationID:
  17568. m.ClearOrganizationID()
  17569. return nil
  17570. }
  17571. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  17572. }
  17573. // ResetField resets all changes in the mutation for the field with the given name.
  17574. // It returns an error if the field is not defined in the schema.
  17575. func (m *EmployeeConfigMutation) ResetField(name string) error {
  17576. switch name {
  17577. case employeeconfig.FieldCreatedAt:
  17578. m.ResetCreatedAt()
  17579. return nil
  17580. case employeeconfig.FieldUpdatedAt:
  17581. m.ResetUpdatedAt()
  17582. return nil
  17583. case employeeconfig.FieldDeletedAt:
  17584. m.ResetDeletedAt()
  17585. return nil
  17586. case employeeconfig.FieldStype:
  17587. m.ResetStype()
  17588. return nil
  17589. case employeeconfig.FieldTitle:
  17590. m.ResetTitle()
  17591. return nil
  17592. case employeeconfig.FieldPhoto:
  17593. m.ResetPhoto()
  17594. return nil
  17595. case employeeconfig.FieldOrganizationID:
  17596. m.ResetOrganizationID()
  17597. return nil
  17598. }
  17599. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17600. }
  17601. // AddedEdges returns all edge names that were set/added in this mutation.
  17602. func (m *EmployeeConfigMutation) AddedEdges() []string {
  17603. edges := make([]string, 0, 0)
  17604. return edges
  17605. }
  17606. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17607. // name in this mutation.
  17608. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  17609. return nil
  17610. }
  17611. // RemovedEdges returns all edge names that were removed in this mutation.
  17612. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  17613. edges := make([]string, 0, 0)
  17614. return edges
  17615. }
  17616. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17617. // the given name in this mutation.
  17618. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  17619. return nil
  17620. }
  17621. // ClearedEdges returns all edge names that were cleared in this mutation.
  17622. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  17623. edges := make([]string, 0, 0)
  17624. return edges
  17625. }
  17626. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17627. // was cleared in this mutation.
  17628. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  17629. return false
  17630. }
  17631. // ClearEdge clears the value of the edge with the given name. It returns an error
  17632. // if that edge is not defined in the schema.
  17633. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  17634. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  17635. }
  17636. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17637. // It returns an error if the edge is not defined in the schema.
  17638. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  17639. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  17640. }
  17641. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  17642. type LabelMutation struct {
  17643. config
  17644. op Op
  17645. typ string
  17646. id *uint64
  17647. created_at *time.Time
  17648. updated_at *time.Time
  17649. status *uint8
  17650. addstatus *int8
  17651. _type *int
  17652. add_type *int
  17653. name *string
  17654. from *int
  17655. addfrom *int
  17656. mode *int
  17657. addmode *int
  17658. conditions *string
  17659. organization_id *uint64
  17660. addorganization_id *int64
  17661. clearedFields map[string]struct{}
  17662. label_relationships map[uint64]struct{}
  17663. removedlabel_relationships map[uint64]struct{}
  17664. clearedlabel_relationships bool
  17665. done bool
  17666. oldValue func(context.Context) (*Label, error)
  17667. predicates []predicate.Label
  17668. }
  17669. var _ ent.Mutation = (*LabelMutation)(nil)
  17670. // labelOption allows management of the mutation configuration using functional options.
  17671. type labelOption func(*LabelMutation)
  17672. // newLabelMutation creates new mutation for the Label entity.
  17673. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  17674. m := &LabelMutation{
  17675. config: c,
  17676. op: op,
  17677. typ: TypeLabel,
  17678. clearedFields: make(map[string]struct{}),
  17679. }
  17680. for _, opt := range opts {
  17681. opt(m)
  17682. }
  17683. return m
  17684. }
  17685. // withLabelID sets the ID field of the mutation.
  17686. func withLabelID(id uint64) labelOption {
  17687. return func(m *LabelMutation) {
  17688. var (
  17689. err error
  17690. once sync.Once
  17691. value *Label
  17692. )
  17693. m.oldValue = func(ctx context.Context) (*Label, error) {
  17694. once.Do(func() {
  17695. if m.done {
  17696. err = errors.New("querying old values post mutation is not allowed")
  17697. } else {
  17698. value, err = m.Client().Label.Get(ctx, id)
  17699. }
  17700. })
  17701. return value, err
  17702. }
  17703. m.id = &id
  17704. }
  17705. }
  17706. // withLabel sets the old Label of the mutation.
  17707. func withLabel(node *Label) labelOption {
  17708. return func(m *LabelMutation) {
  17709. m.oldValue = func(context.Context) (*Label, error) {
  17710. return node, nil
  17711. }
  17712. m.id = &node.ID
  17713. }
  17714. }
  17715. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17716. // executed in a transaction (ent.Tx), a transactional client is returned.
  17717. func (m LabelMutation) Client() *Client {
  17718. client := &Client{config: m.config}
  17719. client.init()
  17720. return client
  17721. }
  17722. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17723. // it returns an error otherwise.
  17724. func (m LabelMutation) Tx() (*Tx, error) {
  17725. if _, ok := m.driver.(*txDriver); !ok {
  17726. return nil, errors.New("ent: mutation is not running in a transaction")
  17727. }
  17728. tx := &Tx{config: m.config}
  17729. tx.init()
  17730. return tx, nil
  17731. }
  17732. // SetID sets the value of the id field. Note that this
  17733. // operation is only accepted on creation of Label entities.
  17734. func (m *LabelMutation) SetID(id uint64) {
  17735. m.id = &id
  17736. }
  17737. // ID returns the ID value in the mutation. Note that the ID is only available
  17738. // if it was provided to the builder or after it was returned from the database.
  17739. func (m *LabelMutation) ID() (id uint64, exists bool) {
  17740. if m.id == nil {
  17741. return
  17742. }
  17743. return *m.id, true
  17744. }
  17745. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17746. // That means, if the mutation is applied within a transaction with an isolation level such
  17747. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17748. // or updated by the mutation.
  17749. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  17750. switch {
  17751. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17752. id, exists := m.ID()
  17753. if exists {
  17754. return []uint64{id}, nil
  17755. }
  17756. fallthrough
  17757. case m.op.Is(OpUpdate | OpDelete):
  17758. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  17759. default:
  17760. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17761. }
  17762. }
  17763. // SetCreatedAt sets the "created_at" field.
  17764. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  17765. m.created_at = &t
  17766. }
  17767. // CreatedAt returns the value of the "created_at" field in the mutation.
  17768. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  17769. v := m.created_at
  17770. if v == nil {
  17771. return
  17772. }
  17773. return *v, true
  17774. }
  17775. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  17776. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17778. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17779. if !m.op.Is(OpUpdateOne) {
  17780. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17781. }
  17782. if m.id == nil || m.oldValue == nil {
  17783. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17784. }
  17785. oldValue, err := m.oldValue(ctx)
  17786. if err != nil {
  17787. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17788. }
  17789. return oldValue.CreatedAt, nil
  17790. }
  17791. // ResetCreatedAt resets all changes to the "created_at" field.
  17792. func (m *LabelMutation) ResetCreatedAt() {
  17793. m.created_at = nil
  17794. }
  17795. // SetUpdatedAt sets the "updated_at" field.
  17796. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  17797. m.updated_at = &t
  17798. }
  17799. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17800. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  17801. v := m.updated_at
  17802. if v == nil {
  17803. return
  17804. }
  17805. return *v, true
  17806. }
  17807. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  17808. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17810. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17811. if !m.op.Is(OpUpdateOne) {
  17812. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17813. }
  17814. if m.id == nil || m.oldValue == nil {
  17815. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17816. }
  17817. oldValue, err := m.oldValue(ctx)
  17818. if err != nil {
  17819. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17820. }
  17821. return oldValue.UpdatedAt, nil
  17822. }
  17823. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17824. func (m *LabelMutation) ResetUpdatedAt() {
  17825. m.updated_at = nil
  17826. }
  17827. // SetStatus sets the "status" field.
  17828. func (m *LabelMutation) SetStatus(u uint8) {
  17829. m.status = &u
  17830. m.addstatus = nil
  17831. }
  17832. // Status returns the value of the "status" field in the mutation.
  17833. func (m *LabelMutation) Status() (r uint8, exists bool) {
  17834. v := m.status
  17835. if v == nil {
  17836. return
  17837. }
  17838. return *v, true
  17839. }
  17840. // OldStatus returns the old "status" field's value of the Label entity.
  17841. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17843. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17844. if !m.op.Is(OpUpdateOne) {
  17845. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17846. }
  17847. if m.id == nil || m.oldValue == nil {
  17848. return v, errors.New("OldStatus requires an ID field in the mutation")
  17849. }
  17850. oldValue, err := m.oldValue(ctx)
  17851. if err != nil {
  17852. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17853. }
  17854. return oldValue.Status, nil
  17855. }
  17856. // AddStatus adds u to the "status" field.
  17857. func (m *LabelMutation) AddStatus(u int8) {
  17858. if m.addstatus != nil {
  17859. *m.addstatus += u
  17860. } else {
  17861. m.addstatus = &u
  17862. }
  17863. }
  17864. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17865. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  17866. v := m.addstatus
  17867. if v == nil {
  17868. return
  17869. }
  17870. return *v, true
  17871. }
  17872. // ClearStatus clears the value of the "status" field.
  17873. func (m *LabelMutation) ClearStatus() {
  17874. m.status = nil
  17875. m.addstatus = nil
  17876. m.clearedFields[label.FieldStatus] = struct{}{}
  17877. }
  17878. // StatusCleared returns if the "status" field was cleared in this mutation.
  17879. func (m *LabelMutation) StatusCleared() bool {
  17880. _, ok := m.clearedFields[label.FieldStatus]
  17881. return ok
  17882. }
  17883. // ResetStatus resets all changes to the "status" field.
  17884. func (m *LabelMutation) ResetStatus() {
  17885. m.status = nil
  17886. m.addstatus = nil
  17887. delete(m.clearedFields, label.FieldStatus)
  17888. }
  17889. // SetType sets the "type" field.
  17890. func (m *LabelMutation) SetType(i int) {
  17891. m._type = &i
  17892. m.add_type = nil
  17893. }
  17894. // GetType returns the value of the "type" field in the mutation.
  17895. func (m *LabelMutation) GetType() (r int, exists bool) {
  17896. v := m._type
  17897. if v == nil {
  17898. return
  17899. }
  17900. return *v, true
  17901. }
  17902. // OldType returns the old "type" field's value of the Label entity.
  17903. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17905. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  17906. if !m.op.Is(OpUpdateOne) {
  17907. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17908. }
  17909. if m.id == nil || m.oldValue == nil {
  17910. return v, errors.New("OldType requires an ID field in the mutation")
  17911. }
  17912. oldValue, err := m.oldValue(ctx)
  17913. if err != nil {
  17914. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17915. }
  17916. return oldValue.Type, nil
  17917. }
  17918. // AddType adds i to the "type" field.
  17919. func (m *LabelMutation) AddType(i int) {
  17920. if m.add_type != nil {
  17921. *m.add_type += i
  17922. } else {
  17923. m.add_type = &i
  17924. }
  17925. }
  17926. // AddedType returns the value that was added to the "type" field in this mutation.
  17927. func (m *LabelMutation) AddedType() (r int, exists bool) {
  17928. v := m.add_type
  17929. if v == nil {
  17930. return
  17931. }
  17932. return *v, true
  17933. }
  17934. // ResetType resets all changes to the "type" field.
  17935. func (m *LabelMutation) ResetType() {
  17936. m._type = nil
  17937. m.add_type = nil
  17938. }
  17939. // SetName sets the "name" field.
  17940. func (m *LabelMutation) SetName(s string) {
  17941. m.name = &s
  17942. }
  17943. // Name returns the value of the "name" field in the mutation.
  17944. func (m *LabelMutation) Name() (r string, exists bool) {
  17945. v := m.name
  17946. if v == nil {
  17947. return
  17948. }
  17949. return *v, true
  17950. }
  17951. // OldName returns the old "name" field's value of the Label entity.
  17952. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17954. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  17955. if !m.op.Is(OpUpdateOne) {
  17956. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17957. }
  17958. if m.id == nil || m.oldValue == nil {
  17959. return v, errors.New("OldName requires an ID field in the mutation")
  17960. }
  17961. oldValue, err := m.oldValue(ctx)
  17962. if err != nil {
  17963. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17964. }
  17965. return oldValue.Name, nil
  17966. }
  17967. // ResetName resets all changes to the "name" field.
  17968. func (m *LabelMutation) ResetName() {
  17969. m.name = nil
  17970. }
  17971. // SetFrom sets the "from" field.
  17972. func (m *LabelMutation) SetFrom(i int) {
  17973. m.from = &i
  17974. m.addfrom = nil
  17975. }
  17976. // From returns the value of the "from" field in the mutation.
  17977. func (m *LabelMutation) From() (r int, exists bool) {
  17978. v := m.from
  17979. if v == nil {
  17980. return
  17981. }
  17982. return *v, true
  17983. }
  17984. // OldFrom returns the old "from" field's value of the Label entity.
  17985. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17987. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  17988. if !m.op.Is(OpUpdateOne) {
  17989. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  17990. }
  17991. if m.id == nil || m.oldValue == nil {
  17992. return v, errors.New("OldFrom requires an ID field in the mutation")
  17993. }
  17994. oldValue, err := m.oldValue(ctx)
  17995. if err != nil {
  17996. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  17997. }
  17998. return oldValue.From, nil
  17999. }
  18000. // AddFrom adds i to the "from" field.
  18001. func (m *LabelMutation) AddFrom(i int) {
  18002. if m.addfrom != nil {
  18003. *m.addfrom += i
  18004. } else {
  18005. m.addfrom = &i
  18006. }
  18007. }
  18008. // AddedFrom returns the value that was added to the "from" field in this mutation.
  18009. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  18010. v := m.addfrom
  18011. if v == nil {
  18012. return
  18013. }
  18014. return *v, true
  18015. }
  18016. // ResetFrom resets all changes to the "from" field.
  18017. func (m *LabelMutation) ResetFrom() {
  18018. m.from = nil
  18019. m.addfrom = nil
  18020. }
  18021. // SetMode sets the "mode" field.
  18022. func (m *LabelMutation) SetMode(i int) {
  18023. m.mode = &i
  18024. m.addmode = nil
  18025. }
  18026. // Mode returns the value of the "mode" field in the mutation.
  18027. func (m *LabelMutation) Mode() (r int, exists bool) {
  18028. v := m.mode
  18029. if v == nil {
  18030. return
  18031. }
  18032. return *v, true
  18033. }
  18034. // OldMode returns the old "mode" field's value of the Label entity.
  18035. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18037. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  18038. if !m.op.Is(OpUpdateOne) {
  18039. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  18040. }
  18041. if m.id == nil || m.oldValue == nil {
  18042. return v, errors.New("OldMode requires an ID field in the mutation")
  18043. }
  18044. oldValue, err := m.oldValue(ctx)
  18045. if err != nil {
  18046. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  18047. }
  18048. return oldValue.Mode, nil
  18049. }
  18050. // AddMode adds i to the "mode" field.
  18051. func (m *LabelMutation) AddMode(i int) {
  18052. if m.addmode != nil {
  18053. *m.addmode += i
  18054. } else {
  18055. m.addmode = &i
  18056. }
  18057. }
  18058. // AddedMode returns the value that was added to the "mode" field in this mutation.
  18059. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  18060. v := m.addmode
  18061. if v == nil {
  18062. return
  18063. }
  18064. return *v, true
  18065. }
  18066. // ResetMode resets all changes to the "mode" field.
  18067. func (m *LabelMutation) ResetMode() {
  18068. m.mode = nil
  18069. m.addmode = nil
  18070. }
  18071. // SetConditions sets the "conditions" field.
  18072. func (m *LabelMutation) SetConditions(s string) {
  18073. m.conditions = &s
  18074. }
  18075. // Conditions returns the value of the "conditions" field in the mutation.
  18076. func (m *LabelMutation) Conditions() (r string, exists bool) {
  18077. v := m.conditions
  18078. if v == nil {
  18079. return
  18080. }
  18081. return *v, true
  18082. }
  18083. // OldConditions returns the old "conditions" field's value of the Label entity.
  18084. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18086. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  18087. if !m.op.Is(OpUpdateOne) {
  18088. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  18089. }
  18090. if m.id == nil || m.oldValue == nil {
  18091. return v, errors.New("OldConditions requires an ID field in the mutation")
  18092. }
  18093. oldValue, err := m.oldValue(ctx)
  18094. if err != nil {
  18095. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  18096. }
  18097. return oldValue.Conditions, nil
  18098. }
  18099. // ClearConditions clears the value of the "conditions" field.
  18100. func (m *LabelMutation) ClearConditions() {
  18101. m.conditions = nil
  18102. m.clearedFields[label.FieldConditions] = struct{}{}
  18103. }
  18104. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  18105. func (m *LabelMutation) ConditionsCleared() bool {
  18106. _, ok := m.clearedFields[label.FieldConditions]
  18107. return ok
  18108. }
  18109. // ResetConditions resets all changes to the "conditions" field.
  18110. func (m *LabelMutation) ResetConditions() {
  18111. m.conditions = nil
  18112. delete(m.clearedFields, label.FieldConditions)
  18113. }
  18114. // SetOrganizationID sets the "organization_id" field.
  18115. func (m *LabelMutation) SetOrganizationID(u uint64) {
  18116. m.organization_id = &u
  18117. m.addorganization_id = nil
  18118. }
  18119. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18120. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  18121. v := m.organization_id
  18122. if v == nil {
  18123. return
  18124. }
  18125. return *v, true
  18126. }
  18127. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  18128. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18130. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18131. if !m.op.Is(OpUpdateOne) {
  18132. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18133. }
  18134. if m.id == nil || m.oldValue == nil {
  18135. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18136. }
  18137. oldValue, err := m.oldValue(ctx)
  18138. if err != nil {
  18139. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18140. }
  18141. return oldValue.OrganizationID, nil
  18142. }
  18143. // AddOrganizationID adds u to the "organization_id" field.
  18144. func (m *LabelMutation) AddOrganizationID(u int64) {
  18145. if m.addorganization_id != nil {
  18146. *m.addorganization_id += u
  18147. } else {
  18148. m.addorganization_id = &u
  18149. }
  18150. }
  18151. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18152. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  18153. v := m.addorganization_id
  18154. if v == nil {
  18155. return
  18156. }
  18157. return *v, true
  18158. }
  18159. // ClearOrganizationID clears the value of the "organization_id" field.
  18160. func (m *LabelMutation) ClearOrganizationID() {
  18161. m.organization_id = nil
  18162. m.addorganization_id = nil
  18163. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  18164. }
  18165. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18166. func (m *LabelMutation) OrganizationIDCleared() bool {
  18167. _, ok := m.clearedFields[label.FieldOrganizationID]
  18168. return ok
  18169. }
  18170. // ResetOrganizationID resets all changes to the "organization_id" field.
  18171. func (m *LabelMutation) ResetOrganizationID() {
  18172. m.organization_id = nil
  18173. m.addorganization_id = nil
  18174. delete(m.clearedFields, label.FieldOrganizationID)
  18175. }
  18176. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  18177. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  18178. if m.label_relationships == nil {
  18179. m.label_relationships = make(map[uint64]struct{})
  18180. }
  18181. for i := range ids {
  18182. m.label_relationships[ids[i]] = struct{}{}
  18183. }
  18184. }
  18185. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  18186. func (m *LabelMutation) ClearLabelRelationships() {
  18187. m.clearedlabel_relationships = true
  18188. }
  18189. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  18190. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  18191. return m.clearedlabel_relationships
  18192. }
  18193. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  18194. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  18195. if m.removedlabel_relationships == nil {
  18196. m.removedlabel_relationships = make(map[uint64]struct{})
  18197. }
  18198. for i := range ids {
  18199. delete(m.label_relationships, ids[i])
  18200. m.removedlabel_relationships[ids[i]] = struct{}{}
  18201. }
  18202. }
  18203. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  18204. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  18205. for id := range m.removedlabel_relationships {
  18206. ids = append(ids, id)
  18207. }
  18208. return
  18209. }
  18210. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  18211. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  18212. for id := range m.label_relationships {
  18213. ids = append(ids, id)
  18214. }
  18215. return
  18216. }
  18217. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  18218. func (m *LabelMutation) ResetLabelRelationships() {
  18219. m.label_relationships = nil
  18220. m.clearedlabel_relationships = false
  18221. m.removedlabel_relationships = nil
  18222. }
  18223. // Where appends a list predicates to the LabelMutation builder.
  18224. func (m *LabelMutation) Where(ps ...predicate.Label) {
  18225. m.predicates = append(m.predicates, ps...)
  18226. }
  18227. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  18228. // users can use type-assertion to append predicates that do not depend on any generated package.
  18229. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  18230. p := make([]predicate.Label, len(ps))
  18231. for i := range ps {
  18232. p[i] = ps[i]
  18233. }
  18234. m.Where(p...)
  18235. }
  18236. // Op returns the operation name.
  18237. func (m *LabelMutation) Op() Op {
  18238. return m.op
  18239. }
  18240. // SetOp allows setting the mutation operation.
  18241. func (m *LabelMutation) SetOp(op Op) {
  18242. m.op = op
  18243. }
  18244. // Type returns the node type of this mutation (Label).
  18245. func (m *LabelMutation) Type() string {
  18246. return m.typ
  18247. }
  18248. // Fields returns all fields that were changed during this mutation. Note that in
  18249. // order to get all numeric fields that were incremented/decremented, call
  18250. // AddedFields().
  18251. func (m *LabelMutation) Fields() []string {
  18252. fields := make([]string, 0, 9)
  18253. if m.created_at != nil {
  18254. fields = append(fields, label.FieldCreatedAt)
  18255. }
  18256. if m.updated_at != nil {
  18257. fields = append(fields, label.FieldUpdatedAt)
  18258. }
  18259. if m.status != nil {
  18260. fields = append(fields, label.FieldStatus)
  18261. }
  18262. if m._type != nil {
  18263. fields = append(fields, label.FieldType)
  18264. }
  18265. if m.name != nil {
  18266. fields = append(fields, label.FieldName)
  18267. }
  18268. if m.from != nil {
  18269. fields = append(fields, label.FieldFrom)
  18270. }
  18271. if m.mode != nil {
  18272. fields = append(fields, label.FieldMode)
  18273. }
  18274. if m.conditions != nil {
  18275. fields = append(fields, label.FieldConditions)
  18276. }
  18277. if m.organization_id != nil {
  18278. fields = append(fields, label.FieldOrganizationID)
  18279. }
  18280. return fields
  18281. }
  18282. // Field returns the value of a field with the given name. The second boolean
  18283. // return value indicates that this field was not set, or was not defined in the
  18284. // schema.
  18285. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  18286. switch name {
  18287. case label.FieldCreatedAt:
  18288. return m.CreatedAt()
  18289. case label.FieldUpdatedAt:
  18290. return m.UpdatedAt()
  18291. case label.FieldStatus:
  18292. return m.Status()
  18293. case label.FieldType:
  18294. return m.GetType()
  18295. case label.FieldName:
  18296. return m.Name()
  18297. case label.FieldFrom:
  18298. return m.From()
  18299. case label.FieldMode:
  18300. return m.Mode()
  18301. case label.FieldConditions:
  18302. return m.Conditions()
  18303. case label.FieldOrganizationID:
  18304. return m.OrganizationID()
  18305. }
  18306. return nil, false
  18307. }
  18308. // OldField returns the old value of the field from the database. An error is
  18309. // returned if the mutation operation is not UpdateOne, or the query to the
  18310. // database failed.
  18311. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18312. switch name {
  18313. case label.FieldCreatedAt:
  18314. return m.OldCreatedAt(ctx)
  18315. case label.FieldUpdatedAt:
  18316. return m.OldUpdatedAt(ctx)
  18317. case label.FieldStatus:
  18318. return m.OldStatus(ctx)
  18319. case label.FieldType:
  18320. return m.OldType(ctx)
  18321. case label.FieldName:
  18322. return m.OldName(ctx)
  18323. case label.FieldFrom:
  18324. return m.OldFrom(ctx)
  18325. case label.FieldMode:
  18326. return m.OldMode(ctx)
  18327. case label.FieldConditions:
  18328. return m.OldConditions(ctx)
  18329. case label.FieldOrganizationID:
  18330. return m.OldOrganizationID(ctx)
  18331. }
  18332. return nil, fmt.Errorf("unknown Label field %s", name)
  18333. }
  18334. // SetField sets the value of a field with the given name. It returns an error if
  18335. // the field is not defined in the schema, or if the type mismatched the field
  18336. // type.
  18337. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  18338. switch name {
  18339. case label.FieldCreatedAt:
  18340. v, ok := value.(time.Time)
  18341. if !ok {
  18342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18343. }
  18344. m.SetCreatedAt(v)
  18345. return nil
  18346. case label.FieldUpdatedAt:
  18347. v, ok := value.(time.Time)
  18348. if !ok {
  18349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18350. }
  18351. m.SetUpdatedAt(v)
  18352. return nil
  18353. case label.FieldStatus:
  18354. v, ok := value.(uint8)
  18355. if !ok {
  18356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18357. }
  18358. m.SetStatus(v)
  18359. return nil
  18360. case label.FieldType:
  18361. v, ok := value.(int)
  18362. if !ok {
  18363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18364. }
  18365. m.SetType(v)
  18366. return nil
  18367. case label.FieldName:
  18368. v, ok := value.(string)
  18369. if !ok {
  18370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18371. }
  18372. m.SetName(v)
  18373. return nil
  18374. case label.FieldFrom:
  18375. v, ok := value.(int)
  18376. if !ok {
  18377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18378. }
  18379. m.SetFrom(v)
  18380. return nil
  18381. case label.FieldMode:
  18382. v, ok := value.(int)
  18383. if !ok {
  18384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18385. }
  18386. m.SetMode(v)
  18387. return nil
  18388. case label.FieldConditions:
  18389. v, ok := value.(string)
  18390. if !ok {
  18391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18392. }
  18393. m.SetConditions(v)
  18394. return nil
  18395. case label.FieldOrganizationID:
  18396. v, ok := value.(uint64)
  18397. if !ok {
  18398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18399. }
  18400. m.SetOrganizationID(v)
  18401. return nil
  18402. }
  18403. return fmt.Errorf("unknown Label field %s", name)
  18404. }
  18405. // AddedFields returns all numeric fields that were incremented/decremented during
  18406. // this mutation.
  18407. func (m *LabelMutation) AddedFields() []string {
  18408. var fields []string
  18409. if m.addstatus != nil {
  18410. fields = append(fields, label.FieldStatus)
  18411. }
  18412. if m.add_type != nil {
  18413. fields = append(fields, label.FieldType)
  18414. }
  18415. if m.addfrom != nil {
  18416. fields = append(fields, label.FieldFrom)
  18417. }
  18418. if m.addmode != nil {
  18419. fields = append(fields, label.FieldMode)
  18420. }
  18421. if m.addorganization_id != nil {
  18422. fields = append(fields, label.FieldOrganizationID)
  18423. }
  18424. return fields
  18425. }
  18426. // AddedField returns the numeric value that was incremented/decremented on a field
  18427. // with the given name. The second boolean return value indicates that this field
  18428. // was not set, or was not defined in the schema.
  18429. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  18430. switch name {
  18431. case label.FieldStatus:
  18432. return m.AddedStatus()
  18433. case label.FieldType:
  18434. return m.AddedType()
  18435. case label.FieldFrom:
  18436. return m.AddedFrom()
  18437. case label.FieldMode:
  18438. return m.AddedMode()
  18439. case label.FieldOrganizationID:
  18440. return m.AddedOrganizationID()
  18441. }
  18442. return nil, false
  18443. }
  18444. // AddField adds the value to the field with the given name. It returns an error if
  18445. // the field is not defined in the schema, or if the type mismatched the field
  18446. // type.
  18447. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  18448. switch name {
  18449. case label.FieldStatus:
  18450. v, ok := value.(int8)
  18451. if !ok {
  18452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18453. }
  18454. m.AddStatus(v)
  18455. return nil
  18456. case label.FieldType:
  18457. v, ok := value.(int)
  18458. if !ok {
  18459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18460. }
  18461. m.AddType(v)
  18462. return nil
  18463. case label.FieldFrom:
  18464. v, ok := value.(int)
  18465. if !ok {
  18466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18467. }
  18468. m.AddFrom(v)
  18469. return nil
  18470. case label.FieldMode:
  18471. v, ok := value.(int)
  18472. if !ok {
  18473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18474. }
  18475. m.AddMode(v)
  18476. return nil
  18477. case label.FieldOrganizationID:
  18478. v, ok := value.(int64)
  18479. if !ok {
  18480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18481. }
  18482. m.AddOrganizationID(v)
  18483. return nil
  18484. }
  18485. return fmt.Errorf("unknown Label numeric field %s", name)
  18486. }
  18487. // ClearedFields returns all nullable fields that were cleared during this
  18488. // mutation.
  18489. func (m *LabelMutation) ClearedFields() []string {
  18490. var fields []string
  18491. if m.FieldCleared(label.FieldStatus) {
  18492. fields = append(fields, label.FieldStatus)
  18493. }
  18494. if m.FieldCleared(label.FieldConditions) {
  18495. fields = append(fields, label.FieldConditions)
  18496. }
  18497. if m.FieldCleared(label.FieldOrganizationID) {
  18498. fields = append(fields, label.FieldOrganizationID)
  18499. }
  18500. return fields
  18501. }
  18502. // FieldCleared returns a boolean indicating if a field with the given name was
  18503. // cleared in this mutation.
  18504. func (m *LabelMutation) FieldCleared(name string) bool {
  18505. _, ok := m.clearedFields[name]
  18506. return ok
  18507. }
  18508. // ClearField clears the value of the field with the given name. It returns an
  18509. // error if the field is not defined in the schema.
  18510. func (m *LabelMutation) ClearField(name string) error {
  18511. switch name {
  18512. case label.FieldStatus:
  18513. m.ClearStatus()
  18514. return nil
  18515. case label.FieldConditions:
  18516. m.ClearConditions()
  18517. return nil
  18518. case label.FieldOrganizationID:
  18519. m.ClearOrganizationID()
  18520. return nil
  18521. }
  18522. return fmt.Errorf("unknown Label nullable field %s", name)
  18523. }
  18524. // ResetField resets all changes in the mutation for the field with the given name.
  18525. // It returns an error if the field is not defined in the schema.
  18526. func (m *LabelMutation) ResetField(name string) error {
  18527. switch name {
  18528. case label.FieldCreatedAt:
  18529. m.ResetCreatedAt()
  18530. return nil
  18531. case label.FieldUpdatedAt:
  18532. m.ResetUpdatedAt()
  18533. return nil
  18534. case label.FieldStatus:
  18535. m.ResetStatus()
  18536. return nil
  18537. case label.FieldType:
  18538. m.ResetType()
  18539. return nil
  18540. case label.FieldName:
  18541. m.ResetName()
  18542. return nil
  18543. case label.FieldFrom:
  18544. m.ResetFrom()
  18545. return nil
  18546. case label.FieldMode:
  18547. m.ResetMode()
  18548. return nil
  18549. case label.FieldConditions:
  18550. m.ResetConditions()
  18551. return nil
  18552. case label.FieldOrganizationID:
  18553. m.ResetOrganizationID()
  18554. return nil
  18555. }
  18556. return fmt.Errorf("unknown Label field %s", name)
  18557. }
  18558. // AddedEdges returns all edge names that were set/added in this mutation.
  18559. func (m *LabelMutation) AddedEdges() []string {
  18560. edges := make([]string, 0, 1)
  18561. if m.label_relationships != nil {
  18562. edges = append(edges, label.EdgeLabelRelationships)
  18563. }
  18564. return edges
  18565. }
  18566. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18567. // name in this mutation.
  18568. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  18569. switch name {
  18570. case label.EdgeLabelRelationships:
  18571. ids := make([]ent.Value, 0, len(m.label_relationships))
  18572. for id := range m.label_relationships {
  18573. ids = append(ids, id)
  18574. }
  18575. return ids
  18576. }
  18577. return nil
  18578. }
  18579. // RemovedEdges returns all edge names that were removed in this mutation.
  18580. func (m *LabelMutation) RemovedEdges() []string {
  18581. edges := make([]string, 0, 1)
  18582. if m.removedlabel_relationships != nil {
  18583. edges = append(edges, label.EdgeLabelRelationships)
  18584. }
  18585. return edges
  18586. }
  18587. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18588. // the given name in this mutation.
  18589. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  18590. switch name {
  18591. case label.EdgeLabelRelationships:
  18592. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  18593. for id := range m.removedlabel_relationships {
  18594. ids = append(ids, id)
  18595. }
  18596. return ids
  18597. }
  18598. return nil
  18599. }
  18600. // ClearedEdges returns all edge names that were cleared in this mutation.
  18601. func (m *LabelMutation) ClearedEdges() []string {
  18602. edges := make([]string, 0, 1)
  18603. if m.clearedlabel_relationships {
  18604. edges = append(edges, label.EdgeLabelRelationships)
  18605. }
  18606. return edges
  18607. }
  18608. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18609. // was cleared in this mutation.
  18610. func (m *LabelMutation) EdgeCleared(name string) bool {
  18611. switch name {
  18612. case label.EdgeLabelRelationships:
  18613. return m.clearedlabel_relationships
  18614. }
  18615. return false
  18616. }
  18617. // ClearEdge clears the value of the edge with the given name. It returns an error
  18618. // if that edge is not defined in the schema.
  18619. func (m *LabelMutation) ClearEdge(name string) error {
  18620. switch name {
  18621. }
  18622. return fmt.Errorf("unknown Label unique edge %s", name)
  18623. }
  18624. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18625. // It returns an error if the edge is not defined in the schema.
  18626. func (m *LabelMutation) ResetEdge(name string) error {
  18627. switch name {
  18628. case label.EdgeLabelRelationships:
  18629. m.ResetLabelRelationships()
  18630. return nil
  18631. }
  18632. return fmt.Errorf("unknown Label edge %s", name)
  18633. }
  18634. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  18635. type LabelRelationshipMutation struct {
  18636. config
  18637. op Op
  18638. typ string
  18639. id *uint64
  18640. created_at *time.Time
  18641. updated_at *time.Time
  18642. status *uint8
  18643. addstatus *int8
  18644. organization_id *uint64
  18645. addorganization_id *int64
  18646. clearedFields map[string]struct{}
  18647. contacts *uint64
  18648. clearedcontacts bool
  18649. labels *uint64
  18650. clearedlabels bool
  18651. done bool
  18652. oldValue func(context.Context) (*LabelRelationship, error)
  18653. predicates []predicate.LabelRelationship
  18654. }
  18655. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  18656. // labelrelationshipOption allows management of the mutation configuration using functional options.
  18657. type labelrelationshipOption func(*LabelRelationshipMutation)
  18658. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  18659. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  18660. m := &LabelRelationshipMutation{
  18661. config: c,
  18662. op: op,
  18663. typ: TypeLabelRelationship,
  18664. clearedFields: make(map[string]struct{}),
  18665. }
  18666. for _, opt := range opts {
  18667. opt(m)
  18668. }
  18669. return m
  18670. }
  18671. // withLabelRelationshipID sets the ID field of the mutation.
  18672. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  18673. return func(m *LabelRelationshipMutation) {
  18674. var (
  18675. err error
  18676. once sync.Once
  18677. value *LabelRelationship
  18678. )
  18679. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  18680. once.Do(func() {
  18681. if m.done {
  18682. err = errors.New("querying old values post mutation is not allowed")
  18683. } else {
  18684. value, err = m.Client().LabelRelationship.Get(ctx, id)
  18685. }
  18686. })
  18687. return value, err
  18688. }
  18689. m.id = &id
  18690. }
  18691. }
  18692. // withLabelRelationship sets the old LabelRelationship of the mutation.
  18693. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  18694. return func(m *LabelRelationshipMutation) {
  18695. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  18696. return node, nil
  18697. }
  18698. m.id = &node.ID
  18699. }
  18700. }
  18701. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18702. // executed in a transaction (ent.Tx), a transactional client is returned.
  18703. func (m LabelRelationshipMutation) Client() *Client {
  18704. client := &Client{config: m.config}
  18705. client.init()
  18706. return client
  18707. }
  18708. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18709. // it returns an error otherwise.
  18710. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  18711. if _, ok := m.driver.(*txDriver); !ok {
  18712. return nil, errors.New("ent: mutation is not running in a transaction")
  18713. }
  18714. tx := &Tx{config: m.config}
  18715. tx.init()
  18716. return tx, nil
  18717. }
  18718. // SetID sets the value of the id field. Note that this
  18719. // operation is only accepted on creation of LabelRelationship entities.
  18720. func (m *LabelRelationshipMutation) SetID(id uint64) {
  18721. m.id = &id
  18722. }
  18723. // ID returns the ID value in the mutation. Note that the ID is only available
  18724. // if it was provided to the builder or after it was returned from the database.
  18725. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  18726. if m.id == nil {
  18727. return
  18728. }
  18729. return *m.id, true
  18730. }
  18731. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18732. // That means, if the mutation is applied within a transaction with an isolation level such
  18733. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18734. // or updated by the mutation.
  18735. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  18736. switch {
  18737. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18738. id, exists := m.ID()
  18739. if exists {
  18740. return []uint64{id}, nil
  18741. }
  18742. fallthrough
  18743. case m.op.Is(OpUpdate | OpDelete):
  18744. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  18745. default:
  18746. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18747. }
  18748. }
  18749. // SetCreatedAt sets the "created_at" field.
  18750. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  18751. m.created_at = &t
  18752. }
  18753. // CreatedAt returns the value of the "created_at" field in the mutation.
  18754. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  18755. v := m.created_at
  18756. if v == nil {
  18757. return
  18758. }
  18759. return *v, true
  18760. }
  18761. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  18762. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18764. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18765. if !m.op.Is(OpUpdateOne) {
  18766. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18767. }
  18768. if m.id == nil || m.oldValue == nil {
  18769. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18770. }
  18771. oldValue, err := m.oldValue(ctx)
  18772. if err != nil {
  18773. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18774. }
  18775. return oldValue.CreatedAt, nil
  18776. }
  18777. // ResetCreatedAt resets all changes to the "created_at" field.
  18778. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  18779. m.created_at = nil
  18780. }
  18781. // SetUpdatedAt sets the "updated_at" field.
  18782. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  18783. m.updated_at = &t
  18784. }
  18785. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18786. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  18787. v := m.updated_at
  18788. if v == nil {
  18789. return
  18790. }
  18791. return *v, true
  18792. }
  18793. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  18794. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18796. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18797. if !m.op.Is(OpUpdateOne) {
  18798. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18799. }
  18800. if m.id == nil || m.oldValue == nil {
  18801. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18802. }
  18803. oldValue, err := m.oldValue(ctx)
  18804. if err != nil {
  18805. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18806. }
  18807. return oldValue.UpdatedAt, nil
  18808. }
  18809. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18810. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  18811. m.updated_at = nil
  18812. }
  18813. // SetStatus sets the "status" field.
  18814. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  18815. m.status = &u
  18816. m.addstatus = nil
  18817. }
  18818. // Status returns the value of the "status" field in the mutation.
  18819. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  18820. v := m.status
  18821. if v == nil {
  18822. return
  18823. }
  18824. return *v, true
  18825. }
  18826. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  18827. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18829. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18830. if !m.op.Is(OpUpdateOne) {
  18831. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18832. }
  18833. if m.id == nil || m.oldValue == nil {
  18834. return v, errors.New("OldStatus requires an ID field in the mutation")
  18835. }
  18836. oldValue, err := m.oldValue(ctx)
  18837. if err != nil {
  18838. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18839. }
  18840. return oldValue.Status, nil
  18841. }
  18842. // AddStatus adds u to the "status" field.
  18843. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  18844. if m.addstatus != nil {
  18845. *m.addstatus += u
  18846. } else {
  18847. m.addstatus = &u
  18848. }
  18849. }
  18850. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18851. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  18852. v := m.addstatus
  18853. if v == nil {
  18854. return
  18855. }
  18856. return *v, true
  18857. }
  18858. // ClearStatus clears the value of the "status" field.
  18859. func (m *LabelRelationshipMutation) ClearStatus() {
  18860. m.status = nil
  18861. m.addstatus = nil
  18862. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  18863. }
  18864. // StatusCleared returns if the "status" field was cleared in this mutation.
  18865. func (m *LabelRelationshipMutation) StatusCleared() bool {
  18866. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  18867. return ok
  18868. }
  18869. // ResetStatus resets all changes to the "status" field.
  18870. func (m *LabelRelationshipMutation) ResetStatus() {
  18871. m.status = nil
  18872. m.addstatus = nil
  18873. delete(m.clearedFields, labelrelationship.FieldStatus)
  18874. }
  18875. // SetLabelID sets the "label_id" field.
  18876. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  18877. m.labels = &u
  18878. }
  18879. // LabelID returns the value of the "label_id" field in the mutation.
  18880. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  18881. v := m.labels
  18882. if v == nil {
  18883. return
  18884. }
  18885. return *v, true
  18886. }
  18887. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  18888. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18890. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  18891. if !m.op.Is(OpUpdateOne) {
  18892. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  18893. }
  18894. if m.id == nil || m.oldValue == nil {
  18895. return v, errors.New("OldLabelID requires an ID field in the mutation")
  18896. }
  18897. oldValue, err := m.oldValue(ctx)
  18898. if err != nil {
  18899. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  18900. }
  18901. return oldValue.LabelID, nil
  18902. }
  18903. // ResetLabelID resets all changes to the "label_id" field.
  18904. func (m *LabelRelationshipMutation) ResetLabelID() {
  18905. m.labels = nil
  18906. }
  18907. // SetContactID sets the "contact_id" field.
  18908. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  18909. m.contacts = &u
  18910. }
  18911. // ContactID returns the value of the "contact_id" field in the mutation.
  18912. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  18913. v := m.contacts
  18914. if v == nil {
  18915. return
  18916. }
  18917. return *v, true
  18918. }
  18919. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  18920. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18922. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  18923. if !m.op.Is(OpUpdateOne) {
  18924. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  18925. }
  18926. if m.id == nil || m.oldValue == nil {
  18927. return v, errors.New("OldContactID requires an ID field in the mutation")
  18928. }
  18929. oldValue, err := m.oldValue(ctx)
  18930. if err != nil {
  18931. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  18932. }
  18933. return oldValue.ContactID, nil
  18934. }
  18935. // ResetContactID resets all changes to the "contact_id" field.
  18936. func (m *LabelRelationshipMutation) ResetContactID() {
  18937. m.contacts = nil
  18938. }
  18939. // SetOrganizationID sets the "organization_id" field.
  18940. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  18941. m.organization_id = &u
  18942. m.addorganization_id = nil
  18943. }
  18944. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18945. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  18946. v := m.organization_id
  18947. if v == nil {
  18948. return
  18949. }
  18950. return *v, true
  18951. }
  18952. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  18953. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18955. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18956. if !m.op.Is(OpUpdateOne) {
  18957. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18958. }
  18959. if m.id == nil || m.oldValue == nil {
  18960. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18961. }
  18962. oldValue, err := m.oldValue(ctx)
  18963. if err != nil {
  18964. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18965. }
  18966. return oldValue.OrganizationID, nil
  18967. }
  18968. // AddOrganizationID adds u to the "organization_id" field.
  18969. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  18970. if m.addorganization_id != nil {
  18971. *m.addorganization_id += u
  18972. } else {
  18973. m.addorganization_id = &u
  18974. }
  18975. }
  18976. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18977. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  18978. v := m.addorganization_id
  18979. if v == nil {
  18980. return
  18981. }
  18982. return *v, true
  18983. }
  18984. // ClearOrganizationID clears the value of the "organization_id" field.
  18985. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  18986. m.organization_id = nil
  18987. m.addorganization_id = nil
  18988. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  18989. }
  18990. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18991. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  18992. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  18993. return ok
  18994. }
  18995. // ResetOrganizationID resets all changes to the "organization_id" field.
  18996. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  18997. m.organization_id = nil
  18998. m.addorganization_id = nil
  18999. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  19000. }
  19001. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  19002. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  19003. m.contacts = &id
  19004. }
  19005. // ClearContacts clears the "contacts" edge to the Contact entity.
  19006. func (m *LabelRelationshipMutation) ClearContacts() {
  19007. m.clearedcontacts = true
  19008. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  19009. }
  19010. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  19011. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  19012. return m.clearedcontacts
  19013. }
  19014. // ContactsID returns the "contacts" edge ID in the mutation.
  19015. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  19016. if m.contacts != nil {
  19017. return *m.contacts, true
  19018. }
  19019. return
  19020. }
  19021. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  19022. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19023. // ContactsID instead. It exists only for internal usage by the builders.
  19024. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  19025. if id := m.contacts; id != nil {
  19026. ids = append(ids, *id)
  19027. }
  19028. return
  19029. }
  19030. // ResetContacts resets all changes to the "contacts" edge.
  19031. func (m *LabelRelationshipMutation) ResetContacts() {
  19032. m.contacts = nil
  19033. m.clearedcontacts = false
  19034. }
  19035. // SetLabelsID sets the "labels" edge to the Label entity by id.
  19036. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  19037. m.labels = &id
  19038. }
  19039. // ClearLabels clears the "labels" edge to the Label entity.
  19040. func (m *LabelRelationshipMutation) ClearLabels() {
  19041. m.clearedlabels = true
  19042. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  19043. }
  19044. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  19045. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  19046. return m.clearedlabels
  19047. }
  19048. // LabelsID returns the "labels" edge ID in the mutation.
  19049. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  19050. if m.labels != nil {
  19051. return *m.labels, true
  19052. }
  19053. return
  19054. }
  19055. // LabelsIDs returns the "labels" edge IDs in the mutation.
  19056. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19057. // LabelsID instead. It exists only for internal usage by the builders.
  19058. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  19059. if id := m.labels; id != nil {
  19060. ids = append(ids, *id)
  19061. }
  19062. return
  19063. }
  19064. // ResetLabels resets all changes to the "labels" edge.
  19065. func (m *LabelRelationshipMutation) ResetLabels() {
  19066. m.labels = nil
  19067. m.clearedlabels = false
  19068. }
  19069. // Where appends a list predicates to the LabelRelationshipMutation builder.
  19070. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  19071. m.predicates = append(m.predicates, ps...)
  19072. }
  19073. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  19074. // users can use type-assertion to append predicates that do not depend on any generated package.
  19075. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  19076. p := make([]predicate.LabelRelationship, len(ps))
  19077. for i := range ps {
  19078. p[i] = ps[i]
  19079. }
  19080. m.Where(p...)
  19081. }
  19082. // Op returns the operation name.
  19083. func (m *LabelRelationshipMutation) Op() Op {
  19084. return m.op
  19085. }
  19086. // SetOp allows setting the mutation operation.
  19087. func (m *LabelRelationshipMutation) SetOp(op Op) {
  19088. m.op = op
  19089. }
  19090. // Type returns the node type of this mutation (LabelRelationship).
  19091. func (m *LabelRelationshipMutation) Type() string {
  19092. return m.typ
  19093. }
  19094. // Fields returns all fields that were changed during this mutation. Note that in
  19095. // order to get all numeric fields that were incremented/decremented, call
  19096. // AddedFields().
  19097. func (m *LabelRelationshipMutation) Fields() []string {
  19098. fields := make([]string, 0, 6)
  19099. if m.created_at != nil {
  19100. fields = append(fields, labelrelationship.FieldCreatedAt)
  19101. }
  19102. if m.updated_at != nil {
  19103. fields = append(fields, labelrelationship.FieldUpdatedAt)
  19104. }
  19105. if m.status != nil {
  19106. fields = append(fields, labelrelationship.FieldStatus)
  19107. }
  19108. if m.labels != nil {
  19109. fields = append(fields, labelrelationship.FieldLabelID)
  19110. }
  19111. if m.contacts != nil {
  19112. fields = append(fields, labelrelationship.FieldContactID)
  19113. }
  19114. if m.organization_id != nil {
  19115. fields = append(fields, labelrelationship.FieldOrganizationID)
  19116. }
  19117. return fields
  19118. }
  19119. // Field returns the value of a field with the given name. The second boolean
  19120. // return value indicates that this field was not set, or was not defined in the
  19121. // schema.
  19122. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  19123. switch name {
  19124. case labelrelationship.FieldCreatedAt:
  19125. return m.CreatedAt()
  19126. case labelrelationship.FieldUpdatedAt:
  19127. return m.UpdatedAt()
  19128. case labelrelationship.FieldStatus:
  19129. return m.Status()
  19130. case labelrelationship.FieldLabelID:
  19131. return m.LabelID()
  19132. case labelrelationship.FieldContactID:
  19133. return m.ContactID()
  19134. case labelrelationship.FieldOrganizationID:
  19135. return m.OrganizationID()
  19136. }
  19137. return nil, false
  19138. }
  19139. // OldField returns the old value of the field from the database. An error is
  19140. // returned if the mutation operation is not UpdateOne, or the query to the
  19141. // database failed.
  19142. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19143. switch name {
  19144. case labelrelationship.FieldCreatedAt:
  19145. return m.OldCreatedAt(ctx)
  19146. case labelrelationship.FieldUpdatedAt:
  19147. return m.OldUpdatedAt(ctx)
  19148. case labelrelationship.FieldStatus:
  19149. return m.OldStatus(ctx)
  19150. case labelrelationship.FieldLabelID:
  19151. return m.OldLabelID(ctx)
  19152. case labelrelationship.FieldContactID:
  19153. return m.OldContactID(ctx)
  19154. case labelrelationship.FieldOrganizationID:
  19155. return m.OldOrganizationID(ctx)
  19156. }
  19157. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  19158. }
  19159. // SetField sets the value of a field with the given name. It returns an error if
  19160. // the field is not defined in the schema, or if the type mismatched the field
  19161. // type.
  19162. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  19163. switch name {
  19164. case labelrelationship.FieldCreatedAt:
  19165. v, ok := value.(time.Time)
  19166. if !ok {
  19167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19168. }
  19169. m.SetCreatedAt(v)
  19170. return nil
  19171. case labelrelationship.FieldUpdatedAt:
  19172. v, ok := value.(time.Time)
  19173. if !ok {
  19174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19175. }
  19176. m.SetUpdatedAt(v)
  19177. return nil
  19178. case labelrelationship.FieldStatus:
  19179. v, ok := value.(uint8)
  19180. if !ok {
  19181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19182. }
  19183. m.SetStatus(v)
  19184. return nil
  19185. case labelrelationship.FieldLabelID:
  19186. v, ok := value.(uint64)
  19187. if !ok {
  19188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19189. }
  19190. m.SetLabelID(v)
  19191. return nil
  19192. case labelrelationship.FieldContactID:
  19193. v, ok := value.(uint64)
  19194. if !ok {
  19195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19196. }
  19197. m.SetContactID(v)
  19198. return nil
  19199. case labelrelationship.FieldOrganizationID:
  19200. v, ok := value.(uint64)
  19201. if !ok {
  19202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19203. }
  19204. m.SetOrganizationID(v)
  19205. return nil
  19206. }
  19207. return fmt.Errorf("unknown LabelRelationship field %s", name)
  19208. }
  19209. // AddedFields returns all numeric fields that were incremented/decremented during
  19210. // this mutation.
  19211. func (m *LabelRelationshipMutation) AddedFields() []string {
  19212. var fields []string
  19213. if m.addstatus != nil {
  19214. fields = append(fields, labelrelationship.FieldStatus)
  19215. }
  19216. if m.addorganization_id != nil {
  19217. fields = append(fields, labelrelationship.FieldOrganizationID)
  19218. }
  19219. return fields
  19220. }
  19221. // AddedField returns the numeric value that was incremented/decremented on a field
  19222. // with the given name. The second boolean return value indicates that this field
  19223. // was not set, or was not defined in the schema.
  19224. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  19225. switch name {
  19226. case labelrelationship.FieldStatus:
  19227. return m.AddedStatus()
  19228. case labelrelationship.FieldOrganizationID:
  19229. return m.AddedOrganizationID()
  19230. }
  19231. return nil, false
  19232. }
  19233. // AddField adds the value to the field with the given name. It returns an error if
  19234. // the field is not defined in the schema, or if the type mismatched the field
  19235. // type.
  19236. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  19237. switch name {
  19238. case labelrelationship.FieldStatus:
  19239. v, ok := value.(int8)
  19240. if !ok {
  19241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19242. }
  19243. m.AddStatus(v)
  19244. return nil
  19245. case labelrelationship.FieldOrganizationID:
  19246. v, ok := value.(int64)
  19247. if !ok {
  19248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19249. }
  19250. m.AddOrganizationID(v)
  19251. return nil
  19252. }
  19253. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  19254. }
  19255. // ClearedFields returns all nullable fields that were cleared during this
  19256. // mutation.
  19257. func (m *LabelRelationshipMutation) ClearedFields() []string {
  19258. var fields []string
  19259. if m.FieldCleared(labelrelationship.FieldStatus) {
  19260. fields = append(fields, labelrelationship.FieldStatus)
  19261. }
  19262. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  19263. fields = append(fields, labelrelationship.FieldOrganizationID)
  19264. }
  19265. return fields
  19266. }
  19267. // FieldCleared returns a boolean indicating if a field with the given name was
  19268. // cleared in this mutation.
  19269. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  19270. _, ok := m.clearedFields[name]
  19271. return ok
  19272. }
  19273. // ClearField clears the value of the field with the given name. It returns an
  19274. // error if the field is not defined in the schema.
  19275. func (m *LabelRelationshipMutation) ClearField(name string) error {
  19276. switch name {
  19277. case labelrelationship.FieldStatus:
  19278. m.ClearStatus()
  19279. return nil
  19280. case labelrelationship.FieldOrganizationID:
  19281. m.ClearOrganizationID()
  19282. return nil
  19283. }
  19284. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  19285. }
  19286. // ResetField resets all changes in the mutation for the field with the given name.
  19287. // It returns an error if the field is not defined in the schema.
  19288. func (m *LabelRelationshipMutation) ResetField(name string) error {
  19289. switch name {
  19290. case labelrelationship.FieldCreatedAt:
  19291. m.ResetCreatedAt()
  19292. return nil
  19293. case labelrelationship.FieldUpdatedAt:
  19294. m.ResetUpdatedAt()
  19295. return nil
  19296. case labelrelationship.FieldStatus:
  19297. m.ResetStatus()
  19298. return nil
  19299. case labelrelationship.FieldLabelID:
  19300. m.ResetLabelID()
  19301. return nil
  19302. case labelrelationship.FieldContactID:
  19303. m.ResetContactID()
  19304. return nil
  19305. case labelrelationship.FieldOrganizationID:
  19306. m.ResetOrganizationID()
  19307. return nil
  19308. }
  19309. return fmt.Errorf("unknown LabelRelationship field %s", name)
  19310. }
  19311. // AddedEdges returns all edge names that were set/added in this mutation.
  19312. func (m *LabelRelationshipMutation) AddedEdges() []string {
  19313. edges := make([]string, 0, 2)
  19314. if m.contacts != nil {
  19315. edges = append(edges, labelrelationship.EdgeContacts)
  19316. }
  19317. if m.labels != nil {
  19318. edges = append(edges, labelrelationship.EdgeLabels)
  19319. }
  19320. return edges
  19321. }
  19322. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19323. // name in this mutation.
  19324. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  19325. switch name {
  19326. case labelrelationship.EdgeContacts:
  19327. if id := m.contacts; id != nil {
  19328. return []ent.Value{*id}
  19329. }
  19330. case labelrelationship.EdgeLabels:
  19331. if id := m.labels; id != nil {
  19332. return []ent.Value{*id}
  19333. }
  19334. }
  19335. return nil
  19336. }
  19337. // RemovedEdges returns all edge names that were removed in this mutation.
  19338. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  19339. edges := make([]string, 0, 2)
  19340. return edges
  19341. }
  19342. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19343. // the given name in this mutation.
  19344. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  19345. return nil
  19346. }
  19347. // ClearedEdges returns all edge names that were cleared in this mutation.
  19348. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  19349. edges := make([]string, 0, 2)
  19350. if m.clearedcontacts {
  19351. edges = append(edges, labelrelationship.EdgeContacts)
  19352. }
  19353. if m.clearedlabels {
  19354. edges = append(edges, labelrelationship.EdgeLabels)
  19355. }
  19356. return edges
  19357. }
  19358. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19359. // was cleared in this mutation.
  19360. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  19361. switch name {
  19362. case labelrelationship.EdgeContacts:
  19363. return m.clearedcontacts
  19364. case labelrelationship.EdgeLabels:
  19365. return m.clearedlabels
  19366. }
  19367. return false
  19368. }
  19369. // ClearEdge clears the value of the edge with the given name. It returns an error
  19370. // if that edge is not defined in the schema.
  19371. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  19372. switch name {
  19373. case labelrelationship.EdgeContacts:
  19374. m.ClearContacts()
  19375. return nil
  19376. case labelrelationship.EdgeLabels:
  19377. m.ClearLabels()
  19378. return nil
  19379. }
  19380. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  19381. }
  19382. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19383. // It returns an error if the edge is not defined in the schema.
  19384. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  19385. switch name {
  19386. case labelrelationship.EdgeContacts:
  19387. m.ResetContacts()
  19388. return nil
  19389. case labelrelationship.EdgeLabels:
  19390. m.ResetLabels()
  19391. return nil
  19392. }
  19393. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  19394. }
  19395. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  19396. type LabelTaggingMutation struct {
  19397. config
  19398. op Op
  19399. typ string
  19400. id *uint64
  19401. created_at *time.Time
  19402. updated_at *time.Time
  19403. status *uint8
  19404. addstatus *int8
  19405. deleted_at *time.Time
  19406. organization_id *uint64
  19407. addorganization_id *int64
  19408. _type *int
  19409. add_type *int
  19410. conditions *string
  19411. action_label_add *[]uint64
  19412. appendaction_label_add []uint64
  19413. action_label_del *[]uint64
  19414. appendaction_label_del []uint64
  19415. clearedFields map[string]struct{}
  19416. done bool
  19417. oldValue func(context.Context) (*LabelTagging, error)
  19418. predicates []predicate.LabelTagging
  19419. }
  19420. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  19421. // labeltaggingOption allows management of the mutation configuration using functional options.
  19422. type labeltaggingOption func(*LabelTaggingMutation)
  19423. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  19424. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  19425. m := &LabelTaggingMutation{
  19426. config: c,
  19427. op: op,
  19428. typ: TypeLabelTagging,
  19429. clearedFields: make(map[string]struct{}),
  19430. }
  19431. for _, opt := range opts {
  19432. opt(m)
  19433. }
  19434. return m
  19435. }
  19436. // withLabelTaggingID sets the ID field of the mutation.
  19437. func withLabelTaggingID(id uint64) labeltaggingOption {
  19438. return func(m *LabelTaggingMutation) {
  19439. var (
  19440. err error
  19441. once sync.Once
  19442. value *LabelTagging
  19443. )
  19444. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  19445. once.Do(func() {
  19446. if m.done {
  19447. err = errors.New("querying old values post mutation is not allowed")
  19448. } else {
  19449. value, err = m.Client().LabelTagging.Get(ctx, id)
  19450. }
  19451. })
  19452. return value, err
  19453. }
  19454. m.id = &id
  19455. }
  19456. }
  19457. // withLabelTagging sets the old LabelTagging of the mutation.
  19458. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  19459. return func(m *LabelTaggingMutation) {
  19460. m.oldValue = func(context.Context) (*LabelTagging, error) {
  19461. return node, nil
  19462. }
  19463. m.id = &node.ID
  19464. }
  19465. }
  19466. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19467. // executed in a transaction (ent.Tx), a transactional client is returned.
  19468. func (m LabelTaggingMutation) Client() *Client {
  19469. client := &Client{config: m.config}
  19470. client.init()
  19471. return client
  19472. }
  19473. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19474. // it returns an error otherwise.
  19475. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  19476. if _, ok := m.driver.(*txDriver); !ok {
  19477. return nil, errors.New("ent: mutation is not running in a transaction")
  19478. }
  19479. tx := &Tx{config: m.config}
  19480. tx.init()
  19481. return tx, nil
  19482. }
  19483. // SetID sets the value of the id field. Note that this
  19484. // operation is only accepted on creation of LabelTagging entities.
  19485. func (m *LabelTaggingMutation) SetID(id uint64) {
  19486. m.id = &id
  19487. }
  19488. // ID returns the ID value in the mutation. Note that the ID is only available
  19489. // if it was provided to the builder or after it was returned from the database.
  19490. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  19491. if m.id == nil {
  19492. return
  19493. }
  19494. return *m.id, true
  19495. }
  19496. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19497. // That means, if the mutation is applied within a transaction with an isolation level such
  19498. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19499. // or updated by the mutation.
  19500. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  19501. switch {
  19502. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19503. id, exists := m.ID()
  19504. if exists {
  19505. return []uint64{id}, nil
  19506. }
  19507. fallthrough
  19508. case m.op.Is(OpUpdate | OpDelete):
  19509. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  19510. default:
  19511. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19512. }
  19513. }
  19514. // SetCreatedAt sets the "created_at" field.
  19515. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  19516. m.created_at = &t
  19517. }
  19518. // CreatedAt returns the value of the "created_at" field in the mutation.
  19519. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  19520. v := m.created_at
  19521. if v == nil {
  19522. return
  19523. }
  19524. return *v, true
  19525. }
  19526. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  19527. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19529. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19530. if !m.op.Is(OpUpdateOne) {
  19531. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19532. }
  19533. if m.id == nil || m.oldValue == nil {
  19534. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19535. }
  19536. oldValue, err := m.oldValue(ctx)
  19537. if err != nil {
  19538. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19539. }
  19540. return oldValue.CreatedAt, nil
  19541. }
  19542. // ResetCreatedAt resets all changes to the "created_at" field.
  19543. func (m *LabelTaggingMutation) ResetCreatedAt() {
  19544. m.created_at = nil
  19545. }
  19546. // SetUpdatedAt sets the "updated_at" field.
  19547. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  19548. m.updated_at = &t
  19549. }
  19550. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19551. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  19552. v := m.updated_at
  19553. if v == nil {
  19554. return
  19555. }
  19556. return *v, true
  19557. }
  19558. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  19559. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19561. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19562. if !m.op.Is(OpUpdateOne) {
  19563. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19564. }
  19565. if m.id == nil || m.oldValue == nil {
  19566. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19567. }
  19568. oldValue, err := m.oldValue(ctx)
  19569. if err != nil {
  19570. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19571. }
  19572. return oldValue.UpdatedAt, nil
  19573. }
  19574. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19575. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  19576. m.updated_at = nil
  19577. }
  19578. // SetStatus sets the "status" field.
  19579. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  19580. m.status = &u
  19581. m.addstatus = nil
  19582. }
  19583. // Status returns the value of the "status" field in the mutation.
  19584. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  19585. v := m.status
  19586. if v == nil {
  19587. return
  19588. }
  19589. return *v, true
  19590. }
  19591. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  19592. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19594. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19595. if !m.op.Is(OpUpdateOne) {
  19596. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19597. }
  19598. if m.id == nil || m.oldValue == nil {
  19599. return v, errors.New("OldStatus requires an ID field in the mutation")
  19600. }
  19601. oldValue, err := m.oldValue(ctx)
  19602. if err != nil {
  19603. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19604. }
  19605. return oldValue.Status, nil
  19606. }
  19607. // AddStatus adds u to the "status" field.
  19608. func (m *LabelTaggingMutation) AddStatus(u int8) {
  19609. if m.addstatus != nil {
  19610. *m.addstatus += u
  19611. } else {
  19612. m.addstatus = &u
  19613. }
  19614. }
  19615. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19616. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  19617. v := m.addstatus
  19618. if v == nil {
  19619. return
  19620. }
  19621. return *v, true
  19622. }
  19623. // ClearStatus clears the value of the "status" field.
  19624. func (m *LabelTaggingMutation) ClearStatus() {
  19625. m.status = nil
  19626. m.addstatus = nil
  19627. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  19628. }
  19629. // StatusCleared returns if the "status" field was cleared in this mutation.
  19630. func (m *LabelTaggingMutation) StatusCleared() bool {
  19631. _, ok := m.clearedFields[labeltagging.FieldStatus]
  19632. return ok
  19633. }
  19634. // ResetStatus resets all changes to the "status" field.
  19635. func (m *LabelTaggingMutation) ResetStatus() {
  19636. m.status = nil
  19637. m.addstatus = nil
  19638. delete(m.clearedFields, labeltagging.FieldStatus)
  19639. }
  19640. // SetDeletedAt sets the "deleted_at" field.
  19641. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  19642. m.deleted_at = &t
  19643. }
  19644. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19645. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  19646. v := m.deleted_at
  19647. if v == nil {
  19648. return
  19649. }
  19650. return *v, true
  19651. }
  19652. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  19653. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19655. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19656. if !m.op.Is(OpUpdateOne) {
  19657. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19658. }
  19659. if m.id == nil || m.oldValue == nil {
  19660. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19661. }
  19662. oldValue, err := m.oldValue(ctx)
  19663. if err != nil {
  19664. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19665. }
  19666. return oldValue.DeletedAt, nil
  19667. }
  19668. // ClearDeletedAt clears the value of the "deleted_at" field.
  19669. func (m *LabelTaggingMutation) ClearDeletedAt() {
  19670. m.deleted_at = nil
  19671. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  19672. }
  19673. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19674. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  19675. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  19676. return ok
  19677. }
  19678. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19679. func (m *LabelTaggingMutation) ResetDeletedAt() {
  19680. m.deleted_at = nil
  19681. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  19682. }
  19683. // SetOrganizationID sets the "organization_id" field.
  19684. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  19685. m.organization_id = &u
  19686. m.addorganization_id = nil
  19687. }
  19688. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19689. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  19690. v := m.organization_id
  19691. if v == nil {
  19692. return
  19693. }
  19694. return *v, true
  19695. }
  19696. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  19697. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19699. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19700. if !m.op.Is(OpUpdateOne) {
  19701. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19702. }
  19703. if m.id == nil || m.oldValue == nil {
  19704. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19705. }
  19706. oldValue, err := m.oldValue(ctx)
  19707. if err != nil {
  19708. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19709. }
  19710. return oldValue.OrganizationID, nil
  19711. }
  19712. // AddOrganizationID adds u to the "organization_id" field.
  19713. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  19714. if m.addorganization_id != nil {
  19715. *m.addorganization_id += u
  19716. } else {
  19717. m.addorganization_id = &u
  19718. }
  19719. }
  19720. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19721. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  19722. v := m.addorganization_id
  19723. if v == nil {
  19724. return
  19725. }
  19726. return *v, true
  19727. }
  19728. // ResetOrganizationID resets all changes to the "organization_id" field.
  19729. func (m *LabelTaggingMutation) ResetOrganizationID() {
  19730. m.organization_id = nil
  19731. m.addorganization_id = nil
  19732. }
  19733. // SetType sets the "type" field.
  19734. func (m *LabelTaggingMutation) SetType(i int) {
  19735. m._type = &i
  19736. m.add_type = nil
  19737. }
  19738. // GetType returns the value of the "type" field in the mutation.
  19739. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  19740. v := m._type
  19741. if v == nil {
  19742. return
  19743. }
  19744. return *v, true
  19745. }
  19746. // OldType returns the old "type" field's value of the LabelTagging entity.
  19747. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19749. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  19750. if !m.op.Is(OpUpdateOne) {
  19751. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19752. }
  19753. if m.id == nil || m.oldValue == nil {
  19754. return v, errors.New("OldType requires an ID field in the mutation")
  19755. }
  19756. oldValue, err := m.oldValue(ctx)
  19757. if err != nil {
  19758. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19759. }
  19760. return oldValue.Type, nil
  19761. }
  19762. // AddType adds i to the "type" field.
  19763. func (m *LabelTaggingMutation) AddType(i int) {
  19764. if m.add_type != nil {
  19765. *m.add_type += i
  19766. } else {
  19767. m.add_type = &i
  19768. }
  19769. }
  19770. // AddedType returns the value that was added to the "type" field in this mutation.
  19771. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  19772. v := m.add_type
  19773. if v == nil {
  19774. return
  19775. }
  19776. return *v, true
  19777. }
  19778. // ResetType resets all changes to the "type" field.
  19779. func (m *LabelTaggingMutation) ResetType() {
  19780. m._type = nil
  19781. m.add_type = nil
  19782. }
  19783. // SetConditions sets the "conditions" field.
  19784. func (m *LabelTaggingMutation) SetConditions(s string) {
  19785. m.conditions = &s
  19786. }
  19787. // Conditions returns the value of the "conditions" field in the mutation.
  19788. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  19789. v := m.conditions
  19790. if v == nil {
  19791. return
  19792. }
  19793. return *v, true
  19794. }
  19795. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  19796. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19798. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  19799. if !m.op.Is(OpUpdateOne) {
  19800. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  19801. }
  19802. if m.id == nil || m.oldValue == nil {
  19803. return v, errors.New("OldConditions requires an ID field in the mutation")
  19804. }
  19805. oldValue, err := m.oldValue(ctx)
  19806. if err != nil {
  19807. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19808. }
  19809. return oldValue.Conditions, nil
  19810. }
  19811. // ResetConditions resets all changes to the "conditions" field.
  19812. func (m *LabelTaggingMutation) ResetConditions() {
  19813. m.conditions = nil
  19814. }
  19815. // SetActionLabelAdd sets the "action_label_add" field.
  19816. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  19817. m.action_label_add = &u
  19818. m.appendaction_label_add = nil
  19819. }
  19820. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19821. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19822. v := m.action_label_add
  19823. if v == nil {
  19824. return
  19825. }
  19826. return *v, true
  19827. }
  19828. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  19829. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19831. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19832. if !m.op.Is(OpUpdateOne) {
  19833. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19834. }
  19835. if m.id == nil || m.oldValue == nil {
  19836. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19837. }
  19838. oldValue, err := m.oldValue(ctx)
  19839. if err != nil {
  19840. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19841. }
  19842. return oldValue.ActionLabelAdd, nil
  19843. }
  19844. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19845. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  19846. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19847. }
  19848. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19849. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19850. if len(m.appendaction_label_add) == 0 {
  19851. return nil, false
  19852. }
  19853. return m.appendaction_label_add, true
  19854. }
  19855. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19856. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  19857. m.action_label_add = nil
  19858. m.appendaction_label_add = nil
  19859. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  19860. }
  19861. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19862. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  19863. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  19864. return ok
  19865. }
  19866. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19867. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  19868. m.action_label_add = nil
  19869. m.appendaction_label_add = nil
  19870. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  19871. }
  19872. // SetActionLabelDel sets the "action_label_del" field.
  19873. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  19874. m.action_label_del = &u
  19875. m.appendaction_label_del = nil
  19876. }
  19877. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19878. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  19879. v := m.action_label_del
  19880. if v == nil {
  19881. return
  19882. }
  19883. return *v, true
  19884. }
  19885. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  19886. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19888. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19889. if !m.op.Is(OpUpdateOne) {
  19890. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19891. }
  19892. if m.id == nil || m.oldValue == nil {
  19893. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19894. }
  19895. oldValue, err := m.oldValue(ctx)
  19896. if err != nil {
  19897. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19898. }
  19899. return oldValue.ActionLabelDel, nil
  19900. }
  19901. // AppendActionLabelDel adds u to the "action_label_del" field.
  19902. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  19903. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19904. }
  19905. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19906. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19907. if len(m.appendaction_label_del) == 0 {
  19908. return nil, false
  19909. }
  19910. return m.appendaction_label_del, true
  19911. }
  19912. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19913. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  19914. m.action_label_del = nil
  19915. m.appendaction_label_del = nil
  19916. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  19917. }
  19918. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19919. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  19920. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  19921. return ok
  19922. }
  19923. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19924. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  19925. m.action_label_del = nil
  19926. m.appendaction_label_del = nil
  19927. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  19928. }
  19929. // Where appends a list predicates to the LabelTaggingMutation builder.
  19930. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  19931. m.predicates = append(m.predicates, ps...)
  19932. }
  19933. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  19934. // users can use type-assertion to append predicates that do not depend on any generated package.
  19935. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  19936. p := make([]predicate.LabelTagging, len(ps))
  19937. for i := range ps {
  19938. p[i] = ps[i]
  19939. }
  19940. m.Where(p...)
  19941. }
  19942. // Op returns the operation name.
  19943. func (m *LabelTaggingMutation) Op() Op {
  19944. return m.op
  19945. }
  19946. // SetOp allows setting the mutation operation.
  19947. func (m *LabelTaggingMutation) SetOp(op Op) {
  19948. m.op = op
  19949. }
  19950. // Type returns the node type of this mutation (LabelTagging).
  19951. func (m *LabelTaggingMutation) Type() string {
  19952. return m.typ
  19953. }
  19954. // Fields returns all fields that were changed during this mutation. Note that in
  19955. // order to get all numeric fields that were incremented/decremented, call
  19956. // AddedFields().
  19957. func (m *LabelTaggingMutation) Fields() []string {
  19958. fields := make([]string, 0, 9)
  19959. if m.created_at != nil {
  19960. fields = append(fields, labeltagging.FieldCreatedAt)
  19961. }
  19962. if m.updated_at != nil {
  19963. fields = append(fields, labeltagging.FieldUpdatedAt)
  19964. }
  19965. if m.status != nil {
  19966. fields = append(fields, labeltagging.FieldStatus)
  19967. }
  19968. if m.deleted_at != nil {
  19969. fields = append(fields, labeltagging.FieldDeletedAt)
  19970. }
  19971. if m.organization_id != nil {
  19972. fields = append(fields, labeltagging.FieldOrganizationID)
  19973. }
  19974. if m._type != nil {
  19975. fields = append(fields, labeltagging.FieldType)
  19976. }
  19977. if m.conditions != nil {
  19978. fields = append(fields, labeltagging.FieldConditions)
  19979. }
  19980. if m.action_label_add != nil {
  19981. fields = append(fields, labeltagging.FieldActionLabelAdd)
  19982. }
  19983. if m.action_label_del != nil {
  19984. fields = append(fields, labeltagging.FieldActionLabelDel)
  19985. }
  19986. return fields
  19987. }
  19988. // Field returns the value of a field with the given name. The second boolean
  19989. // return value indicates that this field was not set, or was not defined in the
  19990. // schema.
  19991. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  19992. switch name {
  19993. case labeltagging.FieldCreatedAt:
  19994. return m.CreatedAt()
  19995. case labeltagging.FieldUpdatedAt:
  19996. return m.UpdatedAt()
  19997. case labeltagging.FieldStatus:
  19998. return m.Status()
  19999. case labeltagging.FieldDeletedAt:
  20000. return m.DeletedAt()
  20001. case labeltagging.FieldOrganizationID:
  20002. return m.OrganizationID()
  20003. case labeltagging.FieldType:
  20004. return m.GetType()
  20005. case labeltagging.FieldConditions:
  20006. return m.Conditions()
  20007. case labeltagging.FieldActionLabelAdd:
  20008. return m.ActionLabelAdd()
  20009. case labeltagging.FieldActionLabelDel:
  20010. return m.ActionLabelDel()
  20011. }
  20012. return nil, false
  20013. }
  20014. // OldField returns the old value of the field from the database. An error is
  20015. // returned if the mutation operation is not UpdateOne, or the query to the
  20016. // database failed.
  20017. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20018. switch name {
  20019. case labeltagging.FieldCreatedAt:
  20020. return m.OldCreatedAt(ctx)
  20021. case labeltagging.FieldUpdatedAt:
  20022. return m.OldUpdatedAt(ctx)
  20023. case labeltagging.FieldStatus:
  20024. return m.OldStatus(ctx)
  20025. case labeltagging.FieldDeletedAt:
  20026. return m.OldDeletedAt(ctx)
  20027. case labeltagging.FieldOrganizationID:
  20028. return m.OldOrganizationID(ctx)
  20029. case labeltagging.FieldType:
  20030. return m.OldType(ctx)
  20031. case labeltagging.FieldConditions:
  20032. return m.OldConditions(ctx)
  20033. case labeltagging.FieldActionLabelAdd:
  20034. return m.OldActionLabelAdd(ctx)
  20035. case labeltagging.FieldActionLabelDel:
  20036. return m.OldActionLabelDel(ctx)
  20037. }
  20038. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  20039. }
  20040. // SetField sets the value of a field with the given name. It returns an error if
  20041. // the field is not defined in the schema, or if the type mismatched the field
  20042. // type.
  20043. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  20044. switch name {
  20045. case labeltagging.FieldCreatedAt:
  20046. v, ok := value.(time.Time)
  20047. if !ok {
  20048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20049. }
  20050. m.SetCreatedAt(v)
  20051. return nil
  20052. case labeltagging.FieldUpdatedAt:
  20053. v, ok := value.(time.Time)
  20054. if !ok {
  20055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20056. }
  20057. m.SetUpdatedAt(v)
  20058. return nil
  20059. case labeltagging.FieldStatus:
  20060. v, ok := value.(uint8)
  20061. if !ok {
  20062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20063. }
  20064. m.SetStatus(v)
  20065. return nil
  20066. case labeltagging.FieldDeletedAt:
  20067. v, ok := value.(time.Time)
  20068. if !ok {
  20069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20070. }
  20071. m.SetDeletedAt(v)
  20072. return nil
  20073. case labeltagging.FieldOrganizationID:
  20074. v, ok := value.(uint64)
  20075. if !ok {
  20076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20077. }
  20078. m.SetOrganizationID(v)
  20079. return nil
  20080. case labeltagging.FieldType:
  20081. v, ok := value.(int)
  20082. if !ok {
  20083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20084. }
  20085. m.SetType(v)
  20086. return nil
  20087. case labeltagging.FieldConditions:
  20088. v, ok := value.(string)
  20089. if !ok {
  20090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20091. }
  20092. m.SetConditions(v)
  20093. return nil
  20094. case labeltagging.FieldActionLabelAdd:
  20095. v, ok := value.([]uint64)
  20096. if !ok {
  20097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20098. }
  20099. m.SetActionLabelAdd(v)
  20100. return nil
  20101. case labeltagging.FieldActionLabelDel:
  20102. v, ok := value.([]uint64)
  20103. if !ok {
  20104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20105. }
  20106. m.SetActionLabelDel(v)
  20107. return nil
  20108. }
  20109. return fmt.Errorf("unknown LabelTagging field %s", name)
  20110. }
  20111. // AddedFields returns all numeric fields that were incremented/decremented during
  20112. // this mutation.
  20113. func (m *LabelTaggingMutation) AddedFields() []string {
  20114. var fields []string
  20115. if m.addstatus != nil {
  20116. fields = append(fields, labeltagging.FieldStatus)
  20117. }
  20118. if m.addorganization_id != nil {
  20119. fields = append(fields, labeltagging.FieldOrganizationID)
  20120. }
  20121. if m.add_type != nil {
  20122. fields = append(fields, labeltagging.FieldType)
  20123. }
  20124. return fields
  20125. }
  20126. // AddedField returns the numeric value that was incremented/decremented on a field
  20127. // with the given name. The second boolean return value indicates that this field
  20128. // was not set, or was not defined in the schema.
  20129. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  20130. switch name {
  20131. case labeltagging.FieldStatus:
  20132. return m.AddedStatus()
  20133. case labeltagging.FieldOrganizationID:
  20134. return m.AddedOrganizationID()
  20135. case labeltagging.FieldType:
  20136. return m.AddedType()
  20137. }
  20138. return nil, false
  20139. }
  20140. // AddField adds the value to the field with the given name. It returns an error if
  20141. // the field is not defined in the schema, or if the type mismatched the field
  20142. // type.
  20143. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  20144. switch name {
  20145. case labeltagging.FieldStatus:
  20146. v, ok := value.(int8)
  20147. if !ok {
  20148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20149. }
  20150. m.AddStatus(v)
  20151. return nil
  20152. case labeltagging.FieldOrganizationID:
  20153. v, ok := value.(int64)
  20154. if !ok {
  20155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20156. }
  20157. m.AddOrganizationID(v)
  20158. return nil
  20159. case labeltagging.FieldType:
  20160. v, ok := value.(int)
  20161. if !ok {
  20162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20163. }
  20164. m.AddType(v)
  20165. return nil
  20166. }
  20167. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  20168. }
  20169. // ClearedFields returns all nullable fields that were cleared during this
  20170. // mutation.
  20171. func (m *LabelTaggingMutation) ClearedFields() []string {
  20172. var fields []string
  20173. if m.FieldCleared(labeltagging.FieldStatus) {
  20174. fields = append(fields, labeltagging.FieldStatus)
  20175. }
  20176. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  20177. fields = append(fields, labeltagging.FieldDeletedAt)
  20178. }
  20179. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  20180. fields = append(fields, labeltagging.FieldActionLabelAdd)
  20181. }
  20182. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  20183. fields = append(fields, labeltagging.FieldActionLabelDel)
  20184. }
  20185. return fields
  20186. }
  20187. // FieldCleared returns a boolean indicating if a field with the given name was
  20188. // cleared in this mutation.
  20189. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  20190. _, ok := m.clearedFields[name]
  20191. return ok
  20192. }
  20193. // ClearField clears the value of the field with the given name. It returns an
  20194. // error if the field is not defined in the schema.
  20195. func (m *LabelTaggingMutation) ClearField(name string) error {
  20196. switch name {
  20197. case labeltagging.FieldStatus:
  20198. m.ClearStatus()
  20199. return nil
  20200. case labeltagging.FieldDeletedAt:
  20201. m.ClearDeletedAt()
  20202. return nil
  20203. case labeltagging.FieldActionLabelAdd:
  20204. m.ClearActionLabelAdd()
  20205. return nil
  20206. case labeltagging.FieldActionLabelDel:
  20207. m.ClearActionLabelDel()
  20208. return nil
  20209. }
  20210. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  20211. }
  20212. // ResetField resets all changes in the mutation for the field with the given name.
  20213. // It returns an error if the field is not defined in the schema.
  20214. func (m *LabelTaggingMutation) ResetField(name string) error {
  20215. switch name {
  20216. case labeltagging.FieldCreatedAt:
  20217. m.ResetCreatedAt()
  20218. return nil
  20219. case labeltagging.FieldUpdatedAt:
  20220. m.ResetUpdatedAt()
  20221. return nil
  20222. case labeltagging.FieldStatus:
  20223. m.ResetStatus()
  20224. return nil
  20225. case labeltagging.FieldDeletedAt:
  20226. m.ResetDeletedAt()
  20227. return nil
  20228. case labeltagging.FieldOrganizationID:
  20229. m.ResetOrganizationID()
  20230. return nil
  20231. case labeltagging.FieldType:
  20232. m.ResetType()
  20233. return nil
  20234. case labeltagging.FieldConditions:
  20235. m.ResetConditions()
  20236. return nil
  20237. case labeltagging.FieldActionLabelAdd:
  20238. m.ResetActionLabelAdd()
  20239. return nil
  20240. case labeltagging.FieldActionLabelDel:
  20241. m.ResetActionLabelDel()
  20242. return nil
  20243. }
  20244. return fmt.Errorf("unknown LabelTagging field %s", name)
  20245. }
  20246. // AddedEdges returns all edge names that were set/added in this mutation.
  20247. func (m *LabelTaggingMutation) AddedEdges() []string {
  20248. edges := make([]string, 0, 0)
  20249. return edges
  20250. }
  20251. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20252. // name in this mutation.
  20253. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  20254. return nil
  20255. }
  20256. // RemovedEdges returns all edge names that were removed in this mutation.
  20257. func (m *LabelTaggingMutation) RemovedEdges() []string {
  20258. edges := make([]string, 0, 0)
  20259. return edges
  20260. }
  20261. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20262. // the given name in this mutation.
  20263. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  20264. return nil
  20265. }
  20266. // ClearedEdges returns all edge names that were cleared in this mutation.
  20267. func (m *LabelTaggingMutation) ClearedEdges() []string {
  20268. edges := make([]string, 0, 0)
  20269. return edges
  20270. }
  20271. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20272. // was cleared in this mutation.
  20273. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  20274. return false
  20275. }
  20276. // ClearEdge clears the value of the edge with the given name. It returns an error
  20277. // if that edge is not defined in the schema.
  20278. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  20279. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  20280. }
  20281. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20282. // It returns an error if the edge is not defined in the schema.
  20283. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  20284. return fmt.Errorf("unknown LabelTagging edge %s", name)
  20285. }
  20286. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  20287. type MessageMutation struct {
  20288. config
  20289. op Op
  20290. typ string
  20291. id *int
  20292. wx_wxid *string
  20293. wxid *string
  20294. content *string
  20295. clearedFields map[string]struct{}
  20296. done bool
  20297. oldValue func(context.Context) (*Message, error)
  20298. predicates []predicate.Message
  20299. }
  20300. var _ ent.Mutation = (*MessageMutation)(nil)
  20301. // messageOption allows management of the mutation configuration using functional options.
  20302. type messageOption func(*MessageMutation)
  20303. // newMessageMutation creates new mutation for the Message entity.
  20304. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  20305. m := &MessageMutation{
  20306. config: c,
  20307. op: op,
  20308. typ: TypeMessage,
  20309. clearedFields: make(map[string]struct{}),
  20310. }
  20311. for _, opt := range opts {
  20312. opt(m)
  20313. }
  20314. return m
  20315. }
  20316. // withMessageID sets the ID field of the mutation.
  20317. func withMessageID(id int) messageOption {
  20318. return func(m *MessageMutation) {
  20319. var (
  20320. err error
  20321. once sync.Once
  20322. value *Message
  20323. )
  20324. m.oldValue = func(ctx context.Context) (*Message, error) {
  20325. once.Do(func() {
  20326. if m.done {
  20327. err = errors.New("querying old values post mutation is not allowed")
  20328. } else {
  20329. value, err = m.Client().Message.Get(ctx, id)
  20330. }
  20331. })
  20332. return value, err
  20333. }
  20334. m.id = &id
  20335. }
  20336. }
  20337. // withMessage sets the old Message of the mutation.
  20338. func withMessage(node *Message) messageOption {
  20339. return func(m *MessageMutation) {
  20340. m.oldValue = func(context.Context) (*Message, error) {
  20341. return node, nil
  20342. }
  20343. m.id = &node.ID
  20344. }
  20345. }
  20346. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20347. // executed in a transaction (ent.Tx), a transactional client is returned.
  20348. func (m MessageMutation) Client() *Client {
  20349. client := &Client{config: m.config}
  20350. client.init()
  20351. return client
  20352. }
  20353. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20354. // it returns an error otherwise.
  20355. func (m MessageMutation) Tx() (*Tx, error) {
  20356. if _, ok := m.driver.(*txDriver); !ok {
  20357. return nil, errors.New("ent: mutation is not running in a transaction")
  20358. }
  20359. tx := &Tx{config: m.config}
  20360. tx.init()
  20361. return tx, nil
  20362. }
  20363. // ID returns the ID value in the mutation. Note that the ID is only available
  20364. // if it was provided to the builder or after it was returned from the database.
  20365. func (m *MessageMutation) ID() (id int, exists bool) {
  20366. if m.id == nil {
  20367. return
  20368. }
  20369. return *m.id, true
  20370. }
  20371. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20372. // That means, if the mutation is applied within a transaction with an isolation level such
  20373. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20374. // or updated by the mutation.
  20375. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  20376. switch {
  20377. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20378. id, exists := m.ID()
  20379. if exists {
  20380. return []int{id}, nil
  20381. }
  20382. fallthrough
  20383. case m.op.Is(OpUpdate | OpDelete):
  20384. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  20385. default:
  20386. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20387. }
  20388. }
  20389. // SetWxWxid sets the "wx_wxid" field.
  20390. func (m *MessageMutation) SetWxWxid(s string) {
  20391. m.wx_wxid = &s
  20392. }
  20393. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  20394. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  20395. v := m.wx_wxid
  20396. if v == nil {
  20397. return
  20398. }
  20399. return *v, true
  20400. }
  20401. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  20402. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20404. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  20405. if !m.op.Is(OpUpdateOne) {
  20406. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  20407. }
  20408. if m.id == nil || m.oldValue == nil {
  20409. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  20410. }
  20411. oldValue, err := m.oldValue(ctx)
  20412. if err != nil {
  20413. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  20414. }
  20415. return oldValue.WxWxid, nil
  20416. }
  20417. // ClearWxWxid clears the value of the "wx_wxid" field.
  20418. func (m *MessageMutation) ClearWxWxid() {
  20419. m.wx_wxid = nil
  20420. m.clearedFields[message.FieldWxWxid] = struct{}{}
  20421. }
  20422. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  20423. func (m *MessageMutation) WxWxidCleared() bool {
  20424. _, ok := m.clearedFields[message.FieldWxWxid]
  20425. return ok
  20426. }
  20427. // ResetWxWxid resets all changes to the "wx_wxid" field.
  20428. func (m *MessageMutation) ResetWxWxid() {
  20429. m.wx_wxid = nil
  20430. delete(m.clearedFields, message.FieldWxWxid)
  20431. }
  20432. // SetWxid sets the "wxid" field.
  20433. func (m *MessageMutation) SetWxid(s string) {
  20434. m.wxid = &s
  20435. }
  20436. // Wxid returns the value of the "wxid" field in the mutation.
  20437. func (m *MessageMutation) Wxid() (r string, exists bool) {
  20438. v := m.wxid
  20439. if v == nil {
  20440. return
  20441. }
  20442. return *v, true
  20443. }
  20444. // OldWxid returns the old "wxid" field's value of the Message entity.
  20445. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20447. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  20448. if !m.op.Is(OpUpdateOne) {
  20449. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  20450. }
  20451. if m.id == nil || m.oldValue == nil {
  20452. return v, errors.New("OldWxid requires an ID field in the mutation")
  20453. }
  20454. oldValue, err := m.oldValue(ctx)
  20455. if err != nil {
  20456. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  20457. }
  20458. return oldValue.Wxid, nil
  20459. }
  20460. // ResetWxid resets all changes to the "wxid" field.
  20461. func (m *MessageMutation) ResetWxid() {
  20462. m.wxid = nil
  20463. }
  20464. // SetContent sets the "content" field.
  20465. func (m *MessageMutation) SetContent(s string) {
  20466. m.content = &s
  20467. }
  20468. // Content returns the value of the "content" field in the mutation.
  20469. func (m *MessageMutation) Content() (r string, exists bool) {
  20470. v := m.content
  20471. if v == nil {
  20472. return
  20473. }
  20474. return *v, true
  20475. }
  20476. // OldContent returns the old "content" field's value of the Message entity.
  20477. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20479. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  20480. if !m.op.Is(OpUpdateOne) {
  20481. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20482. }
  20483. if m.id == nil || m.oldValue == nil {
  20484. return v, errors.New("OldContent requires an ID field in the mutation")
  20485. }
  20486. oldValue, err := m.oldValue(ctx)
  20487. if err != nil {
  20488. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20489. }
  20490. return oldValue.Content, nil
  20491. }
  20492. // ResetContent resets all changes to the "content" field.
  20493. func (m *MessageMutation) ResetContent() {
  20494. m.content = nil
  20495. }
  20496. // Where appends a list predicates to the MessageMutation builder.
  20497. func (m *MessageMutation) Where(ps ...predicate.Message) {
  20498. m.predicates = append(m.predicates, ps...)
  20499. }
  20500. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  20501. // users can use type-assertion to append predicates that do not depend on any generated package.
  20502. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  20503. p := make([]predicate.Message, len(ps))
  20504. for i := range ps {
  20505. p[i] = ps[i]
  20506. }
  20507. m.Where(p...)
  20508. }
  20509. // Op returns the operation name.
  20510. func (m *MessageMutation) Op() Op {
  20511. return m.op
  20512. }
  20513. // SetOp allows setting the mutation operation.
  20514. func (m *MessageMutation) SetOp(op Op) {
  20515. m.op = op
  20516. }
  20517. // Type returns the node type of this mutation (Message).
  20518. func (m *MessageMutation) Type() string {
  20519. return m.typ
  20520. }
  20521. // Fields returns all fields that were changed during this mutation. Note that in
  20522. // order to get all numeric fields that were incremented/decremented, call
  20523. // AddedFields().
  20524. func (m *MessageMutation) Fields() []string {
  20525. fields := make([]string, 0, 3)
  20526. if m.wx_wxid != nil {
  20527. fields = append(fields, message.FieldWxWxid)
  20528. }
  20529. if m.wxid != nil {
  20530. fields = append(fields, message.FieldWxid)
  20531. }
  20532. if m.content != nil {
  20533. fields = append(fields, message.FieldContent)
  20534. }
  20535. return fields
  20536. }
  20537. // Field returns the value of a field with the given name. The second boolean
  20538. // return value indicates that this field was not set, or was not defined in the
  20539. // schema.
  20540. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  20541. switch name {
  20542. case message.FieldWxWxid:
  20543. return m.WxWxid()
  20544. case message.FieldWxid:
  20545. return m.Wxid()
  20546. case message.FieldContent:
  20547. return m.Content()
  20548. }
  20549. return nil, false
  20550. }
  20551. // OldField returns the old value of the field from the database. An error is
  20552. // returned if the mutation operation is not UpdateOne, or the query to the
  20553. // database failed.
  20554. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20555. switch name {
  20556. case message.FieldWxWxid:
  20557. return m.OldWxWxid(ctx)
  20558. case message.FieldWxid:
  20559. return m.OldWxid(ctx)
  20560. case message.FieldContent:
  20561. return m.OldContent(ctx)
  20562. }
  20563. return nil, fmt.Errorf("unknown Message field %s", name)
  20564. }
  20565. // SetField sets the value of a field with the given name. It returns an error if
  20566. // the field is not defined in the schema, or if the type mismatched the field
  20567. // type.
  20568. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  20569. switch name {
  20570. case message.FieldWxWxid:
  20571. v, ok := value.(string)
  20572. if !ok {
  20573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20574. }
  20575. m.SetWxWxid(v)
  20576. return nil
  20577. case message.FieldWxid:
  20578. v, ok := value.(string)
  20579. if !ok {
  20580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20581. }
  20582. m.SetWxid(v)
  20583. return nil
  20584. case message.FieldContent:
  20585. v, ok := value.(string)
  20586. if !ok {
  20587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20588. }
  20589. m.SetContent(v)
  20590. return nil
  20591. }
  20592. return fmt.Errorf("unknown Message field %s", name)
  20593. }
  20594. // AddedFields returns all numeric fields that were incremented/decremented during
  20595. // this mutation.
  20596. func (m *MessageMutation) AddedFields() []string {
  20597. return nil
  20598. }
  20599. // AddedField returns the numeric value that was incremented/decremented on a field
  20600. // with the given name. The second boolean return value indicates that this field
  20601. // was not set, or was not defined in the schema.
  20602. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  20603. return nil, false
  20604. }
  20605. // AddField adds the value to the field with the given name. It returns an error if
  20606. // the field is not defined in the schema, or if the type mismatched the field
  20607. // type.
  20608. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  20609. switch name {
  20610. }
  20611. return fmt.Errorf("unknown Message numeric field %s", name)
  20612. }
  20613. // ClearedFields returns all nullable fields that were cleared during this
  20614. // mutation.
  20615. func (m *MessageMutation) ClearedFields() []string {
  20616. var fields []string
  20617. if m.FieldCleared(message.FieldWxWxid) {
  20618. fields = append(fields, message.FieldWxWxid)
  20619. }
  20620. return fields
  20621. }
  20622. // FieldCleared returns a boolean indicating if a field with the given name was
  20623. // cleared in this mutation.
  20624. func (m *MessageMutation) FieldCleared(name string) bool {
  20625. _, ok := m.clearedFields[name]
  20626. return ok
  20627. }
  20628. // ClearField clears the value of the field with the given name. It returns an
  20629. // error if the field is not defined in the schema.
  20630. func (m *MessageMutation) ClearField(name string) error {
  20631. switch name {
  20632. case message.FieldWxWxid:
  20633. m.ClearWxWxid()
  20634. return nil
  20635. }
  20636. return fmt.Errorf("unknown Message nullable field %s", name)
  20637. }
  20638. // ResetField resets all changes in the mutation for the field with the given name.
  20639. // It returns an error if the field is not defined in the schema.
  20640. func (m *MessageMutation) ResetField(name string) error {
  20641. switch name {
  20642. case message.FieldWxWxid:
  20643. m.ResetWxWxid()
  20644. return nil
  20645. case message.FieldWxid:
  20646. m.ResetWxid()
  20647. return nil
  20648. case message.FieldContent:
  20649. m.ResetContent()
  20650. return nil
  20651. }
  20652. return fmt.Errorf("unknown Message field %s", name)
  20653. }
  20654. // AddedEdges returns all edge names that were set/added in this mutation.
  20655. func (m *MessageMutation) AddedEdges() []string {
  20656. edges := make([]string, 0, 0)
  20657. return edges
  20658. }
  20659. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20660. // name in this mutation.
  20661. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  20662. return nil
  20663. }
  20664. // RemovedEdges returns all edge names that were removed in this mutation.
  20665. func (m *MessageMutation) RemovedEdges() []string {
  20666. edges := make([]string, 0, 0)
  20667. return edges
  20668. }
  20669. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20670. // the given name in this mutation.
  20671. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  20672. return nil
  20673. }
  20674. // ClearedEdges returns all edge names that were cleared in this mutation.
  20675. func (m *MessageMutation) ClearedEdges() []string {
  20676. edges := make([]string, 0, 0)
  20677. return edges
  20678. }
  20679. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20680. // was cleared in this mutation.
  20681. func (m *MessageMutation) EdgeCleared(name string) bool {
  20682. return false
  20683. }
  20684. // ClearEdge clears the value of the edge with the given name. It returns an error
  20685. // if that edge is not defined in the schema.
  20686. func (m *MessageMutation) ClearEdge(name string) error {
  20687. return fmt.Errorf("unknown Message unique edge %s", name)
  20688. }
  20689. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20690. // It returns an error if the edge is not defined in the schema.
  20691. func (m *MessageMutation) ResetEdge(name string) error {
  20692. return fmt.Errorf("unknown Message edge %s", name)
  20693. }
  20694. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  20695. type MessageRecordsMutation struct {
  20696. config
  20697. op Op
  20698. typ string
  20699. id *uint64
  20700. created_at *time.Time
  20701. updated_at *time.Time
  20702. status *uint8
  20703. addstatus *int8
  20704. bot_wxid *string
  20705. contact_type *int
  20706. addcontact_type *int
  20707. contact_wxid *string
  20708. content_type *int
  20709. addcontent_type *int
  20710. content *string
  20711. meta *custom_types.Meta
  20712. error_detail *string
  20713. send_time *time.Time
  20714. source_type *int
  20715. addsource_type *int
  20716. organization_id *uint64
  20717. addorganization_id *int64
  20718. clearedFields map[string]struct{}
  20719. sop_stage *uint64
  20720. clearedsop_stage bool
  20721. sop_node *uint64
  20722. clearedsop_node bool
  20723. message_contact *uint64
  20724. clearedmessage_contact bool
  20725. done bool
  20726. oldValue func(context.Context) (*MessageRecords, error)
  20727. predicates []predicate.MessageRecords
  20728. }
  20729. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  20730. // messagerecordsOption allows management of the mutation configuration using functional options.
  20731. type messagerecordsOption func(*MessageRecordsMutation)
  20732. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  20733. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  20734. m := &MessageRecordsMutation{
  20735. config: c,
  20736. op: op,
  20737. typ: TypeMessageRecords,
  20738. clearedFields: make(map[string]struct{}),
  20739. }
  20740. for _, opt := range opts {
  20741. opt(m)
  20742. }
  20743. return m
  20744. }
  20745. // withMessageRecordsID sets the ID field of the mutation.
  20746. func withMessageRecordsID(id uint64) messagerecordsOption {
  20747. return func(m *MessageRecordsMutation) {
  20748. var (
  20749. err error
  20750. once sync.Once
  20751. value *MessageRecords
  20752. )
  20753. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  20754. once.Do(func() {
  20755. if m.done {
  20756. err = errors.New("querying old values post mutation is not allowed")
  20757. } else {
  20758. value, err = m.Client().MessageRecords.Get(ctx, id)
  20759. }
  20760. })
  20761. return value, err
  20762. }
  20763. m.id = &id
  20764. }
  20765. }
  20766. // withMessageRecords sets the old MessageRecords of the mutation.
  20767. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  20768. return func(m *MessageRecordsMutation) {
  20769. m.oldValue = func(context.Context) (*MessageRecords, error) {
  20770. return node, nil
  20771. }
  20772. m.id = &node.ID
  20773. }
  20774. }
  20775. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20776. // executed in a transaction (ent.Tx), a transactional client is returned.
  20777. func (m MessageRecordsMutation) Client() *Client {
  20778. client := &Client{config: m.config}
  20779. client.init()
  20780. return client
  20781. }
  20782. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20783. // it returns an error otherwise.
  20784. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  20785. if _, ok := m.driver.(*txDriver); !ok {
  20786. return nil, errors.New("ent: mutation is not running in a transaction")
  20787. }
  20788. tx := &Tx{config: m.config}
  20789. tx.init()
  20790. return tx, nil
  20791. }
  20792. // SetID sets the value of the id field. Note that this
  20793. // operation is only accepted on creation of MessageRecords entities.
  20794. func (m *MessageRecordsMutation) SetID(id uint64) {
  20795. m.id = &id
  20796. }
  20797. // ID returns the ID value in the mutation. Note that the ID is only available
  20798. // if it was provided to the builder or after it was returned from the database.
  20799. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  20800. if m.id == nil {
  20801. return
  20802. }
  20803. return *m.id, true
  20804. }
  20805. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20806. // That means, if the mutation is applied within a transaction with an isolation level such
  20807. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20808. // or updated by the mutation.
  20809. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  20810. switch {
  20811. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20812. id, exists := m.ID()
  20813. if exists {
  20814. return []uint64{id}, nil
  20815. }
  20816. fallthrough
  20817. case m.op.Is(OpUpdate | OpDelete):
  20818. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  20819. default:
  20820. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20821. }
  20822. }
  20823. // SetCreatedAt sets the "created_at" field.
  20824. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  20825. m.created_at = &t
  20826. }
  20827. // CreatedAt returns the value of the "created_at" field in the mutation.
  20828. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  20829. v := m.created_at
  20830. if v == nil {
  20831. return
  20832. }
  20833. return *v, true
  20834. }
  20835. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  20836. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20838. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20839. if !m.op.Is(OpUpdateOne) {
  20840. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20841. }
  20842. if m.id == nil || m.oldValue == nil {
  20843. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20844. }
  20845. oldValue, err := m.oldValue(ctx)
  20846. if err != nil {
  20847. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20848. }
  20849. return oldValue.CreatedAt, nil
  20850. }
  20851. // ResetCreatedAt resets all changes to the "created_at" field.
  20852. func (m *MessageRecordsMutation) ResetCreatedAt() {
  20853. m.created_at = nil
  20854. }
  20855. // SetUpdatedAt sets the "updated_at" field.
  20856. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  20857. m.updated_at = &t
  20858. }
  20859. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20860. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  20861. v := m.updated_at
  20862. if v == nil {
  20863. return
  20864. }
  20865. return *v, true
  20866. }
  20867. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  20868. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20870. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20871. if !m.op.Is(OpUpdateOne) {
  20872. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20873. }
  20874. if m.id == nil || m.oldValue == nil {
  20875. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20876. }
  20877. oldValue, err := m.oldValue(ctx)
  20878. if err != nil {
  20879. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20880. }
  20881. return oldValue.UpdatedAt, nil
  20882. }
  20883. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20884. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  20885. m.updated_at = nil
  20886. }
  20887. // SetStatus sets the "status" field.
  20888. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  20889. m.status = &u
  20890. m.addstatus = nil
  20891. }
  20892. // Status returns the value of the "status" field in the mutation.
  20893. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  20894. v := m.status
  20895. if v == nil {
  20896. return
  20897. }
  20898. return *v, true
  20899. }
  20900. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  20901. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20903. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20904. if !m.op.Is(OpUpdateOne) {
  20905. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20906. }
  20907. if m.id == nil || m.oldValue == nil {
  20908. return v, errors.New("OldStatus requires an ID field in the mutation")
  20909. }
  20910. oldValue, err := m.oldValue(ctx)
  20911. if err != nil {
  20912. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20913. }
  20914. return oldValue.Status, nil
  20915. }
  20916. // AddStatus adds u to the "status" field.
  20917. func (m *MessageRecordsMutation) AddStatus(u int8) {
  20918. if m.addstatus != nil {
  20919. *m.addstatus += u
  20920. } else {
  20921. m.addstatus = &u
  20922. }
  20923. }
  20924. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20925. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  20926. v := m.addstatus
  20927. if v == nil {
  20928. return
  20929. }
  20930. return *v, true
  20931. }
  20932. // ClearStatus clears the value of the "status" field.
  20933. func (m *MessageRecordsMutation) ClearStatus() {
  20934. m.status = nil
  20935. m.addstatus = nil
  20936. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  20937. }
  20938. // StatusCleared returns if the "status" field was cleared in this mutation.
  20939. func (m *MessageRecordsMutation) StatusCleared() bool {
  20940. _, ok := m.clearedFields[messagerecords.FieldStatus]
  20941. return ok
  20942. }
  20943. // ResetStatus resets all changes to the "status" field.
  20944. func (m *MessageRecordsMutation) ResetStatus() {
  20945. m.status = nil
  20946. m.addstatus = nil
  20947. delete(m.clearedFields, messagerecords.FieldStatus)
  20948. }
  20949. // SetBotWxid sets the "bot_wxid" field.
  20950. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  20951. m.bot_wxid = &s
  20952. }
  20953. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  20954. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  20955. v := m.bot_wxid
  20956. if v == nil {
  20957. return
  20958. }
  20959. return *v, true
  20960. }
  20961. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  20962. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20964. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  20965. if !m.op.Is(OpUpdateOne) {
  20966. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  20967. }
  20968. if m.id == nil || m.oldValue == nil {
  20969. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  20970. }
  20971. oldValue, err := m.oldValue(ctx)
  20972. if err != nil {
  20973. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  20974. }
  20975. return oldValue.BotWxid, nil
  20976. }
  20977. // ResetBotWxid resets all changes to the "bot_wxid" field.
  20978. func (m *MessageRecordsMutation) ResetBotWxid() {
  20979. m.bot_wxid = nil
  20980. }
  20981. // SetContactID sets the "contact_id" field.
  20982. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  20983. m.message_contact = &u
  20984. }
  20985. // ContactID returns the value of the "contact_id" field in the mutation.
  20986. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  20987. v := m.message_contact
  20988. if v == nil {
  20989. return
  20990. }
  20991. return *v, true
  20992. }
  20993. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  20994. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20996. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  20997. if !m.op.Is(OpUpdateOne) {
  20998. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  20999. }
  21000. if m.id == nil || m.oldValue == nil {
  21001. return v, errors.New("OldContactID requires an ID field in the mutation")
  21002. }
  21003. oldValue, err := m.oldValue(ctx)
  21004. if err != nil {
  21005. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  21006. }
  21007. return oldValue.ContactID, nil
  21008. }
  21009. // ClearContactID clears the value of the "contact_id" field.
  21010. func (m *MessageRecordsMutation) ClearContactID() {
  21011. m.message_contact = nil
  21012. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  21013. }
  21014. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  21015. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  21016. _, ok := m.clearedFields[messagerecords.FieldContactID]
  21017. return ok
  21018. }
  21019. // ResetContactID resets all changes to the "contact_id" field.
  21020. func (m *MessageRecordsMutation) ResetContactID() {
  21021. m.message_contact = nil
  21022. delete(m.clearedFields, messagerecords.FieldContactID)
  21023. }
  21024. // SetContactType sets the "contact_type" field.
  21025. func (m *MessageRecordsMutation) SetContactType(i int) {
  21026. m.contact_type = &i
  21027. m.addcontact_type = nil
  21028. }
  21029. // ContactType returns the value of the "contact_type" field in the mutation.
  21030. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  21031. v := m.contact_type
  21032. if v == nil {
  21033. return
  21034. }
  21035. return *v, true
  21036. }
  21037. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  21038. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21040. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  21041. if !m.op.Is(OpUpdateOne) {
  21042. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  21043. }
  21044. if m.id == nil || m.oldValue == nil {
  21045. return v, errors.New("OldContactType requires an ID field in the mutation")
  21046. }
  21047. oldValue, err := m.oldValue(ctx)
  21048. if err != nil {
  21049. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  21050. }
  21051. return oldValue.ContactType, nil
  21052. }
  21053. // AddContactType adds i to the "contact_type" field.
  21054. func (m *MessageRecordsMutation) AddContactType(i int) {
  21055. if m.addcontact_type != nil {
  21056. *m.addcontact_type += i
  21057. } else {
  21058. m.addcontact_type = &i
  21059. }
  21060. }
  21061. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  21062. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  21063. v := m.addcontact_type
  21064. if v == nil {
  21065. return
  21066. }
  21067. return *v, true
  21068. }
  21069. // ResetContactType resets all changes to the "contact_type" field.
  21070. func (m *MessageRecordsMutation) ResetContactType() {
  21071. m.contact_type = nil
  21072. m.addcontact_type = nil
  21073. }
  21074. // SetContactWxid sets the "contact_wxid" field.
  21075. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  21076. m.contact_wxid = &s
  21077. }
  21078. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  21079. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  21080. v := m.contact_wxid
  21081. if v == nil {
  21082. return
  21083. }
  21084. return *v, true
  21085. }
  21086. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  21087. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21089. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  21090. if !m.op.Is(OpUpdateOne) {
  21091. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  21092. }
  21093. if m.id == nil || m.oldValue == nil {
  21094. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  21095. }
  21096. oldValue, err := m.oldValue(ctx)
  21097. if err != nil {
  21098. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  21099. }
  21100. return oldValue.ContactWxid, nil
  21101. }
  21102. // ResetContactWxid resets all changes to the "contact_wxid" field.
  21103. func (m *MessageRecordsMutation) ResetContactWxid() {
  21104. m.contact_wxid = nil
  21105. }
  21106. // SetContentType sets the "content_type" field.
  21107. func (m *MessageRecordsMutation) SetContentType(i int) {
  21108. m.content_type = &i
  21109. m.addcontent_type = nil
  21110. }
  21111. // ContentType returns the value of the "content_type" field in the mutation.
  21112. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  21113. v := m.content_type
  21114. if v == nil {
  21115. return
  21116. }
  21117. return *v, true
  21118. }
  21119. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  21120. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21122. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  21123. if !m.op.Is(OpUpdateOne) {
  21124. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  21125. }
  21126. if m.id == nil || m.oldValue == nil {
  21127. return v, errors.New("OldContentType requires an ID field in the mutation")
  21128. }
  21129. oldValue, err := m.oldValue(ctx)
  21130. if err != nil {
  21131. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  21132. }
  21133. return oldValue.ContentType, nil
  21134. }
  21135. // AddContentType adds i to the "content_type" field.
  21136. func (m *MessageRecordsMutation) AddContentType(i int) {
  21137. if m.addcontent_type != nil {
  21138. *m.addcontent_type += i
  21139. } else {
  21140. m.addcontent_type = &i
  21141. }
  21142. }
  21143. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  21144. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  21145. v := m.addcontent_type
  21146. if v == nil {
  21147. return
  21148. }
  21149. return *v, true
  21150. }
  21151. // ResetContentType resets all changes to the "content_type" field.
  21152. func (m *MessageRecordsMutation) ResetContentType() {
  21153. m.content_type = nil
  21154. m.addcontent_type = nil
  21155. }
  21156. // SetContent sets the "content" field.
  21157. func (m *MessageRecordsMutation) SetContent(s string) {
  21158. m.content = &s
  21159. }
  21160. // Content returns the value of the "content" field in the mutation.
  21161. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  21162. v := m.content
  21163. if v == nil {
  21164. return
  21165. }
  21166. return *v, true
  21167. }
  21168. // OldContent returns the old "content" field's value of the MessageRecords entity.
  21169. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21171. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  21172. if !m.op.Is(OpUpdateOne) {
  21173. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21174. }
  21175. if m.id == nil || m.oldValue == nil {
  21176. return v, errors.New("OldContent requires an ID field in the mutation")
  21177. }
  21178. oldValue, err := m.oldValue(ctx)
  21179. if err != nil {
  21180. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21181. }
  21182. return oldValue.Content, nil
  21183. }
  21184. // ResetContent resets all changes to the "content" field.
  21185. func (m *MessageRecordsMutation) ResetContent() {
  21186. m.content = nil
  21187. }
  21188. // SetMeta sets the "meta" field.
  21189. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  21190. m.meta = &ct
  21191. }
  21192. // Meta returns the value of the "meta" field in the mutation.
  21193. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  21194. v := m.meta
  21195. if v == nil {
  21196. return
  21197. }
  21198. return *v, true
  21199. }
  21200. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  21201. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21203. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  21204. if !m.op.Is(OpUpdateOne) {
  21205. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  21206. }
  21207. if m.id == nil || m.oldValue == nil {
  21208. return v, errors.New("OldMeta requires an ID field in the mutation")
  21209. }
  21210. oldValue, err := m.oldValue(ctx)
  21211. if err != nil {
  21212. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  21213. }
  21214. return oldValue.Meta, nil
  21215. }
  21216. // ClearMeta clears the value of the "meta" field.
  21217. func (m *MessageRecordsMutation) ClearMeta() {
  21218. m.meta = nil
  21219. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  21220. }
  21221. // MetaCleared returns if the "meta" field was cleared in this mutation.
  21222. func (m *MessageRecordsMutation) MetaCleared() bool {
  21223. _, ok := m.clearedFields[messagerecords.FieldMeta]
  21224. return ok
  21225. }
  21226. // ResetMeta resets all changes to the "meta" field.
  21227. func (m *MessageRecordsMutation) ResetMeta() {
  21228. m.meta = nil
  21229. delete(m.clearedFields, messagerecords.FieldMeta)
  21230. }
  21231. // SetErrorDetail sets the "error_detail" field.
  21232. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  21233. m.error_detail = &s
  21234. }
  21235. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  21236. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  21237. v := m.error_detail
  21238. if v == nil {
  21239. return
  21240. }
  21241. return *v, true
  21242. }
  21243. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  21244. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21246. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  21247. if !m.op.Is(OpUpdateOne) {
  21248. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  21249. }
  21250. if m.id == nil || m.oldValue == nil {
  21251. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  21252. }
  21253. oldValue, err := m.oldValue(ctx)
  21254. if err != nil {
  21255. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  21256. }
  21257. return oldValue.ErrorDetail, nil
  21258. }
  21259. // ResetErrorDetail resets all changes to the "error_detail" field.
  21260. func (m *MessageRecordsMutation) ResetErrorDetail() {
  21261. m.error_detail = nil
  21262. }
  21263. // SetSendTime sets the "send_time" field.
  21264. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  21265. m.send_time = &t
  21266. }
  21267. // SendTime returns the value of the "send_time" field in the mutation.
  21268. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  21269. v := m.send_time
  21270. if v == nil {
  21271. return
  21272. }
  21273. return *v, true
  21274. }
  21275. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  21276. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21278. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  21279. if !m.op.Is(OpUpdateOne) {
  21280. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  21281. }
  21282. if m.id == nil || m.oldValue == nil {
  21283. return v, errors.New("OldSendTime requires an ID field in the mutation")
  21284. }
  21285. oldValue, err := m.oldValue(ctx)
  21286. if err != nil {
  21287. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  21288. }
  21289. return oldValue.SendTime, nil
  21290. }
  21291. // ClearSendTime clears the value of the "send_time" field.
  21292. func (m *MessageRecordsMutation) ClearSendTime() {
  21293. m.send_time = nil
  21294. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  21295. }
  21296. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  21297. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  21298. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  21299. return ok
  21300. }
  21301. // ResetSendTime resets all changes to the "send_time" field.
  21302. func (m *MessageRecordsMutation) ResetSendTime() {
  21303. m.send_time = nil
  21304. delete(m.clearedFields, messagerecords.FieldSendTime)
  21305. }
  21306. // SetSourceType sets the "source_type" field.
  21307. func (m *MessageRecordsMutation) SetSourceType(i int) {
  21308. m.source_type = &i
  21309. m.addsource_type = nil
  21310. }
  21311. // SourceType returns the value of the "source_type" field in the mutation.
  21312. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  21313. v := m.source_type
  21314. if v == nil {
  21315. return
  21316. }
  21317. return *v, true
  21318. }
  21319. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  21320. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21322. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  21323. if !m.op.Is(OpUpdateOne) {
  21324. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  21325. }
  21326. if m.id == nil || m.oldValue == nil {
  21327. return v, errors.New("OldSourceType requires an ID field in the mutation")
  21328. }
  21329. oldValue, err := m.oldValue(ctx)
  21330. if err != nil {
  21331. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  21332. }
  21333. return oldValue.SourceType, nil
  21334. }
  21335. // AddSourceType adds i to the "source_type" field.
  21336. func (m *MessageRecordsMutation) AddSourceType(i int) {
  21337. if m.addsource_type != nil {
  21338. *m.addsource_type += i
  21339. } else {
  21340. m.addsource_type = &i
  21341. }
  21342. }
  21343. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  21344. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  21345. v := m.addsource_type
  21346. if v == nil {
  21347. return
  21348. }
  21349. return *v, true
  21350. }
  21351. // ResetSourceType resets all changes to the "source_type" field.
  21352. func (m *MessageRecordsMutation) ResetSourceType() {
  21353. m.source_type = nil
  21354. m.addsource_type = nil
  21355. }
  21356. // SetSourceID sets the "source_id" field.
  21357. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  21358. m.sop_stage = &u
  21359. }
  21360. // SourceID returns the value of the "source_id" field in the mutation.
  21361. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  21362. v := m.sop_stage
  21363. if v == nil {
  21364. return
  21365. }
  21366. return *v, true
  21367. }
  21368. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  21369. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21371. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  21372. if !m.op.Is(OpUpdateOne) {
  21373. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  21374. }
  21375. if m.id == nil || m.oldValue == nil {
  21376. return v, errors.New("OldSourceID requires an ID field in the mutation")
  21377. }
  21378. oldValue, err := m.oldValue(ctx)
  21379. if err != nil {
  21380. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  21381. }
  21382. return oldValue.SourceID, nil
  21383. }
  21384. // ClearSourceID clears the value of the "source_id" field.
  21385. func (m *MessageRecordsMutation) ClearSourceID() {
  21386. m.sop_stage = nil
  21387. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21388. }
  21389. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  21390. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  21391. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  21392. return ok
  21393. }
  21394. // ResetSourceID resets all changes to the "source_id" field.
  21395. func (m *MessageRecordsMutation) ResetSourceID() {
  21396. m.sop_stage = nil
  21397. delete(m.clearedFields, messagerecords.FieldSourceID)
  21398. }
  21399. // SetSubSourceID sets the "sub_source_id" field.
  21400. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  21401. m.sop_node = &u
  21402. }
  21403. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  21404. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  21405. v := m.sop_node
  21406. if v == nil {
  21407. return
  21408. }
  21409. return *v, true
  21410. }
  21411. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  21412. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21414. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  21415. if !m.op.Is(OpUpdateOne) {
  21416. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  21417. }
  21418. if m.id == nil || m.oldValue == nil {
  21419. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  21420. }
  21421. oldValue, err := m.oldValue(ctx)
  21422. if err != nil {
  21423. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  21424. }
  21425. return oldValue.SubSourceID, nil
  21426. }
  21427. // ClearSubSourceID clears the value of the "sub_source_id" field.
  21428. func (m *MessageRecordsMutation) ClearSubSourceID() {
  21429. m.sop_node = nil
  21430. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21431. }
  21432. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  21433. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  21434. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  21435. return ok
  21436. }
  21437. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  21438. func (m *MessageRecordsMutation) ResetSubSourceID() {
  21439. m.sop_node = nil
  21440. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  21441. }
  21442. // SetOrganizationID sets the "organization_id" field.
  21443. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  21444. m.organization_id = &u
  21445. m.addorganization_id = nil
  21446. }
  21447. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21448. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  21449. v := m.organization_id
  21450. if v == nil {
  21451. return
  21452. }
  21453. return *v, true
  21454. }
  21455. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  21456. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21458. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21459. if !m.op.Is(OpUpdateOne) {
  21460. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21461. }
  21462. if m.id == nil || m.oldValue == nil {
  21463. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21464. }
  21465. oldValue, err := m.oldValue(ctx)
  21466. if err != nil {
  21467. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21468. }
  21469. return oldValue.OrganizationID, nil
  21470. }
  21471. // AddOrganizationID adds u to the "organization_id" field.
  21472. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  21473. if m.addorganization_id != nil {
  21474. *m.addorganization_id += u
  21475. } else {
  21476. m.addorganization_id = &u
  21477. }
  21478. }
  21479. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21480. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  21481. v := m.addorganization_id
  21482. if v == nil {
  21483. return
  21484. }
  21485. return *v, true
  21486. }
  21487. // ClearOrganizationID clears the value of the "organization_id" field.
  21488. func (m *MessageRecordsMutation) ClearOrganizationID() {
  21489. m.organization_id = nil
  21490. m.addorganization_id = nil
  21491. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  21492. }
  21493. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21494. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  21495. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  21496. return ok
  21497. }
  21498. // ResetOrganizationID resets all changes to the "organization_id" field.
  21499. func (m *MessageRecordsMutation) ResetOrganizationID() {
  21500. m.organization_id = nil
  21501. m.addorganization_id = nil
  21502. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  21503. }
  21504. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21505. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  21506. m.sop_stage = &id
  21507. }
  21508. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21509. func (m *MessageRecordsMutation) ClearSopStage() {
  21510. m.clearedsop_stage = true
  21511. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21512. }
  21513. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21514. func (m *MessageRecordsMutation) SopStageCleared() bool {
  21515. return m.SourceIDCleared() || m.clearedsop_stage
  21516. }
  21517. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21518. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  21519. if m.sop_stage != nil {
  21520. return *m.sop_stage, true
  21521. }
  21522. return
  21523. }
  21524. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21525. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21526. // SopStageID instead. It exists only for internal usage by the builders.
  21527. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  21528. if id := m.sop_stage; id != nil {
  21529. ids = append(ids, *id)
  21530. }
  21531. return
  21532. }
  21533. // ResetSopStage resets all changes to the "sop_stage" edge.
  21534. func (m *MessageRecordsMutation) ResetSopStage() {
  21535. m.sop_stage = nil
  21536. m.clearedsop_stage = false
  21537. }
  21538. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  21539. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  21540. m.sop_node = &id
  21541. }
  21542. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  21543. func (m *MessageRecordsMutation) ClearSopNode() {
  21544. m.clearedsop_node = true
  21545. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21546. }
  21547. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  21548. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  21549. return m.SubSourceIDCleared() || m.clearedsop_node
  21550. }
  21551. // SopNodeID returns the "sop_node" edge ID in the mutation.
  21552. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  21553. if m.sop_node != nil {
  21554. return *m.sop_node, true
  21555. }
  21556. return
  21557. }
  21558. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  21559. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21560. // SopNodeID instead. It exists only for internal usage by the builders.
  21561. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  21562. if id := m.sop_node; id != nil {
  21563. ids = append(ids, *id)
  21564. }
  21565. return
  21566. }
  21567. // ResetSopNode resets all changes to the "sop_node" edge.
  21568. func (m *MessageRecordsMutation) ResetSopNode() {
  21569. m.sop_node = nil
  21570. m.clearedsop_node = false
  21571. }
  21572. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  21573. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  21574. m.message_contact = &id
  21575. }
  21576. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  21577. func (m *MessageRecordsMutation) ClearMessageContact() {
  21578. m.clearedmessage_contact = true
  21579. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  21580. }
  21581. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  21582. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  21583. return m.ContactIDCleared() || m.clearedmessage_contact
  21584. }
  21585. // MessageContactID returns the "message_contact" edge ID in the mutation.
  21586. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  21587. if m.message_contact != nil {
  21588. return *m.message_contact, true
  21589. }
  21590. return
  21591. }
  21592. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  21593. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21594. // MessageContactID instead. It exists only for internal usage by the builders.
  21595. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  21596. if id := m.message_contact; id != nil {
  21597. ids = append(ids, *id)
  21598. }
  21599. return
  21600. }
  21601. // ResetMessageContact resets all changes to the "message_contact" edge.
  21602. func (m *MessageRecordsMutation) ResetMessageContact() {
  21603. m.message_contact = nil
  21604. m.clearedmessage_contact = false
  21605. }
  21606. // Where appends a list predicates to the MessageRecordsMutation builder.
  21607. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  21608. m.predicates = append(m.predicates, ps...)
  21609. }
  21610. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  21611. // users can use type-assertion to append predicates that do not depend on any generated package.
  21612. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  21613. p := make([]predicate.MessageRecords, len(ps))
  21614. for i := range ps {
  21615. p[i] = ps[i]
  21616. }
  21617. m.Where(p...)
  21618. }
  21619. // Op returns the operation name.
  21620. func (m *MessageRecordsMutation) Op() Op {
  21621. return m.op
  21622. }
  21623. // SetOp allows setting the mutation operation.
  21624. func (m *MessageRecordsMutation) SetOp(op Op) {
  21625. m.op = op
  21626. }
  21627. // Type returns the node type of this mutation (MessageRecords).
  21628. func (m *MessageRecordsMutation) Type() string {
  21629. return m.typ
  21630. }
  21631. // Fields returns all fields that were changed during this mutation. Note that in
  21632. // order to get all numeric fields that were incremented/decremented, call
  21633. // AddedFields().
  21634. func (m *MessageRecordsMutation) Fields() []string {
  21635. fields := make([]string, 0, 16)
  21636. if m.created_at != nil {
  21637. fields = append(fields, messagerecords.FieldCreatedAt)
  21638. }
  21639. if m.updated_at != nil {
  21640. fields = append(fields, messagerecords.FieldUpdatedAt)
  21641. }
  21642. if m.status != nil {
  21643. fields = append(fields, messagerecords.FieldStatus)
  21644. }
  21645. if m.bot_wxid != nil {
  21646. fields = append(fields, messagerecords.FieldBotWxid)
  21647. }
  21648. if m.message_contact != nil {
  21649. fields = append(fields, messagerecords.FieldContactID)
  21650. }
  21651. if m.contact_type != nil {
  21652. fields = append(fields, messagerecords.FieldContactType)
  21653. }
  21654. if m.contact_wxid != nil {
  21655. fields = append(fields, messagerecords.FieldContactWxid)
  21656. }
  21657. if m.content_type != nil {
  21658. fields = append(fields, messagerecords.FieldContentType)
  21659. }
  21660. if m.content != nil {
  21661. fields = append(fields, messagerecords.FieldContent)
  21662. }
  21663. if m.meta != nil {
  21664. fields = append(fields, messagerecords.FieldMeta)
  21665. }
  21666. if m.error_detail != nil {
  21667. fields = append(fields, messagerecords.FieldErrorDetail)
  21668. }
  21669. if m.send_time != nil {
  21670. fields = append(fields, messagerecords.FieldSendTime)
  21671. }
  21672. if m.source_type != nil {
  21673. fields = append(fields, messagerecords.FieldSourceType)
  21674. }
  21675. if m.sop_stage != nil {
  21676. fields = append(fields, messagerecords.FieldSourceID)
  21677. }
  21678. if m.sop_node != nil {
  21679. fields = append(fields, messagerecords.FieldSubSourceID)
  21680. }
  21681. if m.organization_id != nil {
  21682. fields = append(fields, messagerecords.FieldOrganizationID)
  21683. }
  21684. return fields
  21685. }
  21686. // Field returns the value of a field with the given name. The second boolean
  21687. // return value indicates that this field was not set, or was not defined in the
  21688. // schema.
  21689. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  21690. switch name {
  21691. case messagerecords.FieldCreatedAt:
  21692. return m.CreatedAt()
  21693. case messagerecords.FieldUpdatedAt:
  21694. return m.UpdatedAt()
  21695. case messagerecords.FieldStatus:
  21696. return m.Status()
  21697. case messagerecords.FieldBotWxid:
  21698. return m.BotWxid()
  21699. case messagerecords.FieldContactID:
  21700. return m.ContactID()
  21701. case messagerecords.FieldContactType:
  21702. return m.ContactType()
  21703. case messagerecords.FieldContactWxid:
  21704. return m.ContactWxid()
  21705. case messagerecords.FieldContentType:
  21706. return m.ContentType()
  21707. case messagerecords.FieldContent:
  21708. return m.Content()
  21709. case messagerecords.FieldMeta:
  21710. return m.Meta()
  21711. case messagerecords.FieldErrorDetail:
  21712. return m.ErrorDetail()
  21713. case messagerecords.FieldSendTime:
  21714. return m.SendTime()
  21715. case messagerecords.FieldSourceType:
  21716. return m.SourceType()
  21717. case messagerecords.FieldSourceID:
  21718. return m.SourceID()
  21719. case messagerecords.FieldSubSourceID:
  21720. return m.SubSourceID()
  21721. case messagerecords.FieldOrganizationID:
  21722. return m.OrganizationID()
  21723. }
  21724. return nil, false
  21725. }
  21726. // OldField returns the old value of the field from the database. An error is
  21727. // returned if the mutation operation is not UpdateOne, or the query to the
  21728. // database failed.
  21729. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21730. switch name {
  21731. case messagerecords.FieldCreatedAt:
  21732. return m.OldCreatedAt(ctx)
  21733. case messagerecords.FieldUpdatedAt:
  21734. return m.OldUpdatedAt(ctx)
  21735. case messagerecords.FieldStatus:
  21736. return m.OldStatus(ctx)
  21737. case messagerecords.FieldBotWxid:
  21738. return m.OldBotWxid(ctx)
  21739. case messagerecords.FieldContactID:
  21740. return m.OldContactID(ctx)
  21741. case messagerecords.FieldContactType:
  21742. return m.OldContactType(ctx)
  21743. case messagerecords.FieldContactWxid:
  21744. return m.OldContactWxid(ctx)
  21745. case messagerecords.FieldContentType:
  21746. return m.OldContentType(ctx)
  21747. case messagerecords.FieldContent:
  21748. return m.OldContent(ctx)
  21749. case messagerecords.FieldMeta:
  21750. return m.OldMeta(ctx)
  21751. case messagerecords.FieldErrorDetail:
  21752. return m.OldErrorDetail(ctx)
  21753. case messagerecords.FieldSendTime:
  21754. return m.OldSendTime(ctx)
  21755. case messagerecords.FieldSourceType:
  21756. return m.OldSourceType(ctx)
  21757. case messagerecords.FieldSourceID:
  21758. return m.OldSourceID(ctx)
  21759. case messagerecords.FieldSubSourceID:
  21760. return m.OldSubSourceID(ctx)
  21761. case messagerecords.FieldOrganizationID:
  21762. return m.OldOrganizationID(ctx)
  21763. }
  21764. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  21765. }
  21766. // SetField sets the value of a field with the given name. It returns an error if
  21767. // the field is not defined in the schema, or if the type mismatched the field
  21768. // type.
  21769. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  21770. switch name {
  21771. case messagerecords.FieldCreatedAt:
  21772. v, ok := value.(time.Time)
  21773. if !ok {
  21774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21775. }
  21776. m.SetCreatedAt(v)
  21777. return nil
  21778. case messagerecords.FieldUpdatedAt:
  21779. v, ok := value.(time.Time)
  21780. if !ok {
  21781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21782. }
  21783. m.SetUpdatedAt(v)
  21784. return nil
  21785. case messagerecords.FieldStatus:
  21786. v, ok := value.(uint8)
  21787. if !ok {
  21788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21789. }
  21790. m.SetStatus(v)
  21791. return nil
  21792. case messagerecords.FieldBotWxid:
  21793. v, ok := value.(string)
  21794. if !ok {
  21795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21796. }
  21797. m.SetBotWxid(v)
  21798. return nil
  21799. case messagerecords.FieldContactID:
  21800. v, ok := value.(uint64)
  21801. if !ok {
  21802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21803. }
  21804. m.SetContactID(v)
  21805. return nil
  21806. case messagerecords.FieldContactType:
  21807. v, ok := value.(int)
  21808. if !ok {
  21809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21810. }
  21811. m.SetContactType(v)
  21812. return nil
  21813. case messagerecords.FieldContactWxid:
  21814. v, ok := value.(string)
  21815. if !ok {
  21816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21817. }
  21818. m.SetContactWxid(v)
  21819. return nil
  21820. case messagerecords.FieldContentType:
  21821. v, ok := value.(int)
  21822. if !ok {
  21823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21824. }
  21825. m.SetContentType(v)
  21826. return nil
  21827. case messagerecords.FieldContent:
  21828. v, ok := value.(string)
  21829. if !ok {
  21830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21831. }
  21832. m.SetContent(v)
  21833. return nil
  21834. case messagerecords.FieldMeta:
  21835. v, ok := value.(custom_types.Meta)
  21836. if !ok {
  21837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21838. }
  21839. m.SetMeta(v)
  21840. return nil
  21841. case messagerecords.FieldErrorDetail:
  21842. v, ok := value.(string)
  21843. if !ok {
  21844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21845. }
  21846. m.SetErrorDetail(v)
  21847. return nil
  21848. case messagerecords.FieldSendTime:
  21849. v, ok := value.(time.Time)
  21850. if !ok {
  21851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21852. }
  21853. m.SetSendTime(v)
  21854. return nil
  21855. case messagerecords.FieldSourceType:
  21856. v, ok := value.(int)
  21857. if !ok {
  21858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21859. }
  21860. m.SetSourceType(v)
  21861. return nil
  21862. case messagerecords.FieldSourceID:
  21863. v, ok := value.(uint64)
  21864. if !ok {
  21865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21866. }
  21867. m.SetSourceID(v)
  21868. return nil
  21869. case messagerecords.FieldSubSourceID:
  21870. v, ok := value.(uint64)
  21871. if !ok {
  21872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21873. }
  21874. m.SetSubSourceID(v)
  21875. return nil
  21876. case messagerecords.FieldOrganizationID:
  21877. v, ok := value.(uint64)
  21878. if !ok {
  21879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21880. }
  21881. m.SetOrganizationID(v)
  21882. return nil
  21883. }
  21884. return fmt.Errorf("unknown MessageRecords field %s", name)
  21885. }
  21886. // AddedFields returns all numeric fields that were incremented/decremented during
  21887. // this mutation.
  21888. func (m *MessageRecordsMutation) AddedFields() []string {
  21889. var fields []string
  21890. if m.addstatus != nil {
  21891. fields = append(fields, messagerecords.FieldStatus)
  21892. }
  21893. if m.addcontact_type != nil {
  21894. fields = append(fields, messagerecords.FieldContactType)
  21895. }
  21896. if m.addcontent_type != nil {
  21897. fields = append(fields, messagerecords.FieldContentType)
  21898. }
  21899. if m.addsource_type != nil {
  21900. fields = append(fields, messagerecords.FieldSourceType)
  21901. }
  21902. if m.addorganization_id != nil {
  21903. fields = append(fields, messagerecords.FieldOrganizationID)
  21904. }
  21905. return fields
  21906. }
  21907. // AddedField returns the numeric value that was incremented/decremented on a field
  21908. // with the given name. The second boolean return value indicates that this field
  21909. // was not set, or was not defined in the schema.
  21910. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  21911. switch name {
  21912. case messagerecords.FieldStatus:
  21913. return m.AddedStatus()
  21914. case messagerecords.FieldContactType:
  21915. return m.AddedContactType()
  21916. case messagerecords.FieldContentType:
  21917. return m.AddedContentType()
  21918. case messagerecords.FieldSourceType:
  21919. return m.AddedSourceType()
  21920. case messagerecords.FieldOrganizationID:
  21921. return m.AddedOrganizationID()
  21922. }
  21923. return nil, false
  21924. }
  21925. // AddField adds the value to the field with the given name. It returns an error if
  21926. // the field is not defined in the schema, or if the type mismatched the field
  21927. // type.
  21928. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  21929. switch name {
  21930. case messagerecords.FieldStatus:
  21931. v, ok := value.(int8)
  21932. if !ok {
  21933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21934. }
  21935. m.AddStatus(v)
  21936. return nil
  21937. case messagerecords.FieldContactType:
  21938. v, ok := value.(int)
  21939. if !ok {
  21940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21941. }
  21942. m.AddContactType(v)
  21943. return nil
  21944. case messagerecords.FieldContentType:
  21945. v, ok := value.(int)
  21946. if !ok {
  21947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21948. }
  21949. m.AddContentType(v)
  21950. return nil
  21951. case messagerecords.FieldSourceType:
  21952. v, ok := value.(int)
  21953. if !ok {
  21954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21955. }
  21956. m.AddSourceType(v)
  21957. return nil
  21958. case messagerecords.FieldOrganizationID:
  21959. v, ok := value.(int64)
  21960. if !ok {
  21961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21962. }
  21963. m.AddOrganizationID(v)
  21964. return nil
  21965. }
  21966. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  21967. }
  21968. // ClearedFields returns all nullable fields that were cleared during this
  21969. // mutation.
  21970. func (m *MessageRecordsMutation) ClearedFields() []string {
  21971. var fields []string
  21972. if m.FieldCleared(messagerecords.FieldStatus) {
  21973. fields = append(fields, messagerecords.FieldStatus)
  21974. }
  21975. if m.FieldCleared(messagerecords.FieldContactID) {
  21976. fields = append(fields, messagerecords.FieldContactID)
  21977. }
  21978. if m.FieldCleared(messagerecords.FieldMeta) {
  21979. fields = append(fields, messagerecords.FieldMeta)
  21980. }
  21981. if m.FieldCleared(messagerecords.FieldSendTime) {
  21982. fields = append(fields, messagerecords.FieldSendTime)
  21983. }
  21984. if m.FieldCleared(messagerecords.FieldSourceID) {
  21985. fields = append(fields, messagerecords.FieldSourceID)
  21986. }
  21987. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  21988. fields = append(fields, messagerecords.FieldSubSourceID)
  21989. }
  21990. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  21991. fields = append(fields, messagerecords.FieldOrganizationID)
  21992. }
  21993. return fields
  21994. }
  21995. // FieldCleared returns a boolean indicating if a field with the given name was
  21996. // cleared in this mutation.
  21997. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  21998. _, ok := m.clearedFields[name]
  21999. return ok
  22000. }
  22001. // ClearField clears the value of the field with the given name. It returns an
  22002. // error if the field is not defined in the schema.
  22003. func (m *MessageRecordsMutation) ClearField(name string) error {
  22004. switch name {
  22005. case messagerecords.FieldStatus:
  22006. m.ClearStatus()
  22007. return nil
  22008. case messagerecords.FieldContactID:
  22009. m.ClearContactID()
  22010. return nil
  22011. case messagerecords.FieldMeta:
  22012. m.ClearMeta()
  22013. return nil
  22014. case messagerecords.FieldSendTime:
  22015. m.ClearSendTime()
  22016. return nil
  22017. case messagerecords.FieldSourceID:
  22018. m.ClearSourceID()
  22019. return nil
  22020. case messagerecords.FieldSubSourceID:
  22021. m.ClearSubSourceID()
  22022. return nil
  22023. case messagerecords.FieldOrganizationID:
  22024. m.ClearOrganizationID()
  22025. return nil
  22026. }
  22027. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  22028. }
  22029. // ResetField resets all changes in the mutation for the field with the given name.
  22030. // It returns an error if the field is not defined in the schema.
  22031. func (m *MessageRecordsMutation) ResetField(name string) error {
  22032. switch name {
  22033. case messagerecords.FieldCreatedAt:
  22034. m.ResetCreatedAt()
  22035. return nil
  22036. case messagerecords.FieldUpdatedAt:
  22037. m.ResetUpdatedAt()
  22038. return nil
  22039. case messagerecords.FieldStatus:
  22040. m.ResetStatus()
  22041. return nil
  22042. case messagerecords.FieldBotWxid:
  22043. m.ResetBotWxid()
  22044. return nil
  22045. case messagerecords.FieldContactID:
  22046. m.ResetContactID()
  22047. return nil
  22048. case messagerecords.FieldContactType:
  22049. m.ResetContactType()
  22050. return nil
  22051. case messagerecords.FieldContactWxid:
  22052. m.ResetContactWxid()
  22053. return nil
  22054. case messagerecords.FieldContentType:
  22055. m.ResetContentType()
  22056. return nil
  22057. case messagerecords.FieldContent:
  22058. m.ResetContent()
  22059. return nil
  22060. case messagerecords.FieldMeta:
  22061. m.ResetMeta()
  22062. return nil
  22063. case messagerecords.FieldErrorDetail:
  22064. m.ResetErrorDetail()
  22065. return nil
  22066. case messagerecords.FieldSendTime:
  22067. m.ResetSendTime()
  22068. return nil
  22069. case messagerecords.FieldSourceType:
  22070. m.ResetSourceType()
  22071. return nil
  22072. case messagerecords.FieldSourceID:
  22073. m.ResetSourceID()
  22074. return nil
  22075. case messagerecords.FieldSubSourceID:
  22076. m.ResetSubSourceID()
  22077. return nil
  22078. case messagerecords.FieldOrganizationID:
  22079. m.ResetOrganizationID()
  22080. return nil
  22081. }
  22082. return fmt.Errorf("unknown MessageRecords field %s", name)
  22083. }
  22084. // AddedEdges returns all edge names that were set/added in this mutation.
  22085. func (m *MessageRecordsMutation) AddedEdges() []string {
  22086. edges := make([]string, 0, 3)
  22087. if m.sop_stage != nil {
  22088. edges = append(edges, messagerecords.EdgeSopStage)
  22089. }
  22090. if m.sop_node != nil {
  22091. edges = append(edges, messagerecords.EdgeSopNode)
  22092. }
  22093. if m.message_contact != nil {
  22094. edges = append(edges, messagerecords.EdgeMessageContact)
  22095. }
  22096. return edges
  22097. }
  22098. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22099. // name in this mutation.
  22100. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  22101. switch name {
  22102. case messagerecords.EdgeSopStage:
  22103. if id := m.sop_stage; id != nil {
  22104. return []ent.Value{*id}
  22105. }
  22106. case messagerecords.EdgeSopNode:
  22107. if id := m.sop_node; id != nil {
  22108. return []ent.Value{*id}
  22109. }
  22110. case messagerecords.EdgeMessageContact:
  22111. if id := m.message_contact; id != nil {
  22112. return []ent.Value{*id}
  22113. }
  22114. }
  22115. return nil
  22116. }
  22117. // RemovedEdges returns all edge names that were removed in this mutation.
  22118. func (m *MessageRecordsMutation) RemovedEdges() []string {
  22119. edges := make([]string, 0, 3)
  22120. return edges
  22121. }
  22122. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22123. // the given name in this mutation.
  22124. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  22125. return nil
  22126. }
  22127. // ClearedEdges returns all edge names that were cleared in this mutation.
  22128. func (m *MessageRecordsMutation) ClearedEdges() []string {
  22129. edges := make([]string, 0, 3)
  22130. if m.clearedsop_stage {
  22131. edges = append(edges, messagerecords.EdgeSopStage)
  22132. }
  22133. if m.clearedsop_node {
  22134. edges = append(edges, messagerecords.EdgeSopNode)
  22135. }
  22136. if m.clearedmessage_contact {
  22137. edges = append(edges, messagerecords.EdgeMessageContact)
  22138. }
  22139. return edges
  22140. }
  22141. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22142. // was cleared in this mutation.
  22143. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  22144. switch name {
  22145. case messagerecords.EdgeSopStage:
  22146. return m.clearedsop_stage
  22147. case messagerecords.EdgeSopNode:
  22148. return m.clearedsop_node
  22149. case messagerecords.EdgeMessageContact:
  22150. return m.clearedmessage_contact
  22151. }
  22152. return false
  22153. }
  22154. // ClearEdge clears the value of the edge with the given name. It returns an error
  22155. // if that edge is not defined in the schema.
  22156. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  22157. switch name {
  22158. case messagerecords.EdgeSopStage:
  22159. m.ClearSopStage()
  22160. return nil
  22161. case messagerecords.EdgeSopNode:
  22162. m.ClearSopNode()
  22163. return nil
  22164. case messagerecords.EdgeMessageContact:
  22165. m.ClearMessageContact()
  22166. return nil
  22167. }
  22168. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  22169. }
  22170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22171. // It returns an error if the edge is not defined in the schema.
  22172. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  22173. switch name {
  22174. case messagerecords.EdgeSopStage:
  22175. m.ResetSopStage()
  22176. return nil
  22177. case messagerecords.EdgeSopNode:
  22178. m.ResetSopNode()
  22179. return nil
  22180. case messagerecords.EdgeMessageContact:
  22181. m.ResetMessageContact()
  22182. return nil
  22183. }
  22184. return fmt.Errorf("unknown MessageRecords edge %s", name)
  22185. }
  22186. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  22187. type MsgMutation struct {
  22188. config
  22189. op Op
  22190. typ string
  22191. id *uint64
  22192. created_at *time.Time
  22193. updated_at *time.Time
  22194. deleted_at *time.Time
  22195. status *uint8
  22196. addstatus *int8
  22197. fromwxid *string
  22198. toid *string
  22199. msgtype *int32
  22200. addmsgtype *int32
  22201. msg *string
  22202. batch_no *string
  22203. cc *string
  22204. phone *string
  22205. clearedFields map[string]struct{}
  22206. done bool
  22207. oldValue func(context.Context) (*Msg, error)
  22208. predicates []predicate.Msg
  22209. }
  22210. var _ ent.Mutation = (*MsgMutation)(nil)
  22211. // msgOption allows management of the mutation configuration using functional options.
  22212. type msgOption func(*MsgMutation)
  22213. // newMsgMutation creates new mutation for the Msg entity.
  22214. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  22215. m := &MsgMutation{
  22216. config: c,
  22217. op: op,
  22218. typ: TypeMsg,
  22219. clearedFields: make(map[string]struct{}),
  22220. }
  22221. for _, opt := range opts {
  22222. opt(m)
  22223. }
  22224. return m
  22225. }
  22226. // withMsgID sets the ID field of the mutation.
  22227. func withMsgID(id uint64) msgOption {
  22228. return func(m *MsgMutation) {
  22229. var (
  22230. err error
  22231. once sync.Once
  22232. value *Msg
  22233. )
  22234. m.oldValue = func(ctx context.Context) (*Msg, error) {
  22235. once.Do(func() {
  22236. if m.done {
  22237. err = errors.New("querying old values post mutation is not allowed")
  22238. } else {
  22239. value, err = m.Client().Msg.Get(ctx, id)
  22240. }
  22241. })
  22242. return value, err
  22243. }
  22244. m.id = &id
  22245. }
  22246. }
  22247. // withMsg sets the old Msg of the mutation.
  22248. func withMsg(node *Msg) msgOption {
  22249. return func(m *MsgMutation) {
  22250. m.oldValue = func(context.Context) (*Msg, error) {
  22251. return node, nil
  22252. }
  22253. m.id = &node.ID
  22254. }
  22255. }
  22256. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22257. // executed in a transaction (ent.Tx), a transactional client is returned.
  22258. func (m MsgMutation) Client() *Client {
  22259. client := &Client{config: m.config}
  22260. client.init()
  22261. return client
  22262. }
  22263. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22264. // it returns an error otherwise.
  22265. func (m MsgMutation) Tx() (*Tx, error) {
  22266. if _, ok := m.driver.(*txDriver); !ok {
  22267. return nil, errors.New("ent: mutation is not running in a transaction")
  22268. }
  22269. tx := &Tx{config: m.config}
  22270. tx.init()
  22271. return tx, nil
  22272. }
  22273. // SetID sets the value of the id field. Note that this
  22274. // operation is only accepted on creation of Msg entities.
  22275. func (m *MsgMutation) SetID(id uint64) {
  22276. m.id = &id
  22277. }
  22278. // ID returns the ID value in the mutation. Note that the ID is only available
  22279. // if it was provided to the builder or after it was returned from the database.
  22280. func (m *MsgMutation) ID() (id uint64, exists bool) {
  22281. if m.id == nil {
  22282. return
  22283. }
  22284. return *m.id, true
  22285. }
  22286. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22287. // That means, if the mutation is applied within a transaction with an isolation level such
  22288. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22289. // or updated by the mutation.
  22290. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  22291. switch {
  22292. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22293. id, exists := m.ID()
  22294. if exists {
  22295. return []uint64{id}, nil
  22296. }
  22297. fallthrough
  22298. case m.op.Is(OpUpdate | OpDelete):
  22299. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  22300. default:
  22301. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22302. }
  22303. }
  22304. // SetCreatedAt sets the "created_at" field.
  22305. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  22306. m.created_at = &t
  22307. }
  22308. // CreatedAt returns the value of the "created_at" field in the mutation.
  22309. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  22310. v := m.created_at
  22311. if v == nil {
  22312. return
  22313. }
  22314. return *v, true
  22315. }
  22316. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  22317. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22319. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22320. if !m.op.Is(OpUpdateOne) {
  22321. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22322. }
  22323. if m.id == nil || m.oldValue == nil {
  22324. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22325. }
  22326. oldValue, err := m.oldValue(ctx)
  22327. if err != nil {
  22328. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22329. }
  22330. return oldValue.CreatedAt, nil
  22331. }
  22332. // ResetCreatedAt resets all changes to the "created_at" field.
  22333. func (m *MsgMutation) ResetCreatedAt() {
  22334. m.created_at = nil
  22335. }
  22336. // SetUpdatedAt sets the "updated_at" field.
  22337. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  22338. m.updated_at = &t
  22339. }
  22340. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22341. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  22342. v := m.updated_at
  22343. if v == nil {
  22344. return
  22345. }
  22346. return *v, true
  22347. }
  22348. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  22349. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22351. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22352. if !m.op.Is(OpUpdateOne) {
  22353. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22354. }
  22355. if m.id == nil || m.oldValue == nil {
  22356. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22357. }
  22358. oldValue, err := m.oldValue(ctx)
  22359. if err != nil {
  22360. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22361. }
  22362. return oldValue.UpdatedAt, nil
  22363. }
  22364. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22365. func (m *MsgMutation) ResetUpdatedAt() {
  22366. m.updated_at = nil
  22367. }
  22368. // SetDeletedAt sets the "deleted_at" field.
  22369. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  22370. m.deleted_at = &t
  22371. }
  22372. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22373. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  22374. v := m.deleted_at
  22375. if v == nil {
  22376. return
  22377. }
  22378. return *v, true
  22379. }
  22380. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  22381. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22383. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22384. if !m.op.Is(OpUpdateOne) {
  22385. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22386. }
  22387. if m.id == nil || m.oldValue == nil {
  22388. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22389. }
  22390. oldValue, err := m.oldValue(ctx)
  22391. if err != nil {
  22392. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22393. }
  22394. return oldValue.DeletedAt, nil
  22395. }
  22396. // ClearDeletedAt clears the value of the "deleted_at" field.
  22397. func (m *MsgMutation) ClearDeletedAt() {
  22398. m.deleted_at = nil
  22399. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  22400. }
  22401. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22402. func (m *MsgMutation) DeletedAtCleared() bool {
  22403. _, ok := m.clearedFields[msg.FieldDeletedAt]
  22404. return ok
  22405. }
  22406. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22407. func (m *MsgMutation) ResetDeletedAt() {
  22408. m.deleted_at = nil
  22409. delete(m.clearedFields, msg.FieldDeletedAt)
  22410. }
  22411. // SetStatus sets the "status" field.
  22412. func (m *MsgMutation) SetStatus(u uint8) {
  22413. m.status = &u
  22414. m.addstatus = nil
  22415. }
  22416. // Status returns the value of the "status" field in the mutation.
  22417. func (m *MsgMutation) Status() (r uint8, exists bool) {
  22418. v := m.status
  22419. if v == nil {
  22420. return
  22421. }
  22422. return *v, true
  22423. }
  22424. // OldStatus returns the old "status" field's value of the Msg entity.
  22425. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22427. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22428. if !m.op.Is(OpUpdateOne) {
  22429. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22430. }
  22431. if m.id == nil || m.oldValue == nil {
  22432. return v, errors.New("OldStatus requires an ID field in the mutation")
  22433. }
  22434. oldValue, err := m.oldValue(ctx)
  22435. if err != nil {
  22436. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22437. }
  22438. return oldValue.Status, nil
  22439. }
  22440. // AddStatus adds u to the "status" field.
  22441. func (m *MsgMutation) AddStatus(u int8) {
  22442. if m.addstatus != nil {
  22443. *m.addstatus += u
  22444. } else {
  22445. m.addstatus = &u
  22446. }
  22447. }
  22448. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22449. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  22450. v := m.addstatus
  22451. if v == nil {
  22452. return
  22453. }
  22454. return *v, true
  22455. }
  22456. // ClearStatus clears the value of the "status" field.
  22457. func (m *MsgMutation) ClearStatus() {
  22458. m.status = nil
  22459. m.addstatus = nil
  22460. m.clearedFields[msg.FieldStatus] = struct{}{}
  22461. }
  22462. // StatusCleared returns if the "status" field was cleared in this mutation.
  22463. func (m *MsgMutation) StatusCleared() bool {
  22464. _, ok := m.clearedFields[msg.FieldStatus]
  22465. return ok
  22466. }
  22467. // ResetStatus resets all changes to the "status" field.
  22468. func (m *MsgMutation) ResetStatus() {
  22469. m.status = nil
  22470. m.addstatus = nil
  22471. delete(m.clearedFields, msg.FieldStatus)
  22472. }
  22473. // SetFromwxid sets the "fromwxid" field.
  22474. func (m *MsgMutation) SetFromwxid(s string) {
  22475. m.fromwxid = &s
  22476. }
  22477. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  22478. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  22479. v := m.fromwxid
  22480. if v == nil {
  22481. return
  22482. }
  22483. return *v, true
  22484. }
  22485. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  22486. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22488. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  22489. if !m.op.Is(OpUpdateOne) {
  22490. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  22491. }
  22492. if m.id == nil || m.oldValue == nil {
  22493. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  22494. }
  22495. oldValue, err := m.oldValue(ctx)
  22496. if err != nil {
  22497. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  22498. }
  22499. return oldValue.Fromwxid, nil
  22500. }
  22501. // ClearFromwxid clears the value of the "fromwxid" field.
  22502. func (m *MsgMutation) ClearFromwxid() {
  22503. m.fromwxid = nil
  22504. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  22505. }
  22506. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  22507. func (m *MsgMutation) FromwxidCleared() bool {
  22508. _, ok := m.clearedFields[msg.FieldFromwxid]
  22509. return ok
  22510. }
  22511. // ResetFromwxid resets all changes to the "fromwxid" field.
  22512. func (m *MsgMutation) ResetFromwxid() {
  22513. m.fromwxid = nil
  22514. delete(m.clearedFields, msg.FieldFromwxid)
  22515. }
  22516. // SetToid sets the "toid" field.
  22517. func (m *MsgMutation) SetToid(s string) {
  22518. m.toid = &s
  22519. }
  22520. // Toid returns the value of the "toid" field in the mutation.
  22521. func (m *MsgMutation) Toid() (r string, exists bool) {
  22522. v := m.toid
  22523. if v == nil {
  22524. return
  22525. }
  22526. return *v, true
  22527. }
  22528. // OldToid returns the old "toid" field's value of the Msg entity.
  22529. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22531. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  22532. if !m.op.Is(OpUpdateOne) {
  22533. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  22534. }
  22535. if m.id == nil || m.oldValue == nil {
  22536. return v, errors.New("OldToid requires an ID field in the mutation")
  22537. }
  22538. oldValue, err := m.oldValue(ctx)
  22539. if err != nil {
  22540. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  22541. }
  22542. return oldValue.Toid, nil
  22543. }
  22544. // ClearToid clears the value of the "toid" field.
  22545. func (m *MsgMutation) ClearToid() {
  22546. m.toid = nil
  22547. m.clearedFields[msg.FieldToid] = struct{}{}
  22548. }
  22549. // ToidCleared returns if the "toid" field was cleared in this mutation.
  22550. func (m *MsgMutation) ToidCleared() bool {
  22551. _, ok := m.clearedFields[msg.FieldToid]
  22552. return ok
  22553. }
  22554. // ResetToid resets all changes to the "toid" field.
  22555. func (m *MsgMutation) ResetToid() {
  22556. m.toid = nil
  22557. delete(m.clearedFields, msg.FieldToid)
  22558. }
  22559. // SetMsgtype sets the "msgtype" field.
  22560. func (m *MsgMutation) SetMsgtype(i int32) {
  22561. m.msgtype = &i
  22562. m.addmsgtype = nil
  22563. }
  22564. // Msgtype returns the value of the "msgtype" field in the mutation.
  22565. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  22566. v := m.msgtype
  22567. if v == nil {
  22568. return
  22569. }
  22570. return *v, true
  22571. }
  22572. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  22573. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22575. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  22576. if !m.op.Is(OpUpdateOne) {
  22577. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  22578. }
  22579. if m.id == nil || m.oldValue == nil {
  22580. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  22581. }
  22582. oldValue, err := m.oldValue(ctx)
  22583. if err != nil {
  22584. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  22585. }
  22586. return oldValue.Msgtype, nil
  22587. }
  22588. // AddMsgtype adds i to the "msgtype" field.
  22589. func (m *MsgMutation) AddMsgtype(i int32) {
  22590. if m.addmsgtype != nil {
  22591. *m.addmsgtype += i
  22592. } else {
  22593. m.addmsgtype = &i
  22594. }
  22595. }
  22596. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  22597. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  22598. v := m.addmsgtype
  22599. if v == nil {
  22600. return
  22601. }
  22602. return *v, true
  22603. }
  22604. // ClearMsgtype clears the value of the "msgtype" field.
  22605. func (m *MsgMutation) ClearMsgtype() {
  22606. m.msgtype = nil
  22607. m.addmsgtype = nil
  22608. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  22609. }
  22610. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  22611. func (m *MsgMutation) MsgtypeCleared() bool {
  22612. _, ok := m.clearedFields[msg.FieldMsgtype]
  22613. return ok
  22614. }
  22615. // ResetMsgtype resets all changes to the "msgtype" field.
  22616. func (m *MsgMutation) ResetMsgtype() {
  22617. m.msgtype = nil
  22618. m.addmsgtype = nil
  22619. delete(m.clearedFields, msg.FieldMsgtype)
  22620. }
  22621. // SetMsg sets the "msg" field.
  22622. func (m *MsgMutation) SetMsg(s string) {
  22623. m.msg = &s
  22624. }
  22625. // Msg returns the value of the "msg" field in the mutation.
  22626. func (m *MsgMutation) Msg() (r string, exists bool) {
  22627. v := m.msg
  22628. if v == nil {
  22629. return
  22630. }
  22631. return *v, true
  22632. }
  22633. // OldMsg returns the old "msg" field's value of the Msg entity.
  22634. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22636. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  22637. if !m.op.Is(OpUpdateOne) {
  22638. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  22639. }
  22640. if m.id == nil || m.oldValue == nil {
  22641. return v, errors.New("OldMsg requires an ID field in the mutation")
  22642. }
  22643. oldValue, err := m.oldValue(ctx)
  22644. if err != nil {
  22645. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  22646. }
  22647. return oldValue.Msg, nil
  22648. }
  22649. // ClearMsg clears the value of the "msg" field.
  22650. func (m *MsgMutation) ClearMsg() {
  22651. m.msg = nil
  22652. m.clearedFields[msg.FieldMsg] = struct{}{}
  22653. }
  22654. // MsgCleared returns if the "msg" field was cleared in this mutation.
  22655. func (m *MsgMutation) MsgCleared() bool {
  22656. _, ok := m.clearedFields[msg.FieldMsg]
  22657. return ok
  22658. }
  22659. // ResetMsg resets all changes to the "msg" field.
  22660. func (m *MsgMutation) ResetMsg() {
  22661. m.msg = nil
  22662. delete(m.clearedFields, msg.FieldMsg)
  22663. }
  22664. // SetBatchNo sets the "batch_no" field.
  22665. func (m *MsgMutation) SetBatchNo(s string) {
  22666. m.batch_no = &s
  22667. }
  22668. // BatchNo returns the value of the "batch_no" field in the mutation.
  22669. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  22670. v := m.batch_no
  22671. if v == nil {
  22672. return
  22673. }
  22674. return *v, true
  22675. }
  22676. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  22677. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22679. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  22680. if !m.op.Is(OpUpdateOne) {
  22681. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  22682. }
  22683. if m.id == nil || m.oldValue == nil {
  22684. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  22685. }
  22686. oldValue, err := m.oldValue(ctx)
  22687. if err != nil {
  22688. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  22689. }
  22690. return oldValue.BatchNo, nil
  22691. }
  22692. // ClearBatchNo clears the value of the "batch_no" field.
  22693. func (m *MsgMutation) ClearBatchNo() {
  22694. m.batch_no = nil
  22695. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  22696. }
  22697. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  22698. func (m *MsgMutation) BatchNoCleared() bool {
  22699. _, ok := m.clearedFields[msg.FieldBatchNo]
  22700. return ok
  22701. }
  22702. // ResetBatchNo resets all changes to the "batch_no" field.
  22703. func (m *MsgMutation) ResetBatchNo() {
  22704. m.batch_no = nil
  22705. delete(m.clearedFields, msg.FieldBatchNo)
  22706. }
  22707. // SetCc sets the "cc" field.
  22708. func (m *MsgMutation) SetCc(s string) {
  22709. m.cc = &s
  22710. }
  22711. // Cc returns the value of the "cc" field in the mutation.
  22712. func (m *MsgMutation) Cc() (r string, exists bool) {
  22713. v := m.cc
  22714. if v == nil {
  22715. return
  22716. }
  22717. return *v, true
  22718. }
  22719. // OldCc returns the old "cc" field's value of the Msg entity.
  22720. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22722. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  22723. if !m.op.Is(OpUpdateOne) {
  22724. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  22725. }
  22726. if m.id == nil || m.oldValue == nil {
  22727. return v, errors.New("OldCc requires an ID field in the mutation")
  22728. }
  22729. oldValue, err := m.oldValue(ctx)
  22730. if err != nil {
  22731. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  22732. }
  22733. return oldValue.Cc, nil
  22734. }
  22735. // ResetCc resets all changes to the "cc" field.
  22736. func (m *MsgMutation) ResetCc() {
  22737. m.cc = nil
  22738. }
  22739. // SetPhone sets the "phone" field.
  22740. func (m *MsgMutation) SetPhone(s string) {
  22741. m.phone = &s
  22742. }
  22743. // Phone returns the value of the "phone" field in the mutation.
  22744. func (m *MsgMutation) Phone() (r string, exists bool) {
  22745. v := m.phone
  22746. if v == nil {
  22747. return
  22748. }
  22749. return *v, true
  22750. }
  22751. // OldPhone returns the old "phone" field's value of the Msg entity.
  22752. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22754. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  22755. if !m.op.Is(OpUpdateOne) {
  22756. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  22757. }
  22758. if m.id == nil || m.oldValue == nil {
  22759. return v, errors.New("OldPhone requires an ID field in the mutation")
  22760. }
  22761. oldValue, err := m.oldValue(ctx)
  22762. if err != nil {
  22763. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  22764. }
  22765. return oldValue.Phone, nil
  22766. }
  22767. // ResetPhone resets all changes to the "phone" field.
  22768. func (m *MsgMutation) ResetPhone() {
  22769. m.phone = nil
  22770. }
  22771. // Where appends a list predicates to the MsgMutation builder.
  22772. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  22773. m.predicates = append(m.predicates, ps...)
  22774. }
  22775. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  22776. // users can use type-assertion to append predicates that do not depend on any generated package.
  22777. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  22778. p := make([]predicate.Msg, len(ps))
  22779. for i := range ps {
  22780. p[i] = ps[i]
  22781. }
  22782. m.Where(p...)
  22783. }
  22784. // Op returns the operation name.
  22785. func (m *MsgMutation) Op() Op {
  22786. return m.op
  22787. }
  22788. // SetOp allows setting the mutation operation.
  22789. func (m *MsgMutation) SetOp(op Op) {
  22790. m.op = op
  22791. }
  22792. // Type returns the node type of this mutation (Msg).
  22793. func (m *MsgMutation) Type() string {
  22794. return m.typ
  22795. }
  22796. // Fields returns all fields that were changed during this mutation. Note that in
  22797. // order to get all numeric fields that were incremented/decremented, call
  22798. // AddedFields().
  22799. func (m *MsgMutation) Fields() []string {
  22800. fields := make([]string, 0, 11)
  22801. if m.created_at != nil {
  22802. fields = append(fields, msg.FieldCreatedAt)
  22803. }
  22804. if m.updated_at != nil {
  22805. fields = append(fields, msg.FieldUpdatedAt)
  22806. }
  22807. if m.deleted_at != nil {
  22808. fields = append(fields, msg.FieldDeletedAt)
  22809. }
  22810. if m.status != nil {
  22811. fields = append(fields, msg.FieldStatus)
  22812. }
  22813. if m.fromwxid != nil {
  22814. fields = append(fields, msg.FieldFromwxid)
  22815. }
  22816. if m.toid != nil {
  22817. fields = append(fields, msg.FieldToid)
  22818. }
  22819. if m.msgtype != nil {
  22820. fields = append(fields, msg.FieldMsgtype)
  22821. }
  22822. if m.msg != nil {
  22823. fields = append(fields, msg.FieldMsg)
  22824. }
  22825. if m.batch_no != nil {
  22826. fields = append(fields, msg.FieldBatchNo)
  22827. }
  22828. if m.cc != nil {
  22829. fields = append(fields, msg.FieldCc)
  22830. }
  22831. if m.phone != nil {
  22832. fields = append(fields, msg.FieldPhone)
  22833. }
  22834. return fields
  22835. }
  22836. // Field returns the value of a field with the given name. The second boolean
  22837. // return value indicates that this field was not set, or was not defined in the
  22838. // schema.
  22839. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  22840. switch name {
  22841. case msg.FieldCreatedAt:
  22842. return m.CreatedAt()
  22843. case msg.FieldUpdatedAt:
  22844. return m.UpdatedAt()
  22845. case msg.FieldDeletedAt:
  22846. return m.DeletedAt()
  22847. case msg.FieldStatus:
  22848. return m.Status()
  22849. case msg.FieldFromwxid:
  22850. return m.Fromwxid()
  22851. case msg.FieldToid:
  22852. return m.Toid()
  22853. case msg.FieldMsgtype:
  22854. return m.Msgtype()
  22855. case msg.FieldMsg:
  22856. return m.Msg()
  22857. case msg.FieldBatchNo:
  22858. return m.BatchNo()
  22859. case msg.FieldCc:
  22860. return m.Cc()
  22861. case msg.FieldPhone:
  22862. return m.Phone()
  22863. }
  22864. return nil, false
  22865. }
  22866. // OldField returns the old value of the field from the database. An error is
  22867. // returned if the mutation operation is not UpdateOne, or the query to the
  22868. // database failed.
  22869. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22870. switch name {
  22871. case msg.FieldCreatedAt:
  22872. return m.OldCreatedAt(ctx)
  22873. case msg.FieldUpdatedAt:
  22874. return m.OldUpdatedAt(ctx)
  22875. case msg.FieldDeletedAt:
  22876. return m.OldDeletedAt(ctx)
  22877. case msg.FieldStatus:
  22878. return m.OldStatus(ctx)
  22879. case msg.FieldFromwxid:
  22880. return m.OldFromwxid(ctx)
  22881. case msg.FieldToid:
  22882. return m.OldToid(ctx)
  22883. case msg.FieldMsgtype:
  22884. return m.OldMsgtype(ctx)
  22885. case msg.FieldMsg:
  22886. return m.OldMsg(ctx)
  22887. case msg.FieldBatchNo:
  22888. return m.OldBatchNo(ctx)
  22889. case msg.FieldCc:
  22890. return m.OldCc(ctx)
  22891. case msg.FieldPhone:
  22892. return m.OldPhone(ctx)
  22893. }
  22894. return nil, fmt.Errorf("unknown Msg field %s", name)
  22895. }
  22896. // SetField sets the value of a field with the given name. It returns an error if
  22897. // the field is not defined in the schema, or if the type mismatched the field
  22898. // type.
  22899. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  22900. switch name {
  22901. case msg.FieldCreatedAt:
  22902. v, ok := value.(time.Time)
  22903. if !ok {
  22904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22905. }
  22906. m.SetCreatedAt(v)
  22907. return nil
  22908. case msg.FieldUpdatedAt:
  22909. v, ok := value.(time.Time)
  22910. if !ok {
  22911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22912. }
  22913. m.SetUpdatedAt(v)
  22914. return nil
  22915. case msg.FieldDeletedAt:
  22916. v, ok := value.(time.Time)
  22917. if !ok {
  22918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22919. }
  22920. m.SetDeletedAt(v)
  22921. return nil
  22922. case msg.FieldStatus:
  22923. v, ok := value.(uint8)
  22924. if !ok {
  22925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22926. }
  22927. m.SetStatus(v)
  22928. return nil
  22929. case msg.FieldFromwxid:
  22930. v, ok := value.(string)
  22931. if !ok {
  22932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22933. }
  22934. m.SetFromwxid(v)
  22935. return nil
  22936. case msg.FieldToid:
  22937. v, ok := value.(string)
  22938. if !ok {
  22939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22940. }
  22941. m.SetToid(v)
  22942. return nil
  22943. case msg.FieldMsgtype:
  22944. v, ok := value.(int32)
  22945. if !ok {
  22946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22947. }
  22948. m.SetMsgtype(v)
  22949. return nil
  22950. case msg.FieldMsg:
  22951. v, ok := value.(string)
  22952. if !ok {
  22953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22954. }
  22955. m.SetMsg(v)
  22956. return nil
  22957. case msg.FieldBatchNo:
  22958. v, ok := value.(string)
  22959. if !ok {
  22960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22961. }
  22962. m.SetBatchNo(v)
  22963. return nil
  22964. case msg.FieldCc:
  22965. v, ok := value.(string)
  22966. if !ok {
  22967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22968. }
  22969. m.SetCc(v)
  22970. return nil
  22971. case msg.FieldPhone:
  22972. v, ok := value.(string)
  22973. if !ok {
  22974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22975. }
  22976. m.SetPhone(v)
  22977. return nil
  22978. }
  22979. return fmt.Errorf("unknown Msg field %s", name)
  22980. }
  22981. // AddedFields returns all numeric fields that were incremented/decremented during
  22982. // this mutation.
  22983. func (m *MsgMutation) AddedFields() []string {
  22984. var fields []string
  22985. if m.addstatus != nil {
  22986. fields = append(fields, msg.FieldStatus)
  22987. }
  22988. if m.addmsgtype != nil {
  22989. fields = append(fields, msg.FieldMsgtype)
  22990. }
  22991. return fields
  22992. }
  22993. // AddedField returns the numeric value that was incremented/decremented on a field
  22994. // with the given name. The second boolean return value indicates that this field
  22995. // was not set, or was not defined in the schema.
  22996. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  22997. switch name {
  22998. case msg.FieldStatus:
  22999. return m.AddedStatus()
  23000. case msg.FieldMsgtype:
  23001. return m.AddedMsgtype()
  23002. }
  23003. return nil, false
  23004. }
  23005. // AddField adds the value to the field with the given name. It returns an error if
  23006. // the field is not defined in the schema, or if the type mismatched the field
  23007. // type.
  23008. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  23009. switch name {
  23010. case msg.FieldStatus:
  23011. v, ok := value.(int8)
  23012. if !ok {
  23013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23014. }
  23015. m.AddStatus(v)
  23016. return nil
  23017. case msg.FieldMsgtype:
  23018. v, ok := value.(int32)
  23019. if !ok {
  23020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23021. }
  23022. m.AddMsgtype(v)
  23023. return nil
  23024. }
  23025. return fmt.Errorf("unknown Msg numeric field %s", name)
  23026. }
  23027. // ClearedFields returns all nullable fields that were cleared during this
  23028. // mutation.
  23029. func (m *MsgMutation) ClearedFields() []string {
  23030. var fields []string
  23031. if m.FieldCleared(msg.FieldDeletedAt) {
  23032. fields = append(fields, msg.FieldDeletedAt)
  23033. }
  23034. if m.FieldCleared(msg.FieldStatus) {
  23035. fields = append(fields, msg.FieldStatus)
  23036. }
  23037. if m.FieldCleared(msg.FieldFromwxid) {
  23038. fields = append(fields, msg.FieldFromwxid)
  23039. }
  23040. if m.FieldCleared(msg.FieldToid) {
  23041. fields = append(fields, msg.FieldToid)
  23042. }
  23043. if m.FieldCleared(msg.FieldMsgtype) {
  23044. fields = append(fields, msg.FieldMsgtype)
  23045. }
  23046. if m.FieldCleared(msg.FieldMsg) {
  23047. fields = append(fields, msg.FieldMsg)
  23048. }
  23049. if m.FieldCleared(msg.FieldBatchNo) {
  23050. fields = append(fields, msg.FieldBatchNo)
  23051. }
  23052. return fields
  23053. }
  23054. // FieldCleared returns a boolean indicating if a field with the given name was
  23055. // cleared in this mutation.
  23056. func (m *MsgMutation) FieldCleared(name string) bool {
  23057. _, ok := m.clearedFields[name]
  23058. return ok
  23059. }
  23060. // ClearField clears the value of the field with the given name. It returns an
  23061. // error if the field is not defined in the schema.
  23062. func (m *MsgMutation) ClearField(name string) error {
  23063. switch name {
  23064. case msg.FieldDeletedAt:
  23065. m.ClearDeletedAt()
  23066. return nil
  23067. case msg.FieldStatus:
  23068. m.ClearStatus()
  23069. return nil
  23070. case msg.FieldFromwxid:
  23071. m.ClearFromwxid()
  23072. return nil
  23073. case msg.FieldToid:
  23074. m.ClearToid()
  23075. return nil
  23076. case msg.FieldMsgtype:
  23077. m.ClearMsgtype()
  23078. return nil
  23079. case msg.FieldMsg:
  23080. m.ClearMsg()
  23081. return nil
  23082. case msg.FieldBatchNo:
  23083. m.ClearBatchNo()
  23084. return nil
  23085. }
  23086. return fmt.Errorf("unknown Msg nullable field %s", name)
  23087. }
  23088. // ResetField resets all changes in the mutation for the field with the given name.
  23089. // It returns an error if the field is not defined in the schema.
  23090. func (m *MsgMutation) ResetField(name string) error {
  23091. switch name {
  23092. case msg.FieldCreatedAt:
  23093. m.ResetCreatedAt()
  23094. return nil
  23095. case msg.FieldUpdatedAt:
  23096. m.ResetUpdatedAt()
  23097. return nil
  23098. case msg.FieldDeletedAt:
  23099. m.ResetDeletedAt()
  23100. return nil
  23101. case msg.FieldStatus:
  23102. m.ResetStatus()
  23103. return nil
  23104. case msg.FieldFromwxid:
  23105. m.ResetFromwxid()
  23106. return nil
  23107. case msg.FieldToid:
  23108. m.ResetToid()
  23109. return nil
  23110. case msg.FieldMsgtype:
  23111. m.ResetMsgtype()
  23112. return nil
  23113. case msg.FieldMsg:
  23114. m.ResetMsg()
  23115. return nil
  23116. case msg.FieldBatchNo:
  23117. m.ResetBatchNo()
  23118. return nil
  23119. case msg.FieldCc:
  23120. m.ResetCc()
  23121. return nil
  23122. case msg.FieldPhone:
  23123. m.ResetPhone()
  23124. return nil
  23125. }
  23126. return fmt.Errorf("unknown Msg field %s", name)
  23127. }
  23128. // AddedEdges returns all edge names that were set/added in this mutation.
  23129. func (m *MsgMutation) AddedEdges() []string {
  23130. edges := make([]string, 0, 0)
  23131. return edges
  23132. }
  23133. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23134. // name in this mutation.
  23135. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  23136. return nil
  23137. }
  23138. // RemovedEdges returns all edge names that were removed in this mutation.
  23139. func (m *MsgMutation) RemovedEdges() []string {
  23140. edges := make([]string, 0, 0)
  23141. return edges
  23142. }
  23143. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23144. // the given name in this mutation.
  23145. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  23146. return nil
  23147. }
  23148. // ClearedEdges returns all edge names that were cleared in this mutation.
  23149. func (m *MsgMutation) ClearedEdges() []string {
  23150. edges := make([]string, 0, 0)
  23151. return edges
  23152. }
  23153. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23154. // was cleared in this mutation.
  23155. func (m *MsgMutation) EdgeCleared(name string) bool {
  23156. return false
  23157. }
  23158. // ClearEdge clears the value of the edge with the given name. It returns an error
  23159. // if that edge is not defined in the schema.
  23160. func (m *MsgMutation) ClearEdge(name string) error {
  23161. return fmt.Errorf("unknown Msg unique edge %s", name)
  23162. }
  23163. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23164. // It returns an error if the edge is not defined in the schema.
  23165. func (m *MsgMutation) ResetEdge(name string) error {
  23166. return fmt.Errorf("unknown Msg edge %s", name)
  23167. }
  23168. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  23169. type PayRechargeMutation struct {
  23170. config
  23171. op Op
  23172. typ string
  23173. id *uint64
  23174. created_at *time.Time
  23175. updated_at *time.Time
  23176. deleted_at *time.Time
  23177. user_id *string
  23178. number *float32
  23179. addnumber *float32
  23180. status *int
  23181. addstatus *int
  23182. money *float32
  23183. addmoney *float32
  23184. out_trade_no *string
  23185. organization_id *uint64
  23186. addorganization_id *int64
  23187. clearedFields map[string]struct{}
  23188. done bool
  23189. oldValue func(context.Context) (*PayRecharge, error)
  23190. predicates []predicate.PayRecharge
  23191. }
  23192. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  23193. // payrechargeOption allows management of the mutation configuration using functional options.
  23194. type payrechargeOption func(*PayRechargeMutation)
  23195. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  23196. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  23197. m := &PayRechargeMutation{
  23198. config: c,
  23199. op: op,
  23200. typ: TypePayRecharge,
  23201. clearedFields: make(map[string]struct{}),
  23202. }
  23203. for _, opt := range opts {
  23204. opt(m)
  23205. }
  23206. return m
  23207. }
  23208. // withPayRechargeID sets the ID field of the mutation.
  23209. func withPayRechargeID(id uint64) payrechargeOption {
  23210. return func(m *PayRechargeMutation) {
  23211. var (
  23212. err error
  23213. once sync.Once
  23214. value *PayRecharge
  23215. )
  23216. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  23217. once.Do(func() {
  23218. if m.done {
  23219. err = errors.New("querying old values post mutation is not allowed")
  23220. } else {
  23221. value, err = m.Client().PayRecharge.Get(ctx, id)
  23222. }
  23223. })
  23224. return value, err
  23225. }
  23226. m.id = &id
  23227. }
  23228. }
  23229. // withPayRecharge sets the old PayRecharge of the mutation.
  23230. func withPayRecharge(node *PayRecharge) payrechargeOption {
  23231. return func(m *PayRechargeMutation) {
  23232. m.oldValue = func(context.Context) (*PayRecharge, error) {
  23233. return node, nil
  23234. }
  23235. m.id = &node.ID
  23236. }
  23237. }
  23238. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23239. // executed in a transaction (ent.Tx), a transactional client is returned.
  23240. func (m PayRechargeMutation) Client() *Client {
  23241. client := &Client{config: m.config}
  23242. client.init()
  23243. return client
  23244. }
  23245. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23246. // it returns an error otherwise.
  23247. func (m PayRechargeMutation) Tx() (*Tx, error) {
  23248. if _, ok := m.driver.(*txDriver); !ok {
  23249. return nil, errors.New("ent: mutation is not running in a transaction")
  23250. }
  23251. tx := &Tx{config: m.config}
  23252. tx.init()
  23253. return tx, nil
  23254. }
  23255. // SetID sets the value of the id field. Note that this
  23256. // operation is only accepted on creation of PayRecharge entities.
  23257. func (m *PayRechargeMutation) SetID(id uint64) {
  23258. m.id = &id
  23259. }
  23260. // ID returns the ID value in the mutation. Note that the ID is only available
  23261. // if it was provided to the builder or after it was returned from the database.
  23262. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  23263. if m.id == nil {
  23264. return
  23265. }
  23266. return *m.id, true
  23267. }
  23268. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23269. // That means, if the mutation is applied within a transaction with an isolation level such
  23270. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23271. // or updated by the mutation.
  23272. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23273. switch {
  23274. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23275. id, exists := m.ID()
  23276. if exists {
  23277. return []uint64{id}, nil
  23278. }
  23279. fallthrough
  23280. case m.op.Is(OpUpdate | OpDelete):
  23281. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  23282. default:
  23283. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23284. }
  23285. }
  23286. // SetCreatedAt sets the "created_at" field.
  23287. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  23288. m.created_at = &t
  23289. }
  23290. // CreatedAt returns the value of the "created_at" field in the mutation.
  23291. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  23292. v := m.created_at
  23293. if v == nil {
  23294. return
  23295. }
  23296. return *v, true
  23297. }
  23298. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  23299. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23301. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23302. if !m.op.Is(OpUpdateOne) {
  23303. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23304. }
  23305. if m.id == nil || m.oldValue == nil {
  23306. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23307. }
  23308. oldValue, err := m.oldValue(ctx)
  23309. if err != nil {
  23310. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23311. }
  23312. return oldValue.CreatedAt, nil
  23313. }
  23314. // ResetCreatedAt resets all changes to the "created_at" field.
  23315. func (m *PayRechargeMutation) ResetCreatedAt() {
  23316. m.created_at = nil
  23317. }
  23318. // SetUpdatedAt sets the "updated_at" field.
  23319. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  23320. m.updated_at = &t
  23321. }
  23322. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23323. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  23324. v := m.updated_at
  23325. if v == nil {
  23326. return
  23327. }
  23328. return *v, true
  23329. }
  23330. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  23331. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23333. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23334. if !m.op.Is(OpUpdateOne) {
  23335. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23336. }
  23337. if m.id == nil || m.oldValue == nil {
  23338. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23339. }
  23340. oldValue, err := m.oldValue(ctx)
  23341. if err != nil {
  23342. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23343. }
  23344. return oldValue.UpdatedAt, nil
  23345. }
  23346. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23347. func (m *PayRechargeMutation) ResetUpdatedAt() {
  23348. m.updated_at = nil
  23349. }
  23350. // SetDeletedAt sets the "deleted_at" field.
  23351. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  23352. m.deleted_at = &t
  23353. }
  23354. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23355. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  23356. v := m.deleted_at
  23357. if v == nil {
  23358. return
  23359. }
  23360. return *v, true
  23361. }
  23362. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  23363. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23365. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23366. if !m.op.Is(OpUpdateOne) {
  23367. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23368. }
  23369. if m.id == nil || m.oldValue == nil {
  23370. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23371. }
  23372. oldValue, err := m.oldValue(ctx)
  23373. if err != nil {
  23374. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23375. }
  23376. return oldValue.DeletedAt, nil
  23377. }
  23378. // ClearDeletedAt clears the value of the "deleted_at" field.
  23379. func (m *PayRechargeMutation) ClearDeletedAt() {
  23380. m.deleted_at = nil
  23381. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  23382. }
  23383. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23384. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  23385. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  23386. return ok
  23387. }
  23388. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23389. func (m *PayRechargeMutation) ResetDeletedAt() {
  23390. m.deleted_at = nil
  23391. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  23392. }
  23393. // SetUserID sets the "user_id" field.
  23394. func (m *PayRechargeMutation) SetUserID(s string) {
  23395. m.user_id = &s
  23396. }
  23397. // UserID returns the value of the "user_id" field in the mutation.
  23398. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  23399. v := m.user_id
  23400. if v == nil {
  23401. return
  23402. }
  23403. return *v, true
  23404. }
  23405. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  23406. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23408. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  23409. if !m.op.Is(OpUpdateOne) {
  23410. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  23411. }
  23412. if m.id == nil || m.oldValue == nil {
  23413. return v, errors.New("OldUserID requires an ID field in the mutation")
  23414. }
  23415. oldValue, err := m.oldValue(ctx)
  23416. if err != nil {
  23417. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  23418. }
  23419. return oldValue.UserID, nil
  23420. }
  23421. // ResetUserID resets all changes to the "user_id" field.
  23422. func (m *PayRechargeMutation) ResetUserID() {
  23423. m.user_id = nil
  23424. }
  23425. // SetNumber sets the "number" field.
  23426. func (m *PayRechargeMutation) SetNumber(f float32) {
  23427. m.number = &f
  23428. m.addnumber = nil
  23429. }
  23430. // Number returns the value of the "number" field in the mutation.
  23431. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  23432. v := m.number
  23433. if v == nil {
  23434. return
  23435. }
  23436. return *v, true
  23437. }
  23438. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  23439. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23441. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  23442. if !m.op.Is(OpUpdateOne) {
  23443. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  23444. }
  23445. if m.id == nil || m.oldValue == nil {
  23446. return v, errors.New("OldNumber requires an ID field in the mutation")
  23447. }
  23448. oldValue, err := m.oldValue(ctx)
  23449. if err != nil {
  23450. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  23451. }
  23452. return oldValue.Number, nil
  23453. }
  23454. // AddNumber adds f to the "number" field.
  23455. func (m *PayRechargeMutation) AddNumber(f float32) {
  23456. if m.addnumber != nil {
  23457. *m.addnumber += f
  23458. } else {
  23459. m.addnumber = &f
  23460. }
  23461. }
  23462. // AddedNumber returns the value that was added to the "number" field in this mutation.
  23463. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  23464. v := m.addnumber
  23465. if v == nil {
  23466. return
  23467. }
  23468. return *v, true
  23469. }
  23470. // ResetNumber resets all changes to the "number" field.
  23471. func (m *PayRechargeMutation) ResetNumber() {
  23472. m.number = nil
  23473. m.addnumber = nil
  23474. }
  23475. // SetStatus sets the "status" field.
  23476. func (m *PayRechargeMutation) SetStatus(i int) {
  23477. m.status = &i
  23478. m.addstatus = nil
  23479. }
  23480. // Status returns the value of the "status" field in the mutation.
  23481. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  23482. v := m.status
  23483. if v == nil {
  23484. return
  23485. }
  23486. return *v, true
  23487. }
  23488. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  23489. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23491. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  23492. if !m.op.Is(OpUpdateOne) {
  23493. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23494. }
  23495. if m.id == nil || m.oldValue == nil {
  23496. return v, errors.New("OldStatus requires an ID field in the mutation")
  23497. }
  23498. oldValue, err := m.oldValue(ctx)
  23499. if err != nil {
  23500. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23501. }
  23502. return oldValue.Status, nil
  23503. }
  23504. // AddStatus adds i to the "status" field.
  23505. func (m *PayRechargeMutation) AddStatus(i int) {
  23506. if m.addstatus != nil {
  23507. *m.addstatus += i
  23508. } else {
  23509. m.addstatus = &i
  23510. }
  23511. }
  23512. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23513. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  23514. v := m.addstatus
  23515. if v == nil {
  23516. return
  23517. }
  23518. return *v, true
  23519. }
  23520. // ClearStatus clears the value of the "status" field.
  23521. func (m *PayRechargeMutation) ClearStatus() {
  23522. m.status = nil
  23523. m.addstatus = nil
  23524. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  23525. }
  23526. // StatusCleared returns if the "status" field was cleared in this mutation.
  23527. func (m *PayRechargeMutation) StatusCleared() bool {
  23528. _, ok := m.clearedFields[payrecharge.FieldStatus]
  23529. return ok
  23530. }
  23531. // ResetStatus resets all changes to the "status" field.
  23532. func (m *PayRechargeMutation) ResetStatus() {
  23533. m.status = nil
  23534. m.addstatus = nil
  23535. delete(m.clearedFields, payrecharge.FieldStatus)
  23536. }
  23537. // SetMoney sets the "money" field.
  23538. func (m *PayRechargeMutation) SetMoney(f float32) {
  23539. m.money = &f
  23540. m.addmoney = nil
  23541. }
  23542. // Money returns the value of the "money" field in the mutation.
  23543. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  23544. v := m.money
  23545. if v == nil {
  23546. return
  23547. }
  23548. return *v, true
  23549. }
  23550. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  23551. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23553. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  23554. if !m.op.Is(OpUpdateOne) {
  23555. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  23556. }
  23557. if m.id == nil || m.oldValue == nil {
  23558. return v, errors.New("OldMoney requires an ID field in the mutation")
  23559. }
  23560. oldValue, err := m.oldValue(ctx)
  23561. if err != nil {
  23562. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  23563. }
  23564. return oldValue.Money, nil
  23565. }
  23566. // AddMoney adds f to the "money" field.
  23567. func (m *PayRechargeMutation) AddMoney(f float32) {
  23568. if m.addmoney != nil {
  23569. *m.addmoney += f
  23570. } else {
  23571. m.addmoney = &f
  23572. }
  23573. }
  23574. // AddedMoney returns the value that was added to the "money" field in this mutation.
  23575. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  23576. v := m.addmoney
  23577. if v == nil {
  23578. return
  23579. }
  23580. return *v, true
  23581. }
  23582. // ClearMoney clears the value of the "money" field.
  23583. func (m *PayRechargeMutation) ClearMoney() {
  23584. m.money = nil
  23585. m.addmoney = nil
  23586. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  23587. }
  23588. // MoneyCleared returns if the "money" field was cleared in this mutation.
  23589. func (m *PayRechargeMutation) MoneyCleared() bool {
  23590. _, ok := m.clearedFields[payrecharge.FieldMoney]
  23591. return ok
  23592. }
  23593. // ResetMoney resets all changes to the "money" field.
  23594. func (m *PayRechargeMutation) ResetMoney() {
  23595. m.money = nil
  23596. m.addmoney = nil
  23597. delete(m.clearedFields, payrecharge.FieldMoney)
  23598. }
  23599. // SetOutTradeNo sets the "out_trade_no" field.
  23600. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  23601. m.out_trade_no = &s
  23602. }
  23603. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  23604. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  23605. v := m.out_trade_no
  23606. if v == nil {
  23607. return
  23608. }
  23609. return *v, true
  23610. }
  23611. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  23612. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23614. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  23615. if !m.op.Is(OpUpdateOne) {
  23616. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  23617. }
  23618. if m.id == nil || m.oldValue == nil {
  23619. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  23620. }
  23621. oldValue, err := m.oldValue(ctx)
  23622. if err != nil {
  23623. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  23624. }
  23625. return oldValue.OutTradeNo, nil
  23626. }
  23627. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  23628. func (m *PayRechargeMutation) ClearOutTradeNo() {
  23629. m.out_trade_no = nil
  23630. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  23631. }
  23632. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  23633. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  23634. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  23635. return ok
  23636. }
  23637. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  23638. func (m *PayRechargeMutation) ResetOutTradeNo() {
  23639. m.out_trade_no = nil
  23640. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  23641. }
  23642. // SetOrganizationID sets the "organization_id" field.
  23643. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  23644. m.organization_id = &u
  23645. m.addorganization_id = nil
  23646. }
  23647. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23648. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  23649. v := m.organization_id
  23650. if v == nil {
  23651. return
  23652. }
  23653. return *v, true
  23654. }
  23655. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  23656. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23658. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23659. if !m.op.Is(OpUpdateOne) {
  23660. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23661. }
  23662. if m.id == nil || m.oldValue == nil {
  23663. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23664. }
  23665. oldValue, err := m.oldValue(ctx)
  23666. if err != nil {
  23667. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23668. }
  23669. return oldValue.OrganizationID, nil
  23670. }
  23671. // AddOrganizationID adds u to the "organization_id" field.
  23672. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  23673. if m.addorganization_id != nil {
  23674. *m.addorganization_id += u
  23675. } else {
  23676. m.addorganization_id = &u
  23677. }
  23678. }
  23679. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23680. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  23681. v := m.addorganization_id
  23682. if v == nil {
  23683. return
  23684. }
  23685. return *v, true
  23686. }
  23687. // ResetOrganizationID resets all changes to the "organization_id" field.
  23688. func (m *PayRechargeMutation) ResetOrganizationID() {
  23689. m.organization_id = nil
  23690. m.addorganization_id = nil
  23691. }
  23692. // Where appends a list predicates to the PayRechargeMutation builder.
  23693. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  23694. m.predicates = append(m.predicates, ps...)
  23695. }
  23696. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  23697. // users can use type-assertion to append predicates that do not depend on any generated package.
  23698. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  23699. p := make([]predicate.PayRecharge, len(ps))
  23700. for i := range ps {
  23701. p[i] = ps[i]
  23702. }
  23703. m.Where(p...)
  23704. }
  23705. // Op returns the operation name.
  23706. func (m *PayRechargeMutation) Op() Op {
  23707. return m.op
  23708. }
  23709. // SetOp allows setting the mutation operation.
  23710. func (m *PayRechargeMutation) SetOp(op Op) {
  23711. m.op = op
  23712. }
  23713. // Type returns the node type of this mutation (PayRecharge).
  23714. func (m *PayRechargeMutation) Type() string {
  23715. return m.typ
  23716. }
  23717. // Fields returns all fields that were changed during this mutation. Note that in
  23718. // order to get all numeric fields that were incremented/decremented, call
  23719. // AddedFields().
  23720. func (m *PayRechargeMutation) Fields() []string {
  23721. fields := make([]string, 0, 9)
  23722. if m.created_at != nil {
  23723. fields = append(fields, payrecharge.FieldCreatedAt)
  23724. }
  23725. if m.updated_at != nil {
  23726. fields = append(fields, payrecharge.FieldUpdatedAt)
  23727. }
  23728. if m.deleted_at != nil {
  23729. fields = append(fields, payrecharge.FieldDeletedAt)
  23730. }
  23731. if m.user_id != nil {
  23732. fields = append(fields, payrecharge.FieldUserID)
  23733. }
  23734. if m.number != nil {
  23735. fields = append(fields, payrecharge.FieldNumber)
  23736. }
  23737. if m.status != nil {
  23738. fields = append(fields, payrecharge.FieldStatus)
  23739. }
  23740. if m.money != nil {
  23741. fields = append(fields, payrecharge.FieldMoney)
  23742. }
  23743. if m.out_trade_no != nil {
  23744. fields = append(fields, payrecharge.FieldOutTradeNo)
  23745. }
  23746. if m.organization_id != nil {
  23747. fields = append(fields, payrecharge.FieldOrganizationID)
  23748. }
  23749. return fields
  23750. }
  23751. // Field returns the value of a field with the given name. The second boolean
  23752. // return value indicates that this field was not set, or was not defined in the
  23753. // schema.
  23754. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  23755. switch name {
  23756. case payrecharge.FieldCreatedAt:
  23757. return m.CreatedAt()
  23758. case payrecharge.FieldUpdatedAt:
  23759. return m.UpdatedAt()
  23760. case payrecharge.FieldDeletedAt:
  23761. return m.DeletedAt()
  23762. case payrecharge.FieldUserID:
  23763. return m.UserID()
  23764. case payrecharge.FieldNumber:
  23765. return m.Number()
  23766. case payrecharge.FieldStatus:
  23767. return m.Status()
  23768. case payrecharge.FieldMoney:
  23769. return m.Money()
  23770. case payrecharge.FieldOutTradeNo:
  23771. return m.OutTradeNo()
  23772. case payrecharge.FieldOrganizationID:
  23773. return m.OrganizationID()
  23774. }
  23775. return nil, false
  23776. }
  23777. // OldField returns the old value of the field from the database. An error is
  23778. // returned if the mutation operation is not UpdateOne, or the query to the
  23779. // database failed.
  23780. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23781. switch name {
  23782. case payrecharge.FieldCreatedAt:
  23783. return m.OldCreatedAt(ctx)
  23784. case payrecharge.FieldUpdatedAt:
  23785. return m.OldUpdatedAt(ctx)
  23786. case payrecharge.FieldDeletedAt:
  23787. return m.OldDeletedAt(ctx)
  23788. case payrecharge.FieldUserID:
  23789. return m.OldUserID(ctx)
  23790. case payrecharge.FieldNumber:
  23791. return m.OldNumber(ctx)
  23792. case payrecharge.FieldStatus:
  23793. return m.OldStatus(ctx)
  23794. case payrecharge.FieldMoney:
  23795. return m.OldMoney(ctx)
  23796. case payrecharge.FieldOutTradeNo:
  23797. return m.OldOutTradeNo(ctx)
  23798. case payrecharge.FieldOrganizationID:
  23799. return m.OldOrganizationID(ctx)
  23800. }
  23801. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  23802. }
  23803. // SetField sets the value of a field with the given name. It returns an error if
  23804. // the field is not defined in the schema, or if the type mismatched the field
  23805. // type.
  23806. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  23807. switch name {
  23808. case payrecharge.FieldCreatedAt:
  23809. v, ok := value.(time.Time)
  23810. if !ok {
  23811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23812. }
  23813. m.SetCreatedAt(v)
  23814. return nil
  23815. case payrecharge.FieldUpdatedAt:
  23816. v, ok := value.(time.Time)
  23817. if !ok {
  23818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23819. }
  23820. m.SetUpdatedAt(v)
  23821. return nil
  23822. case payrecharge.FieldDeletedAt:
  23823. v, ok := value.(time.Time)
  23824. if !ok {
  23825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23826. }
  23827. m.SetDeletedAt(v)
  23828. return nil
  23829. case payrecharge.FieldUserID:
  23830. v, ok := value.(string)
  23831. if !ok {
  23832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23833. }
  23834. m.SetUserID(v)
  23835. return nil
  23836. case payrecharge.FieldNumber:
  23837. v, ok := value.(float32)
  23838. if !ok {
  23839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23840. }
  23841. m.SetNumber(v)
  23842. return nil
  23843. case payrecharge.FieldStatus:
  23844. v, ok := value.(int)
  23845. if !ok {
  23846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23847. }
  23848. m.SetStatus(v)
  23849. return nil
  23850. case payrecharge.FieldMoney:
  23851. v, ok := value.(float32)
  23852. if !ok {
  23853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23854. }
  23855. m.SetMoney(v)
  23856. return nil
  23857. case payrecharge.FieldOutTradeNo:
  23858. v, ok := value.(string)
  23859. if !ok {
  23860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23861. }
  23862. m.SetOutTradeNo(v)
  23863. return nil
  23864. case payrecharge.FieldOrganizationID:
  23865. v, ok := value.(uint64)
  23866. if !ok {
  23867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23868. }
  23869. m.SetOrganizationID(v)
  23870. return nil
  23871. }
  23872. return fmt.Errorf("unknown PayRecharge field %s", name)
  23873. }
  23874. // AddedFields returns all numeric fields that were incremented/decremented during
  23875. // this mutation.
  23876. func (m *PayRechargeMutation) AddedFields() []string {
  23877. var fields []string
  23878. if m.addnumber != nil {
  23879. fields = append(fields, payrecharge.FieldNumber)
  23880. }
  23881. if m.addstatus != nil {
  23882. fields = append(fields, payrecharge.FieldStatus)
  23883. }
  23884. if m.addmoney != nil {
  23885. fields = append(fields, payrecharge.FieldMoney)
  23886. }
  23887. if m.addorganization_id != nil {
  23888. fields = append(fields, payrecharge.FieldOrganizationID)
  23889. }
  23890. return fields
  23891. }
  23892. // AddedField returns the numeric value that was incremented/decremented on a field
  23893. // with the given name. The second boolean return value indicates that this field
  23894. // was not set, or was not defined in the schema.
  23895. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  23896. switch name {
  23897. case payrecharge.FieldNumber:
  23898. return m.AddedNumber()
  23899. case payrecharge.FieldStatus:
  23900. return m.AddedStatus()
  23901. case payrecharge.FieldMoney:
  23902. return m.AddedMoney()
  23903. case payrecharge.FieldOrganizationID:
  23904. return m.AddedOrganizationID()
  23905. }
  23906. return nil, false
  23907. }
  23908. // AddField adds the value to the field with the given name. It returns an error if
  23909. // the field is not defined in the schema, or if the type mismatched the field
  23910. // type.
  23911. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  23912. switch name {
  23913. case payrecharge.FieldNumber:
  23914. v, ok := value.(float32)
  23915. if !ok {
  23916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23917. }
  23918. m.AddNumber(v)
  23919. return nil
  23920. case payrecharge.FieldStatus:
  23921. v, ok := value.(int)
  23922. if !ok {
  23923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23924. }
  23925. m.AddStatus(v)
  23926. return nil
  23927. case payrecharge.FieldMoney:
  23928. v, ok := value.(float32)
  23929. if !ok {
  23930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23931. }
  23932. m.AddMoney(v)
  23933. return nil
  23934. case payrecharge.FieldOrganizationID:
  23935. v, ok := value.(int64)
  23936. if !ok {
  23937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23938. }
  23939. m.AddOrganizationID(v)
  23940. return nil
  23941. }
  23942. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  23943. }
  23944. // ClearedFields returns all nullable fields that were cleared during this
  23945. // mutation.
  23946. func (m *PayRechargeMutation) ClearedFields() []string {
  23947. var fields []string
  23948. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  23949. fields = append(fields, payrecharge.FieldDeletedAt)
  23950. }
  23951. if m.FieldCleared(payrecharge.FieldStatus) {
  23952. fields = append(fields, payrecharge.FieldStatus)
  23953. }
  23954. if m.FieldCleared(payrecharge.FieldMoney) {
  23955. fields = append(fields, payrecharge.FieldMoney)
  23956. }
  23957. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  23958. fields = append(fields, payrecharge.FieldOutTradeNo)
  23959. }
  23960. return fields
  23961. }
  23962. // FieldCleared returns a boolean indicating if a field with the given name was
  23963. // cleared in this mutation.
  23964. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  23965. _, ok := m.clearedFields[name]
  23966. return ok
  23967. }
  23968. // ClearField clears the value of the field with the given name. It returns an
  23969. // error if the field is not defined in the schema.
  23970. func (m *PayRechargeMutation) ClearField(name string) error {
  23971. switch name {
  23972. case payrecharge.FieldDeletedAt:
  23973. m.ClearDeletedAt()
  23974. return nil
  23975. case payrecharge.FieldStatus:
  23976. m.ClearStatus()
  23977. return nil
  23978. case payrecharge.FieldMoney:
  23979. m.ClearMoney()
  23980. return nil
  23981. case payrecharge.FieldOutTradeNo:
  23982. m.ClearOutTradeNo()
  23983. return nil
  23984. }
  23985. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  23986. }
  23987. // ResetField resets all changes in the mutation for the field with the given name.
  23988. // It returns an error if the field is not defined in the schema.
  23989. func (m *PayRechargeMutation) ResetField(name string) error {
  23990. switch name {
  23991. case payrecharge.FieldCreatedAt:
  23992. m.ResetCreatedAt()
  23993. return nil
  23994. case payrecharge.FieldUpdatedAt:
  23995. m.ResetUpdatedAt()
  23996. return nil
  23997. case payrecharge.FieldDeletedAt:
  23998. m.ResetDeletedAt()
  23999. return nil
  24000. case payrecharge.FieldUserID:
  24001. m.ResetUserID()
  24002. return nil
  24003. case payrecharge.FieldNumber:
  24004. m.ResetNumber()
  24005. return nil
  24006. case payrecharge.FieldStatus:
  24007. m.ResetStatus()
  24008. return nil
  24009. case payrecharge.FieldMoney:
  24010. m.ResetMoney()
  24011. return nil
  24012. case payrecharge.FieldOutTradeNo:
  24013. m.ResetOutTradeNo()
  24014. return nil
  24015. case payrecharge.FieldOrganizationID:
  24016. m.ResetOrganizationID()
  24017. return nil
  24018. }
  24019. return fmt.Errorf("unknown PayRecharge field %s", name)
  24020. }
  24021. // AddedEdges returns all edge names that were set/added in this mutation.
  24022. func (m *PayRechargeMutation) AddedEdges() []string {
  24023. edges := make([]string, 0, 0)
  24024. return edges
  24025. }
  24026. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24027. // name in this mutation.
  24028. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  24029. return nil
  24030. }
  24031. // RemovedEdges returns all edge names that were removed in this mutation.
  24032. func (m *PayRechargeMutation) RemovedEdges() []string {
  24033. edges := make([]string, 0, 0)
  24034. return edges
  24035. }
  24036. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24037. // the given name in this mutation.
  24038. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  24039. return nil
  24040. }
  24041. // ClearedEdges returns all edge names that were cleared in this mutation.
  24042. func (m *PayRechargeMutation) ClearedEdges() []string {
  24043. edges := make([]string, 0, 0)
  24044. return edges
  24045. }
  24046. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24047. // was cleared in this mutation.
  24048. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  24049. return false
  24050. }
  24051. // ClearEdge clears the value of the edge with the given name. It returns an error
  24052. // if that edge is not defined in the schema.
  24053. func (m *PayRechargeMutation) ClearEdge(name string) error {
  24054. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  24055. }
  24056. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24057. // It returns an error if the edge is not defined in the schema.
  24058. func (m *PayRechargeMutation) ResetEdge(name string) error {
  24059. return fmt.Errorf("unknown PayRecharge edge %s", name)
  24060. }
  24061. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  24062. type ServerMutation struct {
  24063. config
  24064. op Op
  24065. typ string
  24066. id *uint64
  24067. created_at *time.Time
  24068. updated_at *time.Time
  24069. status *uint8
  24070. addstatus *int8
  24071. deleted_at *time.Time
  24072. name *string
  24073. public_ip *string
  24074. private_ip *string
  24075. admin_port *string
  24076. clearedFields map[string]struct{}
  24077. wxs map[uint64]struct{}
  24078. removedwxs map[uint64]struct{}
  24079. clearedwxs bool
  24080. done bool
  24081. oldValue func(context.Context) (*Server, error)
  24082. predicates []predicate.Server
  24083. }
  24084. var _ ent.Mutation = (*ServerMutation)(nil)
  24085. // serverOption allows management of the mutation configuration using functional options.
  24086. type serverOption func(*ServerMutation)
  24087. // newServerMutation creates new mutation for the Server entity.
  24088. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  24089. m := &ServerMutation{
  24090. config: c,
  24091. op: op,
  24092. typ: TypeServer,
  24093. clearedFields: make(map[string]struct{}),
  24094. }
  24095. for _, opt := range opts {
  24096. opt(m)
  24097. }
  24098. return m
  24099. }
  24100. // withServerID sets the ID field of the mutation.
  24101. func withServerID(id uint64) serverOption {
  24102. return func(m *ServerMutation) {
  24103. var (
  24104. err error
  24105. once sync.Once
  24106. value *Server
  24107. )
  24108. m.oldValue = func(ctx context.Context) (*Server, error) {
  24109. once.Do(func() {
  24110. if m.done {
  24111. err = errors.New("querying old values post mutation is not allowed")
  24112. } else {
  24113. value, err = m.Client().Server.Get(ctx, id)
  24114. }
  24115. })
  24116. return value, err
  24117. }
  24118. m.id = &id
  24119. }
  24120. }
  24121. // withServer sets the old Server of the mutation.
  24122. func withServer(node *Server) serverOption {
  24123. return func(m *ServerMutation) {
  24124. m.oldValue = func(context.Context) (*Server, error) {
  24125. return node, nil
  24126. }
  24127. m.id = &node.ID
  24128. }
  24129. }
  24130. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24131. // executed in a transaction (ent.Tx), a transactional client is returned.
  24132. func (m ServerMutation) Client() *Client {
  24133. client := &Client{config: m.config}
  24134. client.init()
  24135. return client
  24136. }
  24137. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24138. // it returns an error otherwise.
  24139. func (m ServerMutation) Tx() (*Tx, error) {
  24140. if _, ok := m.driver.(*txDriver); !ok {
  24141. return nil, errors.New("ent: mutation is not running in a transaction")
  24142. }
  24143. tx := &Tx{config: m.config}
  24144. tx.init()
  24145. return tx, nil
  24146. }
  24147. // SetID sets the value of the id field. Note that this
  24148. // operation is only accepted on creation of Server entities.
  24149. func (m *ServerMutation) SetID(id uint64) {
  24150. m.id = &id
  24151. }
  24152. // ID returns the ID value in the mutation. Note that the ID is only available
  24153. // if it was provided to the builder or after it was returned from the database.
  24154. func (m *ServerMutation) ID() (id uint64, exists bool) {
  24155. if m.id == nil {
  24156. return
  24157. }
  24158. return *m.id, true
  24159. }
  24160. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24161. // That means, if the mutation is applied within a transaction with an isolation level such
  24162. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24163. // or updated by the mutation.
  24164. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  24165. switch {
  24166. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24167. id, exists := m.ID()
  24168. if exists {
  24169. return []uint64{id}, nil
  24170. }
  24171. fallthrough
  24172. case m.op.Is(OpUpdate | OpDelete):
  24173. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  24174. default:
  24175. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24176. }
  24177. }
  24178. // SetCreatedAt sets the "created_at" field.
  24179. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  24180. m.created_at = &t
  24181. }
  24182. // CreatedAt returns the value of the "created_at" field in the mutation.
  24183. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  24184. v := m.created_at
  24185. if v == nil {
  24186. return
  24187. }
  24188. return *v, true
  24189. }
  24190. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  24191. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24193. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24194. if !m.op.Is(OpUpdateOne) {
  24195. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24196. }
  24197. if m.id == nil || m.oldValue == nil {
  24198. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24199. }
  24200. oldValue, err := m.oldValue(ctx)
  24201. if err != nil {
  24202. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24203. }
  24204. return oldValue.CreatedAt, nil
  24205. }
  24206. // ResetCreatedAt resets all changes to the "created_at" field.
  24207. func (m *ServerMutation) ResetCreatedAt() {
  24208. m.created_at = nil
  24209. }
  24210. // SetUpdatedAt sets the "updated_at" field.
  24211. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  24212. m.updated_at = &t
  24213. }
  24214. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24215. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  24216. v := m.updated_at
  24217. if v == nil {
  24218. return
  24219. }
  24220. return *v, true
  24221. }
  24222. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  24223. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24225. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24226. if !m.op.Is(OpUpdateOne) {
  24227. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24228. }
  24229. if m.id == nil || m.oldValue == nil {
  24230. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24231. }
  24232. oldValue, err := m.oldValue(ctx)
  24233. if err != nil {
  24234. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24235. }
  24236. return oldValue.UpdatedAt, nil
  24237. }
  24238. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24239. func (m *ServerMutation) ResetUpdatedAt() {
  24240. m.updated_at = nil
  24241. }
  24242. // SetStatus sets the "status" field.
  24243. func (m *ServerMutation) SetStatus(u uint8) {
  24244. m.status = &u
  24245. m.addstatus = nil
  24246. }
  24247. // Status returns the value of the "status" field in the mutation.
  24248. func (m *ServerMutation) Status() (r uint8, exists bool) {
  24249. v := m.status
  24250. if v == nil {
  24251. return
  24252. }
  24253. return *v, true
  24254. }
  24255. // OldStatus returns the old "status" field's value of the Server entity.
  24256. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24258. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24259. if !m.op.Is(OpUpdateOne) {
  24260. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24261. }
  24262. if m.id == nil || m.oldValue == nil {
  24263. return v, errors.New("OldStatus requires an ID field in the mutation")
  24264. }
  24265. oldValue, err := m.oldValue(ctx)
  24266. if err != nil {
  24267. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24268. }
  24269. return oldValue.Status, nil
  24270. }
  24271. // AddStatus adds u to the "status" field.
  24272. func (m *ServerMutation) AddStatus(u int8) {
  24273. if m.addstatus != nil {
  24274. *m.addstatus += u
  24275. } else {
  24276. m.addstatus = &u
  24277. }
  24278. }
  24279. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24280. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  24281. v := m.addstatus
  24282. if v == nil {
  24283. return
  24284. }
  24285. return *v, true
  24286. }
  24287. // ClearStatus clears the value of the "status" field.
  24288. func (m *ServerMutation) ClearStatus() {
  24289. m.status = nil
  24290. m.addstatus = nil
  24291. m.clearedFields[server.FieldStatus] = struct{}{}
  24292. }
  24293. // StatusCleared returns if the "status" field was cleared in this mutation.
  24294. func (m *ServerMutation) StatusCleared() bool {
  24295. _, ok := m.clearedFields[server.FieldStatus]
  24296. return ok
  24297. }
  24298. // ResetStatus resets all changes to the "status" field.
  24299. func (m *ServerMutation) ResetStatus() {
  24300. m.status = nil
  24301. m.addstatus = nil
  24302. delete(m.clearedFields, server.FieldStatus)
  24303. }
  24304. // SetDeletedAt sets the "deleted_at" field.
  24305. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  24306. m.deleted_at = &t
  24307. }
  24308. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24309. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  24310. v := m.deleted_at
  24311. if v == nil {
  24312. return
  24313. }
  24314. return *v, true
  24315. }
  24316. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  24317. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24319. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24320. if !m.op.Is(OpUpdateOne) {
  24321. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24322. }
  24323. if m.id == nil || m.oldValue == nil {
  24324. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24325. }
  24326. oldValue, err := m.oldValue(ctx)
  24327. if err != nil {
  24328. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24329. }
  24330. return oldValue.DeletedAt, nil
  24331. }
  24332. // ClearDeletedAt clears the value of the "deleted_at" field.
  24333. func (m *ServerMutation) ClearDeletedAt() {
  24334. m.deleted_at = nil
  24335. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  24336. }
  24337. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24338. func (m *ServerMutation) DeletedAtCleared() bool {
  24339. _, ok := m.clearedFields[server.FieldDeletedAt]
  24340. return ok
  24341. }
  24342. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24343. func (m *ServerMutation) ResetDeletedAt() {
  24344. m.deleted_at = nil
  24345. delete(m.clearedFields, server.FieldDeletedAt)
  24346. }
  24347. // SetName sets the "name" field.
  24348. func (m *ServerMutation) SetName(s string) {
  24349. m.name = &s
  24350. }
  24351. // Name returns the value of the "name" field in the mutation.
  24352. func (m *ServerMutation) Name() (r string, exists bool) {
  24353. v := m.name
  24354. if v == nil {
  24355. return
  24356. }
  24357. return *v, true
  24358. }
  24359. // OldName returns the old "name" field's value of the Server entity.
  24360. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24362. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  24363. if !m.op.Is(OpUpdateOne) {
  24364. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24365. }
  24366. if m.id == nil || m.oldValue == nil {
  24367. return v, errors.New("OldName requires an ID field in the mutation")
  24368. }
  24369. oldValue, err := m.oldValue(ctx)
  24370. if err != nil {
  24371. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24372. }
  24373. return oldValue.Name, nil
  24374. }
  24375. // ResetName resets all changes to the "name" field.
  24376. func (m *ServerMutation) ResetName() {
  24377. m.name = nil
  24378. }
  24379. // SetPublicIP sets the "public_ip" field.
  24380. func (m *ServerMutation) SetPublicIP(s string) {
  24381. m.public_ip = &s
  24382. }
  24383. // PublicIP returns the value of the "public_ip" field in the mutation.
  24384. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  24385. v := m.public_ip
  24386. if v == nil {
  24387. return
  24388. }
  24389. return *v, true
  24390. }
  24391. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  24392. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24394. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  24395. if !m.op.Is(OpUpdateOne) {
  24396. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  24397. }
  24398. if m.id == nil || m.oldValue == nil {
  24399. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  24400. }
  24401. oldValue, err := m.oldValue(ctx)
  24402. if err != nil {
  24403. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  24404. }
  24405. return oldValue.PublicIP, nil
  24406. }
  24407. // ResetPublicIP resets all changes to the "public_ip" field.
  24408. func (m *ServerMutation) ResetPublicIP() {
  24409. m.public_ip = nil
  24410. }
  24411. // SetPrivateIP sets the "private_ip" field.
  24412. func (m *ServerMutation) SetPrivateIP(s string) {
  24413. m.private_ip = &s
  24414. }
  24415. // PrivateIP returns the value of the "private_ip" field in the mutation.
  24416. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  24417. v := m.private_ip
  24418. if v == nil {
  24419. return
  24420. }
  24421. return *v, true
  24422. }
  24423. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  24424. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24426. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  24427. if !m.op.Is(OpUpdateOne) {
  24428. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  24429. }
  24430. if m.id == nil || m.oldValue == nil {
  24431. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  24432. }
  24433. oldValue, err := m.oldValue(ctx)
  24434. if err != nil {
  24435. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  24436. }
  24437. return oldValue.PrivateIP, nil
  24438. }
  24439. // ResetPrivateIP resets all changes to the "private_ip" field.
  24440. func (m *ServerMutation) ResetPrivateIP() {
  24441. m.private_ip = nil
  24442. }
  24443. // SetAdminPort sets the "admin_port" field.
  24444. func (m *ServerMutation) SetAdminPort(s string) {
  24445. m.admin_port = &s
  24446. }
  24447. // AdminPort returns the value of the "admin_port" field in the mutation.
  24448. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  24449. v := m.admin_port
  24450. if v == nil {
  24451. return
  24452. }
  24453. return *v, true
  24454. }
  24455. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  24456. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24458. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  24459. if !m.op.Is(OpUpdateOne) {
  24460. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  24461. }
  24462. if m.id == nil || m.oldValue == nil {
  24463. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  24464. }
  24465. oldValue, err := m.oldValue(ctx)
  24466. if err != nil {
  24467. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  24468. }
  24469. return oldValue.AdminPort, nil
  24470. }
  24471. // ResetAdminPort resets all changes to the "admin_port" field.
  24472. func (m *ServerMutation) ResetAdminPort() {
  24473. m.admin_port = nil
  24474. }
  24475. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  24476. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  24477. if m.wxs == nil {
  24478. m.wxs = make(map[uint64]struct{})
  24479. }
  24480. for i := range ids {
  24481. m.wxs[ids[i]] = struct{}{}
  24482. }
  24483. }
  24484. // ClearWxs clears the "wxs" edge to the Wx entity.
  24485. func (m *ServerMutation) ClearWxs() {
  24486. m.clearedwxs = true
  24487. }
  24488. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  24489. func (m *ServerMutation) WxsCleared() bool {
  24490. return m.clearedwxs
  24491. }
  24492. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  24493. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  24494. if m.removedwxs == nil {
  24495. m.removedwxs = make(map[uint64]struct{})
  24496. }
  24497. for i := range ids {
  24498. delete(m.wxs, ids[i])
  24499. m.removedwxs[ids[i]] = struct{}{}
  24500. }
  24501. }
  24502. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  24503. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  24504. for id := range m.removedwxs {
  24505. ids = append(ids, id)
  24506. }
  24507. return
  24508. }
  24509. // WxsIDs returns the "wxs" edge IDs in the mutation.
  24510. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  24511. for id := range m.wxs {
  24512. ids = append(ids, id)
  24513. }
  24514. return
  24515. }
  24516. // ResetWxs resets all changes to the "wxs" edge.
  24517. func (m *ServerMutation) ResetWxs() {
  24518. m.wxs = nil
  24519. m.clearedwxs = false
  24520. m.removedwxs = nil
  24521. }
  24522. // Where appends a list predicates to the ServerMutation builder.
  24523. func (m *ServerMutation) Where(ps ...predicate.Server) {
  24524. m.predicates = append(m.predicates, ps...)
  24525. }
  24526. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  24527. // users can use type-assertion to append predicates that do not depend on any generated package.
  24528. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  24529. p := make([]predicate.Server, len(ps))
  24530. for i := range ps {
  24531. p[i] = ps[i]
  24532. }
  24533. m.Where(p...)
  24534. }
  24535. // Op returns the operation name.
  24536. func (m *ServerMutation) Op() Op {
  24537. return m.op
  24538. }
  24539. // SetOp allows setting the mutation operation.
  24540. func (m *ServerMutation) SetOp(op Op) {
  24541. m.op = op
  24542. }
  24543. // Type returns the node type of this mutation (Server).
  24544. func (m *ServerMutation) Type() string {
  24545. return m.typ
  24546. }
  24547. // Fields returns all fields that were changed during this mutation. Note that in
  24548. // order to get all numeric fields that were incremented/decremented, call
  24549. // AddedFields().
  24550. func (m *ServerMutation) Fields() []string {
  24551. fields := make([]string, 0, 8)
  24552. if m.created_at != nil {
  24553. fields = append(fields, server.FieldCreatedAt)
  24554. }
  24555. if m.updated_at != nil {
  24556. fields = append(fields, server.FieldUpdatedAt)
  24557. }
  24558. if m.status != nil {
  24559. fields = append(fields, server.FieldStatus)
  24560. }
  24561. if m.deleted_at != nil {
  24562. fields = append(fields, server.FieldDeletedAt)
  24563. }
  24564. if m.name != nil {
  24565. fields = append(fields, server.FieldName)
  24566. }
  24567. if m.public_ip != nil {
  24568. fields = append(fields, server.FieldPublicIP)
  24569. }
  24570. if m.private_ip != nil {
  24571. fields = append(fields, server.FieldPrivateIP)
  24572. }
  24573. if m.admin_port != nil {
  24574. fields = append(fields, server.FieldAdminPort)
  24575. }
  24576. return fields
  24577. }
  24578. // Field returns the value of a field with the given name. The second boolean
  24579. // return value indicates that this field was not set, or was not defined in the
  24580. // schema.
  24581. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  24582. switch name {
  24583. case server.FieldCreatedAt:
  24584. return m.CreatedAt()
  24585. case server.FieldUpdatedAt:
  24586. return m.UpdatedAt()
  24587. case server.FieldStatus:
  24588. return m.Status()
  24589. case server.FieldDeletedAt:
  24590. return m.DeletedAt()
  24591. case server.FieldName:
  24592. return m.Name()
  24593. case server.FieldPublicIP:
  24594. return m.PublicIP()
  24595. case server.FieldPrivateIP:
  24596. return m.PrivateIP()
  24597. case server.FieldAdminPort:
  24598. return m.AdminPort()
  24599. }
  24600. return nil, false
  24601. }
  24602. // OldField returns the old value of the field from the database. An error is
  24603. // returned if the mutation operation is not UpdateOne, or the query to the
  24604. // database failed.
  24605. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24606. switch name {
  24607. case server.FieldCreatedAt:
  24608. return m.OldCreatedAt(ctx)
  24609. case server.FieldUpdatedAt:
  24610. return m.OldUpdatedAt(ctx)
  24611. case server.FieldStatus:
  24612. return m.OldStatus(ctx)
  24613. case server.FieldDeletedAt:
  24614. return m.OldDeletedAt(ctx)
  24615. case server.FieldName:
  24616. return m.OldName(ctx)
  24617. case server.FieldPublicIP:
  24618. return m.OldPublicIP(ctx)
  24619. case server.FieldPrivateIP:
  24620. return m.OldPrivateIP(ctx)
  24621. case server.FieldAdminPort:
  24622. return m.OldAdminPort(ctx)
  24623. }
  24624. return nil, fmt.Errorf("unknown Server field %s", name)
  24625. }
  24626. // SetField sets the value of a field with the given name. It returns an error if
  24627. // the field is not defined in the schema, or if the type mismatched the field
  24628. // type.
  24629. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  24630. switch name {
  24631. case server.FieldCreatedAt:
  24632. v, ok := value.(time.Time)
  24633. if !ok {
  24634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24635. }
  24636. m.SetCreatedAt(v)
  24637. return nil
  24638. case server.FieldUpdatedAt:
  24639. v, ok := value.(time.Time)
  24640. if !ok {
  24641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24642. }
  24643. m.SetUpdatedAt(v)
  24644. return nil
  24645. case server.FieldStatus:
  24646. v, ok := value.(uint8)
  24647. if !ok {
  24648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24649. }
  24650. m.SetStatus(v)
  24651. return nil
  24652. case server.FieldDeletedAt:
  24653. v, ok := value.(time.Time)
  24654. if !ok {
  24655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24656. }
  24657. m.SetDeletedAt(v)
  24658. return nil
  24659. case server.FieldName:
  24660. v, ok := value.(string)
  24661. if !ok {
  24662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24663. }
  24664. m.SetName(v)
  24665. return nil
  24666. case server.FieldPublicIP:
  24667. v, ok := value.(string)
  24668. if !ok {
  24669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24670. }
  24671. m.SetPublicIP(v)
  24672. return nil
  24673. case server.FieldPrivateIP:
  24674. v, ok := value.(string)
  24675. if !ok {
  24676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24677. }
  24678. m.SetPrivateIP(v)
  24679. return nil
  24680. case server.FieldAdminPort:
  24681. v, ok := value.(string)
  24682. if !ok {
  24683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24684. }
  24685. m.SetAdminPort(v)
  24686. return nil
  24687. }
  24688. return fmt.Errorf("unknown Server field %s", name)
  24689. }
  24690. // AddedFields returns all numeric fields that were incremented/decremented during
  24691. // this mutation.
  24692. func (m *ServerMutation) AddedFields() []string {
  24693. var fields []string
  24694. if m.addstatus != nil {
  24695. fields = append(fields, server.FieldStatus)
  24696. }
  24697. return fields
  24698. }
  24699. // AddedField returns the numeric value that was incremented/decremented on a field
  24700. // with the given name. The second boolean return value indicates that this field
  24701. // was not set, or was not defined in the schema.
  24702. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  24703. switch name {
  24704. case server.FieldStatus:
  24705. return m.AddedStatus()
  24706. }
  24707. return nil, false
  24708. }
  24709. // AddField adds the value to the field with the given name. It returns an error if
  24710. // the field is not defined in the schema, or if the type mismatched the field
  24711. // type.
  24712. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  24713. switch name {
  24714. case server.FieldStatus:
  24715. v, ok := value.(int8)
  24716. if !ok {
  24717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24718. }
  24719. m.AddStatus(v)
  24720. return nil
  24721. }
  24722. return fmt.Errorf("unknown Server numeric field %s", name)
  24723. }
  24724. // ClearedFields returns all nullable fields that were cleared during this
  24725. // mutation.
  24726. func (m *ServerMutation) ClearedFields() []string {
  24727. var fields []string
  24728. if m.FieldCleared(server.FieldStatus) {
  24729. fields = append(fields, server.FieldStatus)
  24730. }
  24731. if m.FieldCleared(server.FieldDeletedAt) {
  24732. fields = append(fields, server.FieldDeletedAt)
  24733. }
  24734. return fields
  24735. }
  24736. // FieldCleared returns a boolean indicating if a field with the given name was
  24737. // cleared in this mutation.
  24738. func (m *ServerMutation) FieldCleared(name string) bool {
  24739. _, ok := m.clearedFields[name]
  24740. return ok
  24741. }
  24742. // ClearField clears the value of the field with the given name. It returns an
  24743. // error if the field is not defined in the schema.
  24744. func (m *ServerMutation) ClearField(name string) error {
  24745. switch name {
  24746. case server.FieldStatus:
  24747. m.ClearStatus()
  24748. return nil
  24749. case server.FieldDeletedAt:
  24750. m.ClearDeletedAt()
  24751. return nil
  24752. }
  24753. return fmt.Errorf("unknown Server nullable field %s", name)
  24754. }
  24755. // ResetField resets all changes in the mutation for the field with the given name.
  24756. // It returns an error if the field is not defined in the schema.
  24757. func (m *ServerMutation) ResetField(name string) error {
  24758. switch name {
  24759. case server.FieldCreatedAt:
  24760. m.ResetCreatedAt()
  24761. return nil
  24762. case server.FieldUpdatedAt:
  24763. m.ResetUpdatedAt()
  24764. return nil
  24765. case server.FieldStatus:
  24766. m.ResetStatus()
  24767. return nil
  24768. case server.FieldDeletedAt:
  24769. m.ResetDeletedAt()
  24770. return nil
  24771. case server.FieldName:
  24772. m.ResetName()
  24773. return nil
  24774. case server.FieldPublicIP:
  24775. m.ResetPublicIP()
  24776. return nil
  24777. case server.FieldPrivateIP:
  24778. m.ResetPrivateIP()
  24779. return nil
  24780. case server.FieldAdminPort:
  24781. m.ResetAdminPort()
  24782. return nil
  24783. }
  24784. return fmt.Errorf("unknown Server field %s", name)
  24785. }
  24786. // AddedEdges returns all edge names that were set/added in this mutation.
  24787. func (m *ServerMutation) AddedEdges() []string {
  24788. edges := make([]string, 0, 1)
  24789. if m.wxs != nil {
  24790. edges = append(edges, server.EdgeWxs)
  24791. }
  24792. return edges
  24793. }
  24794. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24795. // name in this mutation.
  24796. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  24797. switch name {
  24798. case server.EdgeWxs:
  24799. ids := make([]ent.Value, 0, len(m.wxs))
  24800. for id := range m.wxs {
  24801. ids = append(ids, id)
  24802. }
  24803. return ids
  24804. }
  24805. return nil
  24806. }
  24807. // RemovedEdges returns all edge names that were removed in this mutation.
  24808. func (m *ServerMutation) RemovedEdges() []string {
  24809. edges := make([]string, 0, 1)
  24810. if m.removedwxs != nil {
  24811. edges = append(edges, server.EdgeWxs)
  24812. }
  24813. return edges
  24814. }
  24815. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24816. // the given name in this mutation.
  24817. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  24818. switch name {
  24819. case server.EdgeWxs:
  24820. ids := make([]ent.Value, 0, len(m.removedwxs))
  24821. for id := range m.removedwxs {
  24822. ids = append(ids, id)
  24823. }
  24824. return ids
  24825. }
  24826. return nil
  24827. }
  24828. // ClearedEdges returns all edge names that were cleared in this mutation.
  24829. func (m *ServerMutation) ClearedEdges() []string {
  24830. edges := make([]string, 0, 1)
  24831. if m.clearedwxs {
  24832. edges = append(edges, server.EdgeWxs)
  24833. }
  24834. return edges
  24835. }
  24836. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24837. // was cleared in this mutation.
  24838. func (m *ServerMutation) EdgeCleared(name string) bool {
  24839. switch name {
  24840. case server.EdgeWxs:
  24841. return m.clearedwxs
  24842. }
  24843. return false
  24844. }
  24845. // ClearEdge clears the value of the edge with the given name. It returns an error
  24846. // if that edge is not defined in the schema.
  24847. func (m *ServerMutation) ClearEdge(name string) error {
  24848. switch name {
  24849. }
  24850. return fmt.Errorf("unknown Server unique edge %s", name)
  24851. }
  24852. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24853. // It returns an error if the edge is not defined in the schema.
  24854. func (m *ServerMutation) ResetEdge(name string) error {
  24855. switch name {
  24856. case server.EdgeWxs:
  24857. m.ResetWxs()
  24858. return nil
  24859. }
  24860. return fmt.Errorf("unknown Server edge %s", name)
  24861. }
  24862. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  24863. type SopNodeMutation struct {
  24864. config
  24865. op Op
  24866. typ string
  24867. id *uint64
  24868. created_at *time.Time
  24869. updated_at *time.Time
  24870. status *uint8
  24871. addstatus *int8
  24872. deleted_at *time.Time
  24873. parent_id *uint64
  24874. addparent_id *int64
  24875. name *string
  24876. condition_type *int
  24877. addcondition_type *int
  24878. condition_list *[]string
  24879. appendcondition_list []string
  24880. no_reply_condition *uint64
  24881. addno_reply_condition *int64
  24882. no_reply_unit *string
  24883. action_message *[]custom_types.Action
  24884. appendaction_message []custom_types.Action
  24885. action_label_add *[]uint64
  24886. appendaction_label_add []uint64
  24887. action_label_del *[]uint64
  24888. appendaction_label_del []uint64
  24889. action_forward **custom_types.ActionForward
  24890. clearedFields map[string]struct{}
  24891. sop_stage *uint64
  24892. clearedsop_stage bool
  24893. node_messages map[uint64]struct{}
  24894. removednode_messages map[uint64]struct{}
  24895. clearednode_messages bool
  24896. done bool
  24897. oldValue func(context.Context) (*SopNode, error)
  24898. predicates []predicate.SopNode
  24899. }
  24900. var _ ent.Mutation = (*SopNodeMutation)(nil)
  24901. // sopnodeOption allows management of the mutation configuration using functional options.
  24902. type sopnodeOption func(*SopNodeMutation)
  24903. // newSopNodeMutation creates new mutation for the SopNode entity.
  24904. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  24905. m := &SopNodeMutation{
  24906. config: c,
  24907. op: op,
  24908. typ: TypeSopNode,
  24909. clearedFields: make(map[string]struct{}),
  24910. }
  24911. for _, opt := range opts {
  24912. opt(m)
  24913. }
  24914. return m
  24915. }
  24916. // withSopNodeID sets the ID field of the mutation.
  24917. func withSopNodeID(id uint64) sopnodeOption {
  24918. return func(m *SopNodeMutation) {
  24919. var (
  24920. err error
  24921. once sync.Once
  24922. value *SopNode
  24923. )
  24924. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  24925. once.Do(func() {
  24926. if m.done {
  24927. err = errors.New("querying old values post mutation is not allowed")
  24928. } else {
  24929. value, err = m.Client().SopNode.Get(ctx, id)
  24930. }
  24931. })
  24932. return value, err
  24933. }
  24934. m.id = &id
  24935. }
  24936. }
  24937. // withSopNode sets the old SopNode of the mutation.
  24938. func withSopNode(node *SopNode) sopnodeOption {
  24939. return func(m *SopNodeMutation) {
  24940. m.oldValue = func(context.Context) (*SopNode, error) {
  24941. return node, nil
  24942. }
  24943. m.id = &node.ID
  24944. }
  24945. }
  24946. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24947. // executed in a transaction (ent.Tx), a transactional client is returned.
  24948. func (m SopNodeMutation) Client() *Client {
  24949. client := &Client{config: m.config}
  24950. client.init()
  24951. return client
  24952. }
  24953. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24954. // it returns an error otherwise.
  24955. func (m SopNodeMutation) Tx() (*Tx, error) {
  24956. if _, ok := m.driver.(*txDriver); !ok {
  24957. return nil, errors.New("ent: mutation is not running in a transaction")
  24958. }
  24959. tx := &Tx{config: m.config}
  24960. tx.init()
  24961. return tx, nil
  24962. }
  24963. // SetID sets the value of the id field. Note that this
  24964. // operation is only accepted on creation of SopNode entities.
  24965. func (m *SopNodeMutation) SetID(id uint64) {
  24966. m.id = &id
  24967. }
  24968. // ID returns the ID value in the mutation. Note that the ID is only available
  24969. // if it was provided to the builder or after it was returned from the database.
  24970. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  24971. if m.id == nil {
  24972. return
  24973. }
  24974. return *m.id, true
  24975. }
  24976. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24977. // That means, if the mutation is applied within a transaction with an isolation level such
  24978. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24979. // or updated by the mutation.
  24980. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  24981. switch {
  24982. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24983. id, exists := m.ID()
  24984. if exists {
  24985. return []uint64{id}, nil
  24986. }
  24987. fallthrough
  24988. case m.op.Is(OpUpdate | OpDelete):
  24989. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  24990. default:
  24991. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24992. }
  24993. }
  24994. // SetCreatedAt sets the "created_at" field.
  24995. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  24996. m.created_at = &t
  24997. }
  24998. // CreatedAt returns the value of the "created_at" field in the mutation.
  24999. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  25000. v := m.created_at
  25001. if v == nil {
  25002. return
  25003. }
  25004. return *v, true
  25005. }
  25006. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  25007. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25009. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25010. if !m.op.Is(OpUpdateOne) {
  25011. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25012. }
  25013. if m.id == nil || m.oldValue == nil {
  25014. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25015. }
  25016. oldValue, err := m.oldValue(ctx)
  25017. if err != nil {
  25018. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25019. }
  25020. return oldValue.CreatedAt, nil
  25021. }
  25022. // ResetCreatedAt resets all changes to the "created_at" field.
  25023. func (m *SopNodeMutation) ResetCreatedAt() {
  25024. m.created_at = nil
  25025. }
  25026. // SetUpdatedAt sets the "updated_at" field.
  25027. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  25028. m.updated_at = &t
  25029. }
  25030. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25031. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  25032. v := m.updated_at
  25033. if v == nil {
  25034. return
  25035. }
  25036. return *v, true
  25037. }
  25038. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  25039. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25041. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25042. if !m.op.Is(OpUpdateOne) {
  25043. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25044. }
  25045. if m.id == nil || m.oldValue == nil {
  25046. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25047. }
  25048. oldValue, err := m.oldValue(ctx)
  25049. if err != nil {
  25050. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25051. }
  25052. return oldValue.UpdatedAt, nil
  25053. }
  25054. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25055. func (m *SopNodeMutation) ResetUpdatedAt() {
  25056. m.updated_at = nil
  25057. }
  25058. // SetStatus sets the "status" field.
  25059. func (m *SopNodeMutation) SetStatus(u uint8) {
  25060. m.status = &u
  25061. m.addstatus = nil
  25062. }
  25063. // Status returns the value of the "status" field in the mutation.
  25064. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  25065. v := m.status
  25066. if v == nil {
  25067. return
  25068. }
  25069. return *v, true
  25070. }
  25071. // OldStatus returns the old "status" field's value of the SopNode entity.
  25072. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25074. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25075. if !m.op.Is(OpUpdateOne) {
  25076. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25077. }
  25078. if m.id == nil || m.oldValue == nil {
  25079. return v, errors.New("OldStatus requires an ID field in the mutation")
  25080. }
  25081. oldValue, err := m.oldValue(ctx)
  25082. if err != nil {
  25083. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25084. }
  25085. return oldValue.Status, nil
  25086. }
  25087. // AddStatus adds u to the "status" field.
  25088. func (m *SopNodeMutation) AddStatus(u int8) {
  25089. if m.addstatus != nil {
  25090. *m.addstatus += u
  25091. } else {
  25092. m.addstatus = &u
  25093. }
  25094. }
  25095. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25096. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  25097. v := m.addstatus
  25098. if v == nil {
  25099. return
  25100. }
  25101. return *v, true
  25102. }
  25103. // ClearStatus clears the value of the "status" field.
  25104. func (m *SopNodeMutation) ClearStatus() {
  25105. m.status = nil
  25106. m.addstatus = nil
  25107. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  25108. }
  25109. // StatusCleared returns if the "status" field was cleared in this mutation.
  25110. func (m *SopNodeMutation) StatusCleared() bool {
  25111. _, ok := m.clearedFields[sopnode.FieldStatus]
  25112. return ok
  25113. }
  25114. // ResetStatus resets all changes to the "status" field.
  25115. func (m *SopNodeMutation) ResetStatus() {
  25116. m.status = nil
  25117. m.addstatus = nil
  25118. delete(m.clearedFields, sopnode.FieldStatus)
  25119. }
  25120. // SetDeletedAt sets the "deleted_at" field.
  25121. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  25122. m.deleted_at = &t
  25123. }
  25124. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25125. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  25126. v := m.deleted_at
  25127. if v == nil {
  25128. return
  25129. }
  25130. return *v, true
  25131. }
  25132. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  25133. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25135. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25136. if !m.op.Is(OpUpdateOne) {
  25137. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25138. }
  25139. if m.id == nil || m.oldValue == nil {
  25140. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25141. }
  25142. oldValue, err := m.oldValue(ctx)
  25143. if err != nil {
  25144. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25145. }
  25146. return oldValue.DeletedAt, nil
  25147. }
  25148. // ClearDeletedAt clears the value of the "deleted_at" field.
  25149. func (m *SopNodeMutation) ClearDeletedAt() {
  25150. m.deleted_at = nil
  25151. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  25152. }
  25153. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25154. func (m *SopNodeMutation) DeletedAtCleared() bool {
  25155. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  25156. return ok
  25157. }
  25158. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25159. func (m *SopNodeMutation) ResetDeletedAt() {
  25160. m.deleted_at = nil
  25161. delete(m.clearedFields, sopnode.FieldDeletedAt)
  25162. }
  25163. // SetStageID sets the "stage_id" field.
  25164. func (m *SopNodeMutation) SetStageID(u uint64) {
  25165. m.sop_stage = &u
  25166. }
  25167. // StageID returns the value of the "stage_id" field in the mutation.
  25168. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  25169. v := m.sop_stage
  25170. if v == nil {
  25171. return
  25172. }
  25173. return *v, true
  25174. }
  25175. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  25176. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25178. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  25179. if !m.op.Is(OpUpdateOne) {
  25180. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  25181. }
  25182. if m.id == nil || m.oldValue == nil {
  25183. return v, errors.New("OldStageID requires an ID field in the mutation")
  25184. }
  25185. oldValue, err := m.oldValue(ctx)
  25186. if err != nil {
  25187. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  25188. }
  25189. return oldValue.StageID, nil
  25190. }
  25191. // ResetStageID resets all changes to the "stage_id" field.
  25192. func (m *SopNodeMutation) ResetStageID() {
  25193. m.sop_stage = nil
  25194. }
  25195. // SetParentID sets the "parent_id" field.
  25196. func (m *SopNodeMutation) SetParentID(u uint64) {
  25197. m.parent_id = &u
  25198. m.addparent_id = nil
  25199. }
  25200. // ParentID returns the value of the "parent_id" field in the mutation.
  25201. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  25202. v := m.parent_id
  25203. if v == nil {
  25204. return
  25205. }
  25206. return *v, true
  25207. }
  25208. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  25209. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25211. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  25212. if !m.op.Is(OpUpdateOne) {
  25213. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  25214. }
  25215. if m.id == nil || m.oldValue == nil {
  25216. return v, errors.New("OldParentID requires an ID field in the mutation")
  25217. }
  25218. oldValue, err := m.oldValue(ctx)
  25219. if err != nil {
  25220. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  25221. }
  25222. return oldValue.ParentID, nil
  25223. }
  25224. // AddParentID adds u to the "parent_id" field.
  25225. func (m *SopNodeMutation) AddParentID(u int64) {
  25226. if m.addparent_id != nil {
  25227. *m.addparent_id += u
  25228. } else {
  25229. m.addparent_id = &u
  25230. }
  25231. }
  25232. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  25233. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  25234. v := m.addparent_id
  25235. if v == nil {
  25236. return
  25237. }
  25238. return *v, true
  25239. }
  25240. // ResetParentID resets all changes to the "parent_id" field.
  25241. func (m *SopNodeMutation) ResetParentID() {
  25242. m.parent_id = nil
  25243. m.addparent_id = nil
  25244. }
  25245. // SetName sets the "name" field.
  25246. func (m *SopNodeMutation) SetName(s string) {
  25247. m.name = &s
  25248. }
  25249. // Name returns the value of the "name" field in the mutation.
  25250. func (m *SopNodeMutation) Name() (r string, exists bool) {
  25251. v := m.name
  25252. if v == nil {
  25253. return
  25254. }
  25255. return *v, true
  25256. }
  25257. // OldName returns the old "name" field's value of the SopNode entity.
  25258. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25260. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  25261. if !m.op.Is(OpUpdateOne) {
  25262. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25263. }
  25264. if m.id == nil || m.oldValue == nil {
  25265. return v, errors.New("OldName requires an ID field in the mutation")
  25266. }
  25267. oldValue, err := m.oldValue(ctx)
  25268. if err != nil {
  25269. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25270. }
  25271. return oldValue.Name, nil
  25272. }
  25273. // ResetName resets all changes to the "name" field.
  25274. func (m *SopNodeMutation) ResetName() {
  25275. m.name = nil
  25276. }
  25277. // SetConditionType sets the "condition_type" field.
  25278. func (m *SopNodeMutation) SetConditionType(i int) {
  25279. m.condition_type = &i
  25280. m.addcondition_type = nil
  25281. }
  25282. // ConditionType returns the value of the "condition_type" field in the mutation.
  25283. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  25284. v := m.condition_type
  25285. if v == nil {
  25286. return
  25287. }
  25288. return *v, true
  25289. }
  25290. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  25291. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25293. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  25294. if !m.op.Is(OpUpdateOne) {
  25295. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  25296. }
  25297. if m.id == nil || m.oldValue == nil {
  25298. return v, errors.New("OldConditionType requires an ID field in the mutation")
  25299. }
  25300. oldValue, err := m.oldValue(ctx)
  25301. if err != nil {
  25302. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  25303. }
  25304. return oldValue.ConditionType, nil
  25305. }
  25306. // AddConditionType adds i to the "condition_type" field.
  25307. func (m *SopNodeMutation) AddConditionType(i int) {
  25308. if m.addcondition_type != nil {
  25309. *m.addcondition_type += i
  25310. } else {
  25311. m.addcondition_type = &i
  25312. }
  25313. }
  25314. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  25315. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  25316. v := m.addcondition_type
  25317. if v == nil {
  25318. return
  25319. }
  25320. return *v, true
  25321. }
  25322. // ResetConditionType resets all changes to the "condition_type" field.
  25323. func (m *SopNodeMutation) ResetConditionType() {
  25324. m.condition_type = nil
  25325. m.addcondition_type = nil
  25326. }
  25327. // SetConditionList sets the "condition_list" field.
  25328. func (m *SopNodeMutation) SetConditionList(s []string) {
  25329. m.condition_list = &s
  25330. m.appendcondition_list = nil
  25331. }
  25332. // ConditionList returns the value of the "condition_list" field in the mutation.
  25333. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  25334. v := m.condition_list
  25335. if v == nil {
  25336. return
  25337. }
  25338. return *v, true
  25339. }
  25340. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  25341. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25343. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  25344. if !m.op.Is(OpUpdateOne) {
  25345. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  25346. }
  25347. if m.id == nil || m.oldValue == nil {
  25348. return v, errors.New("OldConditionList requires an ID field in the mutation")
  25349. }
  25350. oldValue, err := m.oldValue(ctx)
  25351. if err != nil {
  25352. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  25353. }
  25354. return oldValue.ConditionList, nil
  25355. }
  25356. // AppendConditionList adds s to the "condition_list" field.
  25357. func (m *SopNodeMutation) AppendConditionList(s []string) {
  25358. m.appendcondition_list = append(m.appendcondition_list, s...)
  25359. }
  25360. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25361. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  25362. if len(m.appendcondition_list) == 0 {
  25363. return nil, false
  25364. }
  25365. return m.appendcondition_list, true
  25366. }
  25367. // ClearConditionList clears the value of the "condition_list" field.
  25368. func (m *SopNodeMutation) ClearConditionList() {
  25369. m.condition_list = nil
  25370. m.appendcondition_list = nil
  25371. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  25372. }
  25373. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  25374. func (m *SopNodeMutation) ConditionListCleared() bool {
  25375. _, ok := m.clearedFields[sopnode.FieldConditionList]
  25376. return ok
  25377. }
  25378. // ResetConditionList resets all changes to the "condition_list" field.
  25379. func (m *SopNodeMutation) ResetConditionList() {
  25380. m.condition_list = nil
  25381. m.appendcondition_list = nil
  25382. delete(m.clearedFields, sopnode.FieldConditionList)
  25383. }
  25384. // SetNoReplyCondition sets the "no_reply_condition" field.
  25385. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  25386. m.no_reply_condition = &u
  25387. m.addno_reply_condition = nil
  25388. }
  25389. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  25390. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  25391. v := m.no_reply_condition
  25392. if v == nil {
  25393. return
  25394. }
  25395. return *v, true
  25396. }
  25397. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  25398. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25400. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  25401. if !m.op.Is(OpUpdateOne) {
  25402. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  25403. }
  25404. if m.id == nil || m.oldValue == nil {
  25405. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  25406. }
  25407. oldValue, err := m.oldValue(ctx)
  25408. if err != nil {
  25409. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  25410. }
  25411. return oldValue.NoReplyCondition, nil
  25412. }
  25413. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  25414. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  25415. if m.addno_reply_condition != nil {
  25416. *m.addno_reply_condition += u
  25417. } else {
  25418. m.addno_reply_condition = &u
  25419. }
  25420. }
  25421. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  25422. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  25423. v := m.addno_reply_condition
  25424. if v == nil {
  25425. return
  25426. }
  25427. return *v, true
  25428. }
  25429. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  25430. func (m *SopNodeMutation) ResetNoReplyCondition() {
  25431. m.no_reply_condition = nil
  25432. m.addno_reply_condition = nil
  25433. }
  25434. // SetNoReplyUnit sets the "no_reply_unit" field.
  25435. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  25436. m.no_reply_unit = &s
  25437. }
  25438. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  25439. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  25440. v := m.no_reply_unit
  25441. if v == nil {
  25442. return
  25443. }
  25444. return *v, true
  25445. }
  25446. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  25447. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25449. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  25450. if !m.op.Is(OpUpdateOne) {
  25451. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  25452. }
  25453. if m.id == nil || m.oldValue == nil {
  25454. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  25455. }
  25456. oldValue, err := m.oldValue(ctx)
  25457. if err != nil {
  25458. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  25459. }
  25460. return oldValue.NoReplyUnit, nil
  25461. }
  25462. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  25463. func (m *SopNodeMutation) ResetNoReplyUnit() {
  25464. m.no_reply_unit = nil
  25465. }
  25466. // SetActionMessage sets the "action_message" field.
  25467. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  25468. m.action_message = &ct
  25469. m.appendaction_message = nil
  25470. }
  25471. // ActionMessage returns the value of the "action_message" field in the mutation.
  25472. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  25473. v := m.action_message
  25474. if v == nil {
  25475. return
  25476. }
  25477. return *v, true
  25478. }
  25479. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  25480. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25482. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25483. if !m.op.Is(OpUpdateOne) {
  25484. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25485. }
  25486. if m.id == nil || m.oldValue == nil {
  25487. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25488. }
  25489. oldValue, err := m.oldValue(ctx)
  25490. if err != nil {
  25491. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25492. }
  25493. return oldValue.ActionMessage, nil
  25494. }
  25495. // AppendActionMessage adds ct to the "action_message" field.
  25496. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  25497. m.appendaction_message = append(m.appendaction_message, ct...)
  25498. }
  25499. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25500. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25501. if len(m.appendaction_message) == 0 {
  25502. return nil, false
  25503. }
  25504. return m.appendaction_message, true
  25505. }
  25506. // ClearActionMessage clears the value of the "action_message" field.
  25507. func (m *SopNodeMutation) ClearActionMessage() {
  25508. m.action_message = nil
  25509. m.appendaction_message = nil
  25510. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  25511. }
  25512. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25513. func (m *SopNodeMutation) ActionMessageCleared() bool {
  25514. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  25515. return ok
  25516. }
  25517. // ResetActionMessage resets all changes to the "action_message" field.
  25518. func (m *SopNodeMutation) ResetActionMessage() {
  25519. m.action_message = nil
  25520. m.appendaction_message = nil
  25521. delete(m.clearedFields, sopnode.FieldActionMessage)
  25522. }
  25523. // SetActionLabelAdd sets the "action_label_add" field.
  25524. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  25525. m.action_label_add = &u
  25526. m.appendaction_label_add = nil
  25527. }
  25528. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25529. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25530. v := m.action_label_add
  25531. if v == nil {
  25532. return
  25533. }
  25534. return *v, true
  25535. }
  25536. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  25537. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25539. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25540. if !m.op.Is(OpUpdateOne) {
  25541. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25542. }
  25543. if m.id == nil || m.oldValue == nil {
  25544. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25545. }
  25546. oldValue, err := m.oldValue(ctx)
  25547. if err != nil {
  25548. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25549. }
  25550. return oldValue.ActionLabelAdd, nil
  25551. }
  25552. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25553. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  25554. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25555. }
  25556. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25557. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25558. if len(m.appendaction_label_add) == 0 {
  25559. return nil, false
  25560. }
  25561. return m.appendaction_label_add, true
  25562. }
  25563. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25564. func (m *SopNodeMutation) ClearActionLabelAdd() {
  25565. m.action_label_add = nil
  25566. m.appendaction_label_add = nil
  25567. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  25568. }
  25569. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25570. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  25571. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  25572. return ok
  25573. }
  25574. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25575. func (m *SopNodeMutation) ResetActionLabelAdd() {
  25576. m.action_label_add = nil
  25577. m.appendaction_label_add = nil
  25578. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  25579. }
  25580. // SetActionLabelDel sets the "action_label_del" field.
  25581. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  25582. m.action_label_del = &u
  25583. m.appendaction_label_del = nil
  25584. }
  25585. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25586. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  25587. v := m.action_label_del
  25588. if v == nil {
  25589. return
  25590. }
  25591. return *v, true
  25592. }
  25593. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  25594. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25596. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25597. if !m.op.Is(OpUpdateOne) {
  25598. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25599. }
  25600. if m.id == nil || m.oldValue == nil {
  25601. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25602. }
  25603. oldValue, err := m.oldValue(ctx)
  25604. if err != nil {
  25605. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25606. }
  25607. return oldValue.ActionLabelDel, nil
  25608. }
  25609. // AppendActionLabelDel adds u to the "action_label_del" field.
  25610. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  25611. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25612. }
  25613. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25614. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25615. if len(m.appendaction_label_del) == 0 {
  25616. return nil, false
  25617. }
  25618. return m.appendaction_label_del, true
  25619. }
  25620. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25621. func (m *SopNodeMutation) ClearActionLabelDel() {
  25622. m.action_label_del = nil
  25623. m.appendaction_label_del = nil
  25624. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  25625. }
  25626. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25627. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  25628. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  25629. return ok
  25630. }
  25631. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25632. func (m *SopNodeMutation) ResetActionLabelDel() {
  25633. m.action_label_del = nil
  25634. m.appendaction_label_del = nil
  25635. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  25636. }
  25637. // SetActionForward sets the "action_forward" field.
  25638. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25639. m.action_forward = &ctf
  25640. }
  25641. // ActionForward returns the value of the "action_forward" field in the mutation.
  25642. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25643. v := m.action_forward
  25644. if v == nil {
  25645. return
  25646. }
  25647. return *v, true
  25648. }
  25649. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  25650. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25652. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25653. if !m.op.Is(OpUpdateOne) {
  25654. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25655. }
  25656. if m.id == nil || m.oldValue == nil {
  25657. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25658. }
  25659. oldValue, err := m.oldValue(ctx)
  25660. if err != nil {
  25661. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25662. }
  25663. return oldValue.ActionForward, nil
  25664. }
  25665. // ClearActionForward clears the value of the "action_forward" field.
  25666. func (m *SopNodeMutation) ClearActionForward() {
  25667. m.action_forward = nil
  25668. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  25669. }
  25670. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25671. func (m *SopNodeMutation) ActionForwardCleared() bool {
  25672. _, ok := m.clearedFields[sopnode.FieldActionForward]
  25673. return ok
  25674. }
  25675. // ResetActionForward resets all changes to the "action_forward" field.
  25676. func (m *SopNodeMutation) ResetActionForward() {
  25677. m.action_forward = nil
  25678. delete(m.clearedFields, sopnode.FieldActionForward)
  25679. }
  25680. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  25681. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  25682. m.sop_stage = &id
  25683. }
  25684. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  25685. func (m *SopNodeMutation) ClearSopStage() {
  25686. m.clearedsop_stage = true
  25687. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  25688. }
  25689. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  25690. func (m *SopNodeMutation) SopStageCleared() bool {
  25691. return m.clearedsop_stage
  25692. }
  25693. // SopStageID returns the "sop_stage" edge ID in the mutation.
  25694. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  25695. if m.sop_stage != nil {
  25696. return *m.sop_stage, true
  25697. }
  25698. return
  25699. }
  25700. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  25701. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25702. // SopStageID instead. It exists only for internal usage by the builders.
  25703. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  25704. if id := m.sop_stage; id != nil {
  25705. ids = append(ids, *id)
  25706. }
  25707. return
  25708. }
  25709. // ResetSopStage resets all changes to the "sop_stage" edge.
  25710. func (m *SopNodeMutation) ResetSopStage() {
  25711. m.sop_stage = nil
  25712. m.clearedsop_stage = false
  25713. }
  25714. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  25715. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  25716. if m.node_messages == nil {
  25717. m.node_messages = make(map[uint64]struct{})
  25718. }
  25719. for i := range ids {
  25720. m.node_messages[ids[i]] = struct{}{}
  25721. }
  25722. }
  25723. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  25724. func (m *SopNodeMutation) ClearNodeMessages() {
  25725. m.clearednode_messages = true
  25726. }
  25727. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  25728. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  25729. return m.clearednode_messages
  25730. }
  25731. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  25732. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  25733. if m.removednode_messages == nil {
  25734. m.removednode_messages = make(map[uint64]struct{})
  25735. }
  25736. for i := range ids {
  25737. delete(m.node_messages, ids[i])
  25738. m.removednode_messages[ids[i]] = struct{}{}
  25739. }
  25740. }
  25741. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  25742. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  25743. for id := range m.removednode_messages {
  25744. ids = append(ids, id)
  25745. }
  25746. return
  25747. }
  25748. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  25749. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  25750. for id := range m.node_messages {
  25751. ids = append(ids, id)
  25752. }
  25753. return
  25754. }
  25755. // ResetNodeMessages resets all changes to the "node_messages" edge.
  25756. func (m *SopNodeMutation) ResetNodeMessages() {
  25757. m.node_messages = nil
  25758. m.clearednode_messages = false
  25759. m.removednode_messages = nil
  25760. }
  25761. // Where appends a list predicates to the SopNodeMutation builder.
  25762. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  25763. m.predicates = append(m.predicates, ps...)
  25764. }
  25765. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  25766. // users can use type-assertion to append predicates that do not depend on any generated package.
  25767. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  25768. p := make([]predicate.SopNode, len(ps))
  25769. for i := range ps {
  25770. p[i] = ps[i]
  25771. }
  25772. m.Where(p...)
  25773. }
  25774. // Op returns the operation name.
  25775. func (m *SopNodeMutation) Op() Op {
  25776. return m.op
  25777. }
  25778. // SetOp allows setting the mutation operation.
  25779. func (m *SopNodeMutation) SetOp(op Op) {
  25780. m.op = op
  25781. }
  25782. // Type returns the node type of this mutation (SopNode).
  25783. func (m *SopNodeMutation) Type() string {
  25784. return m.typ
  25785. }
  25786. // Fields returns all fields that were changed during this mutation. Note that in
  25787. // order to get all numeric fields that were incremented/decremented, call
  25788. // AddedFields().
  25789. func (m *SopNodeMutation) Fields() []string {
  25790. fields := make([]string, 0, 15)
  25791. if m.created_at != nil {
  25792. fields = append(fields, sopnode.FieldCreatedAt)
  25793. }
  25794. if m.updated_at != nil {
  25795. fields = append(fields, sopnode.FieldUpdatedAt)
  25796. }
  25797. if m.status != nil {
  25798. fields = append(fields, sopnode.FieldStatus)
  25799. }
  25800. if m.deleted_at != nil {
  25801. fields = append(fields, sopnode.FieldDeletedAt)
  25802. }
  25803. if m.sop_stage != nil {
  25804. fields = append(fields, sopnode.FieldStageID)
  25805. }
  25806. if m.parent_id != nil {
  25807. fields = append(fields, sopnode.FieldParentID)
  25808. }
  25809. if m.name != nil {
  25810. fields = append(fields, sopnode.FieldName)
  25811. }
  25812. if m.condition_type != nil {
  25813. fields = append(fields, sopnode.FieldConditionType)
  25814. }
  25815. if m.condition_list != nil {
  25816. fields = append(fields, sopnode.FieldConditionList)
  25817. }
  25818. if m.no_reply_condition != nil {
  25819. fields = append(fields, sopnode.FieldNoReplyCondition)
  25820. }
  25821. if m.no_reply_unit != nil {
  25822. fields = append(fields, sopnode.FieldNoReplyUnit)
  25823. }
  25824. if m.action_message != nil {
  25825. fields = append(fields, sopnode.FieldActionMessage)
  25826. }
  25827. if m.action_label_add != nil {
  25828. fields = append(fields, sopnode.FieldActionLabelAdd)
  25829. }
  25830. if m.action_label_del != nil {
  25831. fields = append(fields, sopnode.FieldActionLabelDel)
  25832. }
  25833. if m.action_forward != nil {
  25834. fields = append(fields, sopnode.FieldActionForward)
  25835. }
  25836. return fields
  25837. }
  25838. // Field returns the value of a field with the given name. The second boolean
  25839. // return value indicates that this field was not set, or was not defined in the
  25840. // schema.
  25841. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  25842. switch name {
  25843. case sopnode.FieldCreatedAt:
  25844. return m.CreatedAt()
  25845. case sopnode.FieldUpdatedAt:
  25846. return m.UpdatedAt()
  25847. case sopnode.FieldStatus:
  25848. return m.Status()
  25849. case sopnode.FieldDeletedAt:
  25850. return m.DeletedAt()
  25851. case sopnode.FieldStageID:
  25852. return m.StageID()
  25853. case sopnode.FieldParentID:
  25854. return m.ParentID()
  25855. case sopnode.FieldName:
  25856. return m.Name()
  25857. case sopnode.FieldConditionType:
  25858. return m.ConditionType()
  25859. case sopnode.FieldConditionList:
  25860. return m.ConditionList()
  25861. case sopnode.FieldNoReplyCondition:
  25862. return m.NoReplyCondition()
  25863. case sopnode.FieldNoReplyUnit:
  25864. return m.NoReplyUnit()
  25865. case sopnode.FieldActionMessage:
  25866. return m.ActionMessage()
  25867. case sopnode.FieldActionLabelAdd:
  25868. return m.ActionLabelAdd()
  25869. case sopnode.FieldActionLabelDel:
  25870. return m.ActionLabelDel()
  25871. case sopnode.FieldActionForward:
  25872. return m.ActionForward()
  25873. }
  25874. return nil, false
  25875. }
  25876. // OldField returns the old value of the field from the database. An error is
  25877. // returned if the mutation operation is not UpdateOne, or the query to the
  25878. // database failed.
  25879. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25880. switch name {
  25881. case sopnode.FieldCreatedAt:
  25882. return m.OldCreatedAt(ctx)
  25883. case sopnode.FieldUpdatedAt:
  25884. return m.OldUpdatedAt(ctx)
  25885. case sopnode.FieldStatus:
  25886. return m.OldStatus(ctx)
  25887. case sopnode.FieldDeletedAt:
  25888. return m.OldDeletedAt(ctx)
  25889. case sopnode.FieldStageID:
  25890. return m.OldStageID(ctx)
  25891. case sopnode.FieldParentID:
  25892. return m.OldParentID(ctx)
  25893. case sopnode.FieldName:
  25894. return m.OldName(ctx)
  25895. case sopnode.FieldConditionType:
  25896. return m.OldConditionType(ctx)
  25897. case sopnode.FieldConditionList:
  25898. return m.OldConditionList(ctx)
  25899. case sopnode.FieldNoReplyCondition:
  25900. return m.OldNoReplyCondition(ctx)
  25901. case sopnode.FieldNoReplyUnit:
  25902. return m.OldNoReplyUnit(ctx)
  25903. case sopnode.FieldActionMessage:
  25904. return m.OldActionMessage(ctx)
  25905. case sopnode.FieldActionLabelAdd:
  25906. return m.OldActionLabelAdd(ctx)
  25907. case sopnode.FieldActionLabelDel:
  25908. return m.OldActionLabelDel(ctx)
  25909. case sopnode.FieldActionForward:
  25910. return m.OldActionForward(ctx)
  25911. }
  25912. return nil, fmt.Errorf("unknown SopNode field %s", name)
  25913. }
  25914. // SetField sets the value of a field with the given name. It returns an error if
  25915. // the field is not defined in the schema, or if the type mismatched the field
  25916. // type.
  25917. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  25918. switch name {
  25919. case sopnode.FieldCreatedAt:
  25920. v, ok := value.(time.Time)
  25921. if !ok {
  25922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25923. }
  25924. m.SetCreatedAt(v)
  25925. return nil
  25926. case sopnode.FieldUpdatedAt:
  25927. v, ok := value.(time.Time)
  25928. if !ok {
  25929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25930. }
  25931. m.SetUpdatedAt(v)
  25932. return nil
  25933. case sopnode.FieldStatus:
  25934. v, ok := value.(uint8)
  25935. if !ok {
  25936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25937. }
  25938. m.SetStatus(v)
  25939. return nil
  25940. case sopnode.FieldDeletedAt:
  25941. v, ok := value.(time.Time)
  25942. if !ok {
  25943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25944. }
  25945. m.SetDeletedAt(v)
  25946. return nil
  25947. case sopnode.FieldStageID:
  25948. v, ok := value.(uint64)
  25949. if !ok {
  25950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25951. }
  25952. m.SetStageID(v)
  25953. return nil
  25954. case sopnode.FieldParentID:
  25955. v, ok := value.(uint64)
  25956. if !ok {
  25957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25958. }
  25959. m.SetParentID(v)
  25960. return nil
  25961. case sopnode.FieldName:
  25962. v, ok := value.(string)
  25963. if !ok {
  25964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25965. }
  25966. m.SetName(v)
  25967. return nil
  25968. case sopnode.FieldConditionType:
  25969. v, ok := value.(int)
  25970. if !ok {
  25971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25972. }
  25973. m.SetConditionType(v)
  25974. return nil
  25975. case sopnode.FieldConditionList:
  25976. v, ok := value.([]string)
  25977. if !ok {
  25978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25979. }
  25980. m.SetConditionList(v)
  25981. return nil
  25982. case sopnode.FieldNoReplyCondition:
  25983. v, ok := value.(uint64)
  25984. if !ok {
  25985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25986. }
  25987. m.SetNoReplyCondition(v)
  25988. return nil
  25989. case sopnode.FieldNoReplyUnit:
  25990. v, ok := value.(string)
  25991. if !ok {
  25992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25993. }
  25994. m.SetNoReplyUnit(v)
  25995. return nil
  25996. case sopnode.FieldActionMessage:
  25997. v, ok := value.([]custom_types.Action)
  25998. if !ok {
  25999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26000. }
  26001. m.SetActionMessage(v)
  26002. return nil
  26003. case sopnode.FieldActionLabelAdd:
  26004. v, ok := value.([]uint64)
  26005. if !ok {
  26006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26007. }
  26008. m.SetActionLabelAdd(v)
  26009. return nil
  26010. case sopnode.FieldActionLabelDel:
  26011. v, ok := value.([]uint64)
  26012. if !ok {
  26013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26014. }
  26015. m.SetActionLabelDel(v)
  26016. return nil
  26017. case sopnode.FieldActionForward:
  26018. v, ok := value.(*custom_types.ActionForward)
  26019. if !ok {
  26020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26021. }
  26022. m.SetActionForward(v)
  26023. return nil
  26024. }
  26025. return fmt.Errorf("unknown SopNode field %s", name)
  26026. }
  26027. // AddedFields returns all numeric fields that were incremented/decremented during
  26028. // this mutation.
  26029. func (m *SopNodeMutation) AddedFields() []string {
  26030. var fields []string
  26031. if m.addstatus != nil {
  26032. fields = append(fields, sopnode.FieldStatus)
  26033. }
  26034. if m.addparent_id != nil {
  26035. fields = append(fields, sopnode.FieldParentID)
  26036. }
  26037. if m.addcondition_type != nil {
  26038. fields = append(fields, sopnode.FieldConditionType)
  26039. }
  26040. if m.addno_reply_condition != nil {
  26041. fields = append(fields, sopnode.FieldNoReplyCondition)
  26042. }
  26043. return fields
  26044. }
  26045. // AddedField returns the numeric value that was incremented/decremented on a field
  26046. // with the given name. The second boolean return value indicates that this field
  26047. // was not set, or was not defined in the schema.
  26048. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  26049. switch name {
  26050. case sopnode.FieldStatus:
  26051. return m.AddedStatus()
  26052. case sopnode.FieldParentID:
  26053. return m.AddedParentID()
  26054. case sopnode.FieldConditionType:
  26055. return m.AddedConditionType()
  26056. case sopnode.FieldNoReplyCondition:
  26057. return m.AddedNoReplyCondition()
  26058. }
  26059. return nil, false
  26060. }
  26061. // AddField adds the value to the field with the given name. It returns an error if
  26062. // the field is not defined in the schema, or if the type mismatched the field
  26063. // type.
  26064. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  26065. switch name {
  26066. case sopnode.FieldStatus:
  26067. v, ok := value.(int8)
  26068. if !ok {
  26069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26070. }
  26071. m.AddStatus(v)
  26072. return nil
  26073. case sopnode.FieldParentID:
  26074. v, ok := value.(int64)
  26075. if !ok {
  26076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26077. }
  26078. m.AddParentID(v)
  26079. return nil
  26080. case sopnode.FieldConditionType:
  26081. v, ok := value.(int)
  26082. if !ok {
  26083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26084. }
  26085. m.AddConditionType(v)
  26086. return nil
  26087. case sopnode.FieldNoReplyCondition:
  26088. v, ok := value.(int64)
  26089. if !ok {
  26090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26091. }
  26092. m.AddNoReplyCondition(v)
  26093. return nil
  26094. }
  26095. return fmt.Errorf("unknown SopNode numeric field %s", name)
  26096. }
  26097. // ClearedFields returns all nullable fields that were cleared during this
  26098. // mutation.
  26099. func (m *SopNodeMutation) ClearedFields() []string {
  26100. var fields []string
  26101. if m.FieldCleared(sopnode.FieldStatus) {
  26102. fields = append(fields, sopnode.FieldStatus)
  26103. }
  26104. if m.FieldCleared(sopnode.FieldDeletedAt) {
  26105. fields = append(fields, sopnode.FieldDeletedAt)
  26106. }
  26107. if m.FieldCleared(sopnode.FieldConditionList) {
  26108. fields = append(fields, sopnode.FieldConditionList)
  26109. }
  26110. if m.FieldCleared(sopnode.FieldActionMessage) {
  26111. fields = append(fields, sopnode.FieldActionMessage)
  26112. }
  26113. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  26114. fields = append(fields, sopnode.FieldActionLabelAdd)
  26115. }
  26116. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  26117. fields = append(fields, sopnode.FieldActionLabelDel)
  26118. }
  26119. if m.FieldCleared(sopnode.FieldActionForward) {
  26120. fields = append(fields, sopnode.FieldActionForward)
  26121. }
  26122. return fields
  26123. }
  26124. // FieldCleared returns a boolean indicating if a field with the given name was
  26125. // cleared in this mutation.
  26126. func (m *SopNodeMutation) FieldCleared(name string) bool {
  26127. _, ok := m.clearedFields[name]
  26128. return ok
  26129. }
  26130. // ClearField clears the value of the field with the given name. It returns an
  26131. // error if the field is not defined in the schema.
  26132. func (m *SopNodeMutation) ClearField(name string) error {
  26133. switch name {
  26134. case sopnode.FieldStatus:
  26135. m.ClearStatus()
  26136. return nil
  26137. case sopnode.FieldDeletedAt:
  26138. m.ClearDeletedAt()
  26139. return nil
  26140. case sopnode.FieldConditionList:
  26141. m.ClearConditionList()
  26142. return nil
  26143. case sopnode.FieldActionMessage:
  26144. m.ClearActionMessage()
  26145. return nil
  26146. case sopnode.FieldActionLabelAdd:
  26147. m.ClearActionLabelAdd()
  26148. return nil
  26149. case sopnode.FieldActionLabelDel:
  26150. m.ClearActionLabelDel()
  26151. return nil
  26152. case sopnode.FieldActionForward:
  26153. m.ClearActionForward()
  26154. return nil
  26155. }
  26156. return fmt.Errorf("unknown SopNode nullable field %s", name)
  26157. }
  26158. // ResetField resets all changes in the mutation for the field with the given name.
  26159. // It returns an error if the field is not defined in the schema.
  26160. func (m *SopNodeMutation) ResetField(name string) error {
  26161. switch name {
  26162. case sopnode.FieldCreatedAt:
  26163. m.ResetCreatedAt()
  26164. return nil
  26165. case sopnode.FieldUpdatedAt:
  26166. m.ResetUpdatedAt()
  26167. return nil
  26168. case sopnode.FieldStatus:
  26169. m.ResetStatus()
  26170. return nil
  26171. case sopnode.FieldDeletedAt:
  26172. m.ResetDeletedAt()
  26173. return nil
  26174. case sopnode.FieldStageID:
  26175. m.ResetStageID()
  26176. return nil
  26177. case sopnode.FieldParentID:
  26178. m.ResetParentID()
  26179. return nil
  26180. case sopnode.FieldName:
  26181. m.ResetName()
  26182. return nil
  26183. case sopnode.FieldConditionType:
  26184. m.ResetConditionType()
  26185. return nil
  26186. case sopnode.FieldConditionList:
  26187. m.ResetConditionList()
  26188. return nil
  26189. case sopnode.FieldNoReplyCondition:
  26190. m.ResetNoReplyCondition()
  26191. return nil
  26192. case sopnode.FieldNoReplyUnit:
  26193. m.ResetNoReplyUnit()
  26194. return nil
  26195. case sopnode.FieldActionMessage:
  26196. m.ResetActionMessage()
  26197. return nil
  26198. case sopnode.FieldActionLabelAdd:
  26199. m.ResetActionLabelAdd()
  26200. return nil
  26201. case sopnode.FieldActionLabelDel:
  26202. m.ResetActionLabelDel()
  26203. return nil
  26204. case sopnode.FieldActionForward:
  26205. m.ResetActionForward()
  26206. return nil
  26207. }
  26208. return fmt.Errorf("unknown SopNode field %s", name)
  26209. }
  26210. // AddedEdges returns all edge names that were set/added in this mutation.
  26211. func (m *SopNodeMutation) AddedEdges() []string {
  26212. edges := make([]string, 0, 2)
  26213. if m.sop_stage != nil {
  26214. edges = append(edges, sopnode.EdgeSopStage)
  26215. }
  26216. if m.node_messages != nil {
  26217. edges = append(edges, sopnode.EdgeNodeMessages)
  26218. }
  26219. return edges
  26220. }
  26221. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26222. // name in this mutation.
  26223. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  26224. switch name {
  26225. case sopnode.EdgeSopStage:
  26226. if id := m.sop_stage; id != nil {
  26227. return []ent.Value{*id}
  26228. }
  26229. case sopnode.EdgeNodeMessages:
  26230. ids := make([]ent.Value, 0, len(m.node_messages))
  26231. for id := range m.node_messages {
  26232. ids = append(ids, id)
  26233. }
  26234. return ids
  26235. }
  26236. return nil
  26237. }
  26238. // RemovedEdges returns all edge names that were removed in this mutation.
  26239. func (m *SopNodeMutation) RemovedEdges() []string {
  26240. edges := make([]string, 0, 2)
  26241. if m.removednode_messages != nil {
  26242. edges = append(edges, sopnode.EdgeNodeMessages)
  26243. }
  26244. return edges
  26245. }
  26246. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26247. // the given name in this mutation.
  26248. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  26249. switch name {
  26250. case sopnode.EdgeNodeMessages:
  26251. ids := make([]ent.Value, 0, len(m.removednode_messages))
  26252. for id := range m.removednode_messages {
  26253. ids = append(ids, id)
  26254. }
  26255. return ids
  26256. }
  26257. return nil
  26258. }
  26259. // ClearedEdges returns all edge names that were cleared in this mutation.
  26260. func (m *SopNodeMutation) ClearedEdges() []string {
  26261. edges := make([]string, 0, 2)
  26262. if m.clearedsop_stage {
  26263. edges = append(edges, sopnode.EdgeSopStage)
  26264. }
  26265. if m.clearednode_messages {
  26266. edges = append(edges, sopnode.EdgeNodeMessages)
  26267. }
  26268. return edges
  26269. }
  26270. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26271. // was cleared in this mutation.
  26272. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  26273. switch name {
  26274. case sopnode.EdgeSopStage:
  26275. return m.clearedsop_stage
  26276. case sopnode.EdgeNodeMessages:
  26277. return m.clearednode_messages
  26278. }
  26279. return false
  26280. }
  26281. // ClearEdge clears the value of the edge with the given name. It returns an error
  26282. // if that edge is not defined in the schema.
  26283. func (m *SopNodeMutation) ClearEdge(name string) error {
  26284. switch name {
  26285. case sopnode.EdgeSopStage:
  26286. m.ClearSopStage()
  26287. return nil
  26288. }
  26289. return fmt.Errorf("unknown SopNode unique edge %s", name)
  26290. }
  26291. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26292. // It returns an error if the edge is not defined in the schema.
  26293. func (m *SopNodeMutation) ResetEdge(name string) error {
  26294. switch name {
  26295. case sopnode.EdgeSopStage:
  26296. m.ResetSopStage()
  26297. return nil
  26298. case sopnode.EdgeNodeMessages:
  26299. m.ResetNodeMessages()
  26300. return nil
  26301. }
  26302. return fmt.Errorf("unknown SopNode edge %s", name)
  26303. }
  26304. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  26305. type SopStageMutation struct {
  26306. config
  26307. op Op
  26308. typ string
  26309. id *uint64
  26310. created_at *time.Time
  26311. updated_at *time.Time
  26312. status *uint8
  26313. addstatus *int8
  26314. deleted_at *time.Time
  26315. name *string
  26316. condition_type *int
  26317. addcondition_type *int
  26318. condition_operator *int
  26319. addcondition_operator *int
  26320. condition_list *[]custom_types.Condition
  26321. appendcondition_list []custom_types.Condition
  26322. action_message *[]custom_types.Action
  26323. appendaction_message []custom_types.Action
  26324. action_label_add *[]uint64
  26325. appendaction_label_add []uint64
  26326. action_label_del *[]uint64
  26327. appendaction_label_del []uint64
  26328. action_forward **custom_types.ActionForward
  26329. index_sort *int
  26330. addindex_sort *int
  26331. clearedFields map[string]struct{}
  26332. sop_task *uint64
  26333. clearedsop_task bool
  26334. stage_nodes map[uint64]struct{}
  26335. removedstage_nodes map[uint64]struct{}
  26336. clearedstage_nodes bool
  26337. stage_messages map[uint64]struct{}
  26338. removedstage_messages map[uint64]struct{}
  26339. clearedstage_messages bool
  26340. done bool
  26341. oldValue func(context.Context) (*SopStage, error)
  26342. predicates []predicate.SopStage
  26343. }
  26344. var _ ent.Mutation = (*SopStageMutation)(nil)
  26345. // sopstageOption allows management of the mutation configuration using functional options.
  26346. type sopstageOption func(*SopStageMutation)
  26347. // newSopStageMutation creates new mutation for the SopStage entity.
  26348. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  26349. m := &SopStageMutation{
  26350. config: c,
  26351. op: op,
  26352. typ: TypeSopStage,
  26353. clearedFields: make(map[string]struct{}),
  26354. }
  26355. for _, opt := range opts {
  26356. opt(m)
  26357. }
  26358. return m
  26359. }
  26360. // withSopStageID sets the ID field of the mutation.
  26361. func withSopStageID(id uint64) sopstageOption {
  26362. return func(m *SopStageMutation) {
  26363. var (
  26364. err error
  26365. once sync.Once
  26366. value *SopStage
  26367. )
  26368. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  26369. once.Do(func() {
  26370. if m.done {
  26371. err = errors.New("querying old values post mutation is not allowed")
  26372. } else {
  26373. value, err = m.Client().SopStage.Get(ctx, id)
  26374. }
  26375. })
  26376. return value, err
  26377. }
  26378. m.id = &id
  26379. }
  26380. }
  26381. // withSopStage sets the old SopStage of the mutation.
  26382. func withSopStage(node *SopStage) sopstageOption {
  26383. return func(m *SopStageMutation) {
  26384. m.oldValue = func(context.Context) (*SopStage, error) {
  26385. return node, nil
  26386. }
  26387. m.id = &node.ID
  26388. }
  26389. }
  26390. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26391. // executed in a transaction (ent.Tx), a transactional client is returned.
  26392. func (m SopStageMutation) Client() *Client {
  26393. client := &Client{config: m.config}
  26394. client.init()
  26395. return client
  26396. }
  26397. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26398. // it returns an error otherwise.
  26399. func (m SopStageMutation) Tx() (*Tx, error) {
  26400. if _, ok := m.driver.(*txDriver); !ok {
  26401. return nil, errors.New("ent: mutation is not running in a transaction")
  26402. }
  26403. tx := &Tx{config: m.config}
  26404. tx.init()
  26405. return tx, nil
  26406. }
  26407. // SetID sets the value of the id field. Note that this
  26408. // operation is only accepted on creation of SopStage entities.
  26409. func (m *SopStageMutation) SetID(id uint64) {
  26410. m.id = &id
  26411. }
  26412. // ID returns the ID value in the mutation. Note that the ID is only available
  26413. // if it was provided to the builder or after it was returned from the database.
  26414. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  26415. if m.id == nil {
  26416. return
  26417. }
  26418. return *m.id, true
  26419. }
  26420. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26421. // That means, if the mutation is applied within a transaction with an isolation level such
  26422. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26423. // or updated by the mutation.
  26424. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  26425. switch {
  26426. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26427. id, exists := m.ID()
  26428. if exists {
  26429. return []uint64{id}, nil
  26430. }
  26431. fallthrough
  26432. case m.op.Is(OpUpdate | OpDelete):
  26433. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  26434. default:
  26435. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26436. }
  26437. }
  26438. // SetCreatedAt sets the "created_at" field.
  26439. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  26440. m.created_at = &t
  26441. }
  26442. // CreatedAt returns the value of the "created_at" field in the mutation.
  26443. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  26444. v := m.created_at
  26445. if v == nil {
  26446. return
  26447. }
  26448. return *v, true
  26449. }
  26450. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  26451. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26453. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26454. if !m.op.Is(OpUpdateOne) {
  26455. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26456. }
  26457. if m.id == nil || m.oldValue == nil {
  26458. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26459. }
  26460. oldValue, err := m.oldValue(ctx)
  26461. if err != nil {
  26462. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26463. }
  26464. return oldValue.CreatedAt, nil
  26465. }
  26466. // ResetCreatedAt resets all changes to the "created_at" field.
  26467. func (m *SopStageMutation) ResetCreatedAt() {
  26468. m.created_at = nil
  26469. }
  26470. // SetUpdatedAt sets the "updated_at" field.
  26471. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  26472. m.updated_at = &t
  26473. }
  26474. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26475. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  26476. v := m.updated_at
  26477. if v == nil {
  26478. return
  26479. }
  26480. return *v, true
  26481. }
  26482. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  26483. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26485. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26486. if !m.op.Is(OpUpdateOne) {
  26487. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26488. }
  26489. if m.id == nil || m.oldValue == nil {
  26490. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26491. }
  26492. oldValue, err := m.oldValue(ctx)
  26493. if err != nil {
  26494. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26495. }
  26496. return oldValue.UpdatedAt, nil
  26497. }
  26498. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26499. func (m *SopStageMutation) ResetUpdatedAt() {
  26500. m.updated_at = nil
  26501. }
  26502. // SetStatus sets the "status" field.
  26503. func (m *SopStageMutation) SetStatus(u uint8) {
  26504. m.status = &u
  26505. m.addstatus = nil
  26506. }
  26507. // Status returns the value of the "status" field in the mutation.
  26508. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  26509. v := m.status
  26510. if v == nil {
  26511. return
  26512. }
  26513. return *v, true
  26514. }
  26515. // OldStatus returns the old "status" field's value of the SopStage entity.
  26516. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26518. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26519. if !m.op.Is(OpUpdateOne) {
  26520. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26521. }
  26522. if m.id == nil || m.oldValue == nil {
  26523. return v, errors.New("OldStatus requires an ID field in the mutation")
  26524. }
  26525. oldValue, err := m.oldValue(ctx)
  26526. if err != nil {
  26527. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26528. }
  26529. return oldValue.Status, nil
  26530. }
  26531. // AddStatus adds u to the "status" field.
  26532. func (m *SopStageMutation) AddStatus(u int8) {
  26533. if m.addstatus != nil {
  26534. *m.addstatus += u
  26535. } else {
  26536. m.addstatus = &u
  26537. }
  26538. }
  26539. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26540. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  26541. v := m.addstatus
  26542. if v == nil {
  26543. return
  26544. }
  26545. return *v, true
  26546. }
  26547. // ClearStatus clears the value of the "status" field.
  26548. func (m *SopStageMutation) ClearStatus() {
  26549. m.status = nil
  26550. m.addstatus = nil
  26551. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  26552. }
  26553. // StatusCleared returns if the "status" field was cleared in this mutation.
  26554. func (m *SopStageMutation) StatusCleared() bool {
  26555. _, ok := m.clearedFields[sopstage.FieldStatus]
  26556. return ok
  26557. }
  26558. // ResetStatus resets all changes to the "status" field.
  26559. func (m *SopStageMutation) ResetStatus() {
  26560. m.status = nil
  26561. m.addstatus = nil
  26562. delete(m.clearedFields, sopstage.FieldStatus)
  26563. }
  26564. // SetDeletedAt sets the "deleted_at" field.
  26565. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  26566. m.deleted_at = &t
  26567. }
  26568. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26569. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  26570. v := m.deleted_at
  26571. if v == nil {
  26572. return
  26573. }
  26574. return *v, true
  26575. }
  26576. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  26577. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26579. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26580. if !m.op.Is(OpUpdateOne) {
  26581. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26582. }
  26583. if m.id == nil || m.oldValue == nil {
  26584. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26585. }
  26586. oldValue, err := m.oldValue(ctx)
  26587. if err != nil {
  26588. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26589. }
  26590. return oldValue.DeletedAt, nil
  26591. }
  26592. // ClearDeletedAt clears the value of the "deleted_at" field.
  26593. func (m *SopStageMutation) ClearDeletedAt() {
  26594. m.deleted_at = nil
  26595. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  26596. }
  26597. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26598. func (m *SopStageMutation) DeletedAtCleared() bool {
  26599. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  26600. return ok
  26601. }
  26602. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26603. func (m *SopStageMutation) ResetDeletedAt() {
  26604. m.deleted_at = nil
  26605. delete(m.clearedFields, sopstage.FieldDeletedAt)
  26606. }
  26607. // SetTaskID sets the "task_id" field.
  26608. func (m *SopStageMutation) SetTaskID(u uint64) {
  26609. m.sop_task = &u
  26610. }
  26611. // TaskID returns the value of the "task_id" field in the mutation.
  26612. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  26613. v := m.sop_task
  26614. if v == nil {
  26615. return
  26616. }
  26617. return *v, true
  26618. }
  26619. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  26620. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26622. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  26623. if !m.op.Is(OpUpdateOne) {
  26624. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  26625. }
  26626. if m.id == nil || m.oldValue == nil {
  26627. return v, errors.New("OldTaskID requires an ID field in the mutation")
  26628. }
  26629. oldValue, err := m.oldValue(ctx)
  26630. if err != nil {
  26631. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  26632. }
  26633. return oldValue.TaskID, nil
  26634. }
  26635. // ResetTaskID resets all changes to the "task_id" field.
  26636. func (m *SopStageMutation) ResetTaskID() {
  26637. m.sop_task = nil
  26638. }
  26639. // SetName sets the "name" field.
  26640. func (m *SopStageMutation) SetName(s string) {
  26641. m.name = &s
  26642. }
  26643. // Name returns the value of the "name" field in the mutation.
  26644. func (m *SopStageMutation) Name() (r string, exists bool) {
  26645. v := m.name
  26646. if v == nil {
  26647. return
  26648. }
  26649. return *v, true
  26650. }
  26651. // OldName returns the old "name" field's value of the SopStage entity.
  26652. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26654. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  26655. if !m.op.Is(OpUpdateOne) {
  26656. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26657. }
  26658. if m.id == nil || m.oldValue == nil {
  26659. return v, errors.New("OldName requires an ID field in the mutation")
  26660. }
  26661. oldValue, err := m.oldValue(ctx)
  26662. if err != nil {
  26663. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26664. }
  26665. return oldValue.Name, nil
  26666. }
  26667. // ResetName resets all changes to the "name" field.
  26668. func (m *SopStageMutation) ResetName() {
  26669. m.name = nil
  26670. }
  26671. // SetConditionType sets the "condition_type" field.
  26672. func (m *SopStageMutation) SetConditionType(i int) {
  26673. m.condition_type = &i
  26674. m.addcondition_type = nil
  26675. }
  26676. // ConditionType returns the value of the "condition_type" field in the mutation.
  26677. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  26678. v := m.condition_type
  26679. if v == nil {
  26680. return
  26681. }
  26682. return *v, true
  26683. }
  26684. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  26685. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26687. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  26688. if !m.op.Is(OpUpdateOne) {
  26689. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  26690. }
  26691. if m.id == nil || m.oldValue == nil {
  26692. return v, errors.New("OldConditionType requires an ID field in the mutation")
  26693. }
  26694. oldValue, err := m.oldValue(ctx)
  26695. if err != nil {
  26696. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  26697. }
  26698. return oldValue.ConditionType, nil
  26699. }
  26700. // AddConditionType adds i to the "condition_type" field.
  26701. func (m *SopStageMutation) AddConditionType(i int) {
  26702. if m.addcondition_type != nil {
  26703. *m.addcondition_type += i
  26704. } else {
  26705. m.addcondition_type = &i
  26706. }
  26707. }
  26708. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  26709. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  26710. v := m.addcondition_type
  26711. if v == nil {
  26712. return
  26713. }
  26714. return *v, true
  26715. }
  26716. // ResetConditionType resets all changes to the "condition_type" field.
  26717. func (m *SopStageMutation) ResetConditionType() {
  26718. m.condition_type = nil
  26719. m.addcondition_type = nil
  26720. }
  26721. // SetConditionOperator sets the "condition_operator" field.
  26722. func (m *SopStageMutation) SetConditionOperator(i int) {
  26723. m.condition_operator = &i
  26724. m.addcondition_operator = nil
  26725. }
  26726. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  26727. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  26728. v := m.condition_operator
  26729. if v == nil {
  26730. return
  26731. }
  26732. return *v, true
  26733. }
  26734. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  26735. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26737. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  26738. if !m.op.Is(OpUpdateOne) {
  26739. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  26740. }
  26741. if m.id == nil || m.oldValue == nil {
  26742. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  26743. }
  26744. oldValue, err := m.oldValue(ctx)
  26745. if err != nil {
  26746. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  26747. }
  26748. return oldValue.ConditionOperator, nil
  26749. }
  26750. // AddConditionOperator adds i to the "condition_operator" field.
  26751. func (m *SopStageMutation) AddConditionOperator(i int) {
  26752. if m.addcondition_operator != nil {
  26753. *m.addcondition_operator += i
  26754. } else {
  26755. m.addcondition_operator = &i
  26756. }
  26757. }
  26758. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  26759. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  26760. v := m.addcondition_operator
  26761. if v == nil {
  26762. return
  26763. }
  26764. return *v, true
  26765. }
  26766. // ResetConditionOperator resets all changes to the "condition_operator" field.
  26767. func (m *SopStageMutation) ResetConditionOperator() {
  26768. m.condition_operator = nil
  26769. m.addcondition_operator = nil
  26770. }
  26771. // SetConditionList sets the "condition_list" field.
  26772. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  26773. m.condition_list = &ct
  26774. m.appendcondition_list = nil
  26775. }
  26776. // ConditionList returns the value of the "condition_list" field in the mutation.
  26777. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  26778. v := m.condition_list
  26779. if v == nil {
  26780. return
  26781. }
  26782. return *v, true
  26783. }
  26784. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  26785. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26787. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  26788. if !m.op.Is(OpUpdateOne) {
  26789. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  26790. }
  26791. if m.id == nil || m.oldValue == nil {
  26792. return v, errors.New("OldConditionList requires an ID field in the mutation")
  26793. }
  26794. oldValue, err := m.oldValue(ctx)
  26795. if err != nil {
  26796. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  26797. }
  26798. return oldValue.ConditionList, nil
  26799. }
  26800. // AppendConditionList adds ct to the "condition_list" field.
  26801. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  26802. m.appendcondition_list = append(m.appendcondition_list, ct...)
  26803. }
  26804. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  26805. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  26806. if len(m.appendcondition_list) == 0 {
  26807. return nil, false
  26808. }
  26809. return m.appendcondition_list, true
  26810. }
  26811. // ResetConditionList resets all changes to the "condition_list" field.
  26812. func (m *SopStageMutation) ResetConditionList() {
  26813. m.condition_list = nil
  26814. m.appendcondition_list = nil
  26815. }
  26816. // SetActionMessage sets the "action_message" field.
  26817. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  26818. m.action_message = &ct
  26819. m.appendaction_message = nil
  26820. }
  26821. // ActionMessage returns the value of the "action_message" field in the mutation.
  26822. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  26823. v := m.action_message
  26824. if v == nil {
  26825. return
  26826. }
  26827. return *v, true
  26828. }
  26829. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  26830. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26832. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  26833. if !m.op.Is(OpUpdateOne) {
  26834. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  26835. }
  26836. if m.id == nil || m.oldValue == nil {
  26837. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  26838. }
  26839. oldValue, err := m.oldValue(ctx)
  26840. if err != nil {
  26841. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  26842. }
  26843. return oldValue.ActionMessage, nil
  26844. }
  26845. // AppendActionMessage adds ct to the "action_message" field.
  26846. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  26847. m.appendaction_message = append(m.appendaction_message, ct...)
  26848. }
  26849. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  26850. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  26851. if len(m.appendaction_message) == 0 {
  26852. return nil, false
  26853. }
  26854. return m.appendaction_message, true
  26855. }
  26856. // ClearActionMessage clears the value of the "action_message" field.
  26857. func (m *SopStageMutation) ClearActionMessage() {
  26858. m.action_message = nil
  26859. m.appendaction_message = nil
  26860. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  26861. }
  26862. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  26863. func (m *SopStageMutation) ActionMessageCleared() bool {
  26864. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  26865. return ok
  26866. }
  26867. // ResetActionMessage resets all changes to the "action_message" field.
  26868. func (m *SopStageMutation) ResetActionMessage() {
  26869. m.action_message = nil
  26870. m.appendaction_message = nil
  26871. delete(m.clearedFields, sopstage.FieldActionMessage)
  26872. }
  26873. // SetActionLabelAdd sets the "action_label_add" field.
  26874. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  26875. m.action_label_add = &u
  26876. m.appendaction_label_add = nil
  26877. }
  26878. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  26879. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  26880. v := m.action_label_add
  26881. if v == nil {
  26882. return
  26883. }
  26884. return *v, true
  26885. }
  26886. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  26887. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26889. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  26890. if !m.op.Is(OpUpdateOne) {
  26891. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  26892. }
  26893. if m.id == nil || m.oldValue == nil {
  26894. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  26895. }
  26896. oldValue, err := m.oldValue(ctx)
  26897. if err != nil {
  26898. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  26899. }
  26900. return oldValue.ActionLabelAdd, nil
  26901. }
  26902. // AppendActionLabelAdd adds u to the "action_label_add" field.
  26903. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  26904. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  26905. }
  26906. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  26907. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  26908. if len(m.appendaction_label_add) == 0 {
  26909. return nil, false
  26910. }
  26911. return m.appendaction_label_add, true
  26912. }
  26913. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  26914. func (m *SopStageMutation) ClearActionLabelAdd() {
  26915. m.action_label_add = nil
  26916. m.appendaction_label_add = nil
  26917. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  26918. }
  26919. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  26920. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  26921. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  26922. return ok
  26923. }
  26924. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  26925. func (m *SopStageMutation) ResetActionLabelAdd() {
  26926. m.action_label_add = nil
  26927. m.appendaction_label_add = nil
  26928. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  26929. }
  26930. // SetActionLabelDel sets the "action_label_del" field.
  26931. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  26932. m.action_label_del = &u
  26933. m.appendaction_label_del = nil
  26934. }
  26935. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  26936. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  26937. v := m.action_label_del
  26938. if v == nil {
  26939. return
  26940. }
  26941. return *v, true
  26942. }
  26943. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  26944. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26946. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  26947. if !m.op.Is(OpUpdateOne) {
  26948. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  26949. }
  26950. if m.id == nil || m.oldValue == nil {
  26951. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  26952. }
  26953. oldValue, err := m.oldValue(ctx)
  26954. if err != nil {
  26955. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  26956. }
  26957. return oldValue.ActionLabelDel, nil
  26958. }
  26959. // AppendActionLabelDel adds u to the "action_label_del" field.
  26960. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  26961. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  26962. }
  26963. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  26964. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  26965. if len(m.appendaction_label_del) == 0 {
  26966. return nil, false
  26967. }
  26968. return m.appendaction_label_del, true
  26969. }
  26970. // ClearActionLabelDel clears the value of the "action_label_del" field.
  26971. func (m *SopStageMutation) ClearActionLabelDel() {
  26972. m.action_label_del = nil
  26973. m.appendaction_label_del = nil
  26974. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  26975. }
  26976. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  26977. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  26978. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  26979. return ok
  26980. }
  26981. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  26982. func (m *SopStageMutation) ResetActionLabelDel() {
  26983. m.action_label_del = nil
  26984. m.appendaction_label_del = nil
  26985. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  26986. }
  26987. // SetActionForward sets the "action_forward" field.
  26988. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  26989. m.action_forward = &ctf
  26990. }
  26991. // ActionForward returns the value of the "action_forward" field in the mutation.
  26992. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  26993. v := m.action_forward
  26994. if v == nil {
  26995. return
  26996. }
  26997. return *v, true
  26998. }
  26999. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  27000. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27002. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  27003. if !m.op.Is(OpUpdateOne) {
  27004. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  27005. }
  27006. if m.id == nil || m.oldValue == nil {
  27007. return v, errors.New("OldActionForward requires an ID field in the mutation")
  27008. }
  27009. oldValue, err := m.oldValue(ctx)
  27010. if err != nil {
  27011. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  27012. }
  27013. return oldValue.ActionForward, nil
  27014. }
  27015. // ClearActionForward clears the value of the "action_forward" field.
  27016. func (m *SopStageMutation) ClearActionForward() {
  27017. m.action_forward = nil
  27018. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  27019. }
  27020. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  27021. func (m *SopStageMutation) ActionForwardCleared() bool {
  27022. _, ok := m.clearedFields[sopstage.FieldActionForward]
  27023. return ok
  27024. }
  27025. // ResetActionForward resets all changes to the "action_forward" field.
  27026. func (m *SopStageMutation) ResetActionForward() {
  27027. m.action_forward = nil
  27028. delete(m.clearedFields, sopstage.FieldActionForward)
  27029. }
  27030. // SetIndexSort sets the "index_sort" field.
  27031. func (m *SopStageMutation) SetIndexSort(i int) {
  27032. m.index_sort = &i
  27033. m.addindex_sort = nil
  27034. }
  27035. // IndexSort returns the value of the "index_sort" field in the mutation.
  27036. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  27037. v := m.index_sort
  27038. if v == nil {
  27039. return
  27040. }
  27041. return *v, true
  27042. }
  27043. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  27044. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27046. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  27047. if !m.op.Is(OpUpdateOne) {
  27048. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  27049. }
  27050. if m.id == nil || m.oldValue == nil {
  27051. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  27052. }
  27053. oldValue, err := m.oldValue(ctx)
  27054. if err != nil {
  27055. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  27056. }
  27057. return oldValue.IndexSort, nil
  27058. }
  27059. // AddIndexSort adds i to the "index_sort" field.
  27060. func (m *SopStageMutation) AddIndexSort(i int) {
  27061. if m.addindex_sort != nil {
  27062. *m.addindex_sort += i
  27063. } else {
  27064. m.addindex_sort = &i
  27065. }
  27066. }
  27067. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  27068. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  27069. v := m.addindex_sort
  27070. if v == nil {
  27071. return
  27072. }
  27073. return *v, true
  27074. }
  27075. // ClearIndexSort clears the value of the "index_sort" field.
  27076. func (m *SopStageMutation) ClearIndexSort() {
  27077. m.index_sort = nil
  27078. m.addindex_sort = nil
  27079. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  27080. }
  27081. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  27082. func (m *SopStageMutation) IndexSortCleared() bool {
  27083. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  27084. return ok
  27085. }
  27086. // ResetIndexSort resets all changes to the "index_sort" field.
  27087. func (m *SopStageMutation) ResetIndexSort() {
  27088. m.index_sort = nil
  27089. m.addindex_sort = nil
  27090. delete(m.clearedFields, sopstage.FieldIndexSort)
  27091. }
  27092. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  27093. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  27094. m.sop_task = &id
  27095. }
  27096. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  27097. func (m *SopStageMutation) ClearSopTask() {
  27098. m.clearedsop_task = true
  27099. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  27100. }
  27101. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  27102. func (m *SopStageMutation) SopTaskCleared() bool {
  27103. return m.clearedsop_task
  27104. }
  27105. // SopTaskID returns the "sop_task" edge ID in the mutation.
  27106. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  27107. if m.sop_task != nil {
  27108. return *m.sop_task, true
  27109. }
  27110. return
  27111. }
  27112. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  27113. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27114. // SopTaskID instead. It exists only for internal usage by the builders.
  27115. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  27116. if id := m.sop_task; id != nil {
  27117. ids = append(ids, *id)
  27118. }
  27119. return
  27120. }
  27121. // ResetSopTask resets all changes to the "sop_task" edge.
  27122. func (m *SopStageMutation) ResetSopTask() {
  27123. m.sop_task = nil
  27124. m.clearedsop_task = false
  27125. }
  27126. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  27127. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  27128. if m.stage_nodes == nil {
  27129. m.stage_nodes = make(map[uint64]struct{})
  27130. }
  27131. for i := range ids {
  27132. m.stage_nodes[ids[i]] = struct{}{}
  27133. }
  27134. }
  27135. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  27136. func (m *SopStageMutation) ClearStageNodes() {
  27137. m.clearedstage_nodes = true
  27138. }
  27139. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  27140. func (m *SopStageMutation) StageNodesCleared() bool {
  27141. return m.clearedstage_nodes
  27142. }
  27143. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  27144. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  27145. if m.removedstage_nodes == nil {
  27146. m.removedstage_nodes = make(map[uint64]struct{})
  27147. }
  27148. for i := range ids {
  27149. delete(m.stage_nodes, ids[i])
  27150. m.removedstage_nodes[ids[i]] = struct{}{}
  27151. }
  27152. }
  27153. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  27154. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  27155. for id := range m.removedstage_nodes {
  27156. ids = append(ids, id)
  27157. }
  27158. return
  27159. }
  27160. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  27161. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  27162. for id := range m.stage_nodes {
  27163. ids = append(ids, id)
  27164. }
  27165. return
  27166. }
  27167. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  27168. func (m *SopStageMutation) ResetStageNodes() {
  27169. m.stage_nodes = nil
  27170. m.clearedstage_nodes = false
  27171. m.removedstage_nodes = nil
  27172. }
  27173. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  27174. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  27175. if m.stage_messages == nil {
  27176. m.stage_messages = make(map[uint64]struct{})
  27177. }
  27178. for i := range ids {
  27179. m.stage_messages[ids[i]] = struct{}{}
  27180. }
  27181. }
  27182. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  27183. func (m *SopStageMutation) ClearStageMessages() {
  27184. m.clearedstage_messages = true
  27185. }
  27186. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  27187. func (m *SopStageMutation) StageMessagesCleared() bool {
  27188. return m.clearedstage_messages
  27189. }
  27190. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  27191. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  27192. if m.removedstage_messages == nil {
  27193. m.removedstage_messages = make(map[uint64]struct{})
  27194. }
  27195. for i := range ids {
  27196. delete(m.stage_messages, ids[i])
  27197. m.removedstage_messages[ids[i]] = struct{}{}
  27198. }
  27199. }
  27200. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  27201. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  27202. for id := range m.removedstage_messages {
  27203. ids = append(ids, id)
  27204. }
  27205. return
  27206. }
  27207. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  27208. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  27209. for id := range m.stage_messages {
  27210. ids = append(ids, id)
  27211. }
  27212. return
  27213. }
  27214. // ResetStageMessages resets all changes to the "stage_messages" edge.
  27215. func (m *SopStageMutation) ResetStageMessages() {
  27216. m.stage_messages = nil
  27217. m.clearedstage_messages = false
  27218. m.removedstage_messages = nil
  27219. }
  27220. // Where appends a list predicates to the SopStageMutation builder.
  27221. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  27222. m.predicates = append(m.predicates, ps...)
  27223. }
  27224. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  27225. // users can use type-assertion to append predicates that do not depend on any generated package.
  27226. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  27227. p := make([]predicate.SopStage, len(ps))
  27228. for i := range ps {
  27229. p[i] = ps[i]
  27230. }
  27231. m.Where(p...)
  27232. }
  27233. // Op returns the operation name.
  27234. func (m *SopStageMutation) Op() Op {
  27235. return m.op
  27236. }
  27237. // SetOp allows setting the mutation operation.
  27238. func (m *SopStageMutation) SetOp(op Op) {
  27239. m.op = op
  27240. }
  27241. // Type returns the node type of this mutation (SopStage).
  27242. func (m *SopStageMutation) Type() string {
  27243. return m.typ
  27244. }
  27245. // Fields returns all fields that were changed during this mutation. Note that in
  27246. // order to get all numeric fields that were incremented/decremented, call
  27247. // AddedFields().
  27248. func (m *SopStageMutation) Fields() []string {
  27249. fields := make([]string, 0, 14)
  27250. if m.created_at != nil {
  27251. fields = append(fields, sopstage.FieldCreatedAt)
  27252. }
  27253. if m.updated_at != nil {
  27254. fields = append(fields, sopstage.FieldUpdatedAt)
  27255. }
  27256. if m.status != nil {
  27257. fields = append(fields, sopstage.FieldStatus)
  27258. }
  27259. if m.deleted_at != nil {
  27260. fields = append(fields, sopstage.FieldDeletedAt)
  27261. }
  27262. if m.sop_task != nil {
  27263. fields = append(fields, sopstage.FieldTaskID)
  27264. }
  27265. if m.name != nil {
  27266. fields = append(fields, sopstage.FieldName)
  27267. }
  27268. if m.condition_type != nil {
  27269. fields = append(fields, sopstage.FieldConditionType)
  27270. }
  27271. if m.condition_operator != nil {
  27272. fields = append(fields, sopstage.FieldConditionOperator)
  27273. }
  27274. if m.condition_list != nil {
  27275. fields = append(fields, sopstage.FieldConditionList)
  27276. }
  27277. if m.action_message != nil {
  27278. fields = append(fields, sopstage.FieldActionMessage)
  27279. }
  27280. if m.action_label_add != nil {
  27281. fields = append(fields, sopstage.FieldActionLabelAdd)
  27282. }
  27283. if m.action_label_del != nil {
  27284. fields = append(fields, sopstage.FieldActionLabelDel)
  27285. }
  27286. if m.action_forward != nil {
  27287. fields = append(fields, sopstage.FieldActionForward)
  27288. }
  27289. if m.index_sort != nil {
  27290. fields = append(fields, sopstage.FieldIndexSort)
  27291. }
  27292. return fields
  27293. }
  27294. // Field returns the value of a field with the given name. The second boolean
  27295. // return value indicates that this field was not set, or was not defined in the
  27296. // schema.
  27297. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  27298. switch name {
  27299. case sopstage.FieldCreatedAt:
  27300. return m.CreatedAt()
  27301. case sopstage.FieldUpdatedAt:
  27302. return m.UpdatedAt()
  27303. case sopstage.FieldStatus:
  27304. return m.Status()
  27305. case sopstage.FieldDeletedAt:
  27306. return m.DeletedAt()
  27307. case sopstage.FieldTaskID:
  27308. return m.TaskID()
  27309. case sopstage.FieldName:
  27310. return m.Name()
  27311. case sopstage.FieldConditionType:
  27312. return m.ConditionType()
  27313. case sopstage.FieldConditionOperator:
  27314. return m.ConditionOperator()
  27315. case sopstage.FieldConditionList:
  27316. return m.ConditionList()
  27317. case sopstage.FieldActionMessage:
  27318. return m.ActionMessage()
  27319. case sopstage.FieldActionLabelAdd:
  27320. return m.ActionLabelAdd()
  27321. case sopstage.FieldActionLabelDel:
  27322. return m.ActionLabelDel()
  27323. case sopstage.FieldActionForward:
  27324. return m.ActionForward()
  27325. case sopstage.FieldIndexSort:
  27326. return m.IndexSort()
  27327. }
  27328. return nil, false
  27329. }
  27330. // OldField returns the old value of the field from the database. An error is
  27331. // returned if the mutation operation is not UpdateOne, or the query to the
  27332. // database failed.
  27333. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27334. switch name {
  27335. case sopstage.FieldCreatedAt:
  27336. return m.OldCreatedAt(ctx)
  27337. case sopstage.FieldUpdatedAt:
  27338. return m.OldUpdatedAt(ctx)
  27339. case sopstage.FieldStatus:
  27340. return m.OldStatus(ctx)
  27341. case sopstage.FieldDeletedAt:
  27342. return m.OldDeletedAt(ctx)
  27343. case sopstage.FieldTaskID:
  27344. return m.OldTaskID(ctx)
  27345. case sopstage.FieldName:
  27346. return m.OldName(ctx)
  27347. case sopstage.FieldConditionType:
  27348. return m.OldConditionType(ctx)
  27349. case sopstage.FieldConditionOperator:
  27350. return m.OldConditionOperator(ctx)
  27351. case sopstage.FieldConditionList:
  27352. return m.OldConditionList(ctx)
  27353. case sopstage.FieldActionMessage:
  27354. return m.OldActionMessage(ctx)
  27355. case sopstage.FieldActionLabelAdd:
  27356. return m.OldActionLabelAdd(ctx)
  27357. case sopstage.FieldActionLabelDel:
  27358. return m.OldActionLabelDel(ctx)
  27359. case sopstage.FieldActionForward:
  27360. return m.OldActionForward(ctx)
  27361. case sopstage.FieldIndexSort:
  27362. return m.OldIndexSort(ctx)
  27363. }
  27364. return nil, fmt.Errorf("unknown SopStage field %s", name)
  27365. }
  27366. // SetField sets the value of a field with the given name. It returns an error if
  27367. // the field is not defined in the schema, or if the type mismatched the field
  27368. // type.
  27369. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  27370. switch name {
  27371. case sopstage.FieldCreatedAt:
  27372. v, ok := value.(time.Time)
  27373. if !ok {
  27374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27375. }
  27376. m.SetCreatedAt(v)
  27377. return nil
  27378. case sopstage.FieldUpdatedAt:
  27379. v, ok := value.(time.Time)
  27380. if !ok {
  27381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27382. }
  27383. m.SetUpdatedAt(v)
  27384. return nil
  27385. case sopstage.FieldStatus:
  27386. v, ok := value.(uint8)
  27387. if !ok {
  27388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27389. }
  27390. m.SetStatus(v)
  27391. return nil
  27392. case sopstage.FieldDeletedAt:
  27393. v, ok := value.(time.Time)
  27394. if !ok {
  27395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27396. }
  27397. m.SetDeletedAt(v)
  27398. return nil
  27399. case sopstage.FieldTaskID:
  27400. v, ok := value.(uint64)
  27401. if !ok {
  27402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27403. }
  27404. m.SetTaskID(v)
  27405. return nil
  27406. case sopstage.FieldName:
  27407. v, ok := value.(string)
  27408. if !ok {
  27409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27410. }
  27411. m.SetName(v)
  27412. return nil
  27413. case sopstage.FieldConditionType:
  27414. v, ok := value.(int)
  27415. if !ok {
  27416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27417. }
  27418. m.SetConditionType(v)
  27419. return nil
  27420. case sopstage.FieldConditionOperator:
  27421. v, ok := value.(int)
  27422. if !ok {
  27423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27424. }
  27425. m.SetConditionOperator(v)
  27426. return nil
  27427. case sopstage.FieldConditionList:
  27428. v, ok := value.([]custom_types.Condition)
  27429. if !ok {
  27430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27431. }
  27432. m.SetConditionList(v)
  27433. return nil
  27434. case sopstage.FieldActionMessage:
  27435. v, ok := value.([]custom_types.Action)
  27436. if !ok {
  27437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27438. }
  27439. m.SetActionMessage(v)
  27440. return nil
  27441. case sopstage.FieldActionLabelAdd:
  27442. v, ok := value.([]uint64)
  27443. if !ok {
  27444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27445. }
  27446. m.SetActionLabelAdd(v)
  27447. return nil
  27448. case sopstage.FieldActionLabelDel:
  27449. v, ok := value.([]uint64)
  27450. if !ok {
  27451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27452. }
  27453. m.SetActionLabelDel(v)
  27454. return nil
  27455. case sopstage.FieldActionForward:
  27456. v, ok := value.(*custom_types.ActionForward)
  27457. if !ok {
  27458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27459. }
  27460. m.SetActionForward(v)
  27461. return nil
  27462. case sopstage.FieldIndexSort:
  27463. v, ok := value.(int)
  27464. if !ok {
  27465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27466. }
  27467. m.SetIndexSort(v)
  27468. return nil
  27469. }
  27470. return fmt.Errorf("unknown SopStage field %s", name)
  27471. }
  27472. // AddedFields returns all numeric fields that were incremented/decremented during
  27473. // this mutation.
  27474. func (m *SopStageMutation) AddedFields() []string {
  27475. var fields []string
  27476. if m.addstatus != nil {
  27477. fields = append(fields, sopstage.FieldStatus)
  27478. }
  27479. if m.addcondition_type != nil {
  27480. fields = append(fields, sopstage.FieldConditionType)
  27481. }
  27482. if m.addcondition_operator != nil {
  27483. fields = append(fields, sopstage.FieldConditionOperator)
  27484. }
  27485. if m.addindex_sort != nil {
  27486. fields = append(fields, sopstage.FieldIndexSort)
  27487. }
  27488. return fields
  27489. }
  27490. // AddedField returns the numeric value that was incremented/decremented on a field
  27491. // with the given name. The second boolean return value indicates that this field
  27492. // was not set, or was not defined in the schema.
  27493. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  27494. switch name {
  27495. case sopstage.FieldStatus:
  27496. return m.AddedStatus()
  27497. case sopstage.FieldConditionType:
  27498. return m.AddedConditionType()
  27499. case sopstage.FieldConditionOperator:
  27500. return m.AddedConditionOperator()
  27501. case sopstage.FieldIndexSort:
  27502. return m.AddedIndexSort()
  27503. }
  27504. return nil, false
  27505. }
  27506. // AddField adds the value to the field with the given name. It returns an error if
  27507. // the field is not defined in the schema, or if the type mismatched the field
  27508. // type.
  27509. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  27510. switch name {
  27511. case sopstage.FieldStatus:
  27512. v, ok := value.(int8)
  27513. if !ok {
  27514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27515. }
  27516. m.AddStatus(v)
  27517. return nil
  27518. case sopstage.FieldConditionType:
  27519. v, ok := value.(int)
  27520. if !ok {
  27521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27522. }
  27523. m.AddConditionType(v)
  27524. return nil
  27525. case sopstage.FieldConditionOperator:
  27526. v, ok := value.(int)
  27527. if !ok {
  27528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27529. }
  27530. m.AddConditionOperator(v)
  27531. return nil
  27532. case sopstage.FieldIndexSort:
  27533. v, ok := value.(int)
  27534. if !ok {
  27535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27536. }
  27537. m.AddIndexSort(v)
  27538. return nil
  27539. }
  27540. return fmt.Errorf("unknown SopStage numeric field %s", name)
  27541. }
  27542. // ClearedFields returns all nullable fields that were cleared during this
  27543. // mutation.
  27544. func (m *SopStageMutation) ClearedFields() []string {
  27545. var fields []string
  27546. if m.FieldCleared(sopstage.FieldStatus) {
  27547. fields = append(fields, sopstage.FieldStatus)
  27548. }
  27549. if m.FieldCleared(sopstage.FieldDeletedAt) {
  27550. fields = append(fields, sopstage.FieldDeletedAt)
  27551. }
  27552. if m.FieldCleared(sopstage.FieldActionMessage) {
  27553. fields = append(fields, sopstage.FieldActionMessage)
  27554. }
  27555. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  27556. fields = append(fields, sopstage.FieldActionLabelAdd)
  27557. }
  27558. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  27559. fields = append(fields, sopstage.FieldActionLabelDel)
  27560. }
  27561. if m.FieldCleared(sopstage.FieldActionForward) {
  27562. fields = append(fields, sopstage.FieldActionForward)
  27563. }
  27564. if m.FieldCleared(sopstage.FieldIndexSort) {
  27565. fields = append(fields, sopstage.FieldIndexSort)
  27566. }
  27567. return fields
  27568. }
  27569. // FieldCleared returns a boolean indicating if a field with the given name was
  27570. // cleared in this mutation.
  27571. func (m *SopStageMutation) FieldCleared(name string) bool {
  27572. _, ok := m.clearedFields[name]
  27573. return ok
  27574. }
  27575. // ClearField clears the value of the field with the given name. It returns an
  27576. // error if the field is not defined in the schema.
  27577. func (m *SopStageMutation) ClearField(name string) error {
  27578. switch name {
  27579. case sopstage.FieldStatus:
  27580. m.ClearStatus()
  27581. return nil
  27582. case sopstage.FieldDeletedAt:
  27583. m.ClearDeletedAt()
  27584. return nil
  27585. case sopstage.FieldActionMessage:
  27586. m.ClearActionMessage()
  27587. return nil
  27588. case sopstage.FieldActionLabelAdd:
  27589. m.ClearActionLabelAdd()
  27590. return nil
  27591. case sopstage.FieldActionLabelDel:
  27592. m.ClearActionLabelDel()
  27593. return nil
  27594. case sopstage.FieldActionForward:
  27595. m.ClearActionForward()
  27596. return nil
  27597. case sopstage.FieldIndexSort:
  27598. m.ClearIndexSort()
  27599. return nil
  27600. }
  27601. return fmt.Errorf("unknown SopStage nullable field %s", name)
  27602. }
  27603. // ResetField resets all changes in the mutation for the field with the given name.
  27604. // It returns an error if the field is not defined in the schema.
  27605. func (m *SopStageMutation) ResetField(name string) error {
  27606. switch name {
  27607. case sopstage.FieldCreatedAt:
  27608. m.ResetCreatedAt()
  27609. return nil
  27610. case sopstage.FieldUpdatedAt:
  27611. m.ResetUpdatedAt()
  27612. return nil
  27613. case sopstage.FieldStatus:
  27614. m.ResetStatus()
  27615. return nil
  27616. case sopstage.FieldDeletedAt:
  27617. m.ResetDeletedAt()
  27618. return nil
  27619. case sopstage.FieldTaskID:
  27620. m.ResetTaskID()
  27621. return nil
  27622. case sopstage.FieldName:
  27623. m.ResetName()
  27624. return nil
  27625. case sopstage.FieldConditionType:
  27626. m.ResetConditionType()
  27627. return nil
  27628. case sopstage.FieldConditionOperator:
  27629. m.ResetConditionOperator()
  27630. return nil
  27631. case sopstage.FieldConditionList:
  27632. m.ResetConditionList()
  27633. return nil
  27634. case sopstage.FieldActionMessage:
  27635. m.ResetActionMessage()
  27636. return nil
  27637. case sopstage.FieldActionLabelAdd:
  27638. m.ResetActionLabelAdd()
  27639. return nil
  27640. case sopstage.FieldActionLabelDel:
  27641. m.ResetActionLabelDel()
  27642. return nil
  27643. case sopstage.FieldActionForward:
  27644. m.ResetActionForward()
  27645. return nil
  27646. case sopstage.FieldIndexSort:
  27647. m.ResetIndexSort()
  27648. return nil
  27649. }
  27650. return fmt.Errorf("unknown SopStage field %s", name)
  27651. }
  27652. // AddedEdges returns all edge names that were set/added in this mutation.
  27653. func (m *SopStageMutation) AddedEdges() []string {
  27654. edges := make([]string, 0, 3)
  27655. if m.sop_task != nil {
  27656. edges = append(edges, sopstage.EdgeSopTask)
  27657. }
  27658. if m.stage_nodes != nil {
  27659. edges = append(edges, sopstage.EdgeStageNodes)
  27660. }
  27661. if m.stage_messages != nil {
  27662. edges = append(edges, sopstage.EdgeStageMessages)
  27663. }
  27664. return edges
  27665. }
  27666. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27667. // name in this mutation.
  27668. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  27669. switch name {
  27670. case sopstage.EdgeSopTask:
  27671. if id := m.sop_task; id != nil {
  27672. return []ent.Value{*id}
  27673. }
  27674. case sopstage.EdgeStageNodes:
  27675. ids := make([]ent.Value, 0, len(m.stage_nodes))
  27676. for id := range m.stage_nodes {
  27677. ids = append(ids, id)
  27678. }
  27679. return ids
  27680. case sopstage.EdgeStageMessages:
  27681. ids := make([]ent.Value, 0, len(m.stage_messages))
  27682. for id := range m.stage_messages {
  27683. ids = append(ids, id)
  27684. }
  27685. return ids
  27686. }
  27687. return nil
  27688. }
  27689. // RemovedEdges returns all edge names that were removed in this mutation.
  27690. func (m *SopStageMutation) RemovedEdges() []string {
  27691. edges := make([]string, 0, 3)
  27692. if m.removedstage_nodes != nil {
  27693. edges = append(edges, sopstage.EdgeStageNodes)
  27694. }
  27695. if m.removedstage_messages != nil {
  27696. edges = append(edges, sopstage.EdgeStageMessages)
  27697. }
  27698. return edges
  27699. }
  27700. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27701. // the given name in this mutation.
  27702. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  27703. switch name {
  27704. case sopstage.EdgeStageNodes:
  27705. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  27706. for id := range m.removedstage_nodes {
  27707. ids = append(ids, id)
  27708. }
  27709. return ids
  27710. case sopstage.EdgeStageMessages:
  27711. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  27712. for id := range m.removedstage_messages {
  27713. ids = append(ids, id)
  27714. }
  27715. return ids
  27716. }
  27717. return nil
  27718. }
  27719. // ClearedEdges returns all edge names that were cleared in this mutation.
  27720. func (m *SopStageMutation) ClearedEdges() []string {
  27721. edges := make([]string, 0, 3)
  27722. if m.clearedsop_task {
  27723. edges = append(edges, sopstage.EdgeSopTask)
  27724. }
  27725. if m.clearedstage_nodes {
  27726. edges = append(edges, sopstage.EdgeStageNodes)
  27727. }
  27728. if m.clearedstage_messages {
  27729. edges = append(edges, sopstage.EdgeStageMessages)
  27730. }
  27731. return edges
  27732. }
  27733. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27734. // was cleared in this mutation.
  27735. func (m *SopStageMutation) EdgeCleared(name string) bool {
  27736. switch name {
  27737. case sopstage.EdgeSopTask:
  27738. return m.clearedsop_task
  27739. case sopstage.EdgeStageNodes:
  27740. return m.clearedstage_nodes
  27741. case sopstage.EdgeStageMessages:
  27742. return m.clearedstage_messages
  27743. }
  27744. return false
  27745. }
  27746. // ClearEdge clears the value of the edge with the given name. It returns an error
  27747. // if that edge is not defined in the schema.
  27748. func (m *SopStageMutation) ClearEdge(name string) error {
  27749. switch name {
  27750. case sopstage.EdgeSopTask:
  27751. m.ClearSopTask()
  27752. return nil
  27753. }
  27754. return fmt.Errorf("unknown SopStage unique edge %s", name)
  27755. }
  27756. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27757. // It returns an error if the edge is not defined in the schema.
  27758. func (m *SopStageMutation) ResetEdge(name string) error {
  27759. switch name {
  27760. case sopstage.EdgeSopTask:
  27761. m.ResetSopTask()
  27762. return nil
  27763. case sopstage.EdgeStageNodes:
  27764. m.ResetStageNodes()
  27765. return nil
  27766. case sopstage.EdgeStageMessages:
  27767. m.ResetStageMessages()
  27768. return nil
  27769. }
  27770. return fmt.Errorf("unknown SopStage edge %s", name)
  27771. }
  27772. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  27773. type SopTaskMutation struct {
  27774. config
  27775. op Op
  27776. typ string
  27777. id *uint64
  27778. created_at *time.Time
  27779. updated_at *time.Time
  27780. status *uint8
  27781. addstatus *int8
  27782. deleted_at *time.Time
  27783. name *string
  27784. bot_wxid_list *[]string
  27785. appendbot_wxid_list []string
  27786. _type *int
  27787. add_type *int
  27788. plan_start_time *time.Time
  27789. plan_end_time *time.Time
  27790. creator_id *string
  27791. organization_id *uint64
  27792. addorganization_id *int64
  27793. token *[]string
  27794. appendtoken []string
  27795. clearedFields map[string]struct{}
  27796. task_stages map[uint64]struct{}
  27797. removedtask_stages map[uint64]struct{}
  27798. clearedtask_stages bool
  27799. done bool
  27800. oldValue func(context.Context) (*SopTask, error)
  27801. predicates []predicate.SopTask
  27802. }
  27803. var _ ent.Mutation = (*SopTaskMutation)(nil)
  27804. // soptaskOption allows management of the mutation configuration using functional options.
  27805. type soptaskOption func(*SopTaskMutation)
  27806. // newSopTaskMutation creates new mutation for the SopTask entity.
  27807. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  27808. m := &SopTaskMutation{
  27809. config: c,
  27810. op: op,
  27811. typ: TypeSopTask,
  27812. clearedFields: make(map[string]struct{}),
  27813. }
  27814. for _, opt := range opts {
  27815. opt(m)
  27816. }
  27817. return m
  27818. }
  27819. // withSopTaskID sets the ID field of the mutation.
  27820. func withSopTaskID(id uint64) soptaskOption {
  27821. return func(m *SopTaskMutation) {
  27822. var (
  27823. err error
  27824. once sync.Once
  27825. value *SopTask
  27826. )
  27827. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  27828. once.Do(func() {
  27829. if m.done {
  27830. err = errors.New("querying old values post mutation is not allowed")
  27831. } else {
  27832. value, err = m.Client().SopTask.Get(ctx, id)
  27833. }
  27834. })
  27835. return value, err
  27836. }
  27837. m.id = &id
  27838. }
  27839. }
  27840. // withSopTask sets the old SopTask of the mutation.
  27841. func withSopTask(node *SopTask) soptaskOption {
  27842. return func(m *SopTaskMutation) {
  27843. m.oldValue = func(context.Context) (*SopTask, error) {
  27844. return node, nil
  27845. }
  27846. m.id = &node.ID
  27847. }
  27848. }
  27849. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27850. // executed in a transaction (ent.Tx), a transactional client is returned.
  27851. func (m SopTaskMutation) Client() *Client {
  27852. client := &Client{config: m.config}
  27853. client.init()
  27854. return client
  27855. }
  27856. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27857. // it returns an error otherwise.
  27858. func (m SopTaskMutation) Tx() (*Tx, error) {
  27859. if _, ok := m.driver.(*txDriver); !ok {
  27860. return nil, errors.New("ent: mutation is not running in a transaction")
  27861. }
  27862. tx := &Tx{config: m.config}
  27863. tx.init()
  27864. return tx, nil
  27865. }
  27866. // SetID sets the value of the id field. Note that this
  27867. // operation is only accepted on creation of SopTask entities.
  27868. func (m *SopTaskMutation) SetID(id uint64) {
  27869. m.id = &id
  27870. }
  27871. // ID returns the ID value in the mutation. Note that the ID is only available
  27872. // if it was provided to the builder or after it was returned from the database.
  27873. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  27874. if m.id == nil {
  27875. return
  27876. }
  27877. return *m.id, true
  27878. }
  27879. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27880. // That means, if the mutation is applied within a transaction with an isolation level such
  27881. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27882. // or updated by the mutation.
  27883. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  27884. switch {
  27885. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27886. id, exists := m.ID()
  27887. if exists {
  27888. return []uint64{id}, nil
  27889. }
  27890. fallthrough
  27891. case m.op.Is(OpUpdate | OpDelete):
  27892. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  27893. default:
  27894. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27895. }
  27896. }
  27897. // SetCreatedAt sets the "created_at" field.
  27898. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  27899. m.created_at = &t
  27900. }
  27901. // CreatedAt returns the value of the "created_at" field in the mutation.
  27902. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  27903. v := m.created_at
  27904. if v == nil {
  27905. return
  27906. }
  27907. return *v, true
  27908. }
  27909. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  27910. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27912. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27913. if !m.op.Is(OpUpdateOne) {
  27914. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27915. }
  27916. if m.id == nil || m.oldValue == nil {
  27917. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27918. }
  27919. oldValue, err := m.oldValue(ctx)
  27920. if err != nil {
  27921. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27922. }
  27923. return oldValue.CreatedAt, nil
  27924. }
  27925. // ResetCreatedAt resets all changes to the "created_at" field.
  27926. func (m *SopTaskMutation) ResetCreatedAt() {
  27927. m.created_at = nil
  27928. }
  27929. // SetUpdatedAt sets the "updated_at" field.
  27930. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  27931. m.updated_at = &t
  27932. }
  27933. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27934. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  27935. v := m.updated_at
  27936. if v == nil {
  27937. return
  27938. }
  27939. return *v, true
  27940. }
  27941. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  27942. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27944. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27945. if !m.op.Is(OpUpdateOne) {
  27946. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27947. }
  27948. if m.id == nil || m.oldValue == nil {
  27949. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27950. }
  27951. oldValue, err := m.oldValue(ctx)
  27952. if err != nil {
  27953. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27954. }
  27955. return oldValue.UpdatedAt, nil
  27956. }
  27957. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27958. func (m *SopTaskMutation) ResetUpdatedAt() {
  27959. m.updated_at = nil
  27960. }
  27961. // SetStatus sets the "status" field.
  27962. func (m *SopTaskMutation) SetStatus(u uint8) {
  27963. m.status = &u
  27964. m.addstatus = nil
  27965. }
  27966. // Status returns the value of the "status" field in the mutation.
  27967. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  27968. v := m.status
  27969. if v == nil {
  27970. return
  27971. }
  27972. return *v, true
  27973. }
  27974. // OldStatus returns the old "status" field's value of the SopTask entity.
  27975. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27977. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27978. if !m.op.Is(OpUpdateOne) {
  27979. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27980. }
  27981. if m.id == nil || m.oldValue == nil {
  27982. return v, errors.New("OldStatus requires an ID field in the mutation")
  27983. }
  27984. oldValue, err := m.oldValue(ctx)
  27985. if err != nil {
  27986. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27987. }
  27988. return oldValue.Status, nil
  27989. }
  27990. // AddStatus adds u to the "status" field.
  27991. func (m *SopTaskMutation) AddStatus(u int8) {
  27992. if m.addstatus != nil {
  27993. *m.addstatus += u
  27994. } else {
  27995. m.addstatus = &u
  27996. }
  27997. }
  27998. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27999. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  28000. v := m.addstatus
  28001. if v == nil {
  28002. return
  28003. }
  28004. return *v, true
  28005. }
  28006. // ClearStatus clears the value of the "status" field.
  28007. func (m *SopTaskMutation) ClearStatus() {
  28008. m.status = nil
  28009. m.addstatus = nil
  28010. m.clearedFields[soptask.FieldStatus] = struct{}{}
  28011. }
  28012. // StatusCleared returns if the "status" field was cleared in this mutation.
  28013. func (m *SopTaskMutation) StatusCleared() bool {
  28014. _, ok := m.clearedFields[soptask.FieldStatus]
  28015. return ok
  28016. }
  28017. // ResetStatus resets all changes to the "status" field.
  28018. func (m *SopTaskMutation) ResetStatus() {
  28019. m.status = nil
  28020. m.addstatus = nil
  28021. delete(m.clearedFields, soptask.FieldStatus)
  28022. }
  28023. // SetDeletedAt sets the "deleted_at" field.
  28024. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  28025. m.deleted_at = &t
  28026. }
  28027. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28028. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  28029. v := m.deleted_at
  28030. if v == nil {
  28031. return
  28032. }
  28033. return *v, true
  28034. }
  28035. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  28036. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28038. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28039. if !m.op.Is(OpUpdateOne) {
  28040. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28041. }
  28042. if m.id == nil || m.oldValue == nil {
  28043. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28044. }
  28045. oldValue, err := m.oldValue(ctx)
  28046. if err != nil {
  28047. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28048. }
  28049. return oldValue.DeletedAt, nil
  28050. }
  28051. // ClearDeletedAt clears the value of the "deleted_at" field.
  28052. func (m *SopTaskMutation) ClearDeletedAt() {
  28053. m.deleted_at = nil
  28054. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  28055. }
  28056. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28057. func (m *SopTaskMutation) DeletedAtCleared() bool {
  28058. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  28059. return ok
  28060. }
  28061. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28062. func (m *SopTaskMutation) ResetDeletedAt() {
  28063. m.deleted_at = nil
  28064. delete(m.clearedFields, soptask.FieldDeletedAt)
  28065. }
  28066. // SetName sets the "name" field.
  28067. func (m *SopTaskMutation) SetName(s string) {
  28068. m.name = &s
  28069. }
  28070. // Name returns the value of the "name" field in the mutation.
  28071. func (m *SopTaskMutation) Name() (r string, exists bool) {
  28072. v := m.name
  28073. if v == nil {
  28074. return
  28075. }
  28076. return *v, true
  28077. }
  28078. // OldName returns the old "name" field's value of the SopTask entity.
  28079. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28081. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  28082. if !m.op.Is(OpUpdateOne) {
  28083. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28084. }
  28085. if m.id == nil || m.oldValue == nil {
  28086. return v, errors.New("OldName requires an ID field in the mutation")
  28087. }
  28088. oldValue, err := m.oldValue(ctx)
  28089. if err != nil {
  28090. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28091. }
  28092. return oldValue.Name, nil
  28093. }
  28094. // ResetName resets all changes to the "name" field.
  28095. func (m *SopTaskMutation) ResetName() {
  28096. m.name = nil
  28097. }
  28098. // SetBotWxidList sets the "bot_wxid_list" field.
  28099. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  28100. m.bot_wxid_list = &s
  28101. m.appendbot_wxid_list = nil
  28102. }
  28103. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  28104. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  28105. v := m.bot_wxid_list
  28106. if v == nil {
  28107. return
  28108. }
  28109. return *v, true
  28110. }
  28111. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  28112. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28114. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  28115. if !m.op.Is(OpUpdateOne) {
  28116. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  28117. }
  28118. if m.id == nil || m.oldValue == nil {
  28119. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  28120. }
  28121. oldValue, err := m.oldValue(ctx)
  28122. if err != nil {
  28123. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  28124. }
  28125. return oldValue.BotWxidList, nil
  28126. }
  28127. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  28128. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  28129. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  28130. }
  28131. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  28132. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  28133. if len(m.appendbot_wxid_list) == 0 {
  28134. return nil, false
  28135. }
  28136. return m.appendbot_wxid_list, true
  28137. }
  28138. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  28139. func (m *SopTaskMutation) ClearBotWxidList() {
  28140. m.bot_wxid_list = nil
  28141. m.appendbot_wxid_list = nil
  28142. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  28143. }
  28144. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  28145. func (m *SopTaskMutation) BotWxidListCleared() bool {
  28146. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  28147. return ok
  28148. }
  28149. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  28150. func (m *SopTaskMutation) ResetBotWxidList() {
  28151. m.bot_wxid_list = nil
  28152. m.appendbot_wxid_list = nil
  28153. delete(m.clearedFields, soptask.FieldBotWxidList)
  28154. }
  28155. // SetType sets the "type" field.
  28156. func (m *SopTaskMutation) SetType(i int) {
  28157. m._type = &i
  28158. m.add_type = nil
  28159. }
  28160. // GetType returns the value of the "type" field in the mutation.
  28161. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  28162. v := m._type
  28163. if v == nil {
  28164. return
  28165. }
  28166. return *v, true
  28167. }
  28168. // OldType returns the old "type" field's value of the SopTask entity.
  28169. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28171. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  28172. if !m.op.Is(OpUpdateOne) {
  28173. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28174. }
  28175. if m.id == nil || m.oldValue == nil {
  28176. return v, errors.New("OldType requires an ID field in the mutation")
  28177. }
  28178. oldValue, err := m.oldValue(ctx)
  28179. if err != nil {
  28180. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28181. }
  28182. return oldValue.Type, nil
  28183. }
  28184. // AddType adds i to the "type" field.
  28185. func (m *SopTaskMutation) AddType(i int) {
  28186. if m.add_type != nil {
  28187. *m.add_type += i
  28188. } else {
  28189. m.add_type = &i
  28190. }
  28191. }
  28192. // AddedType returns the value that was added to the "type" field in this mutation.
  28193. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  28194. v := m.add_type
  28195. if v == nil {
  28196. return
  28197. }
  28198. return *v, true
  28199. }
  28200. // ResetType resets all changes to the "type" field.
  28201. func (m *SopTaskMutation) ResetType() {
  28202. m._type = nil
  28203. m.add_type = nil
  28204. }
  28205. // SetPlanStartTime sets the "plan_start_time" field.
  28206. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  28207. m.plan_start_time = &t
  28208. }
  28209. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  28210. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  28211. v := m.plan_start_time
  28212. if v == nil {
  28213. return
  28214. }
  28215. return *v, true
  28216. }
  28217. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  28218. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28220. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  28221. if !m.op.Is(OpUpdateOne) {
  28222. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  28223. }
  28224. if m.id == nil || m.oldValue == nil {
  28225. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  28226. }
  28227. oldValue, err := m.oldValue(ctx)
  28228. if err != nil {
  28229. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  28230. }
  28231. return oldValue.PlanStartTime, nil
  28232. }
  28233. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  28234. func (m *SopTaskMutation) ClearPlanStartTime() {
  28235. m.plan_start_time = nil
  28236. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  28237. }
  28238. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  28239. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  28240. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  28241. return ok
  28242. }
  28243. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  28244. func (m *SopTaskMutation) ResetPlanStartTime() {
  28245. m.plan_start_time = nil
  28246. delete(m.clearedFields, soptask.FieldPlanStartTime)
  28247. }
  28248. // SetPlanEndTime sets the "plan_end_time" field.
  28249. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  28250. m.plan_end_time = &t
  28251. }
  28252. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  28253. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  28254. v := m.plan_end_time
  28255. if v == nil {
  28256. return
  28257. }
  28258. return *v, true
  28259. }
  28260. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  28261. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28263. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  28264. if !m.op.Is(OpUpdateOne) {
  28265. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  28266. }
  28267. if m.id == nil || m.oldValue == nil {
  28268. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  28269. }
  28270. oldValue, err := m.oldValue(ctx)
  28271. if err != nil {
  28272. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  28273. }
  28274. return oldValue.PlanEndTime, nil
  28275. }
  28276. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  28277. func (m *SopTaskMutation) ClearPlanEndTime() {
  28278. m.plan_end_time = nil
  28279. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  28280. }
  28281. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  28282. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  28283. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  28284. return ok
  28285. }
  28286. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  28287. func (m *SopTaskMutation) ResetPlanEndTime() {
  28288. m.plan_end_time = nil
  28289. delete(m.clearedFields, soptask.FieldPlanEndTime)
  28290. }
  28291. // SetCreatorID sets the "creator_id" field.
  28292. func (m *SopTaskMutation) SetCreatorID(s string) {
  28293. m.creator_id = &s
  28294. }
  28295. // CreatorID returns the value of the "creator_id" field in the mutation.
  28296. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  28297. v := m.creator_id
  28298. if v == nil {
  28299. return
  28300. }
  28301. return *v, true
  28302. }
  28303. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  28304. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28306. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  28307. if !m.op.Is(OpUpdateOne) {
  28308. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  28309. }
  28310. if m.id == nil || m.oldValue == nil {
  28311. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  28312. }
  28313. oldValue, err := m.oldValue(ctx)
  28314. if err != nil {
  28315. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  28316. }
  28317. return oldValue.CreatorID, nil
  28318. }
  28319. // ClearCreatorID clears the value of the "creator_id" field.
  28320. func (m *SopTaskMutation) ClearCreatorID() {
  28321. m.creator_id = nil
  28322. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  28323. }
  28324. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  28325. func (m *SopTaskMutation) CreatorIDCleared() bool {
  28326. _, ok := m.clearedFields[soptask.FieldCreatorID]
  28327. return ok
  28328. }
  28329. // ResetCreatorID resets all changes to the "creator_id" field.
  28330. func (m *SopTaskMutation) ResetCreatorID() {
  28331. m.creator_id = nil
  28332. delete(m.clearedFields, soptask.FieldCreatorID)
  28333. }
  28334. // SetOrganizationID sets the "organization_id" field.
  28335. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  28336. m.organization_id = &u
  28337. m.addorganization_id = nil
  28338. }
  28339. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28340. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  28341. v := m.organization_id
  28342. if v == nil {
  28343. return
  28344. }
  28345. return *v, true
  28346. }
  28347. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  28348. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28350. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28351. if !m.op.Is(OpUpdateOne) {
  28352. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28353. }
  28354. if m.id == nil || m.oldValue == nil {
  28355. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28356. }
  28357. oldValue, err := m.oldValue(ctx)
  28358. if err != nil {
  28359. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28360. }
  28361. return oldValue.OrganizationID, nil
  28362. }
  28363. // AddOrganizationID adds u to the "organization_id" field.
  28364. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  28365. if m.addorganization_id != nil {
  28366. *m.addorganization_id += u
  28367. } else {
  28368. m.addorganization_id = &u
  28369. }
  28370. }
  28371. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28372. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  28373. v := m.addorganization_id
  28374. if v == nil {
  28375. return
  28376. }
  28377. return *v, true
  28378. }
  28379. // ClearOrganizationID clears the value of the "organization_id" field.
  28380. func (m *SopTaskMutation) ClearOrganizationID() {
  28381. m.organization_id = nil
  28382. m.addorganization_id = nil
  28383. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  28384. }
  28385. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28386. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  28387. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  28388. return ok
  28389. }
  28390. // ResetOrganizationID resets all changes to the "organization_id" field.
  28391. func (m *SopTaskMutation) ResetOrganizationID() {
  28392. m.organization_id = nil
  28393. m.addorganization_id = nil
  28394. delete(m.clearedFields, soptask.FieldOrganizationID)
  28395. }
  28396. // SetToken sets the "token" field.
  28397. func (m *SopTaskMutation) SetToken(s []string) {
  28398. m.token = &s
  28399. m.appendtoken = nil
  28400. }
  28401. // Token returns the value of the "token" field in the mutation.
  28402. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  28403. v := m.token
  28404. if v == nil {
  28405. return
  28406. }
  28407. return *v, true
  28408. }
  28409. // OldToken returns the old "token" field's value of the SopTask entity.
  28410. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28412. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  28413. if !m.op.Is(OpUpdateOne) {
  28414. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  28415. }
  28416. if m.id == nil || m.oldValue == nil {
  28417. return v, errors.New("OldToken requires an ID field in the mutation")
  28418. }
  28419. oldValue, err := m.oldValue(ctx)
  28420. if err != nil {
  28421. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  28422. }
  28423. return oldValue.Token, nil
  28424. }
  28425. // AppendToken adds s to the "token" field.
  28426. func (m *SopTaskMutation) AppendToken(s []string) {
  28427. m.appendtoken = append(m.appendtoken, s...)
  28428. }
  28429. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  28430. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  28431. if len(m.appendtoken) == 0 {
  28432. return nil, false
  28433. }
  28434. return m.appendtoken, true
  28435. }
  28436. // ClearToken clears the value of the "token" field.
  28437. func (m *SopTaskMutation) ClearToken() {
  28438. m.token = nil
  28439. m.appendtoken = nil
  28440. m.clearedFields[soptask.FieldToken] = struct{}{}
  28441. }
  28442. // TokenCleared returns if the "token" field was cleared in this mutation.
  28443. func (m *SopTaskMutation) TokenCleared() bool {
  28444. _, ok := m.clearedFields[soptask.FieldToken]
  28445. return ok
  28446. }
  28447. // ResetToken resets all changes to the "token" field.
  28448. func (m *SopTaskMutation) ResetToken() {
  28449. m.token = nil
  28450. m.appendtoken = nil
  28451. delete(m.clearedFields, soptask.FieldToken)
  28452. }
  28453. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  28454. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  28455. if m.task_stages == nil {
  28456. m.task_stages = make(map[uint64]struct{})
  28457. }
  28458. for i := range ids {
  28459. m.task_stages[ids[i]] = struct{}{}
  28460. }
  28461. }
  28462. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  28463. func (m *SopTaskMutation) ClearTaskStages() {
  28464. m.clearedtask_stages = true
  28465. }
  28466. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  28467. func (m *SopTaskMutation) TaskStagesCleared() bool {
  28468. return m.clearedtask_stages
  28469. }
  28470. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  28471. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  28472. if m.removedtask_stages == nil {
  28473. m.removedtask_stages = make(map[uint64]struct{})
  28474. }
  28475. for i := range ids {
  28476. delete(m.task_stages, ids[i])
  28477. m.removedtask_stages[ids[i]] = struct{}{}
  28478. }
  28479. }
  28480. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  28481. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  28482. for id := range m.removedtask_stages {
  28483. ids = append(ids, id)
  28484. }
  28485. return
  28486. }
  28487. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  28488. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  28489. for id := range m.task_stages {
  28490. ids = append(ids, id)
  28491. }
  28492. return
  28493. }
  28494. // ResetTaskStages resets all changes to the "task_stages" edge.
  28495. func (m *SopTaskMutation) ResetTaskStages() {
  28496. m.task_stages = nil
  28497. m.clearedtask_stages = false
  28498. m.removedtask_stages = nil
  28499. }
  28500. // Where appends a list predicates to the SopTaskMutation builder.
  28501. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  28502. m.predicates = append(m.predicates, ps...)
  28503. }
  28504. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  28505. // users can use type-assertion to append predicates that do not depend on any generated package.
  28506. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  28507. p := make([]predicate.SopTask, len(ps))
  28508. for i := range ps {
  28509. p[i] = ps[i]
  28510. }
  28511. m.Where(p...)
  28512. }
  28513. // Op returns the operation name.
  28514. func (m *SopTaskMutation) Op() Op {
  28515. return m.op
  28516. }
  28517. // SetOp allows setting the mutation operation.
  28518. func (m *SopTaskMutation) SetOp(op Op) {
  28519. m.op = op
  28520. }
  28521. // Type returns the node type of this mutation (SopTask).
  28522. func (m *SopTaskMutation) Type() string {
  28523. return m.typ
  28524. }
  28525. // Fields returns all fields that were changed during this mutation. Note that in
  28526. // order to get all numeric fields that were incremented/decremented, call
  28527. // AddedFields().
  28528. func (m *SopTaskMutation) Fields() []string {
  28529. fields := make([]string, 0, 12)
  28530. if m.created_at != nil {
  28531. fields = append(fields, soptask.FieldCreatedAt)
  28532. }
  28533. if m.updated_at != nil {
  28534. fields = append(fields, soptask.FieldUpdatedAt)
  28535. }
  28536. if m.status != nil {
  28537. fields = append(fields, soptask.FieldStatus)
  28538. }
  28539. if m.deleted_at != nil {
  28540. fields = append(fields, soptask.FieldDeletedAt)
  28541. }
  28542. if m.name != nil {
  28543. fields = append(fields, soptask.FieldName)
  28544. }
  28545. if m.bot_wxid_list != nil {
  28546. fields = append(fields, soptask.FieldBotWxidList)
  28547. }
  28548. if m._type != nil {
  28549. fields = append(fields, soptask.FieldType)
  28550. }
  28551. if m.plan_start_time != nil {
  28552. fields = append(fields, soptask.FieldPlanStartTime)
  28553. }
  28554. if m.plan_end_time != nil {
  28555. fields = append(fields, soptask.FieldPlanEndTime)
  28556. }
  28557. if m.creator_id != nil {
  28558. fields = append(fields, soptask.FieldCreatorID)
  28559. }
  28560. if m.organization_id != nil {
  28561. fields = append(fields, soptask.FieldOrganizationID)
  28562. }
  28563. if m.token != nil {
  28564. fields = append(fields, soptask.FieldToken)
  28565. }
  28566. return fields
  28567. }
  28568. // Field returns the value of a field with the given name. The second boolean
  28569. // return value indicates that this field was not set, or was not defined in the
  28570. // schema.
  28571. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  28572. switch name {
  28573. case soptask.FieldCreatedAt:
  28574. return m.CreatedAt()
  28575. case soptask.FieldUpdatedAt:
  28576. return m.UpdatedAt()
  28577. case soptask.FieldStatus:
  28578. return m.Status()
  28579. case soptask.FieldDeletedAt:
  28580. return m.DeletedAt()
  28581. case soptask.FieldName:
  28582. return m.Name()
  28583. case soptask.FieldBotWxidList:
  28584. return m.BotWxidList()
  28585. case soptask.FieldType:
  28586. return m.GetType()
  28587. case soptask.FieldPlanStartTime:
  28588. return m.PlanStartTime()
  28589. case soptask.FieldPlanEndTime:
  28590. return m.PlanEndTime()
  28591. case soptask.FieldCreatorID:
  28592. return m.CreatorID()
  28593. case soptask.FieldOrganizationID:
  28594. return m.OrganizationID()
  28595. case soptask.FieldToken:
  28596. return m.Token()
  28597. }
  28598. return nil, false
  28599. }
  28600. // OldField returns the old value of the field from the database. An error is
  28601. // returned if the mutation operation is not UpdateOne, or the query to the
  28602. // database failed.
  28603. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28604. switch name {
  28605. case soptask.FieldCreatedAt:
  28606. return m.OldCreatedAt(ctx)
  28607. case soptask.FieldUpdatedAt:
  28608. return m.OldUpdatedAt(ctx)
  28609. case soptask.FieldStatus:
  28610. return m.OldStatus(ctx)
  28611. case soptask.FieldDeletedAt:
  28612. return m.OldDeletedAt(ctx)
  28613. case soptask.FieldName:
  28614. return m.OldName(ctx)
  28615. case soptask.FieldBotWxidList:
  28616. return m.OldBotWxidList(ctx)
  28617. case soptask.FieldType:
  28618. return m.OldType(ctx)
  28619. case soptask.FieldPlanStartTime:
  28620. return m.OldPlanStartTime(ctx)
  28621. case soptask.FieldPlanEndTime:
  28622. return m.OldPlanEndTime(ctx)
  28623. case soptask.FieldCreatorID:
  28624. return m.OldCreatorID(ctx)
  28625. case soptask.FieldOrganizationID:
  28626. return m.OldOrganizationID(ctx)
  28627. case soptask.FieldToken:
  28628. return m.OldToken(ctx)
  28629. }
  28630. return nil, fmt.Errorf("unknown SopTask field %s", name)
  28631. }
  28632. // SetField sets the value of a field with the given name. It returns an error if
  28633. // the field is not defined in the schema, or if the type mismatched the field
  28634. // type.
  28635. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  28636. switch name {
  28637. case soptask.FieldCreatedAt:
  28638. v, ok := value.(time.Time)
  28639. if !ok {
  28640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28641. }
  28642. m.SetCreatedAt(v)
  28643. return nil
  28644. case soptask.FieldUpdatedAt:
  28645. v, ok := value.(time.Time)
  28646. if !ok {
  28647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28648. }
  28649. m.SetUpdatedAt(v)
  28650. return nil
  28651. case soptask.FieldStatus:
  28652. v, ok := value.(uint8)
  28653. if !ok {
  28654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28655. }
  28656. m.SetStatus(v)
  28657. return nil
  28658. case soptask.FieldDeletedAt:
  28659. v, ok := value.(time.Time)
  28660. if !ok {
  28661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28662. }
  28663. m.SetDeletedAt(v)
  28664. return nil
  28665. case soptask.FieldName:
  28666. v, ok := value.(string)
  28667. if !ok {
  28668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28669. }
  28670. m.SetName(v)
  28671. return nil
  28672. case soptask.FieldBotWxidList:
  28673. v, ok := value.([]string)
  28674. if !ok {
  28675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28676. }
  28677. m.SetBotWxidList(v)
  28678. return nil
  28679. case soptask.FieldType:
  28680. v, ok := value.(int)
  28681. if !ok {
  28682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28683. }
  28684. m.SetType(v)
  28685. return nil
  28686. case soptask.FieldPlanStartTime:
  28687. v, ok := value.(time.Time)
  28688. if !ok {
  28689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28690. }
  28691. m.SetPlanStartTime(v)
  28692. return nil
  28693. case soptask.FieldPlanEndTime:
  28694. v, ok := value.(time.Time)
  28695. if !ok {
  28696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28697. }
  28698. m.SetPlanEndTime(v)
  28699. return nil
  28700. case soptask.FieldCreatorID:
  28701. v, ok := value.(string)
  28702. if !ok {
  28703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28704. }
  28705. m.SetCreatorID(v)
  28706. return nil
  28707. case soptask.FieldOrganizationID:
  28708. v, ok := value.(uint64)
  28709. if !ok {
  28710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28711. }
  28712. m.SetOrganizationID(v)
  28713. return nil
  28714. case soptask.FieldToken:
  28715. v, ok := value.([]string)
  28716. if !ok {
  28717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28718. }
  28719. m.SetToken(v)
  28720. return nil
  28721. }
  28722. return fmt.Errorf("unknown SopTask field %s", name)
  28723. }
  28724. // AddedFields returns all numeric fields that were incremented/decremented during
  28725. // this mutation.
  28726. func (m *SopTaskMutation) AddedFields() []string {
  28727. var fields []string
  28728. if m.addstatus != nil {
  28729. fields = append(fields, soptask.FieldStatus)
  28730. }
  28731. if m.add_type != nil {
  28732. fields = append(fields, soptask.FieldType)
  28733. }
  28734. if m.addorganization_id != nil {
  28735. fields = append(fields, soptask.FieldOrganizationID)
  28736. }
  28737. return fields
  28738. }
  28739. // AddedField returns the numeric value that was incremented/decremented on a field
  28740. // with the given name. The second boolean return value indicates that this field
  28741. // was not set, or was not defined in the schema.
  28742. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  28743. switch name {
  28744. case soptask.FieldStatus:
  28745. return m.AddedStatus()
  28746. case soptask.FieldType:
  28747. return m.AddedType()
  28748. case soptask.FieldOrganizationID:
  28749. return m.AddedOrganizationID()
  28750. }
  28751. return nil, false
  28752. }
  28753. // AddField adds the value to the field with the given name. It returns an error if
  28754. // the field is not defined in the schema, or if the type mismatched the field
  28755. // type.
  28756. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  28757. switch name {
  28758. case soptask.FieldStatus:
  28759. v, ok := value.(int8)
  28760. if !ok {
  28761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28762. }
  28763. m.AddStatus(v)
  28764. return nil
  28765. case soptask.FieldType:
  28766. v, ok := value.(int)
  28767. if !ok {
  28768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28769. }
  28770. m.AddType(v)
  28771. return nil
  28772. case soptask.FieldOrganizationID:
  28773. v, ok := value.(int64)
  28774. if !ok {
  28775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28776. }
  28777. m.AddOrganizationID(v)
  28778. return nil
  28779. }
  28780. return fmt.Errorf("unknown SopTask numeric field %s", name)
  28781. }
  28782. // ClearedFields returns all nullable fields that were cleared during this
  28783. // mutation.
  28784. func (m *SopTaskMutation) ClearedFields() []string {
  28785. var fields []string
  28786. if m.FieldCleared(soptask.FieldStatus) {
  28787. fields = append(fields, soptask.FieldStatus)
  28788. }
  28789. if m.FieldCleared(soptask.FieldDeletedAt) {
  28790. fields = append(fields, soptask.FieldDeletedAt)
  28791. }
  28792. if m.FieldCleared(soptask.FieldBotWxidList) {
  28793. fields = append(fields, soptask.FieldBotWxidList)
  28794. }
  28795. if m.FieldCleared(soptask.FieldPlanStartTime) {
  28796. fields = append(fields, soptask.FieldPlanStartTime)
  28797. }
  28798. if m.FieldCleared(soptask.FieldPlanEndTime) {
  28799. fields = append(fields, soptask.FieldPlanEndTime)
  28800. }
  28801. if m.FieldCleared(soptask.FieldCreatorID) {
  28802. fields = append(fields, soptask.FieldCreatorID)
  28803. }
  28804. if m.FieldCleared(soptask.FieldOrganizationID) {
  28805. fields = append(fields, soptask.FieldOrganizationID)
  28806. }
  28807. if m.FieldCleared(soptask.FieldToken) {
  28808. fields = append(fields, soptask.FieldToken)
  28809. }
  28810. return fields
  28811. }
  28812. // FieldCleared returns a boolean indicating if a field with the given name was
  28813. // cleared in this mutation.
  28814. func (m *SopTaskMutation) FieldCleared(name string) bool {
  28815. _, ok := m.clearedFields[name]
  28816. return ok
  28817. }
  28818. // ClearField clears the value of the field with the given name. It returns an
  28819. // error if the field is not defined in the schema.
  28820. func (m *SopTaskMutation) ClearField(name string) error {
  28821. switch name {
  28822. case soptask.FieldStatus:
  28823. m.ClearStatus()
  28824. return nil
  28825. case soptask.FieldDeletedAt:
  28826. m.ClearDeletedAt()
  28827. return nil
  28828. case soptask.FieldBotWxidList:
  28829. m.ClearBotWxidList()
  28830. return nil
  28831. case soptask.FieldPlanStartTime:
  28832. m.ClearPlanStartTime()
  28833. return nil
  28834. case soptask.FieldPlanEndTime:
  28835. m.ClearPlanEndTime()
  28836. return nil
  28837. case soptask.FieldCreatorID:
  28838. m.ClearCreatorID()
  28839. return nil
  28840. case soptask.FieldOrganizationID:
  28841. m.ClearOrganizationID()
  28842. return nil
  28843. case soptask.FieldToken:
  28844. m.ClearToken()
  28845. return nil
  28846. }
  28847. return fmt.Errorf("unknown SopTask nullable field %s", name)
  28848. }
  28849. // ResetField resets all changes in the mutation for the field with the given name.
  28850. // It returns an error if the field is not defined in the schema.
  28851. func (m *SopTaskMutation) ResetField(name string) error {
  28852. switch name {
  28853. case soptask.FieldCreatedAt:
  28854. m.ResetCreatedAt()
  28855. return nil
  28856. case soptask.FieldUpdatedAt:
  28857. m.ResetUpdatedAt()
  28858. return nil
  28859. case soptask.FieldStatus:
  28860. m.ResetStatus()
  28861. return nil
  28862. case soptask.FieldDeletedAt:
  28863. m.ResetDeletedAt()
  28864. return nil
  28865. case soptask.FieldName:
  28866. m.ResetName()
  28867. return nil
  28868. case soptask.FieldBotWxidList:
  28869. m.ResetBotWxidList()
  28870. return nil
  28871. case soptask.FieldType:
  28872. m.ResetType()
  28873. return nil
  28874. case soptask.FieldPlanStartTime:
  28875. m.ResetPlanStartTime()
  28876. return nil
  28877. case soptask.FieldPlanEndTime:
  28878. m.ResetPlanEndTime()
  28879. return nil
  28880. case soptask.FieldCreatorID:
  28881. m.ResetCreatorID()
  28882. return nil
  28883. case soptask.FieldOrganizationID:
  28884. m.ResetOrganizationID()
  28885. return nil
  28886. case soptask.FieldToken:
  28887. m.ResetToken()
  28888. return nil
  28889. }
  28890. return fmt.Errorf("unknown SopTask field %s", name)
  28891. }
  28892. // AddedEdges returns all edge names that were set/added in this mutation.
  28893. func (m *SopTaskMutation) AddedEdges() []string {
  28894. edges := make([]string, 0, 1)
  28895. if m.task_stages != nil {
  28896. edges = append(edges, soptask.EdgeTaskStages)
  28897. }
  28898. return edges
  28899. }
  28900. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28901. // name in this mutation.
  28902. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  28903. switch name {
  28904. case soptask.EdgeTaskStages:
  28905. ids := make([]ent.Value, 0, len(m.task_stages))
  28906. for id := range m.task_stages {
  28907. ids = append(ids, id)
  28908. }
  28909. return ids
  28910. }
  28911. return nil
  28912. }
  28913. // RemovedEdges returns all edge names that were removed in this mutation.
  28914. func (m *SopTaskMutation) RemovedEdges() []string {
  28915. edges := make([]string, 0, 1)
  28916. if m.removedtask_stages != nil {
  28917. edges = append(edges, soptask.EdgeTaskStages)
  28918. }
  28919. return edges
  28920. }
  28921. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28922. // the given name in this mutation.
  28923. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  28924. switch name {
  28925. case soptask.EdgeTaskStages:
  28926. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  28927. for id := range m.removedtask_stages {
  28928. ids = append(ids, id)
  28929. }
  28930. return ids
  28931. }
  28932. return nil
  28933. }
  28934. // ClearedEdges returns all edge names that were cleared in this mutation.
  28935. func (m *SopTaskMutation) ClearedEdges() []string {
  28936. edges := make([]string, 0, 1)
  28937. if m.clearedtask_stages {
  28938. edges = append(edges, soptask.EdgeTaskStages)
  28939. }
  28940. return edges
  28941. }
  28942. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28943. // was cleared in this mutation.
  28944. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  28945. switch name {
  28946. case soptask.EdgeTaskStages:
  28947. return m.clearedtask_stages
  28948. }
  28949. return false
  28950. }
  28951. // ClearEdge clears the value of the edge with the given name. It returns an error
  28952. // if that edge is not defined in the schema.
  28953. func (m *SopTaskMutation) ClearEdge(name string) error {
  28954. switch name {
  28955. }
  28956. return fmt.Errorf("unknown SopTask unique edge %s", name)
  28957. }
  28958. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28959. // It returns an error if the edge is not defined in the schema.
  28960. func (m *SopTaskMutation) ResetEdge(name string) error {
  28961. switch name {
  28962. case soptask.EdgeTaskStages:
  28963. m.ResetTaskStages()
  28964. return nil
  28965. }
  28966. return fmt.Errorf("unknown SopTask edge %s", name)
  28967. }
  28968. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  28969. type TokenMutation struct {
  28970. config
  28971. op Op
  28972. typ string
  28973. id *uint64
  28974. created_at *time.Time
  28975. updated_at *time.Time
  28976. deleted_at *time.Time
  28977. expire_at *time.Time
  28978. token *string
  28979. mac *string
  28980. organization_id *uint64
  28981. addorganization_id *int64
  28982. custom_agent_base *string
  28983. custom_agent_key *string
  28984. openai_base *string
  28985. openai_key *string
  28986. clearedFields map[string]struct{}
  28987. agent *uint64
  28988. clearedagent bool
  28989. done bool
  28990. oldValue func(context.Context) (*Token, error)
  28991. predicates []predicate.Token
  28992. }
  28993. var _ ent.Mutation = (*TokenMutation)(nil)
  28994. // tokenOption allows management of the mutation configuration using functional options.
  28995. type tokenOption func(*TokenMutation)
  28996. // newTokenMutation creates new mutation for the Token entity.
  28997. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  28998. m := &TokenMutation{
  28999. config: c,
  29000. op: op,
  29001. typ: TypeToken,
  29002. clearedFields: make(map[string]struct{}),
  29003. }
  29004. for _, opt := range opts {
  29005. opt(m)
  29006. }
  29007. return m
  29008. }
  29009. // withTokenID sets the ID field of the mutation.
  29010. func withTokenID(id uint64) tokenOption {
  29011. return func(m *TokenMutation) {
  29012. var (
  29013. err error
  29014. once sync.Once
  29015. value *Token
  29016. )
  29017. m.oldValue = func(ctx context.Context) (*Token, error) {
  29018. once.Do(func() {
  29019. if m.done {
  29020. err = errors.New("querying old values post mutation is not allowed")
  29021. } else {
  29022. value, err = m.Client().Token.Get(ctx, id)
  29023. }
  29024. })
  29025. return value, err
  29026. }
  29027. m.id = &id
  29028. }
  29029. }
  29030. // withToken sets the old Token of the mutation.
  29031. func withToken(node *Token) tokenOption {
  29032. return func(m *TokenMutation) {
  29033. m.oldValue = func(context.Context) (*Token, error) {
  29034. return node, nil
  29035. }
  29036. m.id = &node.ID
  29037. }
  29038. }
  29039. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29040. // executed in a transaction (ent.Tx), a transactional client is returned.
  29041. func (m TokenMutation) Client() *Client {
  29042. client := &Client{config: m.config}
  29043. client.init()
  29044. return client
  29045. }
  29046. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29047. // it returns an error otherwise.
  29048. func (m TokenMutation) Tx() (*Tx, error) {
  29049. if _, ok := m.driver.(*txDriver); !ok {
  29050. return nil, errors.New("ent: mutation is not running in a transaction")
  29051. }
  29052. tx := &Tx{config: m.config}
  29053. tx.init()
  29054. return tx, nil
  29055. }
  29056. // SetID sets the value of the id field. Note that this
  29057. // operation is only accepted on creation of Token entities.
  29058. func (m *TokenMutation) SetID(id uint64) {
  29059. m.id = &id
  29060. }
  29061. // ID returns the ID value in the mutation. Note that the ID is only available
  29062. // if it was provided to the builder or after it was returned from the database.
  29063. func (m *TokenMutation) ID() (id uint64, exists bool) {
  29064. if m.id == nil {
  29065. return
  29066. }
  29067. return *m.id, true
  29068. }
  29069. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29070. // That means, if the mutation is applied within a transaction with an isolation level such
  29071. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29072. // or updated by the mutation.
  29073. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  29074. switch {
  29075. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29076. id, exists := m.ID()
  29077. if exists {
  29078. return []uint64{id}, nil
  29079. }
  29080. fallthrough
  29081. case m.op.Is(OpUpdate | OpDelete):
  29082. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  29083. default:
  29084. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29085. }
  29086. }
  29087. // SetCreatedAt sets the "created_at" field.
  29088. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  29089. m.created_at = &t
  29090. }
  29091. // CreatedAt returns the value of the "created_at" field in the mutation.
  29092. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  29093. v := m.created_at
  29094. if v == nil {
  29095. return
  29096. }
  29097. return *v, true
  29098. }
  29099. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  29100. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29102. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29103. if !m.op.Is(OpUpdateOne) {
  29104. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29105. }
  29106. if m.id == nil || m.oldValue == nil {
  29107. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29108. }
  29109. oldValue, err := m.oldValue(ctx)
  29110. if err != nil {
  29111. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29112. }
  29113. return oldValue.CreatedAt, nil
  29114. }
  29115. // ResetCreatedAt resets all changes to the "created_at" field.
  29116. func (m *TokenMutation) ResetCreatedAt() {
  29117. m.created_at = nil
  29118. }
  29119. // SetUpdatedAt sets the "updated_at" field.
  29120. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  29121. m.updated_at = &t
  29122. }
  29123. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29124. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  29125. v := m.updated_at
  29126. if v == nil {
  29127. return
  29128. }
  29129. return *v, true
  29130. }
  29131. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  29132. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29134. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29135. if !m.op.Is(OpUpdateOne) {
  29136. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29137. }
  29138. if m.id == nil || m.oldValue == nil {
  29139. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29140. }
  29141. oldValue, err := m.oldValue(ctx)
  29142. if err != nil {
  29143. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29144. }
  29145. return oldValue.UpdatedAt, nil
  29146. }
  29147. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29148. func (m *TokenMutation) ResetUpdatedAt() {
  29149. m.updated_at = nil
  29150. }
  29151. // SetDeletedAt sets the "deleted_at" field.
  29152. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  29153. m.deleted_at = &t
  29154. }
  29155. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29156. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  29157. v := m.deleted_at
  29158. if v == nil {
  29159. return
  29160. }
  29161. return *v, true
  29162. }
  29163. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  29164. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29166. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29167. if !m.op.Is(OpUpdateOne) {
  29168. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29169. }
  29170. if m.id == nil || m.oldValue == nil {
  29171. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29172. }
  29173. oldValue, err := m.oldValue(ctx)
  29174. if err != nil {
  29175. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29176. }
  29177. return oldValue.DeletedAt, nil
  29178. }
  29179. // ClearDeletedAt clears the value of the "deleted_at" field.
  29180. func (m *TokenMutation) ClearDeletedAt() {
  29181. m.deleted_at = nil
  29182. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  29183. }
  29184. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29185. func (m *TokenMutation) DeletedAtCleared() bool {
  29186. _, ok := m.clearedFields[token.FieldDeletedAt]
  29187. return ok
  29188. }
  29189. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29190. func (m *TokenMutation) ResetDeletedAt() {
  29191. m.deleted_at = nil
  29192. delete(m.clearedFields, token.FieldDeletedAt)
  29193. }
  29194. // SetExpireAt sets the "expire_at" field.
  29195. func (m *TokenMutation) SetExpireAt(t time.Time) {
  29196. m.expire_at = &t
  29197. }
  29198. // ExpireAt returns the value of the "expire_at" field in the mutation.
  29199. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  29200. v := m.expire_at
  29201. if v == nil {
  29202. return
  29203. }
  29204. return *v, true
  29205. }
  29206. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  29207. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29209. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  29210. if !m.op.Is(OpUpdateOne) {
  29211. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  29212. }
  29213. if m.id == nil || m.oldValue == nil {
  29214. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  29215. }
  29216. oldValue, err := m.oldValue(ctx)
  29217. if err != nil {
  29218. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  29219. }
  29220. return oldValue.ExpireAt, nil
  29221. }
  29222. // ClearExpireAt clears the value of the "expire_at" field.
  29223. func (m *TokenMutation) ClearExpireAt() {
  29224. m.expire_at = nil
  29225. m.clearedFields[token.FieldExpireAt] = struct{}{}
  29226. }
  29227. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  29228. func (m *TokenMutation) ExpireAtCleared() bool {
  29229. _, ok := m.clearedFields[token.FieldExpireAt]
  29230. return ok
  29231. }
  29232. // ResetExpireAt resets all changes to the "expire_at" field.
  29233. func (m *TokenMutation) ResetExpireAt() {
  29234. m.expire_at = nil
  29235. delete(m.clearedFields, token.FieldExpireAt)
  29236. }
  29237. // SetToken sets the "token" field.
  29238. func (m *TokenMutation) SetToken(s string) {
  29239. m.token = &s
  29240. }
  29241. // Token returns the value of the "token" field in the mutation.
  29242. func (m *TokenMutation) Token() (r string, exists bool) {
  29243. v := m.token
  29244. if v == nil {
  29245. return
  29246. }
  29247. return *v, true
  29248. }
  29249. // OldToken returns the old "token" field's value of the Token entity.
  29250. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29252. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  29253. if !m.op.Is(OpUpdateOne) {
  29254. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  29255. }
  29256. if m.id == nil || m.oldValue == nil {
  29257. return v, errors.New("OldToken requires an ID field in the mutation")
  29258. }
  29259. oldValue, err := m.oldValue(ctx)
  29260. if err != nil {
  29261. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  29262. }
  29263. return oldValue.Token, nil
  29264. }
  29265. // ClearToken clears the value of the "token" field.
  29266. func (m *TokenMutation) ClearToken() {
  29267. m.token = nil
  29268. m.clearedFields[token.FieldToken] = struct{}{}
  29269. }
  29270. // TokenCleared returns if the "token" field was cleared in this mutation.
  29271. func (m *TokenMutation) TokenCleared() bool {
  29272. _, ok := m.clearedFields[token.FieldToken]
  29273. return ok
  29274. }
  29275. // ResetToken resets all changes to the "token" field.
  29276. func (m *TokenMutation) ResetToken() {
  29277. m.token = nil
  29278. delete(m.clearedFields, token.FieldToken)
  29279. }
  29280. // SetMAC sets the "mac" field.
  29281. func (m *TokenMutation) SetMAC(s string) {
  29282. m.mac = &s
  29283. }
  29284. // MAC returns the value of the "mac" field in the mutation.
  29285. func (m *TokenMutation) MAC() (r string, exists bool) {
  29286. v := m.mac
  29287. if v == nil {
  29288. return
  29289. }
  29290. return *v, true
  29291. }
  29292. // OldMAC returns the old "mac" field's value of the Token entity.
  29293. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29295. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  29296. if !m.op.Is(OpUpdateOne) {
  29297. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  29298. }
  29299. if m.id == nil || m.oldValue == nil {
  29300. return v, errors.New("OldMAC requires an ID field in the mutation")
  29301. }
  29302. oldValue, err := m.oldValue(ctx)
  29303. if err != nil {
  29304. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  29305. }
  29306. return oldValue.MAC, nil
  29307. }
  29308. // ClearMAC clears the value of the "mac" field.
  29309. func (m *TokenMutation) ClearMAC() {
  29310. m.mac = nil
  29311. m.clearedFields[token.FieldMAC] = struct{}{}
  29312. }
  29313. // MACCleared returns if the "mac" field was cleared in this mutation.
  29314. func (m *TokenMutation) MACCleared() bool {
  29315. _, ok := m.clearedFields[token.FieldMAC]
  29316. return ok
  29317. }
  29318. // ResetMAC resets all changes to the "mac" field.
  29319. func (m *TokenMutation) ResetMAC() {
  29320. m.mac = nil
  29321. delete(m.clearedFields, token.FieldMAC)
  29322. }
  29323. // SetOrganizationID sets the "organization_id" field.
  29324. func (m *TokenMutation) SetOrganizationID(u uint64) {
  29325. m.organization_id = &u
  29326. m.addorganization_id = nil
  29327. }
  29328. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29329. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  29330. v := m.organization_id
  29331. if v == nil {
  29332. return
  29333. }
  29334. return *v, true
  29335. }
  29336. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  29337. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29339. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29340. if !m.op.Is(OpUpdateOne) {
  29341. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29342. }
  29343. if m.id == nil || m.oldValue == nil {
  29344. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29345. }
  29346. oldValue, err := m.oldValue(ctx)
  29347. if err != nil {
  29348. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29349. }
  29350. return oldValue.OrganizationID, nil
  29351. }
  29352. // AddOrganizationID adds u to the "organization_id" field.
  29353. func (m *TokenMutation) AddOrganizationID(u int64) {
  29354. if m.addorganization_id != nil {
  29355. *m.addorganization_id += u
  29356. } else {
  29357. m.addorganization_id = &u
  29358. }
  29359. }
  29360. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29361. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  29362. v := m.addorganization_id
  29363. if v == nil {
  29364. return
  29365. }
  29366. return *v, true
  29367. }
  29368. // ResetOrganizationID resets all changes to the "organization_id" field.
  29369. func (m *TokenMutation) ResetOrganizationID() {
  29370. m.organization_id = nil
  29371. m.addorganization_id = nil
  29372. }
  29373. // SetAgentID sets the "agent_id" field.
  29374. func (m *TokenMutation) SetAgentID(u uint64) {
  29375. m.agent = &u
  29376. }
  29377. // AgentID returns the value of the "agent_id" field in the mutation.
  29378. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  29379. v := m.agent
  29380. if v == nil {
  29381. return
  29382. }
  29383. return *v, true
  29384. }
  29385. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  29386. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29388. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  29389. if !m.op.Is(OpUpdateOne) {
  29390. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  29391. }
  29392. if m.id == nil || m.oldValue == nil {
  29393. return v, errors.New("OldAgentID requires an ID field in the mutation")
  29394. }
  29395. oldValue, err := m.oldValue(ctx)
  29396. if err != nil {
  29397. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  29398. }
  29399. return oldValue.AgentID, nil
  29400. }
  29401. // ResetAgentID resets all changes to the "agent_id" field.
  29402. func (m *TokenMutation) ResetAgentID() {
  29403. m.agent = nil
  29404. }
  29405. // SetCustomAgentBase sets the "custom_agent_base" field.
  29406. func (m *TokenMutation) SetCustomAgentBase(s string) {
  29407. m.custom_agent_base = &s
  29408. }
  29409. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  29410. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  29411. v := m.custom_agent_base
  29412. if v == nil {
  29413. return
  29414. }
  29415. return *v, true
  29416. }
  29417. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  29418. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29420. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  29421. if !m.op.Is(OpUpdateOne) {
  29422. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  29423. }
  29424. if m.id == nil || m.oldValue == nil {
  29425. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  29426. }
  29427. oldValue, err := m.oldValue(ctx)
  29428. if err != nil {
  29429. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  29430. }
  29431. return oldValue.CustomAgentBase, nil
  29432. }
  29433. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  29434. func (m *TokenMutation) ClearCustomAgentBase() {
  29435. m.custom_agent_base = nil
  29436. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  29437. }
  29438. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  29439. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  29440. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  29441. return ok
  29442. }
  29443. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  29444. func (m *TokenMutation) ResetCustomAgentBase() {
  29445. m.custom_agent_base = nil
  29446. delete(m.clearedFields, token.FieldCustomAgentBase)
  29447. }
  29448. // SetCustomAgentKey sets the "custom_agent_key" field.
  29449. func (m *TokenMutation) SetCustomAgentKey(s string) {
  29450. m.custom_agent_key = &s
  29451. }
  29452. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  29453. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  29454. v := m.custom_agent_key
  29455. if v == nil {
  29456. return
  29457. }
  29458. return *v, true
  29459. }
  29460. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  29461. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29463. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  29464. if !m.op.Is(OpUpdateOne) {
  29465. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  29466. }
  29467. if m.id == nil || m.oldValue == nil {
  29468. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  29469. }
  29470. oldValue, err := m.oldValue(ctx)
  29471. if err != nil {
  29472. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  29473. }
  29474. return oldValue.CustomAgentKey, nil
  29475. }
  29476. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  29477. func (m *TokenMutation) ClearCustomAgentKey() {
  29478. m.custom_agent_key = nil
  29479. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  29480. }
  29481. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  29482. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  29483. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  29484. return ok
  29485. }
  29486. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  29487. func (m *TokenMutation) ResetCustomAgentKey() {
  29488. m.custom_agent_key = nil
  29489. delete(m.clearedFields, token.FieldCustomAgentKey)
  29490. }
  29491. // SetOpenaiBase sets the "openai_base" field.
  29492. func (m *TokenMutation) SetOpenaiBase(s string) {
  29493. m.openai_base = &s
  29494. }
  29495. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  29496. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  29497. v := m.openai_base
  29498. if v == nil {
  29499. return
  29500. }
  29501. return *v, true
  29502. }
  29503. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  29504. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29506. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  29507. if !m.op.Is(OpUpdateOne) {
  29508. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  29509. }
  29510. if m.id == nil || m.oldValue == nil {
  29511. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  29512. }
  29513. oldValue, err := m.oldValue(ctx)
  29514. if err != nil {
  29515. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  29516. }
  29517. return oldValue.OpenaiBase, nil
  29518. }
  29519. // ClearOpenaiBase clears the value of the "openai_base" field.
  29520. func (m *TokenMutation) ClearOpenaiBase() {
  29521. m.openai_base = nil
  29522. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  29523. }
  29524. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  29525. func (m *TokenMutation) OpenaiBaseCleared() bool {
  29526. _, ok := m.clearedFields[token.FieldOpenaiBase]
  29527. return ok
  29528. }
  29529. // ResetOpenaiBase resets all changes to the "openai_base" field.
  29530. func (m *TokenMutation) ResetOpenaiBase() {
  29531. m.openai_base = nil
  29532. delete(m.clearedFields, token.FieldOpenaiBase)
  29533. }
  29534. // SetOpenaiKey sets the "openai_key" field.
  29535. func (m *TokenMutation) SetOpenaiKey(s string) {
  29536. m.openai_key = &s
  29537. }
  29538. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  29539. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  29540. v := m.openai_key
  29541. if v == nil {
  29542. return
  29543. }
  29544. return *v, true
  29545. }
  29546. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  29547. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29549. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  29550. if !m.op.Is(OpUpdateOne) {
  29551. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  29552. }
  29553. if m.id == nil || m.oldValue == nil {
  29554. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  29555. }
  29556. oldValue, err := m.oldValue(ctx)
  29557. if err != nil {
  29558. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  29559. }
  29560. return oldValue.OpenaiKey, nil
  29561. }
  29562. // ClearOpenaiKey clears the value of the "openai_key" field.
  29563. func (m *TokenMutation) ClearOpenaiKey() {
  29564. m.openai_key = nil
  29565. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  29566. }
  29567. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  29568. func (m *TokenMutation) OpenaiKeyCleared() bool {
  29569. _, ok := m.clearedFields[token.FieldOpenaiKey]
  29570. return ok
  29571. }
  29572. // ResetOpenaiKey resets all changes to the "openai_key" field.
  29573. func (m *TokenMutation) ResetOpenaiKey() {
  29574. m.openai_key = nil
  29575. delete(m.clearedFields, token.FieldOpenaiKey)
  29576. }
  29577. // ClearAgent clears the "agent" edge to the Agent entity.
  29578. func (m *TokenMutation) ClearAgent() {
  29579. m.clearedagent = true
  29580. m.clearedFields[token.FieldAgentID] = struct{}{}
  29581. }
  29582. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  29583. func (m *TokenMutation) AgentCleared() bool {
  29584. return m.clearedagent
  29585. }
  29586. // AgentIDs returns the "agent" edge IDs in the mutation.
  29587. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29588. // AgentID instead. It exists only for internal usage by the builders.
  29589. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  29590. if id := m.agent; id != nil {
  29591. ids = append(ids, *id)
  29592. }
  29593. return
  29594. }
  29595. // ResetAgent resets all changes to the "agent" edge.
  29596. func (m *TokenMutation) ResetAgent() {
  29597. m.agent = nil
  29598. m.clearedagent = false
  29599. }
  29600. // Where appends a list predicates to the TokenMutation builder.
  29601. func (m *TokenMutation) Where(ps ...predicate.Token) {
  29602. m.predicates = append(m.predicates, ps...)
  29603. }
  29604. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  29605. // users can use type-assertion to append predicates that do not depend on any generated package.
  29606. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  29607. p := make([]predicate.Token, len(ps))
  29608. for i := range ps {
  29609. p[i] = ps[i]
  29610. }
  29611. m.Where(p...)
  29612. }
  29613. // Op returns the operation name.
  29614. func (m *TokenMutation) Op() Op {
  29615. return m.op
  29616. }
  29617. // SetOp allows setting the mutation operation.
  29618. func (m *TokenMutation) SetOp(op Op) {
  29619. m.op = op
  29620. }
  29621. // Type returns the node type of this mutation (Token).
  29622. func (m *TokenMutation) Type() string {
  29623. return m.typ
  29624. }
  29625. // Fields returns all fields that were changed during this mutation. Note that in
  29626. // order to get all numeric fields that were incremented/decremented, call
  29627. // AddedFields().
  29628. func (m *TokenMutation) Fields() []string {
  29629. fields := make([]string, 0, 12)
  29630. if m.created_at != nil {
  29631. fields = append(fields, token.FieldCreatedAt)
  29632. }
  29633. if m.updated_at != nil {
  29634. fields = append(fields, token.FieldUpdatedAt)
  29635. }
  29636. if m.deleted_at != nil {
  29637. fields = append(fields, token.FieldDeletedAt)
  29638. }
  29639. if m.expire_at != nil {
  29640. fields = append(fields, token.FieldExpireAt)
  29641. }
  29642. if m.token != nil {
  29643. fields = append(fields, token.FieldToken)
  29644. }
  29645. if m.mac != nil {
  29646. fields = append(fields, token.FieldMAC)
  29647. }
  29648. if m.organization_id != nil {
  29649. fields = append(fields, token.FieldOrganizationID)
  29650. }
  29651. if m.agent != nil {
  29652. fields = append(fields, token.FieldAgentID)
  29653. }
  29654. if m.custom_agent_base != nil {
  29655. fields = append(fields, token.FieldCustomAgentBase)
  29656. }
  29657. if m.custom_agent_key != nil {
  29658. fields = append(fields, token.FieldCustomAgentKey)
  29659. }
  29660. if m.openai_base != nil {
  29661. fields = append(fields, token.FieldOpenaiBase)
  29662. }
  29663. if m.openai_key != nil {
  29664. fields = append(fields, token.FieldOpenaiKey)
  29665. }
  29666. return fields
  29667. }
  29668. // Field returns the value of a field with the given name. The second boolean
  29669. // return value indicates that this field was not set, or was not defined in the
  29670. // schema.
  29671. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  29672. switch name {
  29673. case token.FieldCreatedAt:
  29674. return m.CreatedAt()
  29675. case token.FieldUpdatedAt:
  29676. return m.UpdatedAt()
  29677. case token.FieldDeletedAt:
  29678. return m.DeletedAt()
  29679. case token.FieldExpireAt:
  29680. return m.ExpireAt()
  29681. case token.FieldToken:
  29682. return m.Token()
  29683. case token.FieldMAC:
  29684. return m.MAC()
  29685. case token.FieldOrganizationID:
  29686. return m.OrganizationID()
  29687. case token.FieldAgentID:
  29688. return m.AgentID()
  29689. case token.FieldCustomAgentBase:
  29690. return m.CustomAgentBase()
  29691. case token.FieldCustomAgentKey:
  29692. return m.CustomAgentKey()
  29693. case token.FieldOpenaiBase:
  29694. return m.OpenaiBase()
  29695. case token.FieldOpenaiKey:
  29696. return m.OpenaiKey()
  29697. }
  29698. return nil, false
  29699. }
  29700. // OldField returns the old value of the field from the database. An error is
  29701. // returned if the mutation operation is not UpdateOne, or the query to the
  29702. // database failed.
  29703. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29704. switch name {
  29705. case token.FieldCreatedAt:
  29706. return m.OldCreatedAt(ctx)
  29707. case token.FieldUpdatedAt:
  29708. return m.OldUpdatedAt(ctx)
  29709. case token.FieldDeletedAt:
  29710. return m.OldDeletedAt(ctx)
  29711. case token.FieldExpireAt:
  29712. return m.OldExpireAt(ctx)
  29713. case token.FieldToken:
  29714. return m.OldToken(ctx)
  29715. case token.FieldMAC:
  29716. return m.OldMAC(ctx)
  29717. case token.FieldOrganizationID:
  29718. return m.OldOrganizationID(ctx)
  29719. case token.FieldAgentID:
  29720. return m.OldAgentID(ctx)
  29721. case token.FieldCustomAgentBase:
  29722. return m.OldCustomAgentBase(ctx)
  29723. case token.FieldCustomAgentKey:
  29724. return m.OldCustomAgentKey(ctx)
  29725. case token.FieldOpenaiBase:
  29726. return m.OldOpenaiBase(ctx)
  29727. case token.FieldOpenaiKey:
  29728. return m.OldOpenaiKey(ctx)
  29729. }
  29730. return nil, fmt.Errorf("unknown Token field %s", name)
  29731. }
  29732. // SetField sets the value of a field with the given name. It returns an error if
  29733. // the field is not defined in the schema, or if the type mismatched the field
  29734. // type.
  29735. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  29736. switch name {
  29737. case token.FieldCreatedAt:
  29738. v, ok := value.(time.Time)
  29739. if !ok {
  29740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29741. }
  29742. m.SetCreatedAt(v)
  29743. return nil
  29744. case token.FieldUpdatedAt:
  29745. v, ok := value.(time.Time)
  29746. if !ok {
  29747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29748. }
  29749. m.SetUpdatedAt(v)
  29750. return nil
  29751. case token.FieldDeletedAt:
  29752. v, ok := value.(time.Time)
  29753. if !ok {
  29754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29755. }
  29756. m.SetDeletedAt(v)
  29757. return nil
  29758. case token.FieldExpireAt:
  29759. v, ok := value.(time.Time)
  29760. if !ok {
  29761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29762. }
  29763. m.SetExpireAt(v)
  29764. return nil
  29765. case token.FieldToken:
  29766. v, ok := value.(string)
  29767. if !ok {
  29768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29769. }
  29770. m.SetToken(v)
  29771. return nil
  29772. case token.FieldMAC:
  29773. v, ok := value.(string)
  29774. if !ok {
  29775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29776. }
  29777. m.SetMAC(v)
  29778. return nil
  29779. case token.FieldOrganizationID:
  29780. v, ok := value.(uint64)
  29781. if !ok {
  29782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29783. }
  29784. m.SetOrganizationID(v)
  29785. return nil
  29786. case token.FieldAgentID:
  29787. v, ok := value.(uint64)
  29788. if !ok {
  29789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29790. }
  29791. m.SetAgentID(v)
  29792. return nil
  29793. case token.FieldCustomAgentBase:
  29794. v, ok := value.(string)
  29795. if !ok {
  29796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29797. }
  29798. m.SetCustomAgentBase(v)
  29799. return nil
  29800. case token.FieldCustomAgentKey:
  29801. v, ok := value.(string)
  29802. if !ok {
  29803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29804. }
  29805. m.SetCustomAgentKey(v)
  29806. return nil
  29807. case token.FieldOpenaiBase:
  29808. v, ok := value.(string)
  29809. if !ok {
  29810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29811. }
  29812. m.SetOpenaiBase(v)
  29813. return nil
  29814. case token.FieldOpenaiKey:
  29815. v, ok := value.(string)
  29816. if !ok {
  29817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29818. }
  29819. m.SetOpenaiKey(v)
  29820. return nil
  29821. }
  29822. return fmt.Errorf("unknown Token field %s", name)
  29823. }
  29824. // AddedFields returns all numeric fields that were incremented/decremented during
  29825. // this mutation.
  29826. func (m *TokenMutation) AddedFields() []string {
  29827. var fields []string
  29828. if m.addorganization_id != nil {
  29829. fields = append(fields, token.FieldOrganizationID)
  29830. }
  29831. return fields
  29832. }
  29833. // AddedField returns the numeric value that was incremented/decremented on a field
  29834. // with the given name. The second boolean return value indicates that this field
  29835. // was not set, or was not defined in the schema.
  29836. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  29837. switch name {
  29838. case token.FieldOrganizationID:
  29839. return m.AddedOrganizationID()
  29840. }
  29841. return nil, false
  29842. }
  29843. // AddField adds the value to the field with the given name. It returns an error if
  29844. // the field is not defined in the schema, or if the type mismatched the field
  29845. // type.
  29846. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  29847. switch name {
  29848. case token.FieldOrganizationID:
  29849. v, ok := value.(int64)
  29850. if !ok {
  29851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29852. }
  29853. m.AddOrganizationID(v)
  29854. return nil
  29855. }
  29856. return fmt.Errorf("unknown Token numeric field %s", name)
  29857. }
  29858. // ClearedFields returns all nullable fields that were cleared during this
  29859. // mutation.
  29860. func (m *TokenMutation) ClearedFields() []string {
  29861. var fields []string
  29862. if m.FieldCleared(token.FieldDeletedAt) {
  29863. fields = append(fields, token.FieldDeletedAt)
  29864. }
  29865. if m.FieldCleared(token.FieldExpireAt) {
  29866. fields = append(fields, token.FieldExpireAt)
  29867. }
  29868. if m.FieldCleared(token.FieldToken) {
  29869. fields = append(fields, token.FieldToken)
  29870. }
  29871. if m.FieldCleared(token.FieldMAC) {
  29872. fields = append(fields, token.FieldMAC)
  29873. }
  29874. if m.FieldCleared(token.FieldCustomAgentBase) {
  29875. fields = append(fields, token.FieldCustomAgentBase)
  29876. }
  29877. if m.FieldCleared(token.FieldCustomAgentKey) {
  29878. fields = append(fields, token.FieldCustomAgentKey)
  29879. }
  29880. if m.FieldCleared(token.FieldOpenaiBase) {
  29881. fields = append(fields, token.FieldOpenaiBase)
  29882. }
  29883. if m.FieldCleared(token.FieldOpenaiKey) {
  29884. fields = append(fields, token.FieldOpenaiKey)
  29885. }
  29886. return fields
  29887. }
  29888. // FieldCleared returns a boolean indicating if a field with the given name was
  29889. // cleared in this mutation.
  29890. func (m *TokenMutation) FieldCleared(name string) bool {
  29891. _, ok := m.clearedFields[name]
  29892. return ok
  29893. }
  29894. // ClearField clears the value of the field with the given name. It returns an
  29895. // error if the field is not defined in the schema.
  29896. func (m *TokenMutation) ClearField(name string) error {
  29897. switch name {
  29898. case token.FieldDeletedAt:
  29899. m.ClearDeletedAt()
  29900. return nil
  29901. case token.FieldExpireAt:
  29902. m.ClearExpireAt()
  29903. return nil
  29904. case token.FieldToken:
  29905. m.ClearToken()
  29906. return nil
  29907. case token.FieldMAC:
  29908. m.ClearMAC()
  29909. return nil
  29910. case token.FieldCustomAgentBase:
  29911. m.ClearCustomAgentBase()
  29912. return nil
  29913. case token.FieldCustomAgentKey:
  29914. m.ClearCustomAgentKey()
  29915. return nil
  29916. case token.FieldOpenaiBase:
  29917. m.ClearOpenaiBase()
  29918. return nil
  29919. case token.FieldOpenaiKey:
  29920. m.ClearOpenaiKey()
  29921. return nil
  29922. }
  29923. return fmt.Errorf("unknown Token nullable field %s", name)
  29924. }
  29925. // ResetField resets all changes in the mutation for the field with the given name.
  29926. // It returns an error if the field is not defined in the schema.
  29927. func (m *TokenMutation) ResetField(name string) error {
  29928. switch name {
  29929. case token.FieldCreatedAt:
  29930. m.ResetCreatedAt()
  29931. return nil
  29932. case token.FieldUpdatedAt:
  29933. m.ResetUpdatedAt()
  29934. return nil
  29935. case token.FieldDeletedAt:
  29936. m.ResetDeletedAt()
  29937. return nil
  29938. case token.FieldExpireAt:
  29939. m.ResetExpireAt()
  29940. return nil
  29941. case token.FieldToken:
  29942. m.ResetToken()
  29943. return nil
  29944. case token.FieldMAC:
  29945. m.ResetMAC()
  29946. return nil
  29947. case token.FieldOrganizationID:
  29948. m.ResetOrganizationID()
  29949. return nil
  29950. case token.FieldAgentID:
  29951. m.ResetAgentID()
  29952. return nil
  29953. case token.FieldCustomAgentBase:
  29954. m.ResetCustomAgentBase()
  29955. return nil
  29956. case token.FieldCustomAgentKey:
  29957. m.ResetCustomAgentKey()
  29958. return nil
  29959. case token.FieldOpenaiBase:
  29960. m.ResetOpenaiBase()
  29961. return nil
  29962. case token.FieldOpenaiKey:
  29963. m.ResetOpenaiKey()
  29964. return nil
  29965. }
  29966. return fmt.Errorf("unknown Token field %s", name)
  29967. }
  29968. // AddedEdges returns all edge names that were set/added in this mutation.
  29969. func (m *TokenMutation) AddedEdges() []string {
  29970. edges := make([]string, 0, 1)
  29971. if m.agent != nil {
  29972. edges = append(edges, token.EdgeAgent)
  29973. }
  29974. return edges
  29975. }
  29976. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29977. // name in this mutation.
  29978. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  29979. switch name {
  29980. case token.EdgeAgent:
  29981. if id := m.agent; id != nil {
  29982. return []ent.Value{*id}
  29983. }
  29984. }
  29985. return nil
  29986. }
  29987. // RemovedEdges returns all edge names that were removed in this mutation.
  29988. func (m *TokenMutation) RemovedEdges() []string {
  29989. edges := make([]string, 0, 1)
  29990. return edges
  29991. }
  29992. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29993. // the given name in this mutation.
  29994. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  29995. return nil
  29996. }
  29997. // ClearedEdges returns all edge names that were cleared in this mutation.
  29998. func (m *TokenMutation) ClearedEdges() []string {
  29999. edges := make([]string, 0, 1)
  30000. if m.clearedagent {
  30001. edges = append(edges, token.EdgeAgent)
  30002. }
  30003. return edges
  30004. }
  30005. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30006. // was cleared in this mutation.
  30007. func (m *TokenMutation) EdgeCleared(name string) bool {
  30008. switch name {
  30009. case token.EdgeAgent:
  30010. return m.clearedagent
  30011. }
  30012. return false
  30013. }
  30014. // ClearEdge clears the value of the edge with the given name. It returns an error
  30015. // if that edge is not defined in the schema.
  30016. func (m *TokenMutation) ClearEdge(name string) error {
  30017. switch name {
  30018. case token.EdgeAgent:
  30019. m.ClearAgent()
  30020. return nil
  30021. }
  30022. return fmt.Errorf("unknown Token unique edge %s", name)
  30023. }
  30024. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30025. // It returns an error if the edge is not defined in the schema.
  30026. func (m *TokenMutation) ResetEdge(name string) error {
  30027. switch name {
  30028. case token.EdgeAgent:
  30029. m.ResetAgent()
  30030. return nil
  30031. }
  30032. return fmt.Errorf("unknown Token edge %s", name)
  30033. }
  30034. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  30035. type TutorialMutation struct {
  30036. config
  30037. op Op
  30038. typ string
  30039. id *uint64
  30040. created_at *time.Time
  30041. updated_at *time.Time
  30042. deleted_at *time.Time
  30043. index *int
  30044. addindex *int
  30045. title *string
  30046. content *string
  30047. organization_id *uint64
  30048. addorganization_id *int64
  30049. clearedFields map[string]struct{}
  30050. employee *uint64
  30051. clearedemployee bool
  30052. done bool
  30053. oldValue func(context.Context) (*Tutorial, error)
  30054. predicates []predicate.Tutorial
  30055. }
  30056. var _ ent.Mutation = (*TutorialMutation)(nil)
  30057. // tutorialOption allows management of the mutation configuration using functional options.
  30058. type tutorialOption func(*TutorialMutation)
  30059. // newTutorialMutation creates new mutation for the Tutorial entity.
  30060. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  30061. m := &TutorialMutation{
  30062. config: c,
  30063. op: op,
  30064. typ: TypeTutorial,
  30065. clearedFields: make(map[string]struct{}),
  30066. }
  30067. for _, opt := range opts {
  30068. opt(m)
  30069. }
  30070. return m
  30071. }
  30072. // withTutorialID sets the ID field of the mutation.
  30073. func withTutorialID(id uint64) tutorialOption {
  30074. return func(m *TutorialMutation) {
  30075. var (
  30076. err error
  30077. once sync.Once
  30078. value *Tutorial
  30079. )
  30080. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  30081. once.Do(func() {
  30082. if m.done {
  30083. err = errors.New("querying old values post mutation is not allowed")
  30084. } else {
  30085. value, err = m.Client().Tutorial.Get(ctx, id)
  30086. }
  30087. })
  30088. return value, err
  30089. }
  30090. m.id = &id
  30091. }
  30092. }
  30093. // withTutorial sets the old Tutorial of the mutation.
  30094. func withTutorial(node *Tutorial) tutorialOption {
  30095. return func(m *TutorialMutation) {
  30096. m.oldValue = func(context.Context) (*Tutorial, error) {
  30097. return node, nil
  30098. }
  30099. m.id = &node.ID
  30100. }
  30101. }
  30102. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30103. // executed in a transaction (ent.Tx), a transactional client is returned.
  30104. func (m TutorialMutation) Client() *Client {
  30105. client := &Client{config: m.config}
  30106. client.init()
  30107. return client
  30108. }
  30109. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30110. // it returns an error otherwise.
  30111. func (m TutorialMutation) Tx() (*Tx, error) {
  30112. if _, ok := m.driver.(*txDriver); !ok {
  30113. return nil, errors.New("ent: mutation is not running in a transaction")
  30114. }
  30115. tx := &Tx{config: m.config}
  30116. tx.init()
  30117. return tx, nil
  30118. }
  30119. // SetID sets the value of the id field. Note that this
  30120. // operation is only accepted on creation of Tutorial entities.
  30121. func (m *TutorialMutation) SetID(id uint64) {
  30122. m.id = &id
  30123. }
  30124. // ID returns the ID value in the mutation. Note that the ID is only available
  30125. // if it was provided to the builder or after it was returned from the database.
  30126. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  30127. if m.id == nil {
  30128. return
  30129. }
  30130. return *m.id, true
  30131. }
  30132. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30133. // That means, if the mutation is applied within a transaction with an isolation level such
  30134. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30135. // or updated by the mutation.
  30136. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  30137. switch {
  30138. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30139. id, exists := m.ID()
  30140. if exists {
  30141. return []uint64{id}, nil
  30142. }
  30143. fallthrough
  30144. case m.op.Is(OpUpdate | OpDelete):
  30145. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  30146. default:
  30147. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30148. }
  30149. }
  30150. // SetCreatedAt sets the "created_at" field.
  30151. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  30152. m.created_at = &t
  30153. }
  30154. // CreatedAt returns the value of the "created_at" field in the mutation.
  30155. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  30156. v := m.created_at
  30157. if v == nil {
  30158. return
  30159. }
  30160. return *v, true
  30161. }
  30162. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  30163. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30165. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30166. if !m.op.Is(OpUpdateOne) {
  30167. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30168. }
  30169. if m.id == nil || m.oldValue == nil {
  30170. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30171. }
  30172. oldValue, err := m.oldValue(ctx)
  30173. if err != nil {
  30174. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30175. }
  30176. return oldValue.CreatedAt, nil
  30177. }
  30178. // ResetCreatedAt resets all changes to the "created_at" field.
  30179. func (m *TutorialMutation) ResetCreatedAt() {
  30180. m.created_at = nil
  30181. }
  30182. // SetUpdatedAt sets the "updated_at" field.
  30183. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  30184. m.updated_at = &t
  30185. }
  30186. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30187. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  30188. v := m.updated_at
  30189. if v == nil {
  30190. return
  30191. }
  30192. return *v, true
  30193. }
  30194. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  30195. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30197. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30198. if !m.op.Is(OpUpdateOne) {
  30199. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30200. }
  30201. if m.id == nil || m.oldValue == nil {
  30202. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30203. }
  30204. oldValue, err := m.oldValue(ctx)
  30205. if err != nil {
  30206. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30207. }
  30208. return oldValue.UpdatedAt, nil
  30209. }
  30210. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30211. func (m *TutorialMutation) ResetUpdatedAt() {
  30212. m.updated_at = nil
  30213. }
  30214. // SetDeletedAt sets the "deleted_at" field.
  30215. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  30216. m.deleted_at = &t
  30217. }
  30218. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30219. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  30220. v := m.deleted_at
  30221. if v == nil {
  30222. return
  30223. }
  30224. return *v, true
  30225. }
  30226. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  30227. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30229. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30230. if !m.op.Is(OpUpdateOne) {
  30231. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30232. }
  30233. if m.id == nil || m.oldValue == nil {
  30234. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30235. }
  30236. oldValue, err := m.oldValue(ctx)
  30237. if err != nil {
  30238. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30239. }
  30240. return oldValue.DeletedAt, nil
  30241. }
  30242. // ClearDeletedAt clears the value of the "deleted_at" field.
  30243. func (m *TutorialMutation) ClearDeletedAt() {
  30244. m.deleted_at = nil
  30245. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  30246. }
  30247. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30248. func (m *TutorialMutation) DeletedAtCleared() bool {
  30249. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  30250. return ok
  30251. }
  30252. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30253. func (m *TutorialMutation) ResetDeletedAt() {
  30254. m.deleted_at = nil
  30255. delete(m.clearedFields, tutorial.FieldDeletedAt)
  30256. }
  30257. // SetEmployeeID sets the "employee_id" field.
  30258. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  30259. m.employee = &u
  30260. }
  30261. // EmployeeID returns the value of the "employee_id" field in the mutation.
  30262. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  30263. v := m.employee
  30264. if v == nil {
  30265. return
  30266. }
  30267. return *v, true
  30268. }
  30269. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  30270. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30272. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  30273. if !m.op.Is(OpUpdateOne) {
  30274. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  30275. }
  30276. if m.id == nil || m.oldValue == nil {
  30277. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  30278. }
  30279. oldValue, err := m.oldValue(ctx)
  30280. if err != nil {
  30281. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  30282. }
  30283. return oldValue.EmployeeID, nil
  30284. }
  30285. // ResetEmployeeID resets all changes to the "employee_id" field.
  30286. func (m *TutorialMutation) ResetEmployeeID() {
  30287. m.employee = nil
  30288. }
  30289. // SetIndex sets the "index" field.
  30290. func (m *TutorialMutation) SetIndex(i int) {
  30291. m.index = &i
  30292. m.addindex = nil
  30293. }
  30294. // Index returns the value of the "index" field in the mutation.
  30295. func (m *TutorialMutation) Index() (r int, exists bool) {
  30296. v := m.index
  30297. if v == nil {
  30298. return
  30299. }
  30300. return *v, true
  30301. }
  30302. // OldIndex returns the old "index" field's value of the Tutorial entity.
  30303. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30305. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  30306. if !m.op.Is(OpUpdateOne) {
  30307. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  30308. }
  30309. if m.id == nil || m.oldValue == nil {
  30310. return v, errors.New("OldIndex requires an ID field in the mutation")
  30311. }
  30312. oldValue, err := m.oldValue(ctx)
  30313. if err != nil {
  30314. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  30315. }
  30316. return oldValue.Index, nil
  30317. }
  30318. // AddIndex adds i to the "index" field.
  30319. func (m *TutorialMutation) AddIndex(i int) {
  30320. if m.addindex != nil {
  30321. *m.addindex += i
  30322. } else {
  30323. m.addindex = &i
  30324. }
  30325. }
  30326. // AddedIndex returns the value that was added to the "index" field in this mutation.
  30327. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  30328. v := m.addindex
  30329. if v == nil {
  30330. return
  30331. }
  30332. return *v, true
  30333. }
  30334. // ResetIndex resets all changes to the "index" field.
  30335. func (m *TutorialMutation) ResetIndex() {
  30336. m.index = nil
  30337. m.addindex = nil
  30338. }
  30339. // SetTitle sets the "title" field.
  30340. func (m *TutorialMutation) SetTitle(s string) {
  30341. m.title = &s
  30342. }
  30343. // Title returns the value of the "title" field in the mutation.
  30344. func (m *TutorialMutation) Title() (r string, exists bool) {
  30345. v := m.title
  30346. if v == nil {
  30347. return
  30348. }
  30349. return *v, true
  30350. }
  30351. // OldTitle returns the old "title" field's value of the Tutorial entity.
  30352. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30354. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  30355. if !m.op.Is(OpUpdateOne) {
  30356. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  30357. }
  30358. if m.id == nil || m.oldValue == nil {
  30359. return v, errors.New("OldTitle requires an ID field in the mutation")
  30360. }
  30361. oldValue, err := m.oldValue(ctx)
  30362. if err != nil {
  30363. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  30364. }
  30365. return oldValue.Title, nil
  30366. }
  30367. // ResetTitle resets all changes to the "title" field.
  30368. func (m *TutorialMutation) ResetTitle() {
  30369. m.title = nil
  30370. }
  30371. // SetContent sets the "content" field.
  30372. func (m *TutorialMutation) SetContent(s string) {
  30373. m.content = &s
  30374. }
  30375. // Content returns the value of the "content" field in the mutation.
  30376. func (m *TutorialMutation) Content() (r string, exists bool) {
  30377. v := m.content
  30378. if v == nil {
  30379. return
  30380. }
  30381. return *v, true
  30382. }
  30383. // OldContent returns the old "content" field's value of the Tutorial entity.
  30384. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30386. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  30387. if !m.op.Is(OpUpdateOne) {
  30388. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  30389. }
  30390. if m.id == nil || m.oldValue == nil {
  30391. return v, errors.New("OldContent requires an ID field in the mutation")
  30392. }
  30393. oldValue, err := m.oldValue(ctx)
  30394. if err != nil {
  30395. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  30396. }
  30397. return oldValue.Content, nil
  30398. }
  30399. // ResetContent resets all changes to the "content" field.
  30400. func (m *TutorialMutation) ResetContent() {
  30401. m.content = nil
  30402. }
  30403. // SetOrganizationID sets the "organization_id" field.
  30404. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  30405. m.organization_id = &u
  30406. m.addorganization_id = nil
  30407. }
  30408. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30409. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  30410. v := m.organization_id
  30411. if v == nil {
  30412. return
  30413. }
  30414. return *v, true
  30415. }
  30416. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  30417. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30419. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30420. if !m.op.Is(OpUpdateOne) {
  30421. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30422. }
  30423. if m.id == nil || m.oldValue == nil {
  30424. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30425. }
  30426. oldValue, err := m.oldValue(ctx)
  30427. if err != nil {
  30428. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30429. }
  30430. return oldValue.OrganizationID, nil
  30431. }
  30432. // AddOrganizationID adds u to the "organization_id" field.
  30433. func (m *TutorialMutation) AddOrganizationID(u int64) {
  30434. if m.addorganization_id != nil {
  30435. *m.addorganization_id += u
  30436. } else {
  30437. m.addorganization_id = &u
  30438. }
  30439. }
  30440. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30441. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  30442. v := m.addorganization_id
  30443. if v == nil {
  30444. return
  30445. }
  30446. return *v, true
  30447. }
  30448. // ResetOrganizationID resets all changes to the "organization_id" field.
  30449. func (m *TutorialMutation) ResetOrganizationID() {
  30450. m.organization_id = nil
  30451. m.addorganization_id = nil
  30452. }
  30453. // ClearEmployee clears the "employee" edge to the Employee entity.
  30454. func (m *TutorialMutation) ClearEmployee() {
  30455. m.clearedemployee = true
  30456. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  30457. }
  30458. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  30459. func (m *TutorialMutation) EmployeeCleared() bool {
  30460. return m.clearedemployee
  30461. }
  30462. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  30463. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30464. // EmployeeID instead. It exists only for internal usage by the builders.
  30465. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  30466. if id := m.employee; id != nil {
  30467. ids = append(ids, *id)
  30468. }
  30469. return
  30470. }
  30471. // ResetEmployee resets all changes to the "employee" edge.
  30472. func (m *TutorialMutation) ResetEmployee() {
  30473. m.employee = nil
  30474. m.clearedemployee = false
  30475. }
  30476. // Where appends a list predicates to the TutorialMutation builder.
  30477. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  30478. m.predicates = append(m.predicates, ps...)
  30479. }
  30480. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  30481. // users can use type-assertion to append predicates that do not depend on any generated package.
  30482. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  30483. p := make([]predicate.Tutorial, len(ps))
  30484. for i := range ps {
  30485. p[i] = ps[i]
  30486. }
  30487. m.Where(p...)
  30488. }
  30489. // Op returns the operation name.
  30490. func (m *TutorialMutation) Op() Op {
  30491. return m.op
  30492. }
  30493. // SetOp allows setting the mutation operation.
  30494. func (m *TutorialMutation) SetOp(op Op) {
  30495. m.op = op
  30496. }
  30497. // Type returns the node type of this mutation (Tutorial).
  30498. func (m *TutorialMutation) Type() string {
  30499. return m.typ
  30500. }
  30501. // Fields returns all fields that were changed during this mutation. Note that in
  30502. // order to get all numeric fields that were incremented/decremented, call
  30503. // AddedFields().
  30504. func (m *TutorialMutation) Fields() []string {
  30505. fields := make([]string, 0, 8)
  30506. if m.created_at != nil {
  30507. fields = append(fields, tutorial.FieldCreatedAt)
  30508. }
  30509. if m.updated_at != nil {
  30510. fields = append(fields, tutorial.FieldUpdatedAt)
  30511. }
  30512. if m.deleted_at != nil {
  30513. fields = append(fields, tutorial.FieldDeletedAt)
  30514. }
  30515. if m.employee != nil {
  30516. fields = append(fields, tutorial.FieldEmployeeID)
  30517. }
  30518. if m.index != nil {
  30519. fields = append(fields, tutorial.FieldIndex)
  30520. }
  30521. if m.title != nil {
  30522. fields = append(fields, tutorial.FieldTitle)
  30523. }
  30524. if m.content != nil {
  30525. fields = append(fields, tutorial.FieldContent)
  30526. }
  30527. if m.organization_id != nil {
  30528. fields = append(fields, tutorial.FieldOrganizationID)
  30529. }
  30530. return fields
  30531. }
  30532. // Field returns the value of a field with the given name. The second boolean
  30533. // return value indicates that this field was not set, or was not defined in the
  30534. // schema.
  30535. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  30536. switch name {
  30537. case tutorial.FieldCreatedAt:
  30538. return m.CreatedAt()
  30539. case tutorial.FieldUpdatedAt:
  30540. return m.UpdatedAt()
  30541. case tutorial.FieldDeletedAt:
  30542. return m.DeletedAt()
  30543. case tutorial.FieldEmployeeID:
  30544. return m.EmployeeID()
  30545. case tutorial.FieldIndex:
  30546. return m.Index()
  30547. case tutorial.FieldTitle:
  30548. return m.Title()
  30549. case tutorial.FieldContent:
  30550. return m.Content()
  30551. case tutorial.FieldOrganizationID:
  30552. return m.OrganizationID()
  30553. }
  30554. return nil, false
  30555. }
  30556. // OldField returns the old value of the field from the database. An error is
  30557. // returned if the mutation operation is not UpdateOne, or the query to the
  30558. // database failed.
  30559. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30560. switch name {
  30561. case tutorial.FieldCreatedAt:
  30562. return m.OldCreatedAt(ctx)
  30563. case tutorial.FieldUpdatedAt:
  30564. return m.OldUpdatedAt(ctx)
  30565. case tutorial.FieldDeletedAt:
  30566. return m.OldDeletedAt(ctx)
  30567. case tutorial.FieldEmployeeID:
  30568. return m.OldEmployeeID(ctx)
  30569. case tutorial.FieldIndex:
  30570. return m.OldIndex(ctx)
  30571. case tutorial.FieldTitle:
  30572. return m.OldTitle(ctx)
  30573. case tutorial.FieldContent:
  30574. return m.OldContent(ctx)
  30575. case tutorial.FieldOrganizationID:
  30576. return m.OldOrganizationID(ctx)
  30577. }
  30578. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  30579. }
  30580. // SetField sets the value of a field with the given name. It returns an error if
  30581. // the field is not defined in the schema, or if the type mismatched the field
  30582. // type.
  30583. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  30584. switch name {
  30585. case tutorial.FieldCreatedAt:
  30586. v, ok := value.(time.Time)
  30587. if !ok {
  30588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30589. }
  30590. m.SetCreatedAt(v)
  30591. return nil
  30592. case tutorial.FieldUpdatedAt:
  30593. v, ok := value.(time.Time)
  30594. if !ok {
  30595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30596. }
  30597. m.SetUpdatedAt(v)
  30598. return nil
  30599. case tutorial.FieldDeletedAt:
  30600. v, ok := value.(time.Time)
  30601. if !ok {
  30602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30603. }
  30604. m.SetDeletedAt(v)
  30605. return nil
  30606. case tutorial.FieldEmployeeID:
  30607. v, ok := value.(uint64)
  30608. if !ok {
  30609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30610. }
  30611. m.SetEmployeeID(v)
  30612. return nil
  30613. case tutorial.FieldIndex:
  30614. v, ok := value.(int)
  30615. if !ok {
  30616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30617. }
  30618. m.SetIndex(v)
  30619. return nil
  30620. case tutorial.FieldTitle:
  30621. v, ok := value.(string)
  30622. if !ok {
  30623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30624. }
  30625. m.SetTitle(v)
  30626. return nil
  30627. case tutorial.FieldContent:
  30628. v, ok := value.(string)
  30629. if !ok {
  30630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30631. }
  30632. m.SetContent(v)
  30633. return nil
  30634. case tutorial.FieldOrganizationID:
  30635. v, ok := value.(uint64)
  30636. if !ok {
  30637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30638. }
  30639. m.SetOrganizationID(v)
  30640. return nil
  30641. }
  30642. return fmt.Errorf("unknown Tutorial field %s", name)
  30643. }
  30644. // AddedFields returns all numeric fields that were incremented/decremented during
  30645. // this mutation.
  30646. func (m *TutorialMutation) AddedFields() []string {
  30647. var fields []string
  30648. if m.addindex != nil {
  30649. fields = append(fields, tutorial.FieldIndex)
  30650. }
  30651. if m.addorganization_id != nil {
  30652. fields = append(fields, tutorial.FieldOrganizationID)
  30653. }
  30654. return fields
  30655. }
  30656. // AddedField returns the numeric value that was incremented/decremented on a field
  30657. // with the given name. The second boolean return value indicates that this field
  30658. // was not set, or was not defined in the schema.
  30659. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  30660. switch name {
  30661. case tutorial.FieldIndex:
  30662. return m.AddedIndex()
  30663. case tutorial.FieldOrganizationID:
  30664. return m.AddedOrganizationID()
  30665. }
  30666. return nil, false
  30667. }
  30668. // AddField adds the value to the field with the given name. It returns an error if
  30669. // the field is not defined in the schema, or if the type mismatched the field
  30670. // type.
  30671. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  30672. switch name {
  30673. case tutorial.FieldIndex:
  30674. v, ok := value.(int)
  30675. if !ok {
  30676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30677. }
  30678. m.AddIndex(v)
  30679. return nil
  30680. case tutorial.FieldOrganizationID:
  30681. v, ok := value.(int64)
  30682. if !ok {
  30683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30684. }
  30685. m.AddOrganizationID(v)
  30686. return nil
  30687. }
  30688. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  30689. }
  30690. // ClearedFields returns all nullable fields that were cleared during this
  30691. // mutation.
  30692. func (m *TutorialMutation) ClearedFields() []string {
  30693. var fields []string
  30694. if m.FieldCleared(tutorial.FieldDeletedAt) {
  30695. fields = append(fields, tutorial.FieldDeletedAt)
  30696. }
  30697. return fields
  30698. }
  30699. // FieldCleared returns a boolean indicating if a field with the given name was
  30700. // cleared in this mutation.
  30701. func (m *TutorialMutation) FieldCleared(name string) bool {
  30702. _, ok := m.clearedFields[name]
  30703. return ok
  30704. }
  30705. // ClearField clears the value of the field with the given name. It returns an
  30706. // error if the field is not defined in the schema.
  30707. func (m *TutorialMutation) ClearField(name string) error {
  30708. switch name {
  30709. case tutorial.FieldDeletedAt:
  30710. m.ClearDeletedAt()
  30711. return nil
  30712. }
  30713. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  30714. }
  30715. // ResetField resets all changes in the mutation for the field with the given name.
  30716. // It returns an error if the field is not defined in the schema.
  30717. func (m *TutorialMutation) ResetField(name string) error {
  30718. switch name {
  30719. case tutorial.FieldCreatedAt:
  30720. m.ResetCreatedAt()
  30721. return nil
  30722. case tutorial.FieldUpdatedAt:
  30723. m.ResetUpdatedAt()
  30724. return nil
  30725. case tutorial.FieldDeletedAt:
  30726. m.ResetDeletedAt()
  30727. return nil
  30728. case tutorial.FieldEmployeeID:
  30729. m.ResetEmployeeID()
  30730. return nil
  30731. case tutorial.FieldIndex:
  30732. m.ResetIndex()
  30733. return nil
  30734. case tutorial.FieldTitle:
  30735. m.ResetTitle()
  30736. return nil
  30737. case tutorial.FieldContent:
  30738. m.ResetContent()
  30739. return nil
  30740. case tutorial.FieldOrganizationID:
  30741. m.ResetOrganizationID()
  30742. return nil
  30743. }
  30744. return fmt.Errorf("unknown Tutorial field %s", name)
  30745. }
  30746. // AddedEdges returns all edge names that were set/added in this mutation.
  30747. func (m *TutorialMutation) AddedEdges() []string {
  30748. edges := make([]string, 0, 1)
  30749. if m.employee != nil {
  30750. edges = append(edges, tutorial.EdgeEmployee)
  30751. }
  30752. return edges
  30753. }
  30754. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30755. // name in this mutation.
  30756. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  30757. switch name {
  30758. case tutorial.EdgeEmployee:
  30759. if id := m.employee; id != nil {
  30760. return []ent.Value{*id}
  30761. }
  30762. }
  30763. return nil
  30764. }
  30765. // RemovedEdges returns all edge names that were removed in this mutation.
  30766. func (m *TutorialMutation) RemovedEdges() []string {
  30767. edges := make([]string, 0, 1)
  30768. return edges
  30769. }
  30770. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30771. // the given name in this mutation.
  30772. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  30773. return nil
  30774. }
  30775. // ClearedEdges returns all edge names that were cleared in this mutation.
  30776. func (m *TutorialMutation) ClearedEdges() []string {
  30777. edges := make([]string, 0, 1)
  30778. if m.clearedemployee {
  30779. edges = append(edges, tutorial.EdgeEmployee)
  30780. }
  30781. return edges
  30782. }
  30783. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30784. // was cleared in this mutation.
  30785. func (m *TutorialMutation) EdgeCleared(name string) bool {
  30786. switch name {
  30787. case tutorial.EdgeEmployee:
  30788. return m.clearedemployee
  30789. }
  30790. return false
  30791. }
  30792. // ClearEdge clears the value of the edge with the given name. It returns an error
  30793. // if that edge is not defined in the schema.
  30794. func (m *TutorialMutation) ClearEdge(name string) error {
  30795. switch name {
  30796. case tutorial.EdgeEmployee:
  30797. m.ClearEmployee()
  30798. return nil
  30799. }
  30800. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  30801. }
  30802. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30803. // It returns an error if the edge is not defined in the schema.
  30804. func (m *TutorialMutation) ResetEdge(name string) error {
  30805. switch name {
  30806. case tutorial.EdgeEmployee:
  30807. m.ResetEmployee()
  30808. return nil
  30809. }
  30810. return fmt.Errorf("unknown Tutorial edge %s", name)
  30811. }
  30812. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  30813. type UsageDetailMutation struct {
  30814. config
  30815. op Op
  30816. typ string
  30817. id *uint64
  30818. created_at *time.Time
  30819. updated_at *time.Time
  30820. status *uint8
  30821. addstatus *int8
  30822. _type *int
  30823. add_type *int
  30824. bot_id *string
  30825. receiver_id *string
  30826. app *int
  30827. addapp *int
  30828. session_id *uint64
  30829. addsession_id *int64
  30830. request *string
  30831. response *string
  30832. original_data *custom_types.OriginalData
  30833. total_tokens *uint64
  30834. addtotal_tokens *int64
  30835. prompt_tokens *uint64
  30836. addprompt_tokens *int64
  30837. completion_tokens *uint64
  30838. addcompletion_tokens *int64
  30839. organization_id *uint64
  30840. addorganization_id *int64
  30841. clearedFields map[string]struct{}
  30842. done bool
  30843. oldValue func(context.Context) (*UsageDetail, error)
  30844. predicates []predicate.UsageDetail
  30845. }
  30846. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  30847. // usagedetailOption allows management of the mutation configuration using functional options.
  30848. type usagedetailOption func(*UsageDetailMutation)
  30849. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  30850. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  30851. m := &UsageDetailMutation{
  30852. config: c,
  30853. op: op,
  30854. typ: TypeUsageDetail,
  30855. clearedFields: make(map[string]struct{}),
  30856. }
  30857. for _, opt := range opts {
  30858. opt(m)
  30859. }
  30860. return m
  30861. }
  30862. // withUsageDetailID sets the ID field of the mutation.
  30863. func withUsageDetailID(id uint64) usagedetailOption {
  30864. return func(m *UsageDetailMutation) {
  30865. var (
  30866. err error
  30867. once sync.Once
  30868. value *UsageDetail
  30869. )
  30870. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  30871. once.Do(func() {
  30872. if m.done {
  30873. err = errors.New("querying old values post mutation is not allowed")
  30874. } else {
  30875. value, err = m.Client().UsageDetail.Get(ctx, id)
  30876. }
  30877. })
  30878. return value, err
  30879. }
  30880. m.id = &id
  30881. }
  30882. }
  30883. // withUsageDetail sets the old UsageDetail of the mutation.
  30884. func withUsageDetail(node *UsageDetail) usagedetailOption {
  30885. return func(m *UsageDetailMutation) {
  30886. m.oldValue = func(context.Context) (*UsageDetail, error) {
  30887. return node, nil
  30888. }
  30889. m.id = &node.ID
  30890. }
  30891. }
  30892. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30893. // executed in a transaction (ent.Tx), a transactional client is returned.
  30894. func (m UsageDetailMutation) Client() *Client {
  30895. client := &Client{config: m.config}
  30896. client.init()
  30897. return client
  30898. }
  30899. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30900. // it returns an error otherwise.
  30901. func (m UsageDetailMutation) Tx() (*Tx, error) {
  30902. if _, ok := m.driver.(*txDriver); !ok {
  30903. return nil, errors.New("ent: mutation is not running in a transaction")
  30904. }
  30905. tx := &Tx{config: m.config}
  30906. tx.init()
  30907. return tx, nil
  30908. }
  30909. // SetID sets the value of the id field. Note that this
  30910. // operation is only accepted on creation of UsageDetail entities.
  30911. func (m *UsageDetailMutation) SetID(id uint64) {
  30912. m.id = &id
  30913. }
  30914. // ID returns the ID value in the mutation. Note that the ID is only available
  30915. // if it was provided to the builder or after it was returned from the database.
  30916. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  30917. if m.id == nil {
  30918. return
  30919. }
  30920. return *m.id, true
  30921. }
  30922. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30923. // That means, if the mutation is applied within a transaction with an isolation level such
  30924. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30925. // or updated by the mutation.
  30926. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  30927. switch {
  30928. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30929. id, exists := m.ID()
  30930. if exists {
  30931. return []uint64{id}, nil
  30932. }
  30933. fallthrough
  30934. case m.op.Is(OpUpdate | OpDelete):
  30935. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  30936. default:
  30937. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30938. }
  30939. }
  30940. // SetCreatedAt sets the "created_at" field.
  30941. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  30942. m.created_at = &t
  30943. }
  30944. // CreatedAt returns the value of the "created_at" field in the mutation.
  30945. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  30946. v := m.created_at
  30947. if v == nil {
  30948. return
  30949. }
  30950. return *v, true
  30951. }
  30952. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  30953. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30955. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30956. if !m.op.Is(OpUpdateOne) {
  30957. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30958. }
  30959. if m.id == nil || m.oldValue == nil {
  30960. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30961. }
  30962. oldValue, err := m.oldValue(ctx)
  30963. if err != nil {
  30964. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30965. }
  30966. return oldValue.CreatedAt, nil
  30967. }
  30968. // ResetCreatedAt resets all changes to the "created_at" field.
  30969. func (m *UsageDetailMutation) ResetCreatedAt() {
  30970. m.created_at = nil
  30971. }
  30972. // SetUpdatedAt sets the "updated_at" field.
  30973. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  30974. m.updated_at = &t
  30975. }
  30976. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30977. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  30978. v := m.updated_at
  30979. if v == nil {
  30980. return
  30981. }
  30982. return *v, true
  30983. }
  30984. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  30985. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30987. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30988. if !m.op.Is(OpUpdateOne) {
  30989. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30990. }
  30991. if m.id == nil || m.oldValue == nil {
  30992. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30993. }
  30994. oldValue, err := m.oldValue(ctx)
  30995. if err != nil {
  30996. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30997. }
  30998. return oldValue.UpdatedAt, nil
  30999. }
  31000. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31001. func (m *UsageDetailMutation) ResetUpdatedAt() {
  31002. m.updated_at = nil
  31003. }
  31004. // SetStatus sets the "status" field.
  31005. func (m *UsageDetailMutation) SetStatus(u uint8) {
  31006. m.status = &u
  31007. m.addstatus = nil
  31008. }
  31009. // Status returns the value of the "status" field in the mutation.
  31010. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  31011. v := m.status
  31012. if v == nil {
  31013. return
  31014. }
  31015. return *v, true
  31016. }
  31017. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  31018. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31020. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31021. if !m.op.Is(OpUpdateOne) {
  31022. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31023. }
  31024. if m.id == nil || m.oldValue == nil {
  31025. return v, errors.New("OldStatus requires an ID field in the mutation")
  31026. }
  31027. oldValue, err := m.oldValue(ctx)
  31028. if err != nil {
  31029. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31030. }
  31031. return oldValue.Status, nil
  31032. }
  31033. // AddStatus adds u to the "status" field.
  31034. func (m *UsageDetailMutation) AddStatus(u int8) {
  31035. if m.addstatus != nil {
  31036. *m.addstatus += u
  31037. } else {
  31038. m.addstatus = &u
  31039. }
  31040. }
  31041. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31042. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  31043. v := m.addstatus
  31044. if v == nil {
  31045. return
  31046. }
  31047. return *v, true
  31048. }
  31049. // ClearStatus clears the value of the "status" field.
  31050. func (m *UsageDetailMutation) ClearStatus() {
  31051. m.status = nil
  31052. m.addstatus = nil
  31053. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  31054. }
  31055. // StatusCleared returns if the "status" field was cleared in this mutation.
  31056. func (m *UsageDetailMutation) StatusCleared() bool {
  31057. _, ok := m.clearedFields[usagedetail.FieldStatus]
  31058. return ok
  31059. }
  31060. // ResetStatus resets all changes to the "status" field.
  31061. func (m *UsageDetailMutation) ResetStatus() {
  31062. m.status = nil
  31063. m.addstatus = nil
  31064. delete(m.clearedFields, usagedetail.FieldStatus)
  31065. }
  31066. // SetType sets the "type" field.
  31067. func (m *UsageDetailMutation) SetType(i int) {
  31068. m._type = &i
  31069. m.add_type = nil
  31070. }
  31071. // GetType returns the value of the "type" field in the mutation.
  31072. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  31073. v := m._type
  31074. if v == nil {
  31075. return
  31076. }
  31077. return *v, true
  31078. }
  31079. // OldType returns the old "type" field's value of the UsageDetail entity.
  31080. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31082. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  31083. if !m.op.Is(OpUpdateOne) {
  31084. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31085. }
  31086. if m.id == nil || m.oldValue == nil {
  31087. return v, errors.New("OldType requires an ID field in the mutation")
  31088. }
  31089. oldValue, err := m.oldValue(ctx)
  31090. if err != nil {
  31091. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31092. }
  31093. return oldValue.Type, nil
  31094. }
  31095. // AddType adds i to the "type" field.
  31096. func (m *UsageDetailMutation) AddType(i int) {
  31097. if m.add_type != nil {
  31098. *m.add_type += i
  31099. } else {
  31100. m.add_type = &i
  31101. }
  31102. }
  31103. // AddedType returns the value that was added to the "type" field in this mutation.
  31104. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  31105. v := m.add_type
  31106. if v == nil {
  31107. return
  31108. }
  31109. return *v, true
  31110. }
  31111. // ClearType clears the value of the "type" field.
  31112. func (m *UsageDetailMutation) ClearType() {
  31113. m._type = nil
  31114. m.add_type = nil
  31115. m.clearedFields[usagedetail.FieldType] = struct{}{}
  31116. }
  31117. // TypeCleared returns if the "type" field was cleared in this mutation.
  31118. func (m *UsageDetailMutation) TypeCleared() bool {
  31119. _, ok := m.clearedFields[usagedetail.FieldType]
  31120. return ok
  31121. }
  31122. // ResetType resets all changes to the "type" field.
  31123. func (m *UsageDetailMutation) ResetType() {
  31124. m._type = nil
  31125. m.add_type = nil
  31126. delete(m.clearedFields, usagedetail.FieldType)
  31127. }
  31128. // SetBotID sets the "bot_id" field.
  31129. func (m *UsageDetailMutation) SetBotID(s string) {
  31130. m.bot_id = &s
  31131. }
  31132. // BotID returns the value of the "bot_id" field in the mutation.
  31133. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  31134. v := m.bot_id
  31135. if v == nil {
  31136. return
  31137. }
  31138. return *v, true
  31139. }
  31140. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  31141. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31143. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  31144. if !m.op.Is(OpUpdateOne) {
  31145. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31146. }
  31147. if m.id == nil || m.oldValue == nil {
  31148. return v, errors.New("OldBotID requires an ID field in the mutation")
  31149. }
  31150. oldValue, err := m.oldValue(ctx)
  31151. if err != nil {
  31152. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31153. }
  31154. return oldValue.BotID, nil
  31155. }
  31156. // ResetBotID resets all changes to the "bot_id" field.
  31157. func (m *UsageDetailMutation) ResetBotID() {
  31158. m.bot_id = nil
  31159. }
  31160. // SetReceiverID sets the "receiver_id" field.
  31161. func (m *UsageDetailMutation) SetReceiverID(s string) {
  31162. m.receiver_id = &s
  31163. }
  31164. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  31165. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  31166. v := m.receiver_id
  31167. if v == nil {
  31168. return
  31169. }
  31170. return *v, true
  31171. }
  31172. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  31173. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31175. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  31176. if !m.op.Is(OpUpdateOne) {
  31177. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  31178. }
  31179. if m.id == nil || m.oldValue == nil {
  31180. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  31181. }
  31182. oldValue, err := m.oldValue(ctx)
  31183. if err != nil {
  31184. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  31185. }
  31186. return oldValue.ReceiverID, nil
  31187. }
  31188. // ResetReceiverID resets all changes to the "receiver_id" field.
  31189. func (m *UsageDetailMutation) ResetReceiverID() {
  31190. m.receiver_id = nil
  31191. }
  31192. // SetApp sets the "app" field.
  31193. func (m *UsageDetailMutation) SetApp(i int) {
  31194. m.app = &i
  31195. m.addapp = nil
  31196. }
  31197. // App returns the value of the "app" field in the mutation.
  31198. func (m *UsageDetailMutation) App() (r int, exists bool) {
  31199. v := m.app
  31200. if v == nil {
  31201. return
  31202. }
  31203. return *v, true
  31204. }
  31205. // OldApp returns the old "app" field's value of the UsageDetail entity.
  31206. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31208. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  31209. if !m.op.Is(OpUpdateOne) {
  31210. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  31211. }
  31212. if m.id == nil || m.oldValue == nil {
  31213. return v, errors.New("OldApp requires an ID field in the mutation")
  31214. }
  31215. oldValue, err := m.oldValue(ctx)
  31216. if err != nil {
  31217. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  31218. }
  31219. return oldValue.App, nil
  31220. }
  31221. // AddApp adds i to the "app" field.
  31222. func (m *UsageDetailMutation) AddApp(i int) {
  31223. if m.addapp != nil {
  31224. *m.addapp += i
  31225. } else {
  31226. m.addapp = &i
  31227. }
  31228. }
  31229. // AddedApp returns the value that was added to the "app" field in this mutation.
  31230. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  31231. v := m.addapp
  31232. if v == nil {
  31233. return
  31234. }
  31235. return *v, true
  31236. }
  31237. // ClearApp clears the value of the "app" field.
  31238. func (m *UsageDetailMutation) ClearApp() {
  31239. m.app = nil
  31240. m.addapp = nil
  31241. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  31242. }
  31243. // AppCleared returns if the "app" field was cleared in this mutation.
  31244. func (m *UsageDetailMutation) AppCleared() bool {
  31245. _, ok := m.clearedFields[usagedetail.FieldApp]
  31246. return ok
  31247. }
  31248. // ResetApp resets all changes to the "app" field.
  31249. func (m *UsageDetailMutation) ResetApp() {
  31250. m.app = nil
  31251. m.addapp = nil
  31252. delete(m.clearedFields, usagedetail.FieldApp)
  31253. }
  31254. // SetSessionID sets the "session_id" field.
  31255. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  31256. m.session_id = &u
  31257. m.addsession_id = nil
  31258. }
  31259. // SessionID returns the value of the "session_id" field in the mutation.
  31260. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  31261. v := m.session_id
  31262. if v == nil {
  31263. return
  31264. }
  31265. return *v, true
  31266. }
  31267. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  31268. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31270. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  31271. if !m.op.Is(OpUpdateOne) {
  31272. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  31273. }
  31274. if m.id == nil || m.oldValue == nil {
  31275. return v, errors.New("OldSessionID requires an ID field in the mutation")
  31276. }
  31277. oldValue, err := m.oldValue(ctx)
  31278. if err != nil {
  31279. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  31280. }
  31281. return oldValue.SessionID, nil
  31282. }
  31283. // AddSessionID adds u to the "session_id" field.
  31284. func (m *UsageDetailMutation) AddSessionID(u int64) {
  31285. if m.addsession_id != nil {
  31286. *m.addsession_id += u
  31287. } else {
  31288. m.addsession_id = &u
  31289. }
  31290. }
  31291. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  31292. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  31293. v := m.addsession_id
  31294. if v == nil {
  31295. return
  31296. }
  31297. return *v, true
  31298. }
  31299. // ClearSessionID clears the value of the "session_id" field.
  31300. func (m *UsageDetailMutation) ClearSessionID() {
  31301. m.session_id = nil
  31302. m.addsession_id = nil
  31303. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  31304. }
  31305. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  31306. func (m *UsageDetailMutation) SessionIDCleared() bool {
  31307. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  31308. return ok
  31309. }
  31310. // ResetSessionID resets all changes to the "session_id" field.
  31311. func (m *UsageDetailMutation) ResetSessionID() {
  31312. m.session_id = nil
  31313. m.addsession_id = nil
  31314. delete(m.clearedFields, usagedetail.FieldSessionID)
  31315. }
  31316. // SetRequest sets the "request" field.
  31317. func (m *UsageDetailMutation) SetRequest(s string) {
  31318. m.request = &s
  31319. }
  31320. // Request returns the value of the "request" field in the mutation.
  31321. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  31322. v := m.request
  31323. if v == nil {
  31324. return
  31325. }
  31326. return *v, true
  31327. }
  31328. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  31329. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31331. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  31332. if !m.op.Is(OpUpdateOne) {
  31333. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  31334. }
  31335. if m.id == nil || m.oldValue == nil {
  31336. return v, errors.New("OldRequest requires an ID field in the mutation")
  31337. }
  31338. oldValue, err := m.oldValue(ctx)
  31339. if err != nil {
  31340. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  31341. }
  31342. return oldValue.Request, nil
  31343. }
  31344. // ResetRequest resets all changes to the "request" field.
  31345. func (m *UsageDetailMutation) ResetRequest() {
  31346. m.request = nil
  31347. }
  31348. // SetResponse sets the "response" field.
  31349. func (m *UsageDetailMutation) SetResponse(s string) {
  31350. m.response = &s
  31351. }
  31352. // Response returns the value of the "response" field in the mutation.
  31353. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  31354. v := m.response
  31355. if v == nil {
  31356. return
  31357. }
  31358. return *v, true
  31359. }
  31360. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  31361. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31363. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  31364. if !m.op.Is(OpUpdateOne) {
  31365. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  31366. }
  31367. if m.id == nil || m.oldValue == nil {
  31368. return v, errors.New("OldResponse requires an ID field in the mutation")
  31369. }
  31370. oldValue, err := m.oldValue(ctx)
  31371. if err != nil {
  31372. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  31373. }
  31374. return oldValue.Response, nil
  31375. }
  31376. // ResetResponse resets all changes to the "response" field.
  31377. func (m *UsageDetailMutation) ResetResponse() {
  31378. m.response = nil
  31379. }
  31380. // SetOriginalData sets the "original_data" field.
  31381. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  31382. m.original_data = &ctd
  31383. }
  31384. // OriginalData returns the value of the "original_data" field in the mutation.
  31385. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  31386. v := m.original_data
  31387. if v == nil {
  31388. return
  31389. }
  31390. return *v, true
  31391. }
  31392. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  31393. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31395. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  31396. if !m.op.Is(OpUpdateOne) {
  31397. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  31398. }
  31399. if m.id == nil || m.oldValue == nil {
  31400. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  31401. }
  31402. oldValue, err := m.oldValue(ctx)
  31403. if err != nil {
  31404. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  31405. }
  31406. return oldValue.OriginalData, nil
  31407. }
  31408. // ResetOriginalData resets all changes to the "original_data" field.
  31409. func (m *UsageDetailMutation) ResetOriginalData() {
  31410. m.original_data = nil
  31411. }
  31412. // SetTotalTokens sets the "total_tokens" field.
  31413. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  31414. m.total_tokens = &u
  31415. m.addtotal_tokens = nil
  31416. }
  31417. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  31418. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  31419. v := m.total_tokens
  31420. if v == nil {
  31421. return
  31422. }
  31423. return *v, true
  31424. }
  31425. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  31426. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31428. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  31429. if !m.op.Is(OpUpdateOne) {
  31430. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  31431. }
  31432. if m.id == nil || m.oldValue == nil {
  31433. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  31434. }
  31435. oldValue, err := m.oldValue(ctx)
  31436. if err != nil {
  31437. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  31438. }
  31439. return oldValue.TotalTokens, nil
  31440. }
  31441. // AddTotalTokens adds u to the "total_tokens" field.
  31442. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  31443. if m.addtotal_tokens != nil {
  31444. *m.addtotal_tokens += u
  31445. } else {
  31446. m.addtotal_tokens = &u
  31447. }
  31448. }
  31449. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  31450. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  31451. v := m.addtotal_tokens
  31452. if v == nil {
  31453. return
  31454. }
  31455. return *v, true
  31456. }
  31457. // ClearTotalTokens clears the value of the "total_tokens" field.
  31458. func (m *UsageDetailMutation) ClearTotalTokens() {
  31459. m.total_tokens = nil
  31460. m.addtotal_tokens = nil
  31461. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  31462. }
  31463. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  31464. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  31465. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  31466. return ok
  31467. }
  31468. // ResetTotalTokens resets all changes to the "total_tokens" field.
  31469. func (m *UsageDetailMutation) ResetTotalTokens() {
  31470. m.total_tokens = nil
  31471. m.addtotal_tokens = nil
  31472. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  31473. }
  31474. // SetPromptTokens sets the "prompt_tokens" field.
  31475. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  31476. m.prompt_tokens = &u
  31477. m.addprompt_tokens = nil
  31478. }
  31479. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  31480. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  31481. v := m.prompt_tokens
  31482. if v == nil {
  31483. return
  31484. }
  31485. return *v, true
  31486. }
  31487. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  31488. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31490. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  31491. if !m.op.Is(OpUpdateOne) {
  31492. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  31493. }
  31494. if m.id == nil || m.oldValue == nil {
  31495. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  31496. }
  31497. oldValue, err := m.oldValue(ctx)
  31498. if err != nil {
  31499. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  31500. }
  31501. return oldValue.PromptTokens, nil
  31502. }
  31503. // AddPromptTokens adds u to the "prompt_tokens" field.
  31504. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  31505. if m.addprompt_tokens != nil {
  31506. *m.addprompt_tokens += u
  31507. } else {
  31508. m.addprompt_tokens = &u
  31509. }
  31510. }
  31511. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  31512. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  31513. v := m.addprompt_tokens
  31514. if v == nil {
  31515. return
  31516. }
  31517. return *v, true
  31518. }
  31519. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  31520. func (m *UsageDetailMutation) ClearPromptTokens() {
  31521. m.prompt_tokens = nil
  31522. m.addprompt_tokens = nil
  31523. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  31524. }
  31525. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  31526. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  31527. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  31528. return ok
  31529. }
  31530. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  31531. func (m *UsageDetailMutation) ResetPromptTokens() {
  31532. m.prompt_tokens = nil
  31533. m.addprompt_tokens = nil
  31534. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  31535. }
  31536. // SetCompletionTokens sets the "completion_tokens" field.
  31537. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  31538. m.completion_tokens = &u
  31539. m.addcompletion_tokens = nil
  31540. }
  31541. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  31542. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  31543. v := m.completion_tokens
  31544. if v == nil {
  31545. return
  31546. }
  31547. return *v, true
  31548. }
  31549. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  31550. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31552. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  31553. if !m.op.Is(OpUpdateOne) {
  31554. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  31555. }
  31556. if m.id == nil || m.oldValue == nil {
  31557. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  31558. }
  31559. oldValue, err := m.oldValue(ctx)
  31560. if err != nil {
  31561. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  31562. }
  31563. return oldValue.CompletionTokens, nil
  31564. }
  31565. // AddCompletionTokens adds u to the "completion_tokens" field.
  31566. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  31567. if m.addcompletion_tokens != nil {
  31568. *m.addcompletion_tokens += u
  31569. } else {
  31570. m.addcompletion_tokens = &u
  31571. }
  31572. }
  31573. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  31574. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  31575. v := m.addcompletion_tokens
  31576. if v == nil {
  31577. return
  31578. }
  31579. return *v, true
  31580. }
  31581. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  31582. func (m *UsageDetailMutation) ClearCompletionTokens() {
  31583. m.completion_tokens = nil
  31584. m.addcompletion_tokens = nil
  31585. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  31586. }
  31587. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  31588. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  31589. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  31590. return ok
  31591. }
  31592. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  31593. func (m *UsageDetailMutation) ResetCompletionTokens() {
  31594. m.completion_tokens = nil
  31595. m.addcompletion_tokens = nil
  31596. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  31597. }
  31598. // SetOrganizationID sets the "organization_id" field.
  31599. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  31600. m.organization_id = &u
  31601. m.addorganization_id = nil
  31602. }
  31603. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31604. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  31605. v := m.organization_id
  31606. if v == nil {
  31607. return
  31608. }
  31609. return *v, true
  31610. }
  31611. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  31612. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31614. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31615. if !m.op.Is(OpUpdateOne) {
  31616. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31617. }
  31618. if m.id == nil || m.oldValue == nil {
  31619. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31620. }
  31621. oldValue, err := m.oldValue(ctx)
  31622. if err != nil {
  31623. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31624. }
  31625. return oldValue.OrganizationID, nil
  31626. }
  31627. // AddOrganizationID adds u to the "organization_id" field.
  31628. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  31629. if m.addorganization_id != nil {
  31630. *m.addorganization_id += u
  31631. } else {
  31632. m.addorganization_id = &u
  31633. }
  31634. }
  31635. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31636. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  31637. v := m.addorganization_id
  31638. if v == nil {
  31639. return
  31640. }
  31641. return *v, true
  31642. }
  31643. // ClearOrganizationID clears the value of the "organization_id" field.
  31644. func (m *UsageDetailMutation) ClearOrganizationID() {
  31645. m.organization_id = nil
  31646. m.addorganization_id = nil
  31647. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  31648. }
  31649. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31650. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  31651. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  31652. return ok
  31653. }
  31654. // ResetOrganizationID resets all changes to the "organization_id" field.
  31655. func (m *UsageDetailMutation) ResetOrganizationID() {
  31656. m.organization_id = nil
  31657. m.addorganization_id = nil
  31658. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  31659. }
  31660. // Where appends a list predicates to the UsageDetailMutation builder.
  31661. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  31662. m.predicates = append(m.predicates, ps...)
  31663. }
  31664. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  31665. // users can use type-assertion to append predicates that do not depend on any generated package.
  31666. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  31667. p := make([]predicate.UsageDetail, len(ps))
  31668. for i := range ps {
  31669. p[i] = ps[i]
  31670. }
  31671. m.Where(p...)
  31672. }
  31673. // Op returns the operation name.
  31674. func (m *UsageDetailMutation) Op() Op {
  31675. return m.op
  31676. }
  31677. // SetOp allows setting the mutation operation.
  31678. func (m *UsageDetailMutation) SetOp(op Op) {
  31679. m.op = op
  31680. }
  31681. // Type returns the node type of this mutation (UsageDetail).
  31682. func (m *UsageDetailMutation) Type() string {
  31683. return m.typ
  31684. }
  31685. // Fields returns all fields that were changed during this mutation. Note that in
  31686. // order to get all numeric fields that were incremented/decremented, call
  31687. // AddedFields().
  31688. func (m *UsageDetailMutation) Fields() []string {
  31689. fields := make([]string, 0, 15)
  31690. if m.created_at != nil {
  31691. fields = append(fields, usagedetail.FieldCreatedAt)
  31692. }
  31693. if m.updated_at != nil {
  31694. fields = append(fields, usagedetail.FieldUpdatedAt)
  31695. }
  31696. if m.status != nil {
  31697. fields = append(fields, usagedetail.FieldStatus)
  31698. }
  31699. if m._type != nil {
  31700. fields = append(fields, usagedetail.FieldType)
  31701. }
  31702. if m.bot_id != nil {
  31703. fields = append(fields, usagedetail.FieldBotID)
  31704. }
  31705. if m.receiver_id != nil {
  31706. fields = append(fields, usagedetail.FieldReceiverID)
  31707. }
  31708. if m.app != nil {
  31709. fields = append(fields, usagedetail.FieldApp)
  31710. }
  31711. if m.session_id != nil {
  31712. fields = append(fields, usagedetail.FieldSessionID)
  31713. }
  31714. if m.request != nil {
  31715. fields = append(fields, usagedetail.FieldRequest)
  31716. }
  31717. if m.response != nil {
  31718. fields = append(fields, usagedetail.FieldResponse)
  31719. }
  31720. if m.original_data != nil {
  31721. fields = append(fields, usagedetail.FieldOriginalData)
  31722. }
  31723. if m.total_tokens != nil {
  31724. fields = append(fields, usagedetail.FieldTotalTokens)
  31725. }
  31726. if m.prompt_tokens != nil {
  31727. fields = append(fields, usagedetail.FieldPromptTokens)
  31728. }
  31729. if m.completion_tokens != nil {
  31730. fields = append(fields, usagedetail.FieldCompletionTokens)
  31731. }
  31732. if m.organization_id != nil {
  31733. fields = append(fields, usagedetail.FieldOrganizationID)
  31734. }
  31735. return fields
  31736. }
  31737. // Field returns the value of a field with the given name. The second boolean
  31738. // return value indicates that this field was not set, or was not defined in the
  31739. // schema.
  31740. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  31741. switch name {
  31742. case usagedetail.FieldCreatedAt:
  31743. return m.CreatedAt()
  31744. case usagedetail.FieldUpdatedAt:
  31745. return m.UpdatedAt()
  31746. case usagedetail.FieldStatus:
  31747. return m.Status()
  31748. case usagedetail.FieldType:
  31749. return m.GetType()
  31750. case usagedetail.FieldBotID:
  31751. return m.BotID()
  31752. case usagedetail.FieldReceiverID:
  31753. return m.ReceiverID()
  31754. case usagedetail.FieldApp:
  31755. return m.App()
  31756. case usagedetail.FieldSessionID:
  31757. return m.SessionID()
  31758. case usagedetail.FieldRequest:
  31759. return m.Request()
  31760. case usagedetail.FieldResponse:
  31761. return m.Response()
  31762. case usagedetail.FieldOriginalData:
  31763. return m.OriginalData()
  31764. case usagedetail.FieldTotalTokens:
  31765. return m.TotalTokens()
  31766. case usagedetail.FieldPromptTokens:
  31767. return m.PromptTokens()
  31768. case usagedetail.FieldCompletionTokens:
  31769. return m.CompletionTokens()
  31770. case usagedetail.FieldOrganizationID:
  31771. return m.OrganizationID()
  31772. }
  31773. return nil, false
  31774. }
  31775. // OldField returns the old value of the field from the database. An error is
  31776. // returned if the mutation operation is not UpdateOne, or the query to the
  31777. // database failed.
  31778. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31779. switch name {
  31780. case usagedetail.FieldCreatedAt:
  31781. return m.OldCreatedAt(ctx)
  31782. case usagedetail.FieldUpdatedAt:
  31783. return m.OldUpdatedAt(ctx)
  31784. case usagedetail.FieldStatus:
  31785. return m.OldStatus(ctx)
  31786. case usagedetail.FieldType:
  31787. return m.OldType(ctx)
  31788. case usagedetail.FieldBotID:
  31789. return m.OldBotID(ctx)
  31790. case usagedetail.FieldReceiverID:
  31791. return m.OldReceiverID(ctx)
  31792. case usagedetail.FieldApp:
  31793. return m.OldApp(ctx)
  31794. case usagedetail.FieldSessionID:
  31795. return m.OldSessionID(ctx)
  31796. case usagedetail.FieldRequest:
  31797. return m.OldRequest(ctx)
  31798. case usagedetail.FieldResponse:
  31799. return m.OldResponse(ctx)
  31800. case usagedetail.FieldOriginalData:
  31801. return m.OldOriginalData(ctx)
  31802. case usagedetail.FieldTotalTokens:
  31803. return m.OldTotalTokens(ctx)
  31804. case usagedetail.FieldPromptTokens:
  31805. return m.OldPromptTokens(ctx)
  31806. case usagedetail.FieldCompletionTokens:
  31807. return m.OldCompletionTokens(ctx)
  31808. case usagedetail.FieldOrganizationID:
  31809. return m.OldOrganizationID(ctx)
  31810. }
  31811. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  31812. }
  31813. // SetField sets the value of a field with the given name. It returns an error if
  31814. // the field is not defined in the schema, or if the type mismatched the field
  31815. // type.
  31816. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  31817. switch name {
  31818. case usagedetail.FieldCreatedAt:
  31819. v, ok := value.(time.Time)
  31820. if !ok {
  31821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31822. }
  31823. m.SetCreatedAt(v)
  31824. return nil
  31825. case usagedetail.FieldUpdatedAt:
  31826. v, ok := value.(time.Time)
  31827. if !ok {
  31828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31829. }
  31830. m.SetUpdatedAt(v)
  31831. return nil
  31832. case usagedetail.FieldStatus:
  31833. v, ok := value.(uint8)
  31834. if !ok {
  31835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31836. }
  31837. m.SetStatus(v)
  31838. return nil
  31839. case usagedetail.FieldType:
  31840. v, ok := value.(int)
  31841. if !ok {
  31842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31843. }
  31844. m.SetType(v)
  31845. return nil
  31846. case usagedetail.FieldBotID:
  31847. v, ok := value.(string)
  31848. if !ok {
  31849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31850. }
  31851. m.SetBotID(v)
  31852. return nil
  31853. case usagedetail.FieldReceiverID:
  31854. v, ok := value.(string)
  31855. if !ok {
  31856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31857. }
  31858. m.SetReceiverID(v)
  31859. return nil
  31860. case usagedetail.FieldApp:
  31861. v, ok := value.(int)
  31862. if !ok {
  31863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31864. }
  31865. m.SetApp(v)
  31866. return nil
  31867. case usagedetail.FieldSessionID:
  31868. v, ok := value.(uint64)
  31869. if !ok {
  31870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31871. }
  31872. m.SetSessionID(v)
  31873. return nil
  31874. case usagedetail.FieldRequest:
  31875. v, ok := value.(string)
  31876. if !ok {
  31877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31878. }
  31879. m.SetRequest(v)
  31880. return nil
  31881. case usagedetail.FieldResponse:
  31882. v, ok := value.(string)
  31883. if !ok {
  31884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31885. }
  31886. m.SetResponse(v)
  31887. return nil
  31888. case usagedetail.FieldOriginalData:
  31889. v, ok := value.(custom_types.OriginalData)
  31890. if !ok {
  31891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31892. }
  31893. m.SetOriginalData(v)
  31894. return nil
  31895. case usagedetail.FieldTotalTokens:
  31896. v, ok := value.(uint64)
  31897. if !ok {
  31898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31899. }
  31900. m.SetTotalTokens(v)
  31901. return nil
  31902. case usagedetail.FieldPromptTokens:
  31903. v, ok := value.(uint64)
  31904. if !ok {
  31905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31906. }
  31907. m.SetPromptTokens(v)
  31908. return nil
  31909. case usagedetail.FieldCompletionTokens:
  31910. v, ok := value.(uint64)
  31911. if !ok {
  31912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31913. }
  31914. m.SetCompletionTokens(v)
  31915. return nil
  31916. case usagedetail.FieldOrganizationID:
  31917. v, ok := value.(uint64)
  31918. if !ok {
  31919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31920. }
  31921. m.SetOrganizationID(v)
  31922. return nil
  31923. }
  31924. return fmt.Errorf("unknown UsageDetail field %s", name)
  31925. }
  31926. // AddedFields returns all numeric fields that were incremented/decremented during
  31927. // this mutation.
  31928. func (m *UsageDetailMutation) AddedFields() []string {
  31929. var fields []string
  31930. if m.addstatus != nil {
  31931. fields = append(fields, usagedetail.FieldStatus)
  31932. }
  31933. if m.add_type != nil {
  31934. fields = append(fields, usagedetail.FieldType)
  31935. }
  31936. if m.addapp != nil {
  31937. fields = append(fields, usagedetail.FieldApp)
  31938. }
  31939. if m.addsession_id != nil {
  31940. fields = append(fields, usagedetail.FieldSessionID)
  31941. }
  31942. if m.addtotal_tokens != nil {
  31943. fields = append(fields, usagedetail.FieldTotalTokens)
  31944. }
  31945. if m.addprompt_tokens != nil {
  31946. fields = append(fields, usagedetail.FieldPromptTokens)
  31947. }
  31948. if m.addcompletion_tokens != nil {
  31949. fields = append(fields, usagedetail.FieldCompletionTokens)
  31950. }
  31951. if m.addorganization_id != nil {
  31952. fields = append(fields, usagedetail.FieldOrganizationID)
  31953. }
  31954. return fields
  31955. }
  31956. // AddedField returns the numeric value that was incremented/decremented on a field
  31957. // with the given name. The second boolean return value indicates that this field
  31958. // was not set, or was not defined in the schema.
  31959. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  31960. switch name {
  31961. case usagedetail.FieldStatus:
  31962. return m.AddedStatus()
  31963. case usagedetail.FieldType:
  31964. return m.AddedType()
  31965. case usagedetail.FieldApp:
  31966. return m.AddedApp()
  31967. case usagedetail.FieldSessionID:
  31968. return m.AddedSessionID()
  31969. case usagedetail.FieldTotalTokens:
  31970. return m.AddedTotalTokens()
  31971. case usagedetail.FieldPromptTokens:
  31972. return m.AddedPromptTokens()
  31973. case usagedetail.FieldCompletionTokens:
  31974. return m.AddedCompletionTokens()
  31975. case usagedetail.FieldOrganizationID:
  31976. return m.AddedOrganizationID()
  31977. }
  31978. return nil, false
  31979. }
  31980. // AddField adds the value to the field with the given name. It returns an error if
  31981. // the field is not defined in the schema, or if the type mismatched the field
  31982. // type.
  31983. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  31984. switch name {
  31985. case usagedetail.FieldStatus:
  31986. v, ok := value.(int8)
  31987. if !ok {
  31988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31989. }
  31990. m.AddStatus(v)
  31991. return nil
  31992. case usagedetail.FieldType:
  31993. v, ok := value.(int)
  31994. if !ok {
  31995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31996. }
  31997. m.AddType(v)
  31998. return nil
  31999. case usagedetail.FieldApp:
  32000. v, ok := value.(int)
  32001. if !ok {
  32002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32003. }
  32004. m.AddApp(v)
  32005. return nil
  32006. case usagedetail.FieldSessionID:
  32007. v, ok := value.(int64)
  32008. if !ok {
  32009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32010. }
  32011. m.AddSessionID(v)
  32012. return nil
  32013. case usagedetail.FieldTotalTokens:
  32014. v, ok := value.(int64)
  32015. if !ok {
  32016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32017. }
  32018. m.AddTotalTokens(v)
  32019. return nil
  32020. case usagedetail.FieldPromptTokens:
  32021. v, ok := value.(int64)
  32022. if !ok {
  32023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32024. }
  32025. m.AddPromptTokens(v)
  32026. return nil
  32027. case usagedetail.FieldCompletionTokens:
  32028. v, ok := value.(int64)
  32029. if !ok {
  32030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32031. }
  32032. m.AddCompletionTokens(v)
  32033. return nil
  32034. case usagedetail.FieldOrganizationID:
  32035. v, ok := value.(int64)
  32036. if !ok {
  32037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32038. }
  32039. m.AddOrganizationID(v)
  32040. return nil
  32041. }
  32042. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  32043. }
  32044. // ClearedFields returns all nullable fields that were cleared during this
  32045. // mutation.
  32046. func (m *UsageDetailMutation) ClearedFields() []string {
  32047. var fields []string
  32048. if m.FieldCleared(usagedetail.FieldStatus) {
  32049. fields = append(fields, usagedetail.FieldStatus)
  32050. }
  32051. if m.FieldCleared(usagedetail.FieldType) {
  32052. fields = append(fields, usagedetail.FieldType)
  32053. }
  32054. if m.FieldCleared(usagedetail.FieldApp) {
  32055. fields = append(fields, usagedetail.FieldApp)
  32056. }
  32057. if m.FieldCleared(usagedetail.FieldSessionID) {
  32058. fields = append(fields, usagedetail.FieldSessionID)
  32059. }
  32060. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  32061. fields = append(fields, usagedetail.FieldTotalTokens)
  32062. }
  32063. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  32064. fields = append(fields, usagedetail.FieldPromptTokens)
  32065. }
  32066. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  32067. fields = append(fields, usagedetail.FieldCompletionTokens)
  32068. }
  32069. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  32070. fields = append(fields, usagedetail.FieldOrganizationID)
  32071. }
  32072. return fields
  32073. }
  32074. // FieldCleared returns a boolean indicating if a field with the given name was
  32075. // cleared in this mutation.
  32076. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  32077. _, ok := m.clearedFields[name]
  32078. return ok
  32079. }
  32080. // ClearField clears the value of the field with the given name. It returns an
  32081. // error if the field is not defined in the schema.
  32082. func (m *UsageDetailMutation) ClearField(name string) error {
  32083. switch name {
  32084. case usagedetail.FieldStatus:
  32085. m.ClearStatus()
  32086. return nil
  32087. case usagedetail.FieldType:
  32088. m.ClearType()
  32089. return nil
  32090. case usagedetail.FieldApp:
  32091. m.ClearApp()
  32092. return nil
  32093. case usagedetail.FieldSessionID:
  32094. m.ClearSessionID()
  32095. return nil
  32096. case usagedetail.FieldTotalTokens:
  32097. m.ClearTotalTokens()
  32098. return nil
  32099. case usagedetail.FieldPromptTokens:
  32100. m.ClearPromptTokens()
  32101. return nil
  32102. case usagedetail.FieldCompletionTokens:
  32103. m.ClearCompletionTokens()
  32104. return nil
  32105. case usagedetail.FieldOrganizationID:
  32106. m.ClearOrganizationID()
  32107. return nil
  32108. }
  32109. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  32110. }
  32111. // ResetField resets all changes in the mutation for the field with the given name.
  32112. // It returns an error if the field is not defined in the schema.
  32113. func (m *UsageDetailMutation) ResetField(name string) error {
  32114. switch name {
  32115. case usagedetail.FieldCreatedAt:
  32116. m.ResetCreatedAt()
  32117. return nil
  32118. case usagedetail.FieldUpdatedAt:
  32119. m.ResetUpdatedAt()
  32120. return nil
  32121. case usagedetail.FieldStatus:
  32122. m.ResetStatus()
  32123. return nil
  32124. case usagedetail.FieldType:
  32125. m.ResetType()
  32126. return nil
  32127. case usagedetail.FieldBotID:
  32128. m.ResetBotID()
  32129. return nil
  32130. case usagedetail.FieldReceiverID:
  32131. m.ResetReceiverID()
  32132. return nil
  32133. case usagedetail.FieldApp:
  32134. m.ResetApp()
  32135. return nil
  32136. case usagedetail.FieldSessionID:
  32137. m.ResetSessionID()
  32138. return nil
  32139. case usagedetail.FieldRequest:
  32140. m.ResetRequest()
  32141. return nil
  32142. case usagedetail.FieldResponse:
  32143. m.ResetResponse()
  32144. return nil
  32145. case usagedetail.FieldOriginalData:
  32146. m.ResetOriginalData()
  32147. return nil
  32148. case usagedetail.FieldTotalTokens:
  32149. m.ResetTotalTokens()
  32150. return nil
  32151. case usagedetail.FieldPromptTokens:
  32152. m.ResetPromptTokens()
  32153. return nil
  32154. case usagedetail.FieldCompletionTokens:
  32155. m.ResetCompletionTokens()
  32156. return nil
  32157. case usagedetail.FieldOrganizationID:
  32158. m.ResetOrganizationID()
  32159. return nil
  32160. }
  32161. return fmt.Errorf("unknown UsageDetail field %s", name)
  32162. }
  32163. // AddedEdges returns all edge names that were set/added in this mutation.
  32164. func (m *UsageDetailMutation) AddedEdges() []string {
  32165. edges := make([]string, 0, 0)
  32166. return edges
  32167. }
  32168. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32169. // name in this mutation.
  32170. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  32171. return nil
  32172. }
  32173. // RemovedEdges returns all edge names that were removed in this mutation.
  32174. func (m *UsageDetailMutation) RemovedEdges() []string {
  32175. edges := make([]string, 0, 0)
  32176. return edges
  32177. }
  32178. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32179. // the given name in this mutation.
  32180. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  32181. return nil
  32182. }
  32183. // ClearedEdges returns all edge names that were cleared in this mutation.
  32184. func (m *UsageDetailMutation) ClearedEdges() []string {
  32185. edges := make([]string, 0, 0)
  32186. return edges
  32187. }
  32188. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32189. // was cleared in this mutation.
  32190. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  32191. return false
  32192. }
  32193. // ClearEdge clears the value of the edge with the given name. It returns an error
  32194. // if that edge is not defined in the schema.
  32195. func (m *UsageDetailMutation) ClearEdge(name string) error {
  32196. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  32197. }
  32198. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32199. // It returns an error if the edge is not defined in the schema.
  32200. func (m *UsageDetailMutation) ResetEdge(name string) error {
  32201. return fmt.Errorf("unknown UsageDetail edge %s", name)
  32202. }
  32203. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  32204. type UsageStatisticDayMutation struct {
  32205. config
  32206. op Op
  32207. typ string
  32208. id *uint64
  32209. created_at *time.Time
  32210. updated_at *time.Time
  32211. status *uint8
  32212. addstatus *int8
  32213. deleted_at *time.Time
  32214. addtime *uint64
  32215. addaddtime *int64
  32216. _type *int
  32217. add_type *int
  32218. bot_id *string
  32219. organization_id *uint64
  32220. addorganization_id *int64
  32221. ai_response *uint64
  32222. addai_response *int64
  32223. sop_run *uint64
  32224. addsop_run *int64
  32225. total_friend *uint64
  32226. addtotal_friend *int64
  32227. total_group *uint64
  32228. addtotal_group *int64
  32229. account_balance *uint64
  32230. addaccount_balance *int64
  32231. consume_token *uint64
  32232. addconsume_token *int64
  32233. active_user *uint64
  32234. addactive_user *int64
  32235. new_user *int64
  32236. addnew_user *int64
  32237. label_dist *[]custom_types.LabelDist
  32238. appendlabel_dist []custom_types.LabelDist
  32239. clearedFields map[string]struct{}
  32240. done bool
  32241. oldValue func(context.Context) (*UsageStatisticDay, error)
  32242. predicates []predicate.UsageStatisticDay
  32243. }
  32244. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  32245. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  32246. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  32247. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  32248. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  32249. m := &UsageStatisticDayMutation{
  32250. config: c,
  32251. op: op,
  32252. typ: TypeUsageStatisticDay,
  32253. clearedFields: make(map[string]struct{}),
  32254. }
  32255. for _, opt := range opts {
  32256. opt(m)
  32257. }
  32258. return m
  32259. }
  32260. // withUsageStatisticDayID sets the ID field of the mutation.
  32261. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  32262. return func(m *UsageStatisticDayMutation) {
  32263. var (
  32264. err error
  32265. once sync.Once
  32266. value *UsageStatisticDay
  32267. )
  32268. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  32269. once.Do(func() {
  32270. if m.done {
  32271. err = errors.New("querying old values post mutation is not allowed")
  32272. } else {
  32273. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  32274. }
  32275. })
  32276. return value, err
  32277. }
  32278. m.id = &id
  32279. }
  32280. }
  32281. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  32282. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  32283. return func(m *UsageStatisticDayMutation) {
  32284. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  32285. return node, nil
  32286. }
  32287. m.id = &node.ID
  32288. }
  32289. }
  32290. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32291. // executed in a transaction (ent.Tx), a transactional client is returned.
  32292. func (m UsageStatisticDayMutation) Client() *Client {
  32293. client := &Client{config: m.config}
  32294. client.init()
  32295. return client
  32296. }
  32297. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32298. // it returns an error otherwise.
  32299. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  32300. if _, ok := m.driver.(*txDriver); !ok {
  32301. return nil, errors.New("ent: mutation is not running in a transaction")
  32302. }
  32303. tx := &Tx{config: m.config}
  32304. tx.init()
  32305. return tx, nil
  32306. }
  32307. // SetID sets the value of the id field. Note that this
  32308. // operation is only accepted on creation of UsageStatisticDay entities.
  32309. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  32310. m.id = &id
  32311. }
  32312. // ID returns the ID value in the mutation. Note that the ID is only available
  32313. // if it was provided to the builder or after it was returned from the database.
  32314. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  32315. if m.id == nil {
  32316. return
  32317. }
  32318. return *m.id, true
  32319. }
  32320. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32321. // That means, if the mutation is applied within a transaction with an isolation level such
  32322. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32323. // or updated by the mutation.
  32324. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  32325. switch {
  32326. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32327. id, exists := m.ID()
  32328. if exists {
  32329. return []uint64{id}, nil
  32330. }
  32331. fallthrough
  32332. case m.op.Is(OpUpdate | OpDelete):
  32333. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  32334. default:
  32335. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32336. }
  32337. }
  32338. // SetCreatedAt sets the "created_at" field.
  32339. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  32340. m.created_at = &t
  32341. }
  32342. // CreatedAt returns the value of the "created_at" field in the mutation.
  32343. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  32344. v := m.created_at
  32345. if v == nil {
  32346. return
  32347. }
  32348. return *v, true
  32349. }
  32350. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  32351. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32353. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32354. if !m.op.Is(OpUpdateOne) {
  32355. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32356. }
  32357. if m.id == nil || m.oldValue == nil {
  32358. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32359. }
  32360. oldValue, err := m.oldValue(ctx)
  32361. if err != nil {
  32362. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32363. }
  32364. return oldValue.CreatedAt, nil
  32365. }
  32366. // ResetCreatedAt resets all changes to the "created_at" field.
  32367. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  32368. m.created_at = nil
  32369. }
  32370. // SetUpdatedAt sets the "updated_at" field.
  32371. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  32372. m.updated_at = &t
  32373. }
  32374. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32375. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  32376. v := m.updated_at
  32377. if v == nil {
  32378. return
  32379. }
  32380. return *v, true
  32381. }
  32382. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  32383. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32385. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32386. if !m.op.Is(OpUpdateOne) {
  32387. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32388. }
  32389. if m.id == nil || m.oldValue == nil {
  32390. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32391. }
  32392. oldValue, err := m.oldValue(ctx)
  32393. if err != nil {
  32394. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32395. }
  32396. return oldValue.UpdatedAt, nil
  32397. }
  32398. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32399. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  32400. m.updated_at = nil
  32401. }
  32402. // SetStatus sets the "status" field.
  32403. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  32404. m.status = &u
  32405. m.addstatus = nil
  32406. }
  32407. // Status returns the value of the "status" field in the mutation.
  32408. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  32409. v := m.status
  32410. if v == nil {
  32411. return
  32412. }
  32413. return *v, true
  32414. }
  32415. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  32416. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32418. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32419. if !m.op.Is(OpUpdateOne) {
  32420. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32421. }
  32422. if m.id == nil || m.oldValue == nil {
  32423. return v, errors.New("OldStatus requires an ID field in the mutation")
  32424. }
  32425. oldValue, err := m.oldValue(ctx)
  32426. if err != nil {
  32427. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32428. }
  32429. return oldValue.Status, nil
  32430. }
  32431. // AddStatus adds u to the "status" field.
  32432. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  32433. if m.addstatus != nil {
  32434. *m.addstatus += u
  32435. } else {
  32436. m.addstatus = &u
  32437. }
  32438. }
  32439. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32440. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  32441. v := m.addstatus
  32442. if v == nil {
  32443. return
  32444. }
  32445. return *v, true
  32446. }
  32447. // ClearStatus clears the value of the "status" field.
  32448. func (m *UsageStatisticDayMutation) ClearStatus() {
  32449. m.status = nil
  32450. m.addstatus = nil
  32451. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  32452. }
  32453. // StatusCleared returns if the "status" field was cleared in this mutation.
  32454. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  32455. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  32456. return ok
  32457. }
  32458. // ResetStatus resets all changes to the "status" field.
  32459. func (m *UsageStatisticDayMutation) ResetStatus() {
  32460. m.status = nil
  32461. m.addstatus = nil
  32462. delete(m.clearedFields, usagestatisticday.FieldStatus)
  32463. }
  32464. // SetDeletedAt sets the "deleted_at" field.
  32465. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  32466. m.deleted_at = &t
  32467. }
  32468. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32469. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  32470. v := m.deleted_at
  32471. if v == nil {
  32472. return
  32473. }
  32474. return *v, true
  32475. }
  32476. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  32477. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32479. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32480. if !m.op.Is(OpUpdateOne) {
  32481. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32482. }
  32483. if m.id == nil || m.oldValue == nil {
  32484. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32485. }
  32486. oldValue, err := m.oldValue(ctx)
  32487. if err != nil {
  32488. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32489. }
  32490. return oldValue.DeletedAt, nil
  32491. }
  32492. // ClearDeletedAt clears the value of the "deleted_at" field.
  32493. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  32494. m.deleted_at = nil
  32495. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  32496. }
  32497. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32498. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  32499. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  32500. return ok
  32501. }
  32502. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32503. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  32504. m.deleted_at = nil
  32505. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  32506. }
  32507. // SetAddtime sets the "addtime" field.
  32508. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  32509. m.addtime = &u
  32510. m.addaddtime = nil
  32511. }
  32512. // Addtime returns the value of the "addtime" field in the mutation.
  32513. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  32514. v := m.addtime
  32515. if v == nil {
  32516. return
  32517. }
  32518. return *v, true
  32519. }
  32520. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  32521. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32523. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32524. if !m.op.Is(OpUpdateOne) {
  32525. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32526. }
  32527. if m.id == nil || m.oldValue == nil {
  32528. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32529. }
  32530. oldValue, err := m.oldValue(ctx)
  32531. if err != nil {
  32532. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32533. }
  32534. return oldValue.Addtime, nil
  32535. }
  32536. // AddAddtime adds u to the "addtime" field.
  32537. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  32538. if m.addaddtime != nil {
  32539. *m.addaddtime += u
  32540. } else {
  32541. m.addaddtime = &u
  32542. }
  32543. }
  32544. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32545. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  32546. v := m.addaddtime
  32547. if v == nil {
  32548. return
  32549. }
  32550. return *v, true
  32551. }
  32552. // ResetAddtime resets all changes to the "addtime" field.
  32553. func (m *UsageStatisticDayMutation) ResetAddtime() {
  32554. m.addtime = nil
  32555. m.addaddtime = nil
  32556. }
  32557. // SetType sets the "type" field.
  32558. func (m *UsageStatisticDayMutation) SetType(i int) {
  32559. m._type = &i
  32560. m.add_type = nil
  32561. }
  32562. // GetType returns the value of the "type" field in the mutation.
  32563. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  32564. v := m._type
  32565. if v == nil {
  32566. return
  32567. }
  32568. return *v, true
  32569. }
  32570. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  32571. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32573. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  32574. if !m.op.Is(OpUpdateOne) {
  32575. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32576. }
  32577. if m.id == nil || m.oldValue == nil {
  32578. return v, errors.New("OldType requires an ID field in the mutation")
  32579. }
  32580. oldValue, err := m.oldValue(ctx)
  32581. if err != nil {
  32582. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32583. }
  32584. return oldValue.Type, nil
  32585. }
  32586. // AddType adds i to the "type" field.
  32587. func (m *UsageStatisticDayMutation) AddType(i int) {
  32588. if m.add_type != nil {
  32589. *m.add_type += i
  32590. } else {
  32591. m.add_type = &i
  32592. }
  32593. }
  32594. // AddedType returns the value that was added to the "type" field in this mutation.
  32595. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  32596. v := m.add_type
  32597. if v == nil {
  32598. return
  32599. }
  32600. return *v, true
  32601. }
  32602. // ResetType resets all changes to the "type" field.
  32603. func (m *UsageStatisticDayMutation) ResetType() {
  32604. m._type = nil
  32605. m.add_type = nil
  32606. }
  32607. // SetBotID sets the "bot_id" field.
  32608. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  32609. m.bot_id = &s
  32610. }
  32611. // BotID returns the value of the "bot_id" field in the mutation.
  32612. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  32613. v := m.bot_id
  32614. if v == nil {
  32615. return
  32616. }
  32617. return *v, true
  32618. }
  32619. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  32620. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32622. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  32623. if !m.op.Is(OpUpdateOne) {
  32624. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32625. }
  32626. if m.id == nil || m.oldValue == nil {
  32627. return v, errors.New("OldBotID requires an ID field in the mutation")
  32628. }
  32629. oldValue, err := m.oldValue(ctx)
  32630. if err != nil {
  32631. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32632. }
  32633. return oldValue.BotID, nil
  32634. }
  32635. // ClearBotID clears the value of the "bot_id" field.
  32636. func (m *UsageStatisticDayMutation) ClearBotID() {
  32637. m.bot_id = nil
  32638. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  32639. }
  32640. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32641. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  32642. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  32643. return ok
  32644. }
  32645. // ResetBotID resets all changes to the "bot_id" field.
  32646. func (m *UsageStatisticDayMutation) ResetBotID() {
  32647. m.bot_id = nil
  32648. delete(m.clearedFields, usagestatisticday.FieldBotID)
  32649. }
  32650. // SetOrganizationID sets the "organization_id" field.
  32651. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  32652. m.organization_id = &u
  32653. m.addorganization_id = nil
  32654. }
  32655. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32656. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  32657. v := m.organization_id
  32658. if v == nil {
  32659. return
  32660. }
  32661. return *v, true
  32662. }
  32663. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  32664. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32666. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32667. if !m.op.Is(OpUpdateOne) {
  32668. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32669. }
  32670. if m.id == nil || m.oldValue == nil {
  32671. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32672. }
  32673. oldValue, err := m.oldValue(ctx)
  32674. if err != nil {
  32675. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32676. }
  32677. return oldValue.OrganizationID, nil
  32678. }
  32679. // AddOrganizationID adds u to the "organization_id" field.
  32680. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  32681. if m.addorganization_id != nil {
  32682. *m.addorganization_id += u
  32683. } else {
  32684. m.addorganization_id = &u
  32685. }
  32686. }
  32687. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32688. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  32689. v := m.addorganization_id
  32690. if v == nil {
  32691. return
  32692. }
  32693. return *v, true
  32694. }
  32695. // ClearOrganizationID clears the value of the "organization_id" field.
  32696. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  32697. m.organization_id = nil
  32698. m.addorganization_id = nil
  32699. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  32700. }
  32701. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32702. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  32703. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  32704. return ok
  32705. }
  32706. // ResetOrganizationID resets all changes to the "organization_id" field.
  32707. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  32708. m.organization_id = nil
  32709. m.addorganization_id = nil
  32710. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  32711. }
  32712. // SetAiResponse sets the "ai_response" field.
  32713. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  32714. m.ai_response = &u
  32715. m.addai_response = nil
  32716. }
  32717. // AiResponse returns the value of the "ai_response" field in the mutation.
  32718. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  32719. v := m.ai_response
  32720. if v == nil {
  32721. return
  32722. }
  32723. return *v, true
  32724. }
  32725. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  32726. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32728. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32729. if !m.op.Is(OpUpdateOne) {
  32730. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32731. }
  32732. if m.id == nil || m.oldValue == nil {
  32733. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32734. }
  32735. oldValue, err := m.oldValue(ctx)
  32736. if err != nil {
  32737. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32738. }
  32739. return oldValue.AiResponse, nil
  32740. }
  32741. // AddAiResponse adds u to the "ai_response" field.
  32742. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  32743. if m.addai_response != nil {
  32744. *m.addai_response += u
  32745. } else {
  32746. m.addai_response = &u
  32747. }
  32748. }
  32749. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32750. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  32751. v := m.addai_response
  32752. if v == nil {
  32753. return
  32754. }
  32755. return *v, true
  32756. }
  32757. // ResetAiResponse resets all changes to the "ai_response" field.
  32758. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  32759. m.ai_response = nil
  32760. m.addai_response = nil
  32761. }
  32762. // SetSopRun sets the "sop_run" field.
  32763. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  32764. m.sop_run = &u
  32765. m.addsop_run = nil
  32766. }
  32767. // SopRun returns the value of the "sop_run" field in the mutation.
  32768. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  32769. v := m.sop_run
  32770. if v == nil {
  32771. return
  32772. }
  32773. return *v, true
  32774. }
  32775. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  32776. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32778. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32779. if !m.op.Is(OpUpdateOne) {
  32780. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32781. }
  32782. if m.id == nil || m.oldValue == nil {
  32783. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32784. }
  32785. oldValue, err := m.oldValue(ctx)
  32786. if err != nil {
  32787. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32788. }
  32789. return oldValue.SopRun, nil
  32790. }
  32791. // AddSopRun adds u to the "sop_run" field.
  32792. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  32793. if m.addsop_run != nil {
  32794. *m.addsop_run += u
  32795. } else {
  32796. m.addsop_run = &u
  32797. }
  32798. }
  32799. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32800. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  32801. v := m.addsop_run
  32802. if v == nil {
  32803. return
  32804. }
  32805. return *v, true
  32806. }
  32807. // ResetSopRun resets all changes to the "sop_run" field.
  32808. func (m *UsageStatisticDayMutation) ResetSopRun() {
  32809. m.sop_run = nil
  32810. m.addsop_run = nil
  32811. }
  32812. // SetTotalFriend sets the "total_friend" field.
  32813. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  32814. m.total_friend = &u
  32815. m.addtotal_friend = nil
  32816. }
  32817. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32818. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  32819. v := m.total_friend
  32820. if v == nil {
  32821. return
  32822. }
  32823. return *v, true
  32824. }
  32825. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  32826. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32828. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32829. if !m.op.Is(OpUpdateOne) {
  32830. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32831. }
  32832. if m.id == nil || m.oldValue == nil {
  32833. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32834. }
  32835. oldValue, err := m.oldValue(ctx)
  32836. if err != nil {
  32837. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32838. }
  32839. return oldValue.TotalFriend, nil
  32840. }
  32841. // AddTotalFriend adds u to the "total_friend" field.
  32842. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  32843. if m.addtotal_friend != nil {
  32844. *m.addtotal_friend += u
  32845. } else {
  32846. m.addtotal_friend = &u
  32847. }
  32848. }
  32849. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32850. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  32851. v := m.addtotal_friend
  32852. if v == nil {
  32853. return
  32854. }
  32855. return *v, true
  32856. }
  32857. // ResetTotalFriend resets all changes to the "total_friend" field.
  32858. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  32859. m.total_friend = nil
  32860. m.addtotal_friend = nil
  32861. }
  32862. // SetTotalGroup sets the "total_group" field.
  32863. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  32864. m.total_group = &u
  32865. m.addtotal_group = nil
  32866. }
  32867. // TotalGroup returns the value of the "total_group" field in the mutation.
  32868. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  32869. v := m.total_group
  32870. if v == nil {
  32871. return
  32872. }
  32873. return *v, true
  32874. }
  32875. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  32876. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32878. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32879. if !m.op.Is(OpUpdateOne) {
  32880. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32881. }
  32882. if m.id == nil || m.oldValue == nil {
  32883. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32884. }
  32885. oldValue, err := m.oldValue(ctx)
  32886. if err != nil {
  32887. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32888. }
  32889. return oldValue.TotalGroup, nil
  32890. }
  32891. // AddTotalGroup adds u to the "total_group" field.
  32892. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  32893. if m.addtotal_group != nil {
  32894. *m.addtotal_group += u
  32895. } else {
  32896. m.addtotal_group = &u
  32897. }
  32898. }
  32899. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32900. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  32901. v := m.addtotal_group
  32902. if v == nil {
  32903. return
  32904. }
  32905. return *v, true
  32906. }
  32907. // ResetTotalGroup resets all changes to the "total_group" field.
  32908. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  32909. m.total_group = nil
  32910. m.addtotal_group = nil
  32911. }
  32912. // SetAccountBalance sets the "account_balance" field.
  32913. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  32914. m.account_balance = &u
  32915. m.addaccount_balance = nil
  32916. }
  32917. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32918. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  32919. v := m.account_balance
  32920. if v == nil {
  32921. return
  32922. }
  32923. return *v, true
  32924. }
  32925. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  32926. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32928. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32929. if !m.op.Is(OpUpdateOne) {
  32930. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32931. }
  32932. if m.id == nil || m.oldValue == nil {
  32933. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32934. }
  32935. oldValue, err := m.oldValue(ctx)
  32936. if err != nil {
  32937. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32938. }
  32939. return oldValue.AccountBalance, nil
  32940. }
  32941. // AddAccountBalance adds u to the "account_balance" field.
  32942. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  32943. if m.addaccount_balance != nil {
  32944. *m.addaccount_balance += u
  32945. } else {
  32946. m.addaccount_balance = &u
  32947. }
  32948. }
  32949. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32950. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  32951. v := m.addaccount_balance
  32952. if v == nil {
  32953. return
  32954. }
  32955. return *v, true
  32956. }
  32957. // ResetAccountBalance resets all changes to the "account_balance" field.
  32958. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  32959. m.account_balance = nil
  32960. m.addaccount_balance = nil
  32961. }
  32962. // SetConsumeToken sets the "consume_token" field.
  32963. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  32964. m.consume_token = &u
  32965. m.addconsume_token = nil
  32966. }
  32967. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32968. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  32969. v := m.consume_token
  32970. if v == nil {
  32971. return
  32972. }
  32973. return *v, true
  32974. }
  32975. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  32976. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32978. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32979. if !m.op.Is(OpUpdateOne) {
  32980. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32981. }
  32982. if m.id == nil || m.oldValue == nil {
  32983. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32984. }
  32985. oldValue, err := m.oldValue(ctx)
  32986. if err != nil {
  32987. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32988. }
  32989. return oldValue.ConsumeToken, nil
  32990. }
  32991. // AddConsumeToken adds u to the "consume_token" field.
  32992. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  32993. if m.addconsume_token != nil {
  32994. *m.addconsume_token += u
  32995. } else {
  32996. m.addconsume_token = &u
  32997. }
  32998. }
  32999. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33000. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  33001. v := m.addconsume_token
  33002. if v == nil {
  33003. return
  33004. }
  33005. return *v, true
  33006. }
  33007. // ResetConsumeToken resets all changes to the "consume_token" field.
  33008. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  33009. m.consume_token = nil
  33010. m.addconsume_token = nil
  33011. }
  33012. // SetActiveUser sets the "active_user" field.
  33013. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  33014. m.active_user = &u
  33015. m.addactive_user = nil
  33016. }
  33017. // ActiveUser returns the value of the "active_user" field in the mutation.
  33018. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  33019. v := m.active_user
  33020. if v == nil {
  33021. return
  33022. }
  33023. return *v, true
  33024. }
  33025. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  33026. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33028. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33029. if !m.op.Is(OpUpdateOne) {
  33030. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33031. }
  33032. if m.id == nil || m.oldValue == nil {
  33033. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33034. }
  33035. oldValue, err := m.oldValue(ctx)
  33036. if err != nil {
  33037. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33038. }
  33039. return oldValue.ActiveUser, nil
  33040. }
  33041. // AddActiveUser adds u to the "active_user" field.
  33042. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  33043. if m.addactive_user != nil {
  33044. *m.addactive_user += u
  33045. } else {
  33046. m.addactive_user = &u
  33047. }
  33048. }
  33049. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33050. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  33051. v := m.addactive_user
  33052. if v == nil {
  33053. return
  33054. }
  33055. return *v, true
  33056. }
  33057. // ResetActiveUser resets all changes to the "active_user" field.
  33058. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  33059. m.active_user = nil
  33060. m.addactive_user = nil
  33061. }
  33062. // SetNewUser sets the "new_user" field.
  33063. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  33064. m.new_user = &i
  33065. m.addnew_user = nil
  33066. }
  33067. // NewUser returns the value of the "new_user" field in the mutation.
  33068. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  33069. v := m.new_user
  33070. if v == nil {
  33071. return
  33072. }
  33073. return *v, true
  33074. }
  33075. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  33076. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33078. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33079. if !m.op.Is(OpUpdateOne) {
  33080. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33081. }
  33082. if m.id == nil || m.oldValue == nil {
  33083. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33084. }
  33085. oldValue, err := m.oldValue(ctx)
  33086. if err != nil {
  33087. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33088. }
  33089. return oldValue.NewUser, nil
  33090. }
  33091. // AddNewUser adds i to the "new_user" field.
  33092. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  33093. if m.addnew_user != nil {
  33094. *m.addnew_user += i
  33095. } else {
  33096. m.addnew_user = &i
  33097. }
  33098. }
  33099. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33100. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  33101. v := m.addnew_user
  33102. if v == nil {
  33103. return
  33104. }
  33105. return *v, true
  33106. }
  33107. // ResetNewUser resets all changes to the "new_user" field.
  33108. func (m *UsageStatisticDayMutation) ResetNewUser() {
  33109. m.new_user = nil
  33110. m.addnew_user = nil
  33111. }
  33112. // SetLabelDist sets the "label_dist" field.
  33113. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33114. m.label_dist = &ctd
  33115. m.appendlabel_dist = nil
  33116. }
  33117. // LabelDist returns the value of the "label_dist" field in the mutation.
  33118. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33119. v := m.label_dist
  33120. if v == nil {
  33121. return
  33122. }
  33123. return *v, true
  33124. }
  33125. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  33126. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33128. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33129. if !m.op.Is(OpUpdateOne) {
  33130. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33131. }
  33132. if m.id == nil || m.oldValue == nil {
  33133. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33134. }
  33135. oldValue, err := m.oldValue(ctx)
  33136. if err != nil {
  33137. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33138. }
  33139. return oldValue.LabelDist, nil
  33140. }
  33141. // AppendLabelDist adds ctd to the "label_dist" field.
  33142. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33143. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33144. }
  33145. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33146. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33147. if len(m.appendlabel_dist) == 0 {
  33148. return nil, false
  33149. }
  33150. return m.appendlabel_dist, true
  33151. }
  33152. // ResetLabelDist resets all changes to the "label_dist" field.
  33153. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  33154. m.label_dist = nil
  33155. m.appendlabel_dist = nil
  33156. }
  33157. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  33158. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  33159. m.predicates = append(m.predicates, ps...)
  33160. }
  33161. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  33162. // users can use type-assertion to append predicates that do not depend on any generated package.
  33163. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  33164. p := make([]predicate.UsageStatisticDay, len(ps))
  33165. for i := range ps {
  33166. p[i] = ps[i]
  33167. }
  33168. m.Where(p...)
  33169. }
  33170. // Op returns the operation name.
  33171. func (m *UsageStatisticDayMutation) Op() Op {
  33172. return m.op
  33173. }
  33174. // SetOp allows setting the mutation operation.
  33175. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  33176. m.op = op
  33177. }
  33178. // Type returns the node type of this mutation (UsageStatisticDay).
  33179. func (m *UsageStatisticDayMutation) Type() string {
  33180. return m.typ
  33181. }
  33182. // Fields returns all fields that were changed during this mutation. Note that in
  33183. // order to get all numeric fields that were incremented/decremented, call
  33184. // AddedFields().
  33185. func (m *UsageStatisticDayMutation) Fields() []string {
  33186. fields := make([]string, 0, 17)
  33187. if m.created_at != nil {
  33188. fields = append(fields, usagestatisticday.FieldCreatedAt)
  33189. }
  33190. if m.updated_at != nil {
  33191. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  33192. }
  33193. if m.status != nil {
  33194. fields = append(fields, usagestatisticday.FieldStatus)
  33195. }
  33196. if m.deleted_at != nil {
  33197. fields = append(fields, usagestatisticday.FieldDeletedAt)
  33198. }
  33199. if m.addtime != nil {
  33200. fields = append(fields, usagestatisticday.FieldAddtime)
  33201. }
  33202. if m._type != nil {
  33203. fields = append(fields, usagestatisticday.FieldType)
  33204. }
  33205. if m.bot_id != nil {
  33206. fields = append(fields, usagestatisticday.FieldBotID)
  33207. }
  33208. if m.organization_id != nil {
  33209. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33210. }
  33211. if m.ai_response != nil {
  33212. fields = append(fields, usagestatisticday.FieldAiResponse)
  33213. }
  33214. if m.sop_run != nil {
  33215. fields = append(fields, usagestatisticday.FieldSopRun)
  33216. }
  33217. if m.total_friend != nil {
  33218. fields = append(fields, usagestatisticday.FieldTotalFriend)
  33219. }
  33220. if m.total_group != nil {
  33221. fields = append(fields, usagestatisticday.FieldTotalGroup)
  33222. }
  33223. if m.account_balance != nil {
  33224. fields = append(fields, usagestatisticday.FieldAccountBalance)
  33225. }
  33226. if m.consume_token != nil {
  33227. fields = append(fields, usagestatisticday.FieldConsumeToken)
  33228. }
  33229. if m.active_user != nil {
  33230. fields = append(fields, usagestatisticday.FieldActiveUser)
  33231. }
  33232. if m.new_user != nil {
  33233. fields = append(fields, usagestatisticday.FieldNewUser)
  33234. }
  33235. if m.label_dist != nil {
  33236. fields = append(fields, usagestatisticday.FieldLabelDist)
  33237. }
  33238. return fields
  33239. }
  33240. // Field returns the value of a field with the given name. The second boolean
  33241. // return value indicates that this field was not set, or was not defined in the
  33242. // schema.
  33243. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  33244. switch name {
  33245. case usagestatisticday.FieldCreatedAt:
  33246. return m.CreatedAt()
  33247. case usagestatisticday.FieldUpdatedAt:
  33248. return m.UpdatedAt()
  33249. case usagestatisticday.FieldStatus:
  33250. return m.Status()
  33251. case usagestatisticday.FieldDeletedAt:
  33252. return m.DeletedAt()
  33253. case usagestatisticday.FieldAddtime:
  33254. return m.Addtime()
  33255. case usagestatisticday.FieldType:
  33256. return m.GetType()
  33257. case usagestatisticday.FieldBotID:
  33258. return m.BotID()
  33259. case usagestatisticday.FieldOrganizationID:
  33260. return m.OrganizationID()
  33261. case usagestatisticday.FieldAiResponse:
  33262. return m.AiResponse()
  33263. case usagestatisticday.FieldSopRun:
  33264. return m.SopRun()
  33265. case usagestatisticday.FieldTotalFriend:
  33266. return m.TotalFriend()
  33267. case usagestatisticday.FieldTotalGroup:
  33268. return m.TotalGroup()
  33269. case usagestatisticday.FieldAccountBalance:
  33270. return m.AccountBalance()
  33271. case usagestatisticday.FieldConsumeToken:
  33272. return m.ConsumeToken()
  33273. case usagestatisticday.FieldActiveUser:
  33274. return m.ActiveUser()
  33275. case usagestatisticday.FieldNewUser:
  33276. return m.NewUser()
  33277. case usagestatisticday.FieldLabelDist:
  33278. return m.LabelDist()
  33279. }
  33280. return nil, false
  33281. }
  33282. // OldField returns the old value of the field from the database. An error is
  33283. // returned if the mutation operation is not UpdateOne, or the query to the
  33284. // database failed.
  33285. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33286. switch name {
  33287. case usagestatisticday.FieldCreatedAt:
  33288. return m.OldCreatedAt(ctx)
  33289. case usagestatisticday.FieldUpdatedAt:
  33290. return m.OldUpdatedAt(ctx)
  33291. case usagestatisticday.FieldStatus:
  33292. return m.OldStatus(ctx)
  33293. case usagestatisticday.FieldDeletedAt:
  33294. return m.OldDeletedAt(ctx)
  33295. case usagestatisticday.FieldAddtime:
  33296. return m.OldAddtime(ctx)
  33297. case usagestatisticday.FieldType:
  33298. return m.OldType(ctx)
  33299. case usagestatisticday.FieldBotID:
  33300. return m.OldBotID(ctx)
  33301. case usagestatisticday.FieldOrganizationID:
  33302. return m.OldOrganizationID(ctx)
  33303. case usagestatisticday.FieldAiResponse:
  33304. return m.OldAiResponse(ctx)
  33305. case usagestatisticday.FieldSopRun:
  33306. return m.OldSopRun(ctx)
  33307. case usagestatisticday.FieldTotalFriend:
  33308. return m.OldTotalFriend(ctx)
  33309. case usagestatisticday.FieldTotalGroup:
  33310. return m.OldTotalGroup(ctx)
  33311. case usagestatisticday.FieldAccountBalance:
  33312. return m.OldAccountBalance(ctx)
  33313. case usagestatisticday.FieldConsumeToken:
  33314. return m.OldConsumeToken(ctx)
  33315. case usagestatisticday.FieldActiveUser:
  33316. return m.OldActiveUser(ctx)
  33317. case usagestatisticday.FieldNewUser:
  33318. return m.OldNewUser(ctx)
  33319. case usagestatisticday.FieldLabelDist:
  33320. return m.OldLabelDist(ctx)
  33321. }
  33322. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33323. }
  33324. // SetField sets the value of a field with the given name. It returns an error if
  33325. // the field is not defined in the schema, or if the type mismatched the field
  33326. // type.
  33327. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  33328. switch name {
  33329. case usagestatisticday.FieldCreatedAt:
  33330. v, ok := value.(time.Time)
  33331. if !ok {
  33332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33333. }
  33334. m.SetCreatedAt(v)
  33335. return nil
  33336. case usagestatisticday.FieldUpdatedAt:
  33337. v, ok := value.(time.Time)
  33338. if !ok {
  33339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33340. }
  33341. m.SetUpdatedAt(v)
  33342. return nil
  33343. case usagestatisticday.FieldStatus:
  33344. v, ok := value.(uint8)
  33345. if !ok {
  33346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33347. }
  33348. m.SetStatus(v)
  33349. return nil
  33350. case usagestatisticday.FieldDeletedAt:
  33351. v, ok := value.(time.Time)
  33352. if !ok {
  33353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33354. }
  33355. m.SetDeletedAt(v)
  33356. return nil
  33357. case usagestatisticday.FieldAddtime:
  33358. v, ok := value.(uint64)
  33359. if !ok {
  33360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33361. }
  33362. m.SetAddtime(v)
  33363. return nil
  33364. case usagestatisticday.FieldType:
  33365. v, ok := value.(int)
  33366. if !ok {
  33367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33368. }
  33369. m.SetType(v)
  33370. return nil
  33371. case usagestatisticday.FieldBotID:
  33372. v, ok := value.(string)
  33373. if !ok {
  33374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33375. }
  33376. m.SetBotID(v)
  33377. return nil
  33378. case usagestatisticday.FieldOrganizationID:
  33379. v, ok := value.(uint64)
  33380. if !ok {
  33381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33382. }
  33383. m.SetOrganizationID(v)
  33384. return nil
  33385. case usagestatisticday.FieldAiResponse:
  33386. v, ok := value.(uint64)
  33387. if !ok {
  33388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33389. }
  33390. m.SetAiResponse(v)
  33391. return nil
  33392. case usagestatisticday.FieldSopRun:
  33393. v, ok := value.(uint64)
  33394. if !ok {
  33395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33396. }
  33397. m.SetSopRun(v)
  33398. return nil
  33399. case usagestatisticday.FieldTotalFriend:
  33400. v, ok := value.(uint64)
  33401. if !ok {
  33402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33403. }
  33404. m.SetTotalFriend(v)
  33405. return nil
  33406. case usagestatisticday.FieldTotalGroup:
  33407. v, ok := value.(uint64)
  33408. if !ok {
  33409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33410. }
  33411. m.SetTotalGroup(v)
  33412. return nil
  33413. case usagestatisticday.FieldAccountBalance:
  33414. v, ok := value.(uint64)
  33415. if !ok {
  33416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33417. }
  33418. m.SetAccountBalance(v)
  33419. return nil
  33420. case usagestatisticday.FieldConsumeToken:
  33421. v, ok := value.(uint64)
  33422. if !ok {
  33423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33424. }
  33425. m.SetConsumeToken(v)
  33426. return nil
  33427. case usagestatisticday.FieldActiveUser:
  33428. v, ok := value.(uint64)
  33429. if !ok {
  33430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33431. }
  33432. m.SetActiveUser(v)
  33433. return nil
  33434. case usagestatisticday.FieldNewUser:
  33435. v, ok := value.(int64)
  33436. if !ok {
  33437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33438. }
  33439. m.SetNewUser(v)
  33440. return nil
  33441. case usagestatisticday.FieldLabelDist:
  33442. v, ok := value.([]custom_types.LabelDist)
  33443. if !ok {
  33444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33445. }
  33446. m.SetLabelDist(v)
  33447. return nil
  33448. }
  33449. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33450. }
  33451. // AddedFields returns all numeric fields that were incremented/decremented during
  33452. // this mutation.
  33453. func (m *UsageStatisticDayMutation) AddedFields() []string {
  33454. var fields []string
  33455. if m.addstatus != nil {
  33456. fields = append(fields, usagestatisticday.FieldStatus)
  33457. }
  33458. if m.addaddtime != nil {
  33459. fields = append(fields, usagestatisticday.FieldAddtime)
  33460. }
  33461. if m.add_type != nil {
  33462. fields = append(fields, usagestatisticday.FieldType)
  33463. }
  33464. if m.addorganization_id != nil {
  33465. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33466. }
  33467. if m.addai_response != nil {
  33468. fields = append(fields, usagestatisticday.FieldAiResponse)
  33469. }
  33470. if m.addsop_run != nil {
  33471. fields = append(fields, usagestatisticday.FieldSopRun)
  33472. }
  33473. if m.addtotal_friend != nil {
  33474. fields = append(fields, usagestatisticday.FieldTotalFriend)
  33475. }
  33476. if m.addtotal_group != nil {
  33477. fields = append(fields, usagestatisticday.FieldTotalGroup)
  33478. }
  33479. if m.addaccount_balance != nil {
  33480. fields = append(fields, usagestatisticday.FieldAccountBalance)
  33481. }
  33482. if m.addconsume_token != nil {
  33483. fields = append(fields, usagestatisticday.FieldConsumeToken)
  33484. }
  33485. if m.addactive_user != nil {
  33486. fields = append(fields, usagestatisticday.FieldActiveUser)
  33487. }
  33488. if m.addnew_user != nil {
  33489. fields = append(fields, usagestatisticday.FieldNewUser)
  33490. }
  33491. return fields
  33492. }
  33493. // AddedField returns the numeric value that was incremented/decremented on a field
  33494. // with the given name. The second boolean return value indicates that this field
  33495. // was not set, or was not defined in the schema.
  33496. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  33497. switch name {
  33498. case usagestatisticday.FieldStatus:
  33499. return m.AddedStatus()
  33500. case usagestatisticday.FieldAddtime:
  33501. return m.AddedAddtime()
  33502. case usagestatisticday.FieldType:
  33503. return m.AddedType()
  33504. case usagestatisticday.FieldOrganizationID:
  33505. return m.AddedOrganizationID()
  33506. case usagestatisticday.FieldAiResponse:
  33507. return m.AddedAiResponse()
  33508. case usagestatisticday.FieldSopRun:
  33509. return m.AddedSopRun()
  33510. case usagestatisticday.FieldTotalFriend:
  33511. return m.AddedTotalFriend()
  33512. case usagestatisticday.FieldTotalGroup:
  33513. return m.AddedTotalGroup()
  33514. case usagestatisticday.FieldAccountBalance:
  33515. return m.AddedAccountBalance()
  33516. case usagestatisticday.FieldConsumeToken:
  33517. return m.AddedConsumeToken()
  33518. case usagestatisticday.FieldActiveUser:
  33519. return m.AddedActiveUser()
  33520. case usagestatisticday.FieldNewUser:
  33521. return m.AddedNewUser()
  33522. }
  33523. return nil, false
  33524. }
  33525. // AddField adds the value to the field with the given name. It returns an error if
  33526. // the field is not defined in the schema, or if the type mismatched the field
  33527. // type.
  33528. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  33529. switch name {
  33530. case usagestatisticday.FieldStatus:
  33531. v, ok := value.(int8)
  33532. if !ok {
  33533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33534. }
  33535. m.AddStatus(v)
  33536. return nil
  33537. case usagestatisticday.FieldAddtime:
  33538. v, ok := value.(int64)
  33539. if !ok {
  33540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33541. }
  33542. m.AddAddtime(v)
  33543. return nil
  33544. case usagestatisticday.FieldType:
  33545. v, ok := value.(int)
  33546. if !ok {
  33547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33548. }
  33549. m.AddType(v)
  33550. return nil
  33551. case usagestatisticday.FieldOrganizationID:
  33552. v, ok := value.(int64)
  33553. if !ok {
  33554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33555. }
  33556. m.AddOrganizationID(v)
  33557. return nil
  33558. case usagestatisticday.FieldAiResponse:
  33559. v, ok := value.(int64)
  33560. if !ok {
  33561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33562. }
  33563. m.AddAiResponse(v)
  33564. return nil
  33565. case usagestatisticday.FieldSopRun:
  33566. v, ok := value.(int64)
  33567. if !ok {
  33568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33569. }
  33570. m.AddSopRun(v)
  33571. return nil
  33572. case usagestatisticday.FieldTotalFriend:
  33573. v, ok := value.(int64)
  33574. if !ok {
  33575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33576. }
  33577. m.AddTotalFriend(v)
  33578. return nil
  33579. case usagestatisticday.FieldTotalGroup:
  33580. v, ok := value.(int64)
  33581. if !ok {
  33582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33583. }
  33584. m.AddTotalGroup(v)
  33585. return nil
  33586. case usagestatisticday.FieldAccountBalance:
  33587. v, ok := value.(int64)
  33588. if !ok {
  33589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33590. }
  33591. m.AddAccountBalance(v)
  33592. return nil
  33593. case usagestatisticday.FieldConsumeToken:
  33594. v, ok := value.(int64)
  33595. if !ok {
  33596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33597. }
  33598. m.AddConsumeToken(v)
  33599. return nil
  33600. case usagestatisticday.FieldActiveUser:
  33601. v, ok := value.(int64)
  33602. if !ok {
  33603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33604. }
  33605. m.AddActiveUser(v)
  33606. return nil
  33607. case usagestatisticday.FieldNewUser:
  33608. v, ok := value.(int64)
  33609. if !ok {
  33610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33611. }
  33612. m.AddNewUser(v)
  33613. return nil
  33614. }
  33615. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  33616. }
  33617. // ClearedFields returns all nullable fields that were cleared during this
  33618. // mutation.
  33619. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  33620. var fields []string
  33621. if m.FieldCleared(usagestatisticday.FieldStatus) {
  33622. fields = append(fields, usagestatisticday.FieldStatus)
  33623. }
  33624. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  33625. fields = append(fields, usagestatisticday.FieldDeletedAt)
  33626. }
  33627. if m.FieldCleared(usagestatisticday.FieldBotID) {
  33628. fields = append(fields, usagestatisticday.FieldBotID)
  33629. }
  33630. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  33631. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33632. }
  33633. return fields
  33634. }
  33635. // FieldCleared returns a boolean indicating if a field with the given name was
  33636. // cleared in this mutation.
  33637. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  33638. _, ok := m.clearedFields[name]
  33639. return ok
  33640. }
  33641. // ClearField clears the value of the field with the given name. It returns an
  33642. // error if the field is not defined in the schema.
  33643. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  33644. switch name {
  33645. case usagestatisticday.FieldStatus:
  33646. m.ClearStatus()
  33647. return nil
  33648. case usagestatisticday.FieldDeletedAt:
  33649. m.ClearDeletedAt()
  33650. return nil
  33651. case usagestatisticday.FieldBotID:
  33652. m.ClearBotID()
  33653. return nil
  33654. case usagestatisticday.FieldOrganizationID:
  33655. m.ClearOrganizationID()
  33656. return nil
  33657. }
  33658. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  33659. }
  33660. // ResetField resets all changes in the mutation for the field with the given name.
  33661. // It returns an error if the field is not defined in the schema.
  33662. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  33663. switch name {
  33664. case usagestatisticday.FieldCreatedAt:
  33665. m.ResetCreatedAt()
  33666. return nil
  33667. case usagestatisticday.FieldUpdatedAt:
  33668. m.ResetUpdatedAt()
  33669. return nil
  33670. case usagestatisticday.FieldStatus:
  33671. m.ResetStatus()
  33672. return nil
  33673. case usagestatisticday.FieldDeletedAt:
  33674. m.ResetDeletedAt()
  33675. return nil
  33676. case usagestatisticday.FieldAddtime:
  33677. m.ResetAddtime()
  33678. return nil
  33679. case usagestatisticday.FieldType:
  33680. m.ResetType()
  33681. return nil
  33682. case usagestatisticday.FieldBotID:
  33683. m.ResetBotID()
  33684. return nil
  33685. case usagestatisticday.FieldOrganizationID:
  33686. m.ResetOrganizationID()
  33687. return nil
  33688. case usagestatisticday.FieldAiResponse:
  33689. m.ResetAiResponse()
  33690. return nil
  33691. case usagestatisticday.FieldSopRun:
  33692. m.ResetSopRun()
  33693. return nil
  33694. case usagestatisticday.FieldTotalFriend:
  33695. m.ResetTotalFriend()
  33696. return nil
  33697. case usagestatisticday.FieldTotalGroup:
  33698. m.ResetTotalGroup()
  33699. return nil
  33700. case usagestatisticday.FieldAccountBalance:
  33701. m.ResetAccountBalance()
  33702. return nil
  33703. case usagestatisticday.FieldConsumeToken:
  33704. m.ResetConsumeToken()
  33705. return nil
  33706. case usagestatisticday.FieldActiveUser:
  33707. m.ResetActiveUser()
  33708. return nil
  33709. case usagestatisticday.FieldNewUser:
  33710. m.ResetNewUser()
  33711. return nil
  33712. case usagestatisticday.FieldLabelDist:
  33713. m.ResetLabelDist()
  33714. return nil
  33715. }
  33716. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33717. }
  33718. // AddedEdges returns all edge names that were set/added in this mutation.
  33719. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  33720. edges := make([]string, 0, 0)
  33721. return edges
  33722. }
  33723. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33724. // name in this mutation.
  33725. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  33726. return nil
  33727. }
  33728. // RemovedEdges returns all edge names that were removed in this mutation.
  33729. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  33730. edges := make([]string, 0, 0)
  33731. return edges
  33732. }
  33733. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33734. // the given name in this mutation.
  33735. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  33736. return nil
  33737. }
  33738. // ClearedEdges returns all edge names that were cleared in this mutation.
  33739. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  33740. edges := make([]string, 0, 0)
  33741. return edges
  33742. }
  33743. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33744. // was cleared in this mutation.
  33745. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  33746. return false
  33747. }
  33748. // ClearEdge clears the value of the edge with the given name. It returns an error
  33749. // if that edge is not defined in the schema.
  33750. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  33751. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  33752. }
  33753. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33754. // It returns an error if the edge is not defined in the schema.
  33755. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  33756. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  33757. }
  33758. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  33759. type UsageStatisticHourMutation struct {
  33760. config
  33761. op Op
  33762. typ string
  33763. id *uint64
  33764. created_at *time.Time
  33765. updated_at *time.Time
  33766. status *uint8
  33767. addstatus *int8
  33768. deleted_at *time.Time
  33769. addtime *uint64
  33770. addaddtime *int64
  33771. _type *int
  33772. add_type *int
  33773. bot_id *string
  33774. organization_id *uint64
  33775. addorganization_id *int64
  33776. ai_response *uint64
  33777. addai_response *int64
  33778. sop_run *uint64
  33779. addsop_run *int64
  33780. total_friend *uint64
  33781. addtotal_friend *int64
  33782. total_group *uint64
  33783. addtotal_group *int64
  33784. account_balance *uint64
  33785. addaccount_balance *int64
  33786. consume_token *uint64
  33787. addconsume_token *int64
  33788. active_user *uint64
  33789. addactive_user *int64
  33790. new_user *int64
  33791. addnew_user *int64
  33792. label_dist *[]custom_types.LabelDist
  33793. appendlabel_dist []custom_types.LabelDist
  33794. clearedFields map[string]struct{}
  33795. done bool
  33796. oldValue func(context.Context) (*UsageStatisticHour, error)
  33797. predicates []predicate.UsageStatisticHour
  33798. }
  33799. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  33800. // usagestatistichourOption allows management of the mutation configuration using functional options.
  33801. type usagestatistichourOption func(*UsageStatisticHourMutation)
  33802. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  33803. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  33804. m := &UsageStatisticHourMutation{
  33805. config: c,
  33806. op: op,
  33807. typ: TypeUsageStatisticHour,
  33808. clearedFields: make(map[string]struct{}),
  33809. }
  33810. for _, opt := range opts {
  33811. opt(m)
  33812. }
  33813. return m
  33814. }
  33815. // withUsageStatisticHourID sets the ID field of the mutation.
  33816. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  33817. return func(m *UsageStatisticHourMutation) {
  33818. var (
  33819. err error
  33820. once sync.Once
  33821. value *UsageStatisticHour
  33822. )
  33823. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  33824. once.Do(func() {
  33825. if m.done {
  33826. err = errors.New("querying old values post mutation is not allowed")
  33827. } else {
  33828. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  33829. }
  33830. })
  33831. return value, err
  33832. }
  33833. m.id = &id
  33834. }
  33835. }
  33836. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  33837. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  33838. return func(m *UsageStatisticHourMutation) {
  33839. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  33840. return node, nil
  33841. }
  33842. m.id = &node.ID
  33843. }
  33844. }
  33845. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33846. // executed in a transaction (ent.Tx), a transactional client is returned.
  33847. func (m UsageStatisticHourMutation) Client() *Client {
  33848. client := &Client{config: m.config}
  33849. client.init()
  33850. return client
  33851. }
  33852. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33853. // it returns an error otherwise.
  33854. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  33855. if _, ok := m.driver.(*txDriver); !ok {
  33856. return nil, errors.New("ent: mutation is not running in a transaction")
  33857. }
  33858. tx := &Tx{config: m.config}
  33859. tx.init()
  33860. return tx, nil
  33861. }
  33862. // SetID sets the value of the id field. Note that this
  33863. // operation is only accepted on creation of UsageStatisticHour entities.
  33864. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  33865. m.id = &id
  33866. }
  33867. // ID returns the ID value in the mutation. Note that the ID is only available
  33868. // if it was provided to the builder or after it was returned from the database.
  33869. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  33870. if m.id == nil {
  33871. return
  33872. }
  33873. return *m.id, true
  33874. }
  33875. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33876. // That means, if the mutation is applied within a transaction with an isolation level such
  33877. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33878. // or updated by the mutation.
  33879. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  33880. switch {
  33881. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33882. id, exists := m.ID()
  33883. if exists {
  33884. return []uint64{id}, nil
  33885. }
  33886. fallthrough
  33887. case m.op.Is(OpUpdate | OpDelete):
  33888. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  33889. default:
  33890. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33891. }
  33892. }
  33893. // SetCreatedAt sets the "created_at" field.
  33894. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  33895. m.created_at = &t
  33896. }
  33897. // CreatedAt returns the value of the "created_at" field in the mutation.
  33898. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  33899. v := m.created_at
  33900. if v == nil {
  33901. return
  33902. }
  33903. return *v, true
  33904. }
  33905. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  33906. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33908. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33909. if !m.op.Is(OpUpdateOne) {
  33910. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33911. }
  33912. if m.id == nil || m.oldValue == nil {
  33913. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33914. }
  33915. oldValue, err := m.oldValue(ctx)
  33916. if err != nil {
  33917. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33918. }
  33919. return oldValue.CreatedAt, nil
  33920. }
  33921. // ResetCreatedAt resets all changes to the "created_at" field.
  33922. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  33923. m.created_at = nil
  33924. }
  33925. // SetUpdatedAt sets the "updated_at" field.
  33926. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  33927. m.updated_at = &t
  33928. }
  33929. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33930. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  33931. v := m.updated_at
  33932. if v == nil {
  33933. return
  33934. }
  33935. return *v, true
  33936. }
  33937. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  33938. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33940. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33941. if !m.op.Is(OpUpdateOne) {
  33942. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33943. }
  33944. if m.id == nil || m.oldValue == nil {
  33945. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33946. }
  33947. oldValue, err := m.oldValue(ctx)
  33948. if err != nil {
  33949. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33950. }
  33951. return oldValue.UpdatedAt, nil
  33952. }
  33953. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33954. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  33955. m.updated_at = nil
  33956. }
  33957. // SetStatus sets the "status" field.
  33958. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  33959. m.status = &u
  33960. m.addstatus = nil
  33961. }
  33962. // Status returns the value of the "status" field in the mutation.
  33963. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  33964. v := m.status
  33965. if v == nil {
  33966. return
  33967. }
  33968. return *v, true
  33969. }
  33970. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  33971. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33973. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33974. if !m.op.Is(OpUpdateOne) {
  33975. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33976. }
  33977. if m.id == nil || m.oldValue == nil {
  33978. return v, errors.New("OldStatus requires an ID field in the mutation")
  33979. }
  33980. oldValue, err := m.oldValue(ctx)
  33981. if err != nil {
  33982. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33983. }
  33984. return oldValue.Status, nil
  33985. }
  33986. // AddStatus adds u to the "status" field.
  33987. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  33988. if m.addstatus != nil {
  33989. *m.addstatus += u
  33990. } else {
  33991. m.addstatus = &u
  33992. }
  33993. }
  33994. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33995. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  33996. v := m.addstatus
  33997. if v == nil {
  33998. return
  33999. }
  34000. return *v, true
  34001. }
  34002. // ClearStatus clears the value of the "status" field.
  34003. func (m *UsageStatisticHourMutation) ClearStatus() {
  34004. m.status = nil
  34005. m.addstatus = nil
  34006. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  34007. }
  34008. // StatusCleared returns if the "status" field was cleared in this mutation.
  34009. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  34010. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  34011. return ok
  34012. }
  34013. // ResetStatus resets all changes to the "status" field.
  34014. func (m *UsageStatisticHourMutation) ResetStatus() {
  34015. m.status = nil
  34016. m.addstatus = nil
  34017. delete(m.clearedFields, usagestatistichour.FieldStatus)
  34018. }
  34019. // SetDeletedAt sets the "deleted_at" field.
  34020. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  34021. m.deleted_at = &t
  34022. }
  34023. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34024. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  34025. v := m.deleted_at
  34026. if v == nil {
  34027. return
  34028. }
  34029. return *v, true
  34030. }
  34031. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  34032. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34034. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34035. if !m.op.Is(OpUpdateOne) {
  34036. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34037. }
  34038. if m.id == nil || m.oldValue == nil {
  34039. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34040. }
  34041. oldValue, err := m.oldValue(ctx)
  34042. if err != nil {
  34043. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34044. }
  34045. return oldValue.DeletedAt, nil
  34046. }
  34047. // ClearDeletedAt clears the value of the "deleted_at" field.
  34048. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  34049. m.deleted_at = nil
  34050. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  34051. }
  34052. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34053. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  34054. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  34055. return ok
  34056. }
  34057. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34058. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  34059. m.deleted_at = nil
  34060. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  34061. }
  34062. // SetAddtime sets the "addtime" field.
  34063. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  34064. m.addtime = &u
  34065. m.addaddtime = nil
  34066. }
  34067. // Addtime returns the value of the "addtime" field in the mutation.
  34068. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  34069. v := m.addtime
  34070. if v == nil {
  34071. return
  34072. }
  34073. return *v, true
  34074. }
  34075. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  34076. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34078. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34079. if !m.op.Is(OpUpdateOne) {
  34080. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34081. }
  34082. if m.id == nil || m.oldValue == nil {
  34083. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34084. }
  34085. oldValue, err := m.oldValue(ctx)
  34086. if err != nil {
  34087. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34088. }
  34089. return oldValue.Addtime, nil
  34090. }
  34091. // AddAddtime adds u to the "addtime" field.
  34092. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  34093. if m.addaddtime != nil {
  34094. *m.addaddtime += u
  34095. } else {
  34096. m.addaddtime = &u
  34097. }
  34098. }
  34099. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34100. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  34101. v := m.addaddtime
  34102. if v == nil {
  34103. return
  34104. }
  34105. return *v, true
  34106. }
  34107. // ResetAddtime resets all changes to the "addtime" field.
  34108. func (m *UsageStatisticHourMutation) ResetAddtime() {
  34109. m.addtime = nil
  34110. m.addaddtime = nil
  34111. }
  34112. // SetType sets the "type" field.
  34113. func (m *UsageStatisticHourMutation) SetType(i int) {
  34114. m._type = &i
  34115. m.add_type = nil
  34116. }
  34117. // GetType returns the value of the "type" field in the mutation.
  34118. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  34119. v := m._type
  34120. if v == nil {
  34121. return
  34122. }
  34123. return *v, true
  34124. }
  34125. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  34126. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34128. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  34129. if !m.op.Is(OpUpdateOne) {
  34130. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34131. }
  34132. if m.id == nil || m.oldValue == nil {
  34133. return v, errors.New("OldType requires an ID field in the mutation")
  34134. }
  34135. oldValue, err := m.oldValue(ctx)
  34136. if err != nil {
  34137. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34138. }
  34139. return oldValue.Type, nil
  34140. }
  34141. // AddType adds i to the "type" field.
  34142. func (m *UsageStatisticHourMutation) AddType(i int) {
  34143. if m.add_type != nil {
  34144. *m.add_type += i
  34145. } else {
  34146. m.add_type = &i
  34147. }
  34148. }
  34149. // AddedType returns the value that was added to the "type" field in this mutation.
  34150. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  34151. v := m.add_type
  34152. if v == nil {
  34153. return
  34154. }
  34155. return *v, true
  34156. }
  34157. // ResetType resets all changes to the "type" field.
  34158. func (m *UsageStatisticHourMutation) ResetType() {
  34159. m._type = nil
  34160. m.add_type = nil
  34161. }
  34162. // SetBotID sets the "bot_id" field.
  34163. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  34164. m.bot_id = &s
  34165. }
  34166. // BotID returns the value of the "bot_id" field in the mutation.
  34167. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  34168. v := m.bot_id
  34169. if v == nil {
  34170. return
  34171. }
  34172. return *v, true
  34173. }
  34174. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  34175. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34177. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  34178. if !m.op.Is(OpUpdateOne) {
  34179. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34180. }
  34181. if m.id == nil || m.oldValue == nil {
  34182. return v, errors.New("OldBotID requires an ID field in the mutation")
  34183. }
  34184. oldValue, err := m.oldValue(ctx)
  34185. if err != nil {
  34186. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34187. }
  34188. return oldValue.BotID, nil
  34189. }
  34190. // ClearBotID clears the value of the "bot_id" field.
  34191. func (m *UsageStatisticHourMutation) ClearBotID() {
  34192. m.bot_id = nil
  34193. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  34194. }
  34195. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34196. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  34197. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  34198. return ok
  34199. }
  34200. // ResetBotID resets all changes to the "bot_id" field.
  34201. func (m *UsageStatisticHourMutation) ResetBotID() {
  34202. m.bot_id = nil
  34203. delete(m.clearedFields, usagestatistichour.FieldBotID)
  34204. }
  34205. // SetOrganizationID sets the "organization_id" field.
  34206. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  34207. m.organization_id = &u
  34208. m.addorganization_id = nil
  34209. }
  34210. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34211. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  34212. v := m.organization_id
  34213. if v == nil {
  34214. return
  34215. }
  34216. return *v, true
  34217. }
  34218. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  34219. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34221. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34222. if !m.op.Is(OpUpdateOne) {
  34223. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34224. }
  34225. if m.id == nil || m.oldValue == nil {
  34226. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34227. }
  34228. oldValue, err := m.oldValue(ctx)
  34229. if err != nil {
  34230. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34231. }
  34232. return oldValue.OrganizationID, nil
  34233. }
  34234. // AddOrganizationID adds u to the "organization_id" field.
  34235. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  34236. if m.addorganization_id != nil {
  34237. *m.addorganization_id += u
  34238. } else {
  34239. m.addorganization_id = &u
  34240. }
  34241. }
  34242. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34243. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  34244. v := m.addorganization_id
  34245. if v == nil {
  34246. return
  34247. }
  34248. return *v, true
  34249. }
  34250. // ClearOrganizationID clears the value of the "organization_id" field.
  34251. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  34252. m.organization_id = nil
  34253. m.addorganization_id = nil
  34254. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  34255. }
  34256. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34257. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  34258. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  34259. return ok
  34260. }
  34261. // ResetOrganizationID resets all changes to the "organization_id" field.
  34262. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  34263. m.organization_id = nil
  34264. m.addorganization_id = nil
  34265. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  34266. }
  34267. // SetAiResponse sets the "ai_response" field.
  34268. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  34269. m.ai_response = &u
  34270. m.addai_response = nil
  34271. }
  34272. // AiResponse returns the value of the "ai_response" field in the mutation.
  34273. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  34274. v := m.ai_response
  34275. if v == nil {
  34276. return
  34277. }
  34278. return *v, true
  34279. }
  34280. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  34281. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34283. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34284. if !m.op.Is(OpUpdateOne) {
  34285. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34286. }
  34287. if m.id == nil || m.oldValue == nil {
  34288. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34289. }
  34290. oldValue, err := m.oldValue(ctx)
  34291. if err != nil {
  34292. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34293. }
  34294. return oldValue.AiResponse, nil
  34295. }
  34296. // AddAiResponse adds u to the "ai_response" field.
  34297. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  34298. if m.addai_response != nil {
  34299. *m.addai_response += u
  34300. } else {
  34301. m.addai_response = &u
  34302. }
  34303. }
  34304. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34305. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  34306. v := m.addai_response
  34307. if v == nil {
  34308. return
  34309. }
  34310. return *v, true
  34311. }
  34312. // ResetAiResponse resets all changes to the "ai_response" field.
  34313. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  34314. m.ai_response = nil
  34315. m.addai_response = nil
  34316. }
  34317. // SetSopRun sets the "sop_run" field.
  34318. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  34319. m.sop_run = &u
  34320. m.addsop_run = nil
  34321. }
  34322. // SopRun returns the value of the "sop_run" field in the mutation.
  34323. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  34324. v := m.sop_run
  34325. if v == nil {
  34326. return
  34327. }
  34328. return *v, true
  34329. }
  34330. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  34331. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34333. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34334. if !m.op.Is(OpUpdateOne) {
  34335. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34336. }
  34337. if m.id == nil || m.oldValue == nil {
  34338. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34339. }
  34340. oldValue, err := m.oldValue(ctx)
  34341. if err != nil {
  34342. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34343. }
  34344. return oldValue.SopRun, nil
  34345. }
  34346. // AddSopRun adds u to the "sop_run" field.
  34347. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  34348. if m.addsop_run != nil {
  34349. *m.addsop_run += u
  34350. } else {
  34351. m.addsop_run = &u
  34352. }
  34353. }
  34354. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34355. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  34356. v := m.addsop_run
  34357. if v == nil {
  34358. return
  34359. }
  34360. return *v, true
  34361. }
  34362. // ResetSopRun resets all changes to the "sop_run" field.
  34363. func (m *UsageStatisticHourMutation) ResetSopRun() {
  34364. m.sop_run = nil
  34365. m.addsop_run = nil
  34366. }
  34367. // SetTotalFriend sets the "total_friend" field.
  34368. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  34369. m.total_friend = &u
  34370. m.addtotal_friend = nil
  34371. }
  34372. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34373. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  34374. v := m.total_friend
  34375. if v == nil {
  34376. return
  34377. }
  34378. return *v, true
  34379. }
  34380. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  34381. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34383. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34384. if !m.op.Is(OpUpdateOne) {
  34385. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34386. }
  34387. if m.id == nil || m.oldValue == nil {
  34388. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34389. }
  34390. oldValue, err := m.oldValue(ctx)
  34391. if err != nil {
  34392. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34393. }
  34394. return oldValue.TotalFriend, nil
  34395. }
  34396. // AddTotalFriend adds u to the "total_friend" field.
  34397. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  34398. if m.addtotal_friend != nil {
  34399. *m.addtotal_friend += u
  34400. } else {
  34401. m.addtotal_friend = &u
  34402. }
  34403. }
  34404. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34405. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  34406. v := m.addtotal_friend
  34407. if v == nil {
  34408. return
  34409. }
  34410. return *v, true
  34411. }
  34412. // ResetTotalFriend resets all changes to the "total_friend" field.
  34413. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  34414. m.total_friend = nil
  34415. m.addtotal_friend = nil
  34416. }
  34417. // SetTotalGroup sets the "total_group" field.
  34418. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  34419. m.total_group = &u
  34420. m.addtotal_group = nil
  34421. }
  34422. // TotalGroup returns the value of the "total_group" field in the mutation.
  34423. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  34424. v := m.total_group
  34425. if v == nil {
  34426. return
  34427. }
  34428. return *v, true
  34429. }
  34430. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  34431. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34433. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34434. if !m.op.Is(OpUpdateOne) {
  34435. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34436. }
  34437. if m.id == nil || m.oldValue == nil {
  34438. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34439. }
  34440. oldValue, err := m.oldValue(ctx)
  34441. if err != nil {
  34442. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34443. }
  34444. return oldValue.TotalGroup, nil
  34445. }
  34446. // AddTotalGroup adds u to the "total_group" field.
  34447. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  34448. if m.addtotal_group != nil {
  34449. *m.addtotal_group += u
  34450. } else {
  34451. m.addtotal_group = &u
  34452. }
  34453. }
  34454. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34455. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  34456. v := m.addtotal_group
  34457. if v == nil {
  34458. return
  34459. }
  34460. return *v, true
  34461. }
  34462. // ResetTotalGroup resets all changes to the "total_group" field.
  34463. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  34464. m.total_group = nil
  34465. m.addtotal_group = nil
  34466. }
  34467. // SetAccountBalance sets the "account_balance" field.
  34468. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  34469. m.account_balance = &u
  34470. m.addaccount_balance = nil
  34471. }
  34472. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34473. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  34474. v := m.account_balance
  34475. if v == nil {
  34476. return
  34477. }
  34478. return *v, true
  34479. }
  34480. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  34481. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34483. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34484. if !m.op.Is(OpUpdateOne) {
  34485. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34486. }
  34487. if m.id == nil || m.oldValue == nil {
  34488. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34489. }
  34490. oldValue, err := m.oldValue(ctx)
  34491. if err != nil {
  34492. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34493. }
  34494. return oldValue.AccountBalance, nil
  34495. }
  34496. // AddAccountBalance adds u to the "account_balance" field.
  34497. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  34498. if m.addaccount_balance != nil {
  34499. *m.addaccount_balance += u
  34500. } else {
  34501. m.addaccount_balance = &u
  34502. }
  34503. }
  34504. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34505. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  34506. v := m.addaccount_balance
  34507. if v == nil {
  34508. return
  34509. }
  34510. return *v, true
  34511. }
  34512. // ResetAccountBalance resets all changes to the "account_balance" field.
  34513. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  34514. m.account_balance = nil
  34515. m.addaccount_balance = nil
  34516. }
  34517. // SetConsumeToken sets the "consume_token" field.
  34518. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  34519. m.consume_token = &u
  34520. m.addconsume_token = nil
  34521. }
  34522. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34523. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  34524. v := m.consume_token
  34525. if v == nil {
  34526. return
  34527. }
  34528. return *v, true
  34529. }
  34530. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  34531. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34533. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34534. if !m.op.Is(OpUpdateOne) {
  34535. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34536. }
  34537. if m.id == nil || m.oldValue == nil {
  34538. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34539. }
  34540. oldValue, err := m.oldValue(ctx)
  34541. if err != nil {
  34542. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34543. }
  34544. return oldValue.ConsumeToken, nil
  34545. }
  34546. // AddConsumeToken adds u to the "consume_token" field.
  34547. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  34548. if m.addconsume_token != nil {
  34549. *m.addconsume_token += u
  34550. } else {
  34551. m.addconsume_token = &u
  34552. }
  34553. }
  34554. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34555. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  34556. v := m.addconsume_token
  34557. if v == nil {
  34558. return
  34559. }
  34560. return *v, true
  34561. }
  34562. // ResetConsumeToken resets all changes to the "consume_token" field.
  34563. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  34564. m.consume_token = nil
  34565. m.addconsume_token = nil
  34566. }
  34567. // SetActiveUser sets the "active_user" field.
  34568. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  34569. m.active_user = &u
  34570. m.addactive_user = nil
  34571. }
  34572. // ActiveUser returns the value of the "active_user" field in the mutation.
  34573. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  34574. v := m.active_user
  34575. if v == nil {
  34576. return
  34577. }
  34578. return *v, true
  34579. }
  34580. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  34581. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34583. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34584. if !m.op.Is(OpUpdateOne) {
  34585. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34586. }
  34587. if m.id == nil || m.oldValue == nil {
  34588. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34589. }
  34590. oldValue, err := m.oldValue(ctx)
  34591. if err != nil {
  34592. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34593. }
  34594. return oldValue.ActiveUser, nil
  34595. }
  34596. // AddActiveUser adds u to the "active_user" field.
  34597. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  34598. if m.addactive_user != nil {
  34599. *m.addactive_user += u
  34600. } else {
  34601. m.addactive_user = &u
  34602. }
  34603. }
  34604. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34605. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  34606. v := m.addactive_user
  34607. if v == nil {
  34608. return
  34609. }
  34610. return *v, true
  34611. }
  34612. // ResetActiveUser resets all changes to the "active_user" field.
  34613. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  34614. m.active_user = nil
  34615. m.addactive_user = nil
  34616. }
  34617. // SetNewUser sets the "new_user" field.
  34618. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  34619. m.new_user = &i
  34620. m.addnew_user = nil
  34621. }
  34622. // NewUser returns the value of the "new_user" field in the mutation.
  34623. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  34624. v := m.new_user
  34625. if v == nil {
  34626. return
  34627. }
  34628. return *v, true
  34629. }
  34630. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  34631. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34633. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34634. if !m.op.Is(OpUpdateOne) {
  34635. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34636. }
  34637. if m.id == nil || m.oldValue == nil {
  34638. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34639. }
  34640. oldValue, err := m.oldValue(ctx)
  34641. if err != nil {
  34642. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34643. }
  34644. return oldValue.NewUser, nil
  34645. }
  34646. // AddNewUser adds i to the "new_user" field.
  34647. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  34648. if m.addnew_user != nil {
  34649. *m.addnew_user += i
  34650. } else {
  34651. m.addnew_user = &i
  34652. }
  34653. }
  34654. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34655. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  34656. v := m.addnew_user
  34657. if v == nil {
  34658. return
  34659. }
  34660. return *v, true
  34661. }
  34662. // ResetNewUser resets all changes to the "new_user" field.
  34663. func (m *UsageStatisticHourMutation) ResetNewUser() {
  34664. m.new_user = nil
  34665. m.addnew_user = nil
  34666. }
  34667. // SetLabelDist sets the "label_dist" field.
  34668. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34669. m.label_dist = &ctd
  34670. m.appendlabel_dist = nil
  34671. }
  34672. // LabelDist returns the value of the "label_dist" field in the mutation.
  34673. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34674. v := m.label_dist
  34675. if v == nil {
  34676. return
  34677. }
  34678. return *v, true
  34679. }
  34680. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  34681. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34683. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34684. if !m.op.Is(OpUpdateOne) {
  34685. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34686. }
  34687. if m.id == nil || m.oldValue == nil {
  34688. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34689. }
  34690. oldValue, err := m.oldValue(ctx)
  34691. if err != nil {
  34692. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34693. }
  34694. return oldValue.LabelDist, nil
  34695. }
  34696. // AppendLabelDist adds ctd to the "label_dist" field.
  34697. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34698. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34699. }
  34700. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34701. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34702. if len(m.appendlabel_dist) == 0 {
  34703. return nil, false
  34704. }
  34705. return m.appendlabel_dist, true
  34706. }
  34707. // ResetLabelDist resets all changes to the "label_dist" field.
  34708. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  34709. m.label_dist = nil
  34710. m.appendlabel_dist = nil
  34711. }
  34712. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  34713. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  34714. m.predicates = append(m.predicates, ps...)
  34715. }
  34716. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  34717. // users can use type-assertion to append predicates that do not depend on any generated package.
  34718. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  34719. p := make([]predicate.UsageStatisticHour, len(ps))
  34720. for i := range ps {
  34721. p[i] = ps[i]
  34722. }
  34723. m.Where(p...)
  34724. }
  34725. // Op returns the operation name.
  34726. func (m *UsageStatisticHourMutation) Op() Op {
  34727. return m.op
  34728. }
  34729. // SetOp allows setting the mutation operation.
  34730. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  34731. m.op = op
  34732. }
  34733. // Type returns the node type of this mutation (UsageStatisticHour).
  34734. func (m *UsageStatisticHourMutation) Type() string {
  34735. return m.typ
  34736. }
  34737. // Fields returns all fields that were changed during this mutation. Note that in
  34738. // order to get all numeric fields that were incremented/decremented, call
  34739. // AddedFields().
  34740. func (m *UsageStatisticHourMutation) Fields() []string {
  34741. fields := make([]string, 0, 17)
  34742. if m.created_at != nil {
  34743. fields = append(fields, usagestatistichour.FieldCreatedAt)
  34744. }
  34745. if m.updated_at != nil {
  34746. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  34747. }
  34748. if m.status != nil {
  34749. fields = append(fields, usagestatistichour.FieldStatus)
  34750. }
  34751. if m.deleted_at != nil {
  34752. fields = append(fields, usagestatistichour.FieldDeletedAt)
  34753. }
  34754. if m.addtime != nil {
  34755. fields = append(fields, usagestatistichour.FieldAddtime)
  34756. }
  34757. if m._type != nil {
  34758. fields = append(fields, usagestatistichour.FieldType)
  34759. }
  34760. if m.bot_id != nil {
  34761. fields = append(fields, usagestatistichour.FieldBotID)
  34762. }
  34763. if m.organization_id != nil {
  34764. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34765. }
  34766. if m.ai_response != nil {
  34767. fields = append(fields, usagestatistichour.FieldAiResponse)
  34768. }
  34769. if m.sop_run != nil {
  34770. fields = append(fields, usagestatistichour.FieldSopRun)
  34771. }
  34772. if m.total_friend != nil {
  34773. fields = append(fields, usagestatistichour.FieldTotalFriend)
  34774. }
  34775. if m.total_group != nil {
  34776. fields = append(fields, usagestatistichour.FieldTotalGroup)
  34777. }
  34778. if m.account_balance != nil {
  34779. fields = append(fields, usagestatistichour.FieldAccountBalance)
  34780. }
  34781. if m.consume_token != nil {
  34782. fields = append(fields, usagestatistichour.FieldConsumeToken)
  34783. }
  34784. if m.active_user != nil {
  34785. fields = append(fields, usagestatistichour.FieldActiveUser)
  34786. }
  34787. if m.new_user != nil {
  34788. fields = append(fields, usagestatistichour.FieldNewUser)
  34789. }
  34790. if m.label_dist != nil {
  34791. fields = append(fields, usagestatistichour.FieldLabelDist)
  34792. }
  34793. return fields
  34794. }
  34795. // Field returns the value of a field with the given name. The second boolean
  34796. // return value indicates that this field was not set, or was not defined in the
  34797. // schema.
  34798. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  34799. switch name {
  34800. case usagestatistichour.FieldCreatedAt:
  34801. return m.CreatedAt()
  34802. case usagestatistichour.FieldUpdatedAt:
  34803. return m.UpdatedAt()
  34804. case usagestatistichour.FieldStatus:
  34805. return m.Status()
  34806. case usagestatistichour.FieldDeletedAt:
  34807. return m.DeletedAt()
  34808. case usagestatistichour.FieldAddtime:
  34809. return m.Addtime()
  34810. case usagestatistichour.FieldType:
  34811. return m.GetType()
  34812. case usagestatistichour.FieldBotID:
  34813. return m.BotID()
  34814. case usagestatistichour.FieldOrganizationID:
  34815. return m.OrganizationID()
  34816. case usagestatistichour.FieldAiResponse:
  34817. return m.AiResponse()
  34818. case usagestatistichour.FieldSopRun:
  34819. return m.SopRun()
  34820. case usagestatistichour.FieldTotalFriend:
  34821. return m.TotalFriend()
  34822. case usagestatistichour.FieldTotalGroup:
  34823. return m.TotalGroup()
  34824. case usagestatistichour.FieldAccountBalance:
  34825. return m.AccountBalance()
  34826. case usagestatistichour.FieldConsumeToken:
  34827. return m.ConsumeToken()
  34828. case usagestatistichour.FieldActiveUser:
  34829. return m.ActiveUser()
  34830. case usagestatistichour.FieldNewUser:
  34831. return m.NewUser()
  34832. case usagestatistichour.FieldLabelDist:
  34833. return m.LabelDist()
  34834. }
  34835. return nil, false
  34836. }
  34837. // OldField returns the old value of the field from the database. An error is
  34838. // returned if the mutation operation is not UpdateOne, or the query to the
  34839. // database failed.
  34840. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34841. switch name {
  34842. case usagestatistichour.FieldCreatedAt:
  34843. return m.OldCreatedAt(ctx)
  34844. case usagestatistichour.FieldUpdatedAt:
  34845. return m.OldUpdatedAt(ctx)
  34846. case usagestatistichour.FieldStatus:
  34847. return m.OldStatus(ctx)
  34848. case usagestatistichour.FieldDeletedAt:
  34849. return m.OldDeletedAt(ctx)
  34850. case usagestatistichour.FieldAddtime:
  34851. return m.OldAddtime(ctx)
  34852. case usagestatistichour.FieldType:
  34853. return m.OldType(ctx)
  34854. case usagestatistichour.FieldBotID:
  34855. return m.OldBotID(ctx)
  34856. case usagestatistichour.FieldOrganizationID:
  34857. return m.OldOrganizationID(ctx)
  34858. case usagestatistichour.FieldAiResponse:
  34859. return m.OldAiResponse(ctx)
  34860. case usagestatistichour.FieldSopRun:
  34861. return m.OldSopRun(ctx)
  34862. case usagestatistichour.FieldTotalFriend:
  34863. return m.OldTotalFriend(ctx)
  34864. case usagestatistichour.FieldTotalGroup:
  34865. return m.OldTotalGroup(ctx)
  34866. case usagestatistichour.FieldAccountBalance:
  34867. return m.OldAccountBalance(ctx)
  34868. case usagestatistichour.FieldConsumeToken:
  34869. return m.OldConsumeToken(ctx)
  34870. case usagestatistichour.FieldActiveUser:
  34871. return m.OldActiveUser(ctx)
  34872. case usagestatistichour.FieldNewUser:
  34873. return m.OldNewUser(ctx)
  34874. case usagestatistichour.FieldLabelDist:
  34875. return m.OldLabelDist(ctx)
  34876. }
  34877. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34878. }
  34879. // SetField sets the value of a field with the given name. It returns an error if
  34880. // the field is not defined in the schema, or if the type mismatched the field
  34881. // type.
  34882. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  34883. switch name {
  34884. case usagestatistichour.FieldCreatedAt:
  34885. v, ok := value.(time.Time)
  34886. if !ok {
  34887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34888. }
  34889. m.SetCreatedAt(v)
  34890. return nil
  34891. case usagestatistichour.FieldUpdatedAt:
  34892. v, ok := value.(time.Time)
  34893. if !ok {
  34894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34895. }
  34896. m.SetUpdatedAt(v)
  34897. return nil
  34898. case usagestatistichour.FieldStatus:
  34899. v, ok := value.(uint8)
  34900. if !ok {
  34901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34902. }
  34903. m.SetStatus(v)
  34904. return nil
  34905. case usagestatistichour.FieldDeletedAt:
  34906. v, ok := value.(time.Time)
  34907. if !ok {
  34908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34909. }
  34910. m.SetDeletedAt(v)
  34911. return nil
  34912. case usagestatistichour.FieldAddtime:
  34913. v, ok := value.(uint64)
  34914. if !ok {
  34915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34916. }
  34917. m.SetAddtime(v)
  34918. return nil
  34919. case usagestatistichour.FieldType:
  34920. v, ok := value.(int)
  34921. if !ok {
  34922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34923. }
  34924. m.SetType(v)
  34925. return nil
  34926. case usagestatistichour.FieldBotID:
  34927. v, ok := value.(string)
  34928. if !ok {
  34929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34930. }
  34931. m.SetBotID(v)
  34932. return nil
  34933. case usagestatistichour.FieldOrganizationID:
  34934. v, ok := value.(uint64)
  34935. if !ok {
  34936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34937. }
  34938. m.SetOrganizationID(v)
  34939. return nil
  34940. case usagestatistichour.FieldAiResponse:
  34941. v, ok := value.(uint64)
  34942. if !ok {
  34943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34944. }
  34945. m.SetAiResponse(v)
  34946. return nil
  34947. case usagestatistichour.FieldSopRun:
  34948. v, ok := value.(uint64)
  34949. if !ok {
  34950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34951. }
  34952. m.SetSopRun(v)
  34953. return nil
  34954. case usagestatistichour.FieldTotalFriend:
  34955. v, ok := value.(uint64)
  34956. if !ok {
  34957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34958. }
  34959. m.SetTotalFriend(v)
  34960. return nil
  34961. case usagestatistichour.FieldTotalGroup:
  34962. v, ok := value.(uint64)
  34963. if !ok {
  34964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34965. }
  34966. m.SetTotalGroup(v)
  34967. return nil
  34968. case usagestatistichour.FieldAccountBalance:
  34969. v, ok := value.(uint64)
  34970. if !ok {
  34971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34972. }
  34973. m.SetAccountBalance(v)
  34974. return nil
  34975. case usagestatistichour.FieldConsumeToken:
  34976. v, ok := value.(uint64)
  34977. if !ok {
  34978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34979. }
  34980. m.SetConsumeToken(v)
  34981. return nil
  34982. case usagestatistichour.FieldActiveUser:
  34983. v, ok := value.(uint64)
  34984. if !ok {
  34985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34986. }
  34987. m.SetActiveUser(v)
  34988. return nil
  34989. case usagestatistichour.FieldNewUser:
  34990. v, ok := value.(int64)
  34991. if !ok {
  34992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34993. }
  34994. m.SetNewUser(v)
  34995. return nil
  34996. case usagestatistichour.FieldLabelDist:
  34997. v, ok := value.([]custom_types.LabelDist)
  34998. if !ok {
  34999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35000. }
  35001. m.SetLabelDist(v)
  35002. return nil
  35003. }
  35004. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  35005. }
  35006. // AddedFields returns all numeric fields that were incremented/decremented during
  35007. // this mutation.
  35008. func (m *UsageStatisticHourMutation) AddedFields() []string {
  35009. var fields []string
  35010. if m.addstatus != nil {
  35011. fields = append(fields, usagestatistichour.FieldStatus)
  35012. }
  35013. if m.addaddtime != nil {
  35014. fields = append(fields, usagestatistichour.FieldAddtime)
  35015. }
  35016. if m.add_type != nil {
  35017. fields = append(fields, usagestatistichour.FieldType)
  35018. }
  35019. if m.addorganization_id != nil {
  35020. fields = append(fields, usagestatistichour.FieldOrganizationID)
  35021. }
  35022. if m.addai_response != nil {
  35023. fields = append(fields, usagestatistichour.FieldAiResponse)
  35024. }
  35025. if m.addsop_run != nil {
  35026. fields = append(fields, usagestatistichour.FieldSopRun)
  35027. }
  35028. if m.addtotal_friend != nil {
  35029. fields = append(fields, usagestatistichour.FieldTotalFriend)
  35030. }
  35031. if m.addtotal_group != nil {
  35032. fields = append(fields, usagestatistichour.FieldTotalGroup)
  35033. }
  35034. if m.addaccount_balance != nil {
  35035. fields = append(fields, usagestatistichour.FieldAccountBalance)
  35036. }
  35037. if m.addconsume_token != nil {
  35038. fields = append(fields, usagestatistichour.FieldConsumeToken)
  35039. }
  35040. if m.addactive_user != nil {
  35041. fields = append(fields, usagestatistichour.FieldActiveUser)
  35042. }
  35043. if m.addnew_user != nil {
  35044. fields = append(fields, usagestatistichour.FieldNewUser)
  35045. }
  35046. return fields
  35047. }
  35048. // AddedField returns the numeric value that was incremented/decremented on a field
  35049. // with the given name. The second boolean return value indicates that this field
  35050. // was not set, or was not defined in the schema.
  35051. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  35052. switch name {
  35053. case usagestatistichour.FieldStatus:
  35054. return m.AddedStatus()
  35055. case usagestatistichour.FieldAddtime:
  35056. return m.AddedAddtime()
  35057. case usagestatistichour.FieldType:
  35058. return m.AddedType()
  35059. case usagestatistichour.FieldOrganizationID:
  35060. return m.AddedOrganizationID()
  35061. case usagestatistichour.FieldAiResponse:
  35062. return m.AddedAiResponse()
  35063. case usagestatistichour.FieldSopRun:
  35064. return m.AddedSopRun()
  35065. case usagestatistichour.FieldTotalFriend:
  35066. return m.AddedTotalFriend()
  35067. case usagestatistichour.FieldTotalGroup:
  35068. return m.AddedTotalGroup()
  35069. case usagestatistichour.FieldAccountBalance:
  35070. return m.AddedAccountBalance()
  35071. case usagestatistichour.FieldConsumeToken:
  35072. return m.AddedConsumeToken()
  35073. case usagestatistichour.FieldActiveUser:
  35074. return m.AddedActiveUser()
  35075. case usagestatistichour.FieldNewUser:
  35076. return m.AddedNewUser()
  35077. }
  35078. return nil, false
  35079. }
  35080. // AddField adds the value to the field with the given name. It returns an error if
  35081. // the field is not defined in the schema, or if the type mismatched the field
  35082. // type.
  35083. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  35084. switch name {
  35085. case usagestatistichour.FieldStatus:
  35086. v, ok := value.(int8)
  35087. if !ok {
  35088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35089. }
  35090. m.AddStatus(v)
  35091. return nil
  35092. case usagestatistichour.FieldAddtime:
  35093. v, ok := value.(int64)
  35094. if !ok {
  35095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35096. }
  35097. m.AddAddtime(v)
  35098. return nil
  35099. case usagestatistichour.FieldType:
  35100. v, ok := value.(int)
  35101. if !ok {
  35102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35103. }
  35104. m.AddType(v)
  35105. return nil
  35106. case usagestatistichour.FieldOrganizationID:
  35107. v, ok := value.(int64)
  35108. if !ok {
  35109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35110. }
  35111. m.AddOrganizationID(v)
  35112. return nil
  35113. case usagestatistichour.FieldAiResponse:
  35114. v, ok := value.(int64)
  35115. if !ok {
  35116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35117. }
  35118. m.AddAiResponse(v)
  35119. return nil
  35120. case usagestatistichour.FieldSopRun:
  35121. v, ok := value.(int64)
  35122. if !ok {
  35123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35124. }
  35125. m.AddSopRun(v)
  35126. return nil
  35127. case usagestatistichour.FieldTotalFriend:
  35128. v, ok := value.(int64)
  35129. if !ok {
  35130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35131. }
  35132. m.AddTotalFriend(v)
  35133. return nil
  35134. case usagestatistichour.FieldTotalGroup:
  35135. v, ok := value.(int64)
  35136. if !ok {
  35137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35138. }
  35139. m.AddTotalGroup(v)
  35140. return nil
  35141. case usagestatistichour.FieldAccountBalance:
  35142. v, ok := value.(int64)
  35143. if !ok {
  35144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35145. }
  35146. m.AddAccountBalance(v)
  35147. return nil
  35148. case usagestatistichour.FieldConsumeToken:
  35149. v, ok := value.(int64)
  35150. if !ok {
  35151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35152. }
  35153. m.AddConsumeToken(v)
  35154. return nil
  35155. case usagestatistichour.FieldActiveUser:
  35156. v, ok := value.(int64)
  35157. if !ok {
  35158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35159. }
  35160. m.AddActiveUser(v)
  35161. return nil
  35162. case usagestatistichour.FieldNewUser:
  35163. v, ok := value.(int64)
  35164. if !ok {
  35165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35166. }
  35167. m.AddNewUser(v)
  35168. return nil
  35169. }
  35170. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  35171. }
  35172. // ClearedFields returns all nullable fields that were cleared during this
  35173. // mutation.
  35174. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  35175. var fields []string
  35176. if m.FieldCleared(usagestatistichour.FieldStatus) {
  35177. fields = append(fields, usagestatistichour.FieldStatus)
  35178. }
  35179. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  35180. fields = append(fields, usagestatistichour.FieldDeletedAt)
  35181. }
  35182. if m.FieldCleared(usagestatistichour.FieldBotID) {
  35183. fields = append(fields, usagestatistichour.FieldBotID)
  35184. }
  35185. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  35186. fields = append(fields, usagestatistichour.FieldOrganizationID)
  35187. }
  35188. return fields
  35189. }
  35190. // FieldCleared returns a boolean indicating if a field with the given name was
  35191. // cleared in this mutation.
  35192. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  35193. _, ok := m.clearedFields[name]
  35194. return ok
  35195. }
  35196. // ClearField clears the value of the field with the given name. It returns an
  35197. // error if the field is not defined in the schema.
  35198. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  35199. switch name {
  35200. case usagestatistichour.FieldStatus:
  35201. m.ClearStatus()
  35202. return nil
  35203. case usagestatistichour.FieldDeletedAt:
  35204. m.ClearDeletedAt()
  35205. return nil
  35206. case usagestatistichour.FieldBotID:
  35207. m.ClearBotID()
  35208. return nil
  35209. case usagestatistichour.FieldOrganizationID:
  35210. m.ClearOrganizationID()
  35211. return nil
  35212. }
  35213. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  35214. }
  35215. // ResetField resets all changes in the mutation for the field with the given name.
  35216. // It returns an error if the field is not defined in the schema.
  35217. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  35218. switch name {
  35219. case usagestatistichour.FieldCreatedAt:
  35220. m.ResetCreatedAt()
  35221. return nil
  35222. case usagestatistichour.FieldUpdatedAt:
  35223. m.ResetUpdatedAt()
  35224. return nil
  35225. case usagestatistichour.FieldStatus:
  35226. m.ResetStatus()
  35227. return nil
  35228. case usagestatistichour.FieldDeletedAt:
  35229. m.ResetDeletedAt()
  35230. return nil
  35231. case usagestatistichour.FieldAddtime:
  35232. m.ResetAddtime()
  35233. return nil
  35234. case usagestatistichour.FieldType:
  35235. m.ResetType()
  35236. return nil
  35237. case usagestatistichour.FieldBotID:
  35238. m.ResetBotID()
  35239. return nil
  35240. case usagestatistichour.FieldOrganizationID:
  35241. m.ResetOrganizationID()
  35242. return nil
  35243. case usagestatistichour.FieldAiResponse:
  35244. m.ResetAiResponse()
  35245. return nil
  35246. case usagestatistichour.FieldSopRun:
  35247. m.ResetSopRun()
  35248. return nil
  35249. case usagestatistichour.FieldTotalFriend:
  35250. m.ResetTotalFriend()
  35251. return nil
  35252. case usagestatistichour.FieldTotalGroup:
  35253. m.ResetTotalGroup()
  35254. return nil
  35255. case usagestatistichour.FieldAccountBalance:
  35256. m.ResetAccountBalance()
  35257. return nil
  35258. case usagestatistichour.FieldConsumeToken:
  35259. m.ResetConsumeToken()
  35260. return nil
  35261. case usagestatistichour.FieldActiveUser:
  35262. m.ResetActiveUser()
  35263. return nil
  35264. case usagestatistichour.FieldNewUser:
  35265. m.ResetNewUser()
  35266. return nil
  35267. case usagestatistichour.FieldLabelDist:
  35268. m.ResetLabelDist()
  35269. return nil
  35270. }
  35271. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  35272. }
  35273. // AddedEdges returns all edge names that were set/added in this mutation.
  35274. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  35275. edges := make([]string, 0, 0)
  35276. return edges
  35277. }
  35278. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35279. // name in this mutation.
  35280. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  35281. return nil
  35282. }
  35283. // RemovedEdges returns all edge names that were removed in this mutation.
  35284. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  35285. edges := make([]string, 0, 0)
  35286. return edges
  35287. }
  35288. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35289. // the given name in this mutation.
  35290. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  35291. return nil
  35292. }
  35293. // ClearedEdges returns all edge names that were cleared in this mutation.
  35294. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  35295. edges := make([]string, 0, 0)
  35296. return edges
  35297. }
  35298. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35299. // was cleared in this mutation.
  35300. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  35301. return false
  35302. }
  35303. // ClearEdge clears the value of the edge with the given name. It returns an error
  35304. // if that edge is not defined in the schema.
  35305. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  35306. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  35307. }
  35308. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35309. // It returns an error if the edge is not defined in the schema.
  35310. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  35311. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  35312. }
  35313. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  35314. type UsageStatisticMonthMutation struct {
  35315. config
  35316. op Op
  35317. typ string
  35318. id *uint64
  35319. created_at *time.Time
  35320. updated_at *time.Time
  35321. status *uint8
  35322. addstatus *int8
  35323. deleted_at *time.Time
  35324. addtime *uint64
  35325. addaddtime *int64
  35326. _type *int
  35327. add_type *int
  35328. bot_id *string
  35329. organization_id *uint64
  35330. addorganization_id *int64
  35331. ai_response *uint64
  35332. addai_response *int64
  35333. sop_run *uint64
  35334. addsop_run *int64
  35335. total_friend *uint64
  35336. addtotal_friend *int64
  35337. total_group *uint64
  35338. addtotal_group *int64
  35339. account_balance *uint64
  35340. addaccount_balance *int64
  35341. consume_token *uint64
  35342. addconsume_token *int64
  35343. active_user *uint64
  35344. addactive_user *int64
  35345. new_user *int64
  35346. addnew_user *int64
  35347. label_dist *[]custom_types.LabelDist
  35348. appendlabel_dist []custom_types.LabelDist
  35349. clearedFields map[string]struct{}
  35350. done bool
  35351. oldValue func(context.Context) (*UsageStatisticMonth, error)
  35352. predicates []predicate.UsageStatisticMonth
  35353. }
  35354. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  35355. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  35356. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  35357. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  35358. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  35359. m := &UsageStatisticMonthMutation{
  35360. config: c,
  35361. op: op,
  35362. typ: TypeUsageStatisticMonth,
  35363. clearedFields: make(map[string]struct{}),
  35364. }
  35365. for _, opt := range opts {
  35366. opt(m)
  35367. }
  35368. return m
  35369. }
  35370. // withUsageStatisticMonthID sets the ID field of the mutation.
  35371. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  35372. return func(m *UsageStatisticMonthMutation) {
  35373. var (
  35374. err error
  35375. once sync.Once
  35376. value *UsageStatisticMonth
  35377. )
  35378. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  35379. once.Do(func() {
  35380. if m.done {
  35381. err = errors.New("querying old values post mutation is not allowed")
  35382. } else {
  35383. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  35384. }
  35385. })
  35386. return value, err
  35387. }
  35388. m.id = &id
  35389. }
  35390. }
  35391. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  35392. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  35393. return func(m *UsageStatisticMonthMutation) {
  35394. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  35395. return node, nil
  35396. }
  35397. m.id = &node.ID
  35398. }
  35399. }
  35400. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35401. // executed in a transaction (ent.Tx), a transactional client is returned.
  35402. func (m UsageStatisticMonthMutation) Client() *Client {
  35403. client := &Client{config: m.config}
  35404. client.init()
  35405. return client
  35406. }
  35407. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35408. // it returns an error otherwise.
  35409. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  35410. if _, ok := m.driver.(*txDriver); !ok {
  35411. return nil, errors.New("ent: mutation is not running in a transaction")
  35412. }
  35413. tx := &Tx{config: m.config}
  35414. tx.init()
  35415. return tx, nil
  35416. }
  35417. // SetID sets the value of the id field. Note that this
  35418. // operation is only accepted on creation of UsageStatisticMonth entities.
  35419. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  35420. m.id = &id
  35421. }
  35422. // ID returns the ID value in the mutation. Note that the ID is only available
  35423. // if it was provided to the builder or after it was returned from the database.
  35424. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  35425. if m.id == nil {
  35426. return
  35427. }
  35428. return *m.id, true
  35429. }
  35430. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35431. // That means, if the mutation is applied within a transaction with an isolation level such
  35432. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35433. // or updated by the mutation.
  35434. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  35435. switch {
  35436. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35437. id, exists := m.ID()
  35438. if exists {
  35439. return []uint64{id}, nil
  35440. }
  35441. fallthrough
  35442. case m.op.Is(OpUpdate | OpDelete):
  35443. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  35444. default:
  35445. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35446. }
  35447. }
  35448. // SetCreatedAt sets the "created_at" field.
  35449. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  35450. m.created_at = &t
  35451. }
  35452. // CreatedAt returns the value of the "created_at" field in the mutation.
  35453. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  35454. v := m.created_at
  35455. if v == nil {
  35456. return
  35457. }
  35458. return *v, true
  35459. }
  35460. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  35461. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35463. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35464. if !m.op.Is(OpUpdateOne) {
  35465. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35466. }
  35467. if m.id == nil || m.oldValue == nil {
  35468. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35469. }
  35470. oldValue, err := m.oldValue(ctx)
  35471. if err != nil {
  35472. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35473. }
  35474. return oldValue.CreatedAt, nil
  35475. }
  35476. // ResetCreatedAt resets all changes to the "created_at" field.
  35477. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  35478. m.created_at = nil
  35479. }
  35480. // SetUpdatedAt sets the "updated_at" field.
  35481. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  35482. m.updated_at = &t
  35483. }
  35484. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35485. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  35486. v := m.updated_at
  35487. if v == nil {
  35488. return
  35489. }
  35490. return *v, true
  35491. }
  35492. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  35493. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35495. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35496. if !m.op.Is(OpUpdateOne) {
  35497. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35498. }
  35499. if m.id == nil || m.oldValue == nil {
  35500. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35501. }
  35502. oldValue, err := m.oldValue(ctx)
  35503. if err != nil {
  35504. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35505. }
  35506. return oldValue.UpdatedAt, nil
  35507. }
  35508. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35509. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  35510. m.updated_at = nil
  35511. }
  35512. // SetStatus sets the "status" field.
  35513. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  35514. m.status = &u
  35515. m.addstatus = nil
  35516. }
  35517. // Status returns the value of the "status" field in the mutation.
  35518. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  35519. v := m.status
  35520. if v == nil {
  35521. return
  35522. }
  35523. return *v, true
  35524. }
  35525. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  35526. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35528. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35529. if !m.op.Is(OpUpdateOne) {
  35530. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35531. }
  35532. if m.id == nil || m.oldValue == nil {
  35533. return v, errors.New("OldStatus requires an ID field in the mutation")
  35534. }
  35535. oldValue, err := m.oldValue(ctx)
  35536. if err != nil {
  35537. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35538. }
  35539. return oldValue.Status, nil
  35540. }
  35541. // AddStatus adds u to the "status" field.
  35542. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  35543. if m.addstatus != nil {
  35544. *m.addstatus += u
  35545. } else {
  35546. m.addstatus = &u
  35547. }
  35548. }
  35549. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35550. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  35551. v := m.addstatus
  35552. if v == nil {
  35553. return
  35554. }
  35555. return *v, true
  35556. }
  35557. // ClearStatus clears the value of the "status" field.
  35558. func (m *UsageStatisticMonthMutation) ClearStatus() {
  35559. m.status = nil
  35560. m.addstatus = nil
  35561. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  35562. }
  35563. // StatusCleared returns if the "status" field was cleared in this mutation.
  35564. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  35565. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  35566. return ok
  35567. }
  35568. // ResetStatus resets all changes to the "status" field.
  35569. func (m *UsageStatisticMonthMutation) ResetStatus() {
  35570. m.status = nil
  35571. m.addstatus = nil
  35572. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  35573. }
  35574. // SetDeletedAt sets the "deleted_at" field.
  35575. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  35576. m.deleted_at = &t
  35577. }
  35578. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35579. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  35580. v := m.deleted_at
  35581. if v == nil {
  35582. return
  35583. }
  35584. return *v, true
  35585. }
  35586. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  35587. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35589. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35590. if !m.op.Is(OpUpdateOne) {
  35591. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35592. }
  35593. if m.id == nil || m.oldValue == nil {
  35594. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35595. }
  35596. oldValue, err := m.oldValue(ctx)
  35597. if err != nil {
  35598. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35599. }
  35600. return oldValue.DeletedAt, nil
  35601. }
  35602. // ClearDeletedAt clears the value of the "deleted_at" field.
  35603. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  35604. m.deleted_at = nil
  35605. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  35606. }
  35607. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35608. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  35609. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  35610. return ok
  35611. }
  35612. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35613. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  35614. m.deleted_at = nil
  35615. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  35616. }
  35617. // SetAddtime sets the "addtime" field.
  35618. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  35619. m.addtime = &u
  35620. m.addaddtime = nil
  35621. }
  35622. // Addtime returns the value of the "addtime" field in the mutation.
  35623. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  35624. v := m.addtime
  35625. if v == nil {
  35626. return
  35627. }
  35628. return *v, true
  35629. }
  35630. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  35631. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35633. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35634. if !m.op.Is(OpUpdateOne) {
  35635. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35636. }
  35637. if m.id == nil || m.oldValue == nil {
  35638. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35639. }
  35640. oldValue, err := m.oldValue(ctx)
  35641. if err != nil {
  35642. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35643. }
  35644. return oldValue.Addtime, nil
  35645. }
  35646. // AddAddtime adds u to the "addtime" field.
  35647. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  35648. if m.addaddtime != nil {
  35649. *m.addaddtime += u
  35650. } else {
  35651. m.addaddtime = &u
  35652. }
  35653. }
  35654. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35655. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  35656. v := m.addaddtime
  35657. if v == nil {
  35658. return
  35659. }
  35660. return *v, true
  35661. }
  35662. // ResetAddtime resets all changes to the "addtime" field.
  35663. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  35664. m.addtime = nil
  35665. m.addaddtime = nil
  35666. }
  35667. // SetType sets the "type" field.
  35668. func (m *UsageStatisticMonthMutation) SetType(i int) {
  35669. m._type = &i
  35670. m.add_type = nil
  35671. }
  35672. // GetType returns the value of the "type" field in the mutation.
  35673. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  35674. v := m._type
  35675. if v == nil {
  35676. return
  35677. }
  35678. return *v, true
  35679. }
  35680. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  35681. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35683. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  35684. if !m.op.Is(OpUpdateOne) {
  35685. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35686. }
  35687. if m.id == nil || m.oldValue == nil {
  35688. return v, errors.New("OldType requires an ID field in the mutation")
  35689. }
  35690. oldValue, err := m.oldValue(ctx)
  35691. if err != nil {
  35692. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35693. }
  35694. return oldValue.Type, nil
  35695. }
  35696. // AddType adds i to the "type" field.
  35697. func (m *UsageStatisticMonthMutation) AddType(i int) {
  35698. if m.add_type != nil {
  35699. *m.add_type += i
  35700. } else {
  35701. m.add_type = &i
  35702. }
  35703. }
  35704. // AddedType returns the value that was added to the "type" field in this mutation.
  35705. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  35706. v := m.add_type
  35707. if v == nil {
  35708. return
  35709. }
  35710. return *v, true
  35711. }
  35712. // ResetType resets all changes to the "type" field.
  35713. func (m *UsageStatisticMonthMutation) ResetType() {
  35714. m._type = nil
  35715. m.add_type = nil
  35716. }
  35717. // SetBotID sets the "bot_id" field.
  35718. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  35719. m.bot_id = &s
  35720. }
  35721. // BotID returns the value of the "bot_id" field in the mutation.
  35722. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  35723. v := m.bot_id
  35724. if v == nil {
  35725. return
  35726. }
  35727. return *v, true
  35728. }
  35729. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  35730. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35732. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  35733. if !m.op.Is(OpUpdateOne) {
  35734. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35735. }
  35736. if m.id == nil || m.oldValue == nil {
  35737. return v, errors.New("OldBotID requires an ID field in the mutation")
  35738. }
  35739. oldValue, err := m.oldValue(ctx)
  35740. if err != nil {
  35741. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35742. }
  35743. return oldValue.BotID, nil
  35744. }
  35745. // ClearBotID clears the value of the "bot_id" field.
  35746. func (m *UsageStatisticMonthMutation) ClearBotID() {
  35747. m.bot_id = nil
  35748. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  35749. }
  35750. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  35751. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  35752. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  35753. return ok
  35754. }
  35755. // ResetBotID resets all changes to the "bot_id" field.
  35756. func (m *UsageStatisticMonthMutation) ResetBotID() {
  35757. m.bot_id = nil
  35758. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  35759. }
  35760. // SetOrganizationID sets the "organization_id" field.
  35761. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  35762. m.organization_id = &u
  35763. m.addorganization_id = nil
  35764. }
  35765. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35766. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  35767. v := m.organization_id
  35768. if v == nil {
  35769. return
  35770. }
  35771. return *v, true
  35772. }
  35773. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  35774. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35776. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35777. if !m.op.Is(OpUpdateOne) {
  35778. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35779. }
  35780. if m.id == nil || m.oldValue == nil {
  35781. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35782. }
  35783. oldValue, err := m.oldValue(ctx)
  35784. if err != nil {
  35785. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35786. }
  35787. return oldValue.OrganizationID, nil
  35788. }
  35789. // AddOrganizationID adds u to the "organization_id" field.
  35790. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  35791. if m.addorganization_id != nil {
  35792. *m.addorganization_id += u
  35793. } else {
  35794. m.addorganization_id = &u
  35795. }
  35796. }
  35797. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35798. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  35799. v := m.addorganization_id
  35800. if v == nil {
  35801. return
  35802. }
  35803. return *v, true
  35804. }
  35805. // ClearOrganizationID clears the value of the "organization_id" field.
  35806. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  35807. m.organization_id = nil
  35808. m.addorganization_id = nil
  35809. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  35810. }
  35811. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35812. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  35813. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  35814. return ok
  35815. }
  35816. // ResetOrganizationID resets all changes to the "organization_id" field.
  35817. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  35818. m.organization_id = nil
  35819. m.addorganization_id = nil
  35820. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  35821. }
  35822. // SetAiResponse sets the "ai_response" field.
  35823. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  35824. m.ai_response = &u
  35825. m.addai_response = nil
  35826. }
  35827. // AiResponse returns the value of the "ai_response" field in the mutation.
  35828. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  35829. v := m.ai_response
  35830. if v == nil {
  35831. return
  35832. }
  35833. return *v, true
  35834. }
  35835. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  35836. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35838. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  35839. if !m.op.Is(OpUpdateOne) {
  35840. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  35841. }
  35842. if m.id == nil || m.oldValue == nil {
  35843. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  35844. }
  35845. oldValue, err := m.oldValue(ctx)
  35846. if err != nil {
  35847. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  35848. }
  35849. return oldValue.AiResponse, nil
  35850. }
  35851. // AddAiResponse adds u to the "ai_response" field.
  35852. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  35853. if m.addai_response != nil {
  35854. *m.addai_response += u
  35855. } else {
  35856. m.addai_response = &u
  35857. }
  35858. }
  35859. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  35860. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  35861. v := m.addai_response
  35862. if v == nil {
  35863. return
  35864. }
  35865. return *v, true
  35866. }
  35867. // ResetAiResponse resets all changes to the "ai_response" field.
  35868. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  35869. m.ai_response = nil
  35870. m.addai_response = nil
  35871. }
  35872. // SetSopRun sets the "sop_run" field.
  35873. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  35874. m.sop_run = &u
  35875. m.addsop_run = nil
  35876. }
  35877. // SopRun returns the value of the "sop_run" field in the mutation.
  35878. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  35879. v := m.sop_run
  35880. if v == nil {
  35881. return
  35882. }
  35883. return *v, true
  35884. }
  35885. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  35886. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35888. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  35889. if !m.op.Is(OpUpdateOne) {
  35890. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  35891. }
  35892. if m.id == nil || m.oldValue == nil {
  35893. return v, errors.New("OldSopRun requires an ID field in the mutation")
  35894. }
  35895. oldValue, err := m.oldValue(ctx)
  35896. if err != nil {
  35897. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  35898. }
  35899. return oldValue.SopRun, nil
  35900. }
  35901. // AddSopRun adds u to the "sop_run" field.
  35902. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  35903. if m.addsop_run != nil {
  35904. *m.addsop_run += u
  35905. } else {
  35906. m.addsop_run = &u
  35907. }
  35908. }
  35909. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  35910. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  35911. v := m.addsop_run
  35912. if v == nil {
  35913. return
  35914. }
  35915. return *v, true
  35916. }
  35917. // ResetSopRun resets all changes to the "sop_run" field.
  35918. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  35919. m.sop_run = nil
  35920. m.addsop_run = nil
  35921. }
  35922. // SetTotalFriend sets the "total_friend" field.
  35923. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  35924. m.total_friend = &u
  35925. m.addtotal_friend = nil
  35926. }
  35927. // TotalFriend returns the value of the "total_friend" field in the mutation.
  35928. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  35929. v := m.total_friend
  35930. if v == nil {
  35931. return
  35932. }
  35933. return *v, true
  35934. }
  35935. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  35936. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35938. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  35939. if !m.op.Is(OpUpdateOne) {
  35940. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  35941. }
  35942. if m.id == nil || m.oldValue == nil {
  35943. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  35944. }
  35945. oldValue, err := m.oldValue(ctx)
  35946. if err != nil {
  35947. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  35948. }
  35949. return oldValue.TotalFriend, nil
  35950. }
  35951. // AddTotalFriend adds u to the "total_friend" field.
  35952. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  35953. if m.addtotal_friend != nil {
  35954. *m.addtotal_friend += u
  35955. } else {
  35956. m.addtotal_friend = &u
  35957. }
  35958. }
  35959. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  35960. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  35961. v := m.addtotal_friend
  35962. if v == nil {
  35963. return
  35964. }
  35965. return *v, true
  35966. }
  35967. // ResetTotalFriend resets all changes to the "total_friend" field.
  35968. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  35969. m.total_friend = nil
  35970. m.addtotal_friend = nil
  35971. }
  35972. // SetTotalGroup sets the "total_group" field.
  35973. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  35974. m.total_group = &u
  35975. m.addtotal_group = nil
  35976. }
  35977. // TotalGroup returns the value of the "total_group" field in the mutation.
  35978. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  35979. v := m.total_group
  35980. if v == nil {
  35981. return
  35982. }
  35983. return *v, true
  35984. }
  35985. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  35986. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35988. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  35989. if !m.op.Is(OpUpdateOne) {
  35990. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  35991. }
  35992. if m.id == nil || m.oldValue == nil {
  35993. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  35994. }
  35995. oldValue, err := m.oldValue(ctx)
  35996. if err != nil {
  35997. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  35998. }
  35999. return oldValue.TotalGroup, nil
  36000. }
  36001. // AddTotalGroup adds u to the "total_group" field.
  36002. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  36003. if m.addtotal_group != nil {
  36004. *m.addtotal_group += u
  36005. } else {
  36006. m.addtotal_group = &u
  36007. }
  36008. }
  36009. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36010. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  36011. v := m.addtotal_group
  36012. if v == nil {
  36013. return
  36014. }
  36015. return *v, true
  36016. }
  36017. // ResetTotalGroup resets all changes to the "total_group" field.
  36018. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  36019. m.total_group = nil
  36020. m.addtotal_group = nil
  36021. }
  36022. // SetAccountBalance sets the "account_balance" field.
  36023. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  36024. m.account_balance = &u
  36025. m.addaccount_balance = nil
  36026. }
  36027. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36028. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  36029. v := m.account_balance
  36030. if v == nil {
  36031. return
  36032. }
  36033. return *v, true
  36034. }
  36035. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  36036. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36038. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36039. if !m.op.Is(OpUpdateOne) {
  36040. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36041. }
  36042. if m.id == nil || m.oldValue == nil {
  36043. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36044. }
  36045. oldValue, err := m.oldValue(ctx)
  36046. if err != nil {
  36047. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36048. }
  36049. return oldValue.AccountBalance, nil
  36050. }
  36051. // AddAccountBalance adds u to the "account_balance" field.
  36052. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  36053. if m.addaccount_balance != nil {
  36054. *m.addaccount_balance += u
  36055. } else {
  36056. m.addaccount_balance = &u
  36057. }
  36058. }
  36059. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36060. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  36061. v := m.addaccount_balance
  36062. if v == nil {
  36063. return
  36064. }
  36065. return *v, true
  36066. }
  36067. // ResetAccountBalance resets all changes to the "account_balance" field.
  36068. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  36069. m.account_balance = nil
  36070. m.addaccount_balance = nil
  36071. }
  36072. // SetConsumeToken sets the "consume_token" field.
  36073. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  36074. m.consume_token = &u
  36075. m.addconsume_token = nil
  36076. }
  36077. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36078. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  36079. v := m.consume_token
  36080. if v == nil {
  36081. return
  36082. }
  36083. return *v, true
  36084. }
  36085. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  36086. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36088. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36089. if !m.op.Is(OpUpdateOne) {
  36090. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36091. }
  36092. if m.id == nil || m.oldValue == nil {
  36093. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36094. }
  36095. oldValue, err := m.oldValue(ctx)
  36096. if err != nil {
  36097. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36098. }
  36099. return oldValue.ConsumeToken, nil
  36100. }
  36101. // AddConsumeToken adds u to the "consume_token" field.
  36102. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  36103. if m.addconsume_token != nil {
  36104. *m.addconsume_token += u
  36105. } else {
  36106. m.addconsume_token = &u
  36107. }
  36108. }
  36109. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36110. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  36111. v := m.addconsume_token
  36112. if v == nil {
  36113. return
  36114. }
  36115. return *v, true
  36116. }
  36117. // ResetConsumeToken resets all changes to the "consume_token" field.
  36118. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  36119. m.consume_token = nil
  36120. m.addconsume_token = nil
  36121. }
  36122. // SetActiveUser sets the "active_user" field.
  36123. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  36124. m.active_user = &u
  36125. m.addactive_user = nil
  36126. }
  36127. // ActiveUser returns the value of the "active_user" field in the mutation.
  36128. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  36129. v := m.active_user
  36130. if v == nil {
  36131. return
  36132. }
  36133. return *v, true
  36134. }
  36135. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  36136. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36138. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36139. if !m.op.Is(OpUpdateOne) {
  36140. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36141. }
  36142. if m.id == nil || m.oldValue == nil {
  36143. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36144. }
  36145. oldValue, err := m.oldValue(ctx)
  36146. if err != nil {
  36147. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36148. }
  36149. return oldValue.ActiveUser, nil
  36150. }
  36151. // AddActiveUser adds u to the "active_user" field.
  36152. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  36153. if m.addactive_user != nil {
  36154. *m.addactive_user += u
  36155. } else {
  36156. m.addactive_user = &u
  36157. }
  36158. }
  36159. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36160. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  36161. v := m.addactive_user
  36162. if v == nil {
  36163. return
  36164. }
  36165. return *v, true
  36166. }
  36167. // ResetActiveUser resets all changes to the "active_user" field.
  36168. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  36169. m.active_user = nil
  36170. m.addactive_user = nil
  36171. }
  36172. // SetNewUser sets the "new_user" field.
  36173. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  36174. m.new_user = &i
  36175. m.addnew_user = nil
  36176. }
  36177. // NewUser returns the value of the "new_user" field in the mutation.
  36178. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  36179. v := m.new_user
  36180. if v == nil {
  36181. return
  36182. }
  36183. return *v, true
  36184. }
  36185. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  36186. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36188. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36189. if !m.op.Is(OpUpdateOne) {
  36190. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36191. }
  36192. if m.id == nil || m.oldValue == nil {
  36193. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36194. }
  36195. oldValue, err := m.oldValue(ctx)
  36196. if err != nil {
  36197. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36198. }
  36199. return oldValue.NewUser, nil
  36200. }
  36201. // AddNewUser adds i to the "new_user" field.
  36202. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  36203. if m.addnew_user != nil {
  36204. *m.addnew_user += i
  36205. } else {
  36206. m.addnew_user = &i
  36207. }
  36208. }
  36209. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36210. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  36211. v := m.addnew_user
  36212. if v == nil {
  36213. return
  36214. }
  36215. return *v, true
  36216. }
  36217. // ResetNewUser resets all changes to the "new_user" field.
  36218. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  36219. m.new_user = nil
  36220. m.addnew_user = nil
  36221. }
  36222. // SetLabelDist sets the "label_dist" field.
  36223. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36224. m.label_dist = &ctd
  36225. m.appendlabel_dist = nil
  36226. }
  36227. // LabelDist returns the value of the "label_dist" field in the mutation.
  36228. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36229. v := m.label_dist
  36230. if v == nil {
  36231. return
  36232. }
  36233. return *v, true
  36234. }
  36235. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  36236. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36238. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36239. if !m.op.Is(OpUpdateOne) {
  36240. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36241. }
  36242. if m.id == nil || m.oldValue == nil {
  36243. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36244. }
  36245. oldValue, err := m.oldValue(ctx)
  36246. if err != nil {
  36247. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36248. }
  36249. return oldValue.LabelDist, nil
  36250. }
  36251. // AppendLabelDist adds ctd to the "label_dist" field.
  36252. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36253. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36254. }
  36255. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36256. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36257. if len(m.appendlabel_dist) == 0 {
  36258. return nil, false
  36259. }
  36260. return m.appendlabel_dist, true
  36261. }
  36262. // ResetLabelDist resets all changes to the "label_dist" field.
  36263. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  36264. m.label_dist = nil
  36265. m.appendlabel_dist = nil
  36266. }
  36267. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  36268. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  36269. m.predicates = append(m.predicates, ps...)
  36270. }
  36271. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  36272. // users can use type-assertion to append predicates that do not depend on any generated package.
  36273. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  36274. p := make([]predicate.UsageStatisticMonth, len(ps))
  36275. for i := range ps {
  36276. p[i] = ps[i]
  36277. }
  36278. m.Where(p...)
  36279. }
  36280. // Op returns the operation name.
  36281. func (m *UsageStatisticMonthMutation) Op() Op {
  36282. return m.op
  36283. }
  36284. // SetOp allows setting the mutation operation.
  36285. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  36286. m.op = op
  36287. }
  36288. // Type returns the node type of this mutation (UsageStatisticMonth).
  36289. func (m *UsageStatisticMonthMutation) Type() string {
  36290. return m.typ
  36291. }
  36292. // Fields returns all fields that were changed during this mutation. Note that in
  36293. // order to get all numeric fields that were incremented/decremented, call
  36294. // AddedFields().
  36295. func (m *UsageStatisticMonthMutation) Fields() []string {
  36296. fields := make([]string, 0, 17)
  36297. if m.created_at != nil {
  36298. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  36299. }
  36300. if m.updated_at != nil {
  36301. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  36302. }
  36303. if m.status != nil {
  36304. fields = append(fields, usagestatisticmonth.FieldStatus)
  36305. }
  36306. if m.deleted_at != nil {
  36307. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  36308. }
  36309. if m.addtime != nil {
  36310. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36311. }
  36312. if m._type != nil {
  36313. fields = append(fields, usagestatisticmonth.FieldType)
  36314. }
  36315. if m.bot_id != nil {
  36316. fields = append(fields, usagestatisticmonth.FieldBotID)
  36317. }
  36318. if m.organization_id != nil {
  36319. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36320. }
  36321. if m.ai_response != nil {
  36322. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36323. }
  36324. if m.sop_run != nil {
  36325. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36326. }
  36327. if m.total_friend != nil {
  36328. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36329. }
  36330. if m.total_group != nil {
  36331. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36332. }
  36333. if m.account_balance != nil {
  36334. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36335. }
  36336. if m.consume_token != nil {
  36337. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36338. }
  36339. if m.active_user != nil {
  36340. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36341. }
  36342. if m.new_user != nil {
  36343. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36344. }
  36345. if m.label_dist != nil {
  36346. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  36347. }
  36348. return fields
  36349. }
  36350. // Field returns the value of a field with the given name. The second boolean
  36351. // return value indicates that this field was not set, or was not defined in the
  36352. // schema.
  36353. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  36354. switch name {
  36355. case usagestatisticmonth.FieldCreatedAt:
  36356. return m.CreatedAt()
  36357. case usagestatisticmonth.FieldUpdatedAt:
  36358. return m.UpdatedAt()
  36359. case usagestatisticmonth.FieldStatus:
  36360. return m.Status()
  36361. case usagestatisticmonth.FieldDeletedAt:
  36362. return m.DeletedAt()
  36363. case usagestatisticmonth.FieldAddtime:
  36364. return m.Addtime()
  36365. case usagestatisticmonth.FieldType:
  36366. return m.GetType()
  36367. case usagestatisticmonth.FieldBotID:
  36368. return m.BotID()
  36369. case usagestatisticmonth.FieldOrganizationID:
  36370. return m.OrganizationID()
  36371. case usagestatisticmonth.FieldAiResponse:
  36372. return m.AiResponse()
  36373. case usagestatisticmonth.FieldSopRun:
  36374. return m.SopRun()
  36375. case usagestatisticmonth.FieldTotalFriend:
  36376. return m.TotalFriend()
  36377. case usagestatisticmonth.FieldTotalGroup:
  36378. return m.TotalGroup()
  36379. case usagestatisticmonth.FieldAccountBalance:
  36380. return m.AccountBalance()
  36381. case usagestatisticmonth.FieldConsumeToken:
  36382. return m.ConsumeToken()
  36383. case usagestatisticmonth.FieldActiveUser:
  36384. return m.ActiveUser()
  36385. case usagestatisticmonth.FieldNewUser:
  36386. return m.NewUser()
  36387. case usagestatisticmonth.FieldLabelDist:
  36388. return m.LabelDist()
  36389. }
  36390. return nil, false
  36391. }
  36392. // OldField returns the old value of the field from the database. An error is
  36393. // returned if the mutation operation is not UpdateOne, or the query to the
  36394. // database failed.
  36395. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36396. switch name {
  36397. case usagestatisticmonth.FieldCreatedAt:
  36398. return m.OldCreatedAt(ctx)
  36399. case usagestatisticmonth.FieldUpdatedAt:
  36400. return m.OldUpdatedAt(ctx)
  36401. case usagestatisticmonth.FieldStatus:
  36402. return m.OldStatus(ctx)
  36403. case usagestatisticmonth.FieldDeletedAt:
  36404. return m.OldDeletedAt(ctx)
  36405. case usagestatisticmonth.FieldAddtime:
  36406. return m.OldAddtime(ctx)
  36407. case usagestatisticmonth.FieldType:
  36408. return m.OldType(ctx)
  36409. case usagestatisticmonth.FieldBotID:
  36410. return m.OldBotID(ctx)
  36411. case usagestatisticmonth.FieldOrganizationID:
  36412. return m.OldOrganizationID(ctx)
  36413. case usagestatisticmonth.FieldAiResponse:
  36414. return m.OldAiResponse(ctx)
  36415. case usagestatisticmonth.FieldSopRun:
  36416. return m.OldSopRun(ctx)
  36417. case usagestatisticmonth.FieldTotalFriend:
  36418. return m.OldTotalFriend(ctx)
  36419. case usagestatisticmonth.FieldTotalGroup:
  36420. return m.OldTotalGroup(ctx)
  36421. case usagestatisticmonth.FieldAccountBalance:
  36422. return m.OldAccountBalance(ctx)
  36423. case usagestatisticmonth.FieldConsumeToken:
  36424. return m.OldConsumeToken(ctx)
  36425. case usagestatisticmonth.FieldActiveUser:
  36426. return m.OldActiveUser(ctx)
  36427. case usagestatisticmonth.FieldNewUser:
  36428. return m.OldNewUser(ctx)
  36429. case usagestatisticmonth.FieldLabelDist:
  36430. return m.OldLabelDist(ctx)
  36431. }
  36432. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36433. }
  36434. // SetField sets the value of a field with the given name. It returns an error if
  36435. // the field is not defined in the schema, or if the type mismatched the field
  36436. // type.
  36437. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  36438. switch name {
  36439. case usagestatisticmonth.FieldCreatedAt:
  36440. v, ok := value.(time.Time)
  36441. if !ok {
  36442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36443. }
  36444. m.SetCreatedAt(v)
  36445. return nil
  36446. case usagestatisticmonth.FieldUpdatedAt:
  36447. v, ok := value.(time.Time)
  36448. if !ok {
  36449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36450. }
  36451. m.SetUpdatedAt(v)
  36452. return nil
  36453. case usagestatisticmonth.FieldStatus:
  36454. v, ok := value.(uint8)
  36455. if !ok {
  36456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36457. }
  36458. m.SetStatus(v)
  36459. return nil
  36460. case usagestatisticmonth.FieldDeletedAt:
  36461. v, ok := value.(time.Time)
  36462. if !ok {
  36463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36464. }
  36465. m.SetDeletedAt(v)
  36466. return nil
  36467. case usagestatisticmonth.FieldAddtime:
  36468. v, ok := value.(uint64)
  36469. if !ok {
  36470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36471. }
  36472. m.SetAddtime(v)
  36473. return nil
  36474. case usagestatisticmonth.FieldType:
  36475. v, ok := value.(int)
  36476. if !ok {
  36477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36478. }
  36479. m.SetType(v)
  36480. return nil
  36481. case usagestatisticmonth.FieldBotID:
  36482. v, ok := value.(string)
  36483. if !ok {
  36484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36485. }
  36486. m.SetBotID(v)
  36487. return nil
  36488. case usagestatisticmonth.FieldOrganizationID:
  36489. v, ok := value.(uint64)
  36490. if !ok {
  36491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36492. }
  36493. m.SetOrganizationID(v)
  36494. return nil
  36495. case usagestatisticmonth.FieldAiResponse:
  36496. v, ok := value.(uint64)
  36497. if !ok {
  36498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36499. }
  36500. m.SetAiResponse(v)
  36501. return nil
  36502. case usagestatisticmonth.FieldSopRun:
  36503. v, ok := value.(uint64)
  36504. if !ok {
  36505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36506. }
  36507. m.SetSopRun(v)
  36508. return nil
  36509. case usagestatisticmonth.FieldTotalFriend:
  36510. v, ok := value.(uint64)
  36511. if !ok {
  36512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36513. }
  36514. m.SetTotalFriend(v)
  36515. return nil
  36516. case usagestatisticmonth.FieldTotalGroup:
  36517. v, ok := value.(uint64)
  36518. if !ok {
  36519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36520. }
  36521. m.SetTotalGroup(v)
  36522. return nil
  36523. case usagestatisticmonth.FieldAccountBalance:
  36524. v, ok := value.(uint64)
  36525. if !ok {
  36526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36527. }
  36528. m.SetAccountBalance(v)
  36529. return nil
  36530. case usagestatisticmonth.FieldConsumeToken:
  36531. v, ok := value.(uint64)
  36532. if !ok {
  36533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36534. }
  36535. m.SetConsumeToken(v)
  36536. return nil
  36537. case usagestatisticmonth.FieldActiveUser:
  36538. v, ok := value.(uint64)
  36539. if !ok {
  36540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36541. }
  36542. m.SetActiveUser(v)
  36543. return nil
  36544. case usagestatisticmonth.FieldNewUser:
  36545. v, ok := value.(int64)
  36546. if !ok {
  36547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36548. }
  36549. m.SetNewUser(v)
  36550. return nil
  36551. case usagestatisticmonth.FieldLabelDist:
  36552. v, ok := value.([]custom_types.LabelDist)
  36553. if !ok {
  36554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36555. }
  36556. m.SetLabelDist(v)
  36557. return nil
  36558. }
  36559. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36560. }
  36561. // AddedFields returns all numeric fields that were incremented/decremented during
  36562. // this mutation.
  36563. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  36564. var fields []string
  36565. if m.addstatus != nil {
  36566. fields = append(fields, usagestatisticmonth.FieldStatus)
  36567. }
  36568. if m.addaddtime != nil {
  36569. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36570. }
  36571. if m.add_type != nil {
  36572. fields = append(fields, usagestatisticmonth.FieldType)
  36573. }
  36574. if m.addorganization_id != nil {
  36575. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36576. }
  36577. if m.addai_response != nil {
  36578. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36579. }
  36580. if m.addsop_run != nil {
  36581. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36582. }
  36583. if m.addtotal_friend != nil {
  36584. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36585. }
  36586. if m.addtotal_group != nil {
  36587. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36588. }
  36589. if m.addaccount_balance != nil {
  36590. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36591. }
  36592. if m.addconsume_token != nil {
  36593. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36594. }
  36595. if m.addactive_user != nil {
  36596. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36597. }
  36598. if m.addnew_user != nil {
  36599. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36600. }
  36601. return fields
  36602. }
  36603. // AddedField returns the numeric value that was incremented/decremented on a field
  36604. // with the given name. The second boolean return value indicates that this field
  36605. // was not set, or was not defined in the schema.
  36606. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  36607. switch name {
  36608. case usagestatisticmonth.FieldStatus:
  36609. return m.AddedStatus()
  36610. case usagestatisticmonth.FieldAddtime:
  36611. return m.AddedAddtime()
  36612. case usagestatisticmonth.FieldType:
  36613. return m.AddedType()
  36614. case usagestatisticmonth.FieldOrganizationID:
  36615. return m.AddedOrganizationID()
  36616. case usagestatisticmonth.FieldAiResponse:
  36617. return m.AddedAiResponse()
  36618. case usagestatisticmonth.FieldSopRun:
  36619. return m.AddedSopRun()
  36620. case usagestatisticmonth.FieldTotalFriend:
  36621. return m.AddedTotalFriend()
  36622. case usagestatisticmonth.FieldTotalGroup:
  36623. return m.AddedTotalGroup()
  36624. case usagestatisticmonth.FieldAccountBalance:
  36625. return m.AddedAccountBalance()
  36626. case usagestatisticmonth.FieldConsumeToken:
  36627. return m.AddedConsumeToken()
  36628. case usagestatisticmonth.FieldActiveUser:
  36629. return m.AddedActiveUser()
  36630. case usagestatisticmonth.FieldNewUser:
  36631. return m.AddedNewUser()
  36632. }
  36633. return nil, false
  36634. }
  36635. // AddField adds the value to the field with the given name. It returns an error if
  36636. // the field is not defined in the schema, or if the type mismatched the field
  36637. // type.
  36638. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  36639. switch name {
  36640. case usagestatisticmonth.FieldStatus:
  36641. v, ok := value.(int8)
  36642. if !ok {
  36643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36644. }
  36645. m.AddStatus(v)
  36646. return nil
  36647. case usagestatisticmonth.FieldAddtime:
  36648. v, ok := value.(int64)
  36649. if !ok {
  36650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36651. }
  36652. m.AddAddtime(v)
  36653. return nil
  36654. case usagestatisticmonth.FieldType:
  36655. v, ok := value.(int)
  36656. if !ok {
  36657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36658. }
  36659. m.AddType(v)
  36660. return nil
  36661. case usagestatisticmonth.FieldOrganizationID:
  36662. v, ok := value.(int64)
  36663. if !ok {
  36664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36665. }
  36666. m.AddOrganizationID(v)
  36667. return nil
  36668. case usagestatisticmonth.FieldAiResponse:
  36669. v, ok := value.(int64)
  36670. if !ok {
  36671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36672. }
  36673. m.AddAiResponse(v)
  36674. return nil
  36675. case usagestatisticmonth.FieldSopRun:
  36676. v, ok := value.(int64)
  36677. if !ok {
  36678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36679. }
  36680. m.AddSopRun(v)
  36681. return nil
  36682. case usagestatisticmonth.FieldTotalFriend:
  36683. v, ok := value.(int64)
  36684. if !ok {
  36685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36686. }
  36687. m.AddTotalFriend(v)
  36688. return nil
  36689. case usagestatisticmonth.FieldTotalGroup:
  36690. v, ok := value.(int64)
  36691. if !ok {
  36692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36693. }
  36694. m.AddTotalGroup(v)
  36695. return nil
  36696. case usagestatisticmonth.FieldAccountBalance:
  36697. v, ok := value.(int64)
  36698. if !ok {
  36699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36700. }
  36701. m.AddAccountBalance(v)
  36702. return nil
  36703. case usagestatisticmonth.FieldConsumeToken:
  36704. v, ok := value.(int64)
  36705. if !ok {
  36706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36707. }
  36708. m.AddConsumeToken(v)
  36709. return nil
  36710. case usagestatisticmonth.FieldActiveUser:
  36711. v, ok := value.(int64)
  36712. if !ok {
  36713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36714. }
  36715. m.AddActiveUser(v)
  36716. return nil
  36717. case usagestatisticmonth.FieldNewUser:
  36718. v, ok := value.(int64)
  36719. if !ok {
  36720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36721. }
  36722. m.AddNewUser(v)
  36723. return nil
  36724. }
  36725. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  36726. }
  36727. // ClearedFields returns all nullable fields that were cleared during this
  36728. // mutation.
  36729. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  36730. var fields []string
  36731. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  36732. fields = append(fields, usagestatisticmonth.FieldStatus)
  36733. }
  36734. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  36735. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  36736. }
  36737. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  36738. fields = append(fields, usagestatisticmonth.FieldBotID)
  36739. }
  36740. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  36741. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36742. }
  36743. return fields
  36744. }
  36745. // FieldCleared returns a boolean indicating if a field with the given name was
  36746. // cleared in this mutation.
  36747. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  36748. _, ok := m.clearedFields[name]
  36749. return ok
  36750. }
  36751. // ClearField clears the value of the field with the given name. It returns an
  36752. // error if the field is not defined in the schema.
  36753. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  36754. switch name {
  36755. case usagestatisticmonth.FieldStatus:
  36756. m.ClearStatus()
  36757. return nil
  36758. case usagestatisticmonth.FieldDeletedAt:
  36759. m.ClearDeletedAt()
  36760. return nil
  36761. case usagestatisticmonth.FieldBotID:
  36762. m.ClearBotID()
  36763. return nil
  36764. case usagestatisticmonth.FieldOrganizationID:
  36765. m.ClearOrganizationID()
  36766. return nil
  36767. }
  36768. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  36769. }
  36770. // ResetField resets all changes in the mutation for the field with the given name.
  36771. // It returns an error if the field is not defined in the schema.
  36772. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  36773. switch name {
  36774. case usagestatisticmonth.FieldCreatedAt:
  36775. m.ResetCreatedAt()
  36776. return nil
  36777. case usagestatisticmonth.FieldUpdatedAt:
  36778. m.ResetUpdatedAt()
  36779. return nil
  36780. case usagestatisticmonth.FieldStatus:
  36781. m.ResetStatus()
  36782. return nil
  36783. case usagestatisticmonth.FieldDeletedAt:
  36784. m.ResetDeletedAt()
  36785. return nil
  36786. case usagestatisticmonth.FieldAddtime:
  36787. m.ResetAddtime()
  36788. return nil
  36789. case usagestatisticmonth.FieldType:
  36790. m.ResetType()
  36791. return nil
  36792. case usagestatisticmonth.FieldBotID:
  36793. m.ResetBotID()
  36794. return nil
  36795. case usagestatisticmonth.FieldOrganizationID:
  36796. m.ResetOrganizationID()
  36797. return nil
  36798. case usagestatisticmonth.FieldAiResponse:
  36799. m.ResetAiResponse()
  36800. return nil
  36801. case usagestatisticmonth.FieldSopRun:
  36802. m.ResetSopRun()
  36803. return nil
  36804. case usagestatisticmonth.FieldTotalFriend:
  36805. m.ResetTotalFriend()
  36806. return nil
  36807. case usagestatisticmonth.FieldTotalGroup:
  36808. m.ResetTotalGroup()
  36809. return nil
  36810. case usagestatisticmonth.FieldAccountBalance:
  36811. m.ResetAccountBalance()
  36812. return nil
  36813. case usagestatisticmonth.FieldConsumeToken:
  36814. m.ResetConsumeToken()
  36815. return nil
  36816. case usagestatisticmonth.FieldActiveUser:
  36817. m.ResetActiveUser()
  36818. return nil
  36819. case usagestatisticmonth.FieldNewUser:
  36820. m.ResetNewUser()
  36821. return nil
  36822. case usagestatisticmonth.FieldLabelDist:
  36823. m.ResetLabelDist()
  36824. return nil
  36825. }
  36826. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36827. }
  36828. // AddedEdges returns all edge names that were set/added in this mutation.
  36829. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  36830. edges := make([]string, 0, 0)
  36831. return edges
  36832. }
  36833. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36834. // name in this mutation.
  36835. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  36836. return nil
  36837. }
  36838. // RemovedEdges returns all edge names that were removed in this mutation.
  36839. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  36840. edges := make([]string, 0, 0)
  36841. return edges
  36842. }
  36843. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36844. // the given name in this mutation.
  36845. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  36846. return nil
  36847. }
  36848. // ClearedEdges returns all edge names that were cleared in this mutation.
  36849. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  36850. edges := make([]string, 0, 0)
  36851. return edges
  36852. }
  36853. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36854. // was cleared in this mutation.
  36855. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  36856. return false
  36857. }
  36858. // ClearEdge clears the value of the edge with the given name. It returns an error
  36859. // if that edge is not defined in the schema.
  36860. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  36861. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  36862. }
  36863. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36864. // It returns an error if the edge is not defined in the schema.
  36865. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  36866. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  36867. }
  36868. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  36869. type UsageTotalMutation struct {
  36870. config
  36871. op Op
  36872. typ string
  36873. id *uint64
  36874. created_at *time.Time
  36875. updated_at *time.Time
  36876. status *uint8
  36877. addstatus *int8
  36878. _type *int
  36879. add_type *int
  36880. bot_id *string
  36881. total_tokens *uint64
  36882. addtotal_tokens *int64
  36883. start_index *uint64
  36884. addstart_index *int64
  36885. end_index *uint64
  36886. addend_index *int64
  36887. organization_id *uint64
  36888. addorganization_id *int64
  36889. clearedFields map[string]struct{}
  36890. done bool
  36891. oldValue func(context.Context) (*UsageTotal, error)
  36892. predicates []predicate.UsageTotal
  36893. }
  36894. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  36895. // usagetotalOption allows management of the mutation configuration using functional options.
  36896. type usagetotalOption func(*UsageTotalMutation)
  36897. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  36898. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  36899. m := &UsageTotalMutation{
  36900. config: c,
  36901. op: op,
  36902. typ: TypeUsageTotal,
  36903. clearedFields: make(map[string]struct{}),
  36904. }
  36905. for _, opt := range opts {
  36906. opt(m)
  36907. }
  36908. return m
  36909. }
  36910. // withUsageTotalID sets the ID field of the mutation.
  36911. func withUsageTotalID(id uint64) usagetotalOption {
  36912. return func(m *UsageTotalMutation) {
  36913. var (
  36914. err error
  36915. once sync.Once
  36916. value *UsageTotal
  36917. )
  36918. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  36919. once.Do(func() {
  36920. if m.done {
  36921. err = errors.New("querying old values post mutation is not allowed")
  36922. } else {
  36923. value, err = m.Client().UsageTotal.Get(ctx, id)
  36924. }
  36925. })
  36926. return value, err
  36927. }
  36928. m.id = &id
  36929. }
  36930. }
  36931. // withUsageTotal sets the old UsageTotal of the mutation.
  36932. func withUsageTotal(node *UsageTotal) usagetotalOption {
  36933. return func(m *UsageTotalMutation) {
  36934. m.oldValue = func(context.Context) (*UsageTotal, error) {
  36935. return node, nil
  36936. }
  36937. m.id = &node.ID
  36938. }
  36939. }
  36940. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36941. // executed in a transaction (ent.Tx), a transactional client is returned.
  36942. func (m UsageTotalMutation) Client() *Client {
  36943. client := &Client{config: m.config}
  36944. client.init()
  36945. return client
  36946. }
  36947. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36948. // it returns an error otherwise.
  36949. func (m UsageTotalMutation) Tx() (*Tx, error) {
  36950. if _, ok := m.driver.(*txDriver); !ok {
  36951. return nil, errors.New("ent: mutation is not running in a transaction")
  36952. }
  36953. tx := &Tx{config: m.config}
  36954. tx.init()
  36955. return tx, nil
  36956. }
  36957. // SetID sets the value of the id field. Note that this
  36958. // operation is only accepted on creation of UsageTotal entities.
  36959. func (m *UsageTotalMutation) SetID(id uint64) {
  36960. m.id = &id
  36961. }
  36962. // ID returns the ID value in the mutation. Note that the ID is only available
  36963. // if it was provided to the builder or after it was returned from the database.
  36964. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  36965. if m.id == nil {
  36966. return
  36967. }
  36968. return *m.id, true
  36969. }
  36970. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36971. // That means, if the mutation is applied within a transaction with an isolation level such
  36972. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36973. // or updated by the mutation.
  36974. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  36975. switch {
  36976. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36977. id, exists := m.ID()
  36978. if exists {
  36979. return []uint64{id}, nil
  36980. }
  36981. fallthrough
  36982. case m.op.Is(OpUpdate | OpDelete):
  36983. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  36984. default:
  36985. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36986. }
  36987. }
  36988. // SetCreatedAt sets the "created_at" field.
  36989. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  36990. m.created_at = &t
  36991. }
  36992. // CreatedAt returns the value of the "created_at" field in the mutation.
  36993. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  36994. v := m.created_at
  36995. if v == nil {
  36996. return
  36997. }
  36998. return *v, true
  36999. }
  37000. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  37001. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37003. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37004. if !m.op.Is(OpUpdateOne) {
  37005. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37006. }
  37007. if m.id == nil || m.oldValue == nil {
  37008. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37009. }
  37010. oldValue, err := m.oldValue(ctx)
  37011. if err != nil {
  37012. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37013. }
  37014. return oldValue.CreatedAt, nil
  37015. }
  37016. // ResetCreatedAt resets all changes to the "created_at" field.
  37017. func (m *UsageTotalMutation) ResetCreatedAt() {
  37018. m.created_at = nil
  37019. }
  37020. // SetUpdatedAt sets the "updated_at" field.
  37021. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  37022. m.updated_at = &t
  37023. }
  37024. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37025. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  37026. v := m.updated_at
  37027. if v == nil {
  37028. return
  37029. }
  37030. return *v, true
  37031. }
  37032. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  37033. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37035. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37036. if !m.op.Is(OpUpdateOne) {
  37037. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37038. }
  37039. if m.id == nil || m.oldValue == nil {
  37040. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37041. }
  37042. oldValue, err := m.oldValue(ctx)
  37043. if err != nil {
  37044. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37045. }
  37046. return oldValue.UpdatedAt, nil
  37047. }
  37048. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37049. func (m *UsageTotalMutation) ResetUpdatedAt() {
  37050. m.updated_at = nil
  37051. }
  37052. // SetStatus sets the "status" field.
  37053. func (m *UsageTotalMutation) SetStatus(u uint8) {
  37054. m.status = &u
  37055. m.addstatus = nil
  37056. }
  37057. // Status returns the value of the "status" field in the mutation.
  37058. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  37059. v := m.status
  37060. if v == nil {
  37061. return
  37062. }
  37063. return *v, true
  37064. }
  37065. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  37066. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37068. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37069. if !m.op.Is(OpUpdateOne) {
  37070. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37071. }
  37072. if m.id == nil || m.oldValue == nil {
  37073. return v, errors.New("OldStatus requires an ID field in the mutation")
  37074. }
  37075. oldValue, err := m.oldValue(ctx)
  37076. if err != nil {
  37077. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37078. }
  37079. return oldValue.Status, nil
  37080. }
  37081. // AddStatus adds u to the "status" field.
  37082. func (m *UsageTotalMutation) AddStatus(u int8) {
  37083. if m.addstatus != nil {
  37084. *m.addstatus += u
  37085. } else {
  37086. m.addstatus = &u
  37087. }
  37088. }
  37089. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37090. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  37091. v := m.addstatus
  37092. if v == nil {
  37093. return
  37094. }
  37095. return *v, true
  37096. }
  37097. // ClearStatus clears the value of the "status" field.
  37098. func (m *UsageTotalMutation) ClearStatus() {
  37099. m.status = nil
  37100. m.addstatus = nil
  37101. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  37102. }
  37103. // StatusCleared returns if the "status" field was cleared in this mutation.
  37104. func (m *UsageTotalMutation) StatusCleared() bool {
  37105. _, ok := m.clearedFields[usagetotal.FieldStatus]
  37106. return ok
  37107. }
  37108. // ResetStatus resets all changes to the "status" field.
  37109. func (m *UsageTotalMutation) ResetStatus() {
  37110. m.status = nil
  37111. m.addstatus = nil
  37112. delete(m.clearedFields, usagetotal.FieldStatus)
  37113. }
  37114. // SetType sets the "type" field.
  37115. func (m *UsageTotalMutation) SetType(i int) {
  37116. m._type = &i
  37117. m.add_type = nil
  37118. }
  37119. // GetType returns the value of the "type" field in the mutation.
  37120. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  37121. v := m._type
  37122. if v == nil {
  37123. return
  37124. }
  37125. return *v, true
  37126. }
  37127. // OldType returns the old "type" field's value of the UsageTotal entity.
  37128. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37130. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  37131. if !m.op.Is(OpUpdateOne) {
  37132. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37133. }
  37134. if m.id == nil || m.oldValue == nil {
  37135. return v, errors.New("OldType requires an ID field in the mutation")
  37136. }
  37137. oldValue, err := m.oldValue(ctx)
  37138. if err != nil {
  37139. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37140. }
  37141. return oldValue.Type, nil
  37142. }
  37143. // AddType adds i to the "type" field.
  37144. func (m *UsageTotalMutation) AddType(i int) {
  37145. if m.add_type != nil {
  37146. *m.add_type += i
  37147. } else {
  37148. m.add_type = &i
  37149. }
  37150. }
  37151. // AddedType returns the value that was added to the "type" field in this mutation.
  37152. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  37153. v := m.add_type
  37154. if v == nil {
  37155. return
  37156. }
  37157. return *v, true
  37158. }
  37159. // ClearType clears the value of the "type" field.
  37160. func (m *UsageTotalMutation) ClearType() {
  37161. m._type = nil
  37162. m.add_type = nil
  37163. m.clearedFields[usagetotal.FieldType] = struct{}{}
  37164. }
  37165. // TypeCleared returns if the "type" field was cleared in this mutation.
  37166. func (m *UsageTotalMutation) TypeCleared() bool {
  37167. _, ok := m.clearedFields[usagetotal.FieldType]
  37168. return ok
  37169. }
  37170. // ResetType resets all changes to the "type" field.
  37171. func (m *UsageTotalMutation) ResetType() {
  37172. m._type = nil
  37173. m.add_type = nil
  37174. delete(m.clearedFields, usagetotal.FieldType)
  37175. }
  37176. // SetBotID sets the "bot_id" field.
  37177. func (m *UsageTotalMutation) SetBotID(s string) {
  37178. m.bot_id = &s
  37179. }
  37180. // BotID returns the value of the "bot_id" field in the mutation.
  37181. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  37182. v := m.bot_id
  37183. if v == nil {
  37184. return
  37185. }
  37186. return *v, true
  37187. }
  37188. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  37189. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37191. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  37192. if !m.op.Is(OpUpdateOne) {
  37193. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37194. }
  37195. if m.id == nil || m.oldValue == nil {
  37196. return v, errors.New("OldBotID requires an ID field in the mutation")
  37197. }
  37198. oldValue, err := m.oldValue(ctx)
  37199. if err != nil {
  37200. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37201. }
  37202. return oldValue.BotID, nil
  37203. }
  37204. // ResetBotID resets all changes to the "bot_id" field.
  37205. func (m *UsageTotalMutation) ResetBotID() {
  37206. m.bot_id = nil
  37207. }
  37208. // SetTotalTokens sets the "total_tokens" field.
  37209. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  37210. m.total_tokens = &u
  37211. m.addtotal_tokens = nil
  37212. }
  37213. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  37214. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  37215. v := m.total_tokens
  37216. if v == nil {
  37217. return
  37218. }
  37219. return *v, true
  37220. }
  37221. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  37222. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37224. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  37225. if !m.op.Is(OpUpdateOne) {
  37226. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  37227. }
  37228. if m.id == nil || m.oldValue == nil {
  37229. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  37230. }
  37231. oldValue, err := m.oldValue(ctx)
  37232. if err != nil {
  37233. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  37234. }
  37235. return oldValue.TotalTokens, nil
  37236. }
  37237. // AddTotalTokens adds u to the "total_tokens" field.
  37238. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  37239. if m.addtotal_tokens != nil {
  37240. *m.addtotal_tokens += u
  37241. } else {
  37242. m.addtotal_tokens = &u
  37243. }
  37244. }
  37245. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  37246. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  37247. v := m.addtotal_tokens
  37248. if v == nil {
  37249. return
  37250. }
  37251. return *v, true
  37252. }
  37253. // ClearTotalTokens clears the value of the "total_tokens" field.
  37254. func (m *UsageTotalMutation) ClearTotalTokens() {
  37255. m.total_tokens = nil
  37256. m.addtotal_tokens = nil
  37257. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  37258. }
  37259. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  37260. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  37261. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  37262. return ok
  37263. }
  37264. // ResetTotalTokens resets all changes to the "total_tokens" field.
  37265. func (m *UsageTotalMutation) ResetTotalTokens() {
  37266. m.total_tokens = nil
  37267. m.addtotal_tokens = nil
  37268. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  37269. }
  37270. // SetStartIndex sets the "start_index" field.
  37271. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  37272. m.start_index = &u
  37273. m.addstart_index = nil
  37274. }
  37275. // StartIndex returns the value of the "start_index" field in the mutation.
  37276. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  37277. v := m.start_index
  37278. if v == nil {
  37279. return
  37280. }
  37281. return *v, true
  37282. }
  37283. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  37284. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37286. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  37287. if !m.op.Is(OpUpdateOne) {
  37288. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  37289. }
  37290. if m.id == nil || m.oldValue == nil {
  37291. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  37292. }
  37293. oldValue, err := m.oldValue(ctx)
  37294. if err != nil {
  37295. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  37296. }
  37297. return oldValue.StartIndex, nil
  37298. }
  37299. // AddStartIndex adds u to the "start_index" field.
  37300. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  37301. if m.addstart_index != nil {
  37302. *m.addstart_index += u
  37303. } else {
  37304. m.addstart_index = &u
  37305. }
  37306. }
  37307. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  37308. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  37309. v := m.addstart_index
  37310. if v == nil {
  37311. return
  37312. }
  37313. return *v, true
  37314. }
  37315. // ClearStartIndex clears the value of the "start_index" field.
  37316. func (m *UsageTotalMutation) ClearStartIndex() {
  37317. m.start_index = nil
  37318. m.addstart_index = nil
  37319. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  37320. }
  37321. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  37322. func (m *UsageTotalMutation) StartIndexCleared() bool {
  37323. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  37324. return ok
  37325. }
  37326. // ResetStartIndex resets all changes to the "start_index" field.
  37327. func (m *UsageTotalMutation) ResetStartIndex() {
  37328. m.start_index = nil
  37329. m.addstart_index = nil
  37330. delete(m.clearedFields, usagetotal.FieldStartIndex)
  37331. }
  37332. // SetEndIndex sets the "end_index" field.
  37333. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  37334. m.end_index = &u
  37335. m.addend_index = nil
  37336. }
  37337. // EndIndex returns the value of the "end_index" field in the mutation.
  37338. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  37339. v := m.end_index
  37340. if v == nil {
  37341. return
  37342. }
  37343. return *v, true
  37344. }
  37345. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  37346. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37348. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  37349. if !m.op.Is(OpUpdateOne) {
  37350. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  37351. }
  37352. if m.id == nil || m.oldValue == nil {
  37353. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  37354. }
  37355. oldValue, err := m.oldValue(ctx)
  37356. if err != nil {
  37357. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  37358. }
  37359. return oldValue.EndIndex, nil
  37360. }
  37361. // AddEndIndex adds u to the "end_index" field.
  37362. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  37363. if m.addend_index != nil {
  37364. *m.addend_index += u
  37365. } else {
  37366. m.addend_index = &u
  37367. }
  37368. }
  37369. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  37370. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  37371. v := m.addend_index
  37372. if v == nil {
  37373. return
  37374. }
  37375. return *v, true
  37376. }
  37377. // ClearEndIndex clears the value of the "end_index" field.
  37378. func (m *UsageTotalMutation) ClearEndIndex() {
  37379. m.end_index = nil
  37380. m.addend_index = nil
  37381. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  37382. }
  37383. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  37384. func (m *UsageTotalMutation) EndIndexCleared() bool {
  37385. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  37386. return ok
  37387. }
  37388. // ResetEndIndex resets all changes to the "end_index" field.
  37389. func (m *UsageTotalMutation) ResetEndIndex() {
  37390. m.end_index = nil
  37391. m.addend_index = nil
  37392. delete(m.clearedFields, usagetotal.FieldEndIndex)
  37393. }
  37394. // SetOrganizationID sets the "organization_id" field.
  37395. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  37396. m.organization_id = &u
  37397. m.addorganization_id = nil
  37398. }
  37399. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37400. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  37401. v := m.organization_id
  37402. if v == nil {
  37403. return
  37404. }
  37405. return *v, true
  37406. }
  37407. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  37408. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37410. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37411. if !m.op.Is(OpUpdateOne) {
  37412. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37413. }
  37414. if m.id == nil || m.oldValue == nil {
  37415. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37416. }
  37417. oldValue, err := m.oldValue(ctx)
  37418. if err != nil {
  37419. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37420. }
  37421. return oldValue.OrganizationID, nil
  37422. }
  37423. // AddOrganizationID adds u to the "organization_id" field.
  37424. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  37425. if m.addorganization_id != nil {
  37426. *m.addorganization_id += u
  37427. } else {
  37428. m.addorganization_id = &u
  37429. }
  37430. }
  37431. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37432. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  37433. v := m.addorganization_id
  37434. if v == nil {
  37435. return
  37436. }
  37437. return *v, true
  37438. }
  37439. // ClearOrganizationID clears the value of the "organization_id" field.
  37440. func (m *UsageTotalMutation) ClearOrganizationID() {
  37441. m.organization_id = nil
  37442. m.addorganization_id = nil
  37443. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  37444. }
  37445. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37446. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  37447. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  37448. return ok
  37449. }
  37450. // ResetOrganizationID resets all changes to the "organization_id" field.
  37451. func (m *UsageTotalMutation) ResetOrganizationID() {
  37452. m.organization_id = nil
  37453. m.addorganization_id = nil
  37454. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  37455. }
  37456. // Where appends a list predicates to the UsageTotalMutation builder.
  37457. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  37458. m.predicates = append(m.predicates, ps...)
  37459. }
  37460. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  37461. // users can use type-assertion to append predicates that do not depend on any generated package.
  37462. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  37463. p := make([]predicate.UsageTotal, len(ps))
  37464. for i := range ps {
  37465. p[i] = ps[i]
  37466. }
  37467. m.Where(p...)
  37468. }
  37469. // Op returns the operation name.
  37470. func (m *UsageTotalMutation) Op() Op {
  37471. return m.op
  37472. }
  37473. // SetOp allows setting the mutation operation.
  37474. func (m *UsageTotalMutation) SetOp(op Op) {
  37475. m.op = op
  37476. }
  37477. // Type returns the node type of this mutation (UsageTotal).
  37478. func (m *UsageTotalMutation) Type() string {
  37479. return m.typ
  37480. }
  37481. // Fields returns all fields that were changed during this mutation. Note that in
  37482. // order to get all numeric fields that were incremented/decremented, call
  37483. // AddedFields().
  37484. func (m *UsageTotalMutation) Fields() []string {
  37485. fields := make([]string, 0, 9)
  37486. if m.created_at != nil {
  37487. fields = append(fields, usagetotal.FieldCreatedAt)
  37488. }
  37489. if m.updated_at != nil {
  37490. fields = append(fields, usagetotal.FieldUpdatedAt)
  37491. }
  37492. if m.status != nil {
  37493. fields = append(fields, usagetotal.FieldStatus)
  37494. }
  37495. if m._type != nil {
  37496. fields = append(fields, usagetotal.FieldType)
  37497. }
  37498. if m.bot_id != nil {
  37499. fields = append(fields, usagetotal.FieldBotID)
  37500. }
  37501. if m.total_tokens != nil {
  37502. fields = append(fields, usagetotal.FieldTotalTokens)
  37503. }
  37504. if m.start_index != nil {
  37505. fields = append(fields, usagetotal.FieldStartIndex)
  37506. }
  37507. if m.end_index != nil {
  37508. fields = append(fields, usagetotal.FieldEndIndex)
  37509. }
  37510. if m.organization_id != nil {
  37511. fields = append(fields, usagetotal.FieldOrganizationID)
  37512. }
  37513. return fields
  37514. }
  37515. // Field returns the value of a field with the given name. The second boolean
  37516. // return value indicates that this field was not set, or was not defined in the
  37517. // schema.
  37518. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  37519. switch name {
  37520. case usagetotal.FieldCreatedAt:
  37521. return m.CreatedAt()
  37522. case usagetotal.FieldUpdatedAt:
  37523. return m.UpdatedAt()
  37524. case usagetotal.FieldStatus:
  37525. return m.Status()
  37526. case usagetotal.FieldType:
  37527. return m.GetType()
  37528. case usagetotal.FieldBotID:
  37529. return m.BotID()
  37530. case usagetotal.FieldTotalTokens:
  37531. return m.TotalTokens()
  37532. case usagetotal.FieldStartIndex:
  37533. return m.StartIndex()
  37534. case usagetotal.FieldEndIndex:
  37535. return m.EndIndex()
  37536. case usagetotal.FieldOrganizationID:
  37537. return m.OrganizationID()
  37538. }
  37539. return nil, false
  37540. }
  37541. // OldField returns the old value of the field from the database. An error is
  37542. // returned if the mutation operation is not UpdateOne, or the query to the
  37543. // database failed.
  37544. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37545. switch name {
  37546. case usagetotal.FieldCreatedAt:
  37547. return m.OldCreatedAt(ctx)
  37548. case usagetotal.FieldUpdatedAt:
  37549. return m.OldUpdatedAt(ctx)
  37550. case usagetotal.FieldStatus:
  37551. return m.OldStatus(ctx)
  37552. case usagetotal.FieldType:
  37553. return m.OldType(ctx)
  37554. case usagetotal.FieldBotID:
  37555. return m.OldBotID(ctx)
  37556. case usagetotal.FieldTotalTokens:
  37557. return m.OldTotalTokens(ctx)
  37558. case usagetotal.FieldStartIndex:
  37559. return m.OldStartIndex(ctx)
  37560. case usagetotal.FieldEndIndex:
  37561. return m.OldEndIndex(ctx)
  37562. case usagetotal.FieldOrganizationID:
  37563. return m.OldOrganizationID(ctx)
  37564. }
  37565. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  37566. }
  37567. // SetField sets the value of a field with the given name. It returns an error if
  37568. // the field is not defined in the schema, or if the type mismatched the field
  37569. // type.
  37570. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  37571. switch name {
  37572. case usagetotal.FieldCreatedAt:
  37573. v, ok := value.(time.Time)
  37574. if !ok {
  37575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37576. }
  37577. m.SetCreatedAt(v)
  37578. return nil
  37579. case usagetotal.FieldUpdatedAt:
  37580. v, ok := value.(time.Time)
  37581. if !ok {
  37582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37583. }
  37584. m.SetUpdatedAt(v)
  37585. return nil
  37586. case usagetotal.FieldStatus:
  37587. v, ok := value.(uint8)
  37588. if !ok {
  37589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37590. }
  37591. m.SetStatus(v)
  37592. return nil
  37593. case usagetotal.FieldType:
  37594. v, ok := value.(int)
  37595. if !ok {
  37596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37597. }
  37598. m.SetType(v)
  37599. return nil
  37600. case usagetotal.FieldBotID:
  37601. v, ok := value.(string)
  37602. if !ok {
  37603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37604. }
  37605. m.SetBotID(v)
  37606. return nil
  37607. case usagetotal.FieldTotalTokens:
  37608. v, ok := value.(uint64)
  37609. if !ok {
  37610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37611. }
  37612. m.SetTotalTokens(v)
  37613. return nil
  37614. case usagetotal.FieldStartIndex:
  37615. v, ok := value.(uint64)
  37616. if !ok {
  37617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37618. }
  37619. m.SetStartIndex(v)
  37620. return nil
  37621. case usagetotal.FieldEndIndex:
  37622. v, ok := value.(uint64)
  37623. if !ok {
  37624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37625. }
  37626. m.SetEndIndex(v)
  37627. return nil
  37628. case usagetotal.FieldOrganizationID:
  37629. v, ok := value.(uint64)
  37630. if !ok {
  37631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37632. }
  37633. m.SetOrganizationID(v)
  37634. return nil
  37635. }
  37636. return fmt.Errorf("unknown UsageTotal field %s", name)
  37637. }
  37638. // AddedFields returns all numeric fields that were incremented/decremented during
  37639. // this mutation.
  37640. func (m *UsageTotalMutation) AddedFields() []string {
  37641. var fields []string
  37642. if m.addstatus != nil {
  37643. fields = append(fields, usagetotal.FieldStatus)
  37644. }
  37645. if m.add_type != nil {
  37646. fields = append(fields, usagetotal.FieldType)
  37647. }
  37648. if m.addtotal_tokens != nil {
  37649. fields = append(fields, usagetotal.FieldTotalTokens)
  37650. }
  37651. if m.addstart_index != nil {
  37652. fields = append(fields, usagetotal.FieldStartIndex)
  37653. }
  37654. if m.addend_index != nil {
  37655. fields = append(fields, usagetotal.FieldEndIndex)
  37656. }
  37657. if m.addorganization_id != nil {
  37658. fields = append(fields, usagetotal.FieldOrganizationID)
  37659. }
  37660. return fields
  37661. }
  37662. // AddedField returns the numeric value that was incremented/decremented on a field
  37663. // with the given name. The second boolean return value indicates that this field
  37664. // was not set, or was not defined in the schema.
  37665. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  37666. switch name {
  37667. case usagetotal.FieldStatus:
  37668. return m.AddedStatus()
  37669. case usagetotal.FieldType:
  37670. return m.AddedType()
  37671. case usagetotal.FieldTotalTokens:
  37672. return m.AddedTotalTokens()
  37673. case usagetotal.FieldStartIndex:
  37674. return m.AddedStartIndex()
  37675. case usagetotal.FieldEndIndex:
  37676. return m.AddedEndIndex()
  37677. case usagetotal.FieldOrganizationID:
  37678. return m.AddedOrganizationID()
  37679. }
  37680. return nil, false
  37681. }
  37682. // AddField adds the value to the field with the given name. It returns an error if
  37683. // the field is not defined in the schema, or if the type mismatched the field
  37684. // type.
  37685. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  37686. switch name {
  37687. case usagetotal.FieldStatus:
  37688. v, ok := value.(int8)
  37689. if !ok {
  37690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37691. }
  37692. m.AddStatus(v)
  37693. return nil
  37694. case usagetotal.FieldType:
  37695. v, ok := value.(int)
  37696. if !ok {
  37697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37698. }
  37699. m.AddType(v)
  37700. return nil
  37701. case usagetotal.FieldTotalTokens:
  37702. v, ok := value.(int64)
  37703. if !ok {
  37704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37705. }
  37706. m.AddTotalTokens(v)
  37707. return nil
  37708. case usagetotal.FieldStartIndex:
  37709. v, ok := value.(int64)
  37710. if !ok {
  37711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37712. }
  37713. m.AddStartIndex(v)
  37714. return nil
  37715. case usagetotal.FieldEndIndex:
  37716. v, ok := value.(int64)
  37717. if !ok {
  37718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37719. }
  37720. m.AddEndIndex(v)
  37721. return nil
  37722. case usagetotal.FieldOrganizationID:
  37723. v, ok := value.(int64)
  37724. if !ok {
  37725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37726. }
  37727. m.AddOrganizationID(v)
  37728. return nil
  37729. }
  37730. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  37731. }
  37732. // ClearedFields returns all nullable fields that were cleared during this
  37733. // mutation.
  37734. func (m *UsageTotalMutation) ClearedFields() []string {
  37735. var fields []string
  37736. if m.FieldCleared(usagetotal.FieldStatus) {
  37737. fields = append(fields, usagetotal.FieldStatus)
  37738. }
  37739. if m.FieldCleared(usagetotal.FieldType) {
  37740. fields = append(fields, usagetotal.FieldType)
  37741. }
  37742. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  37743. fields = append(fields, usagetotal.FieldTotalTokens)
  37744. }
  37745. if m.FieldCleared(usagetotal.FieldStartIndex) {
  37746. fields = append(fields, usagetotal.FieldStartIndex)
  37747. }
  37748. if m.FieldCleared(usagetotal.FieldEndIndex) {
  37749. fields = append(fields, usagetotal.FieldEndIndex)
  37750. }
  37751. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  37752. fields = append(fields, usagetotal.FieldOrganizationID)
  37753. }
  37754. return fields
  37755. }
  37756. // FieldCleared returns a boolean indicating if a field with the given name was
  37757. // cleared in this mutation.
  37758. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  37759. _, ok := m.clearedFields[name]
  37760. return ok
  37761. }
  37762. // ClearField clears the value of the field with the given name. It returns an
  37763. // error if the field is not defined in the schema.
  37764. func (m *UsageTotalMutation) ClearField(name string) error {
  37765. switch name {
  37766. case usagetotal.FieldStatus:
  37767. m.ClearStatus()
  37768. return nil
  37769. case usagetotal.FieldType:
  37770. m.ClearType()
  37771. return nil
  37772. case usagetotal.FieldTotalTokens:
  37773. m.ClearTotalTokens()
  37774. return nil
  37775. case usagetotal.FieldStartIndex:
  37776. m.ClearStartIndex()
  37777. return nil
  37778. case usagetotal.FieldEndIndex:
  37779. m.ClearEndIndex()
  37780. return nil
  37781. case usagetotal.FieldOrganizationID:
  37782. m.ClearOrganizationID()
  37783. return nil
  37784. }
  37785. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  37786. }
  37787. // ResetField resets all changes in the mutation for the field with the given name.
  37788. // It returns an error if the field is not defined in the schema.
  37789. func (m *UsageTotalMutation) ResetField(name string) error {
  37790. switch name {
  37791. case usagetotal.FieldCreatedAt:
  37792. m.ResetCreatedAt()
  37793. return nil
  37794. case usagetotal.FieldUpdatedAt:
  37795. m.ResetUpdatedAt()
  37796. return nil
  37797. case usagetotal.FieldStatus:
  37798. m.ResetStatus()
  37799. return nil
  37800. case usagetotal.FieldType:
  37801. m.ResetType()
  37802. return nil
  37803. case usagetotal.FieldBotID:
  37804. m.ResetBotID()
  37805. return nil
  37806. case usagetotal.FieldTotalTokens:
  37807. m.ResetTotalTokens()
  37808. return nil
  37809. case usagetotal.FieldStartIndex:
  37810. m.ResetStartIndex()
  37811. return nil
  37812. case usagetotal.FieldEndIndex:
  37813. m.ResetEndIndex()
  37814. return nil
  37815. case usagetotal.FieldOrganizationID:
  37816. m.ResetOrganizationID()
  37817. return nil
  37818. }
  37819. return fmt.Errorf("unknown UsageTotal field %s", name)
  37820. }
  37821. // AddedEdges returns all edge names that were set/added in this mutation.
  37822. func (m *UsageTotalMutation) AddedEdges() []string {
  37823. edges := make([]string, 0, 0)
  37824. return edges
  37825. }
  37826. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37827. // name in this mutation.
  37828. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  37829. return nil
  37830. }
  37831. // RemovedEdges returns all edge names that were removed in this mutation.
  37832. func (m *UsageTotalMutation) RemovedEdges() []string {
  37833. edges := make([]string, 0, 0)
  37834. return edges
  37835. }
  37836. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37837. // the given name in this mutation.
  37838. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  37839. return nil
  37840. }
  37841. // ClearedEdges returns all edge names that were cleared in this mutation.
  37842. func (m *UsageTotalMutation) ClearedEdges() []string {
  37843. edges := make([]string, 0, 0)
  37844. return edges
  37845. }
  37846. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37847. // was cleared in this mutation.
  37848. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  37849. return false
  37850. }
  37851. // ClearEdge clears the value of the edge with the given name. It returns an error
  37852. // if that edge is not defined in the schema.
  37853. func (m *UsageTotalMutation) ClearEdge(name string) error {
  37854. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  37855. }
  37856. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37857. // It returns an error if the edge is not defined in the schema.
  37858. func (m *UsageTotalMutation) ResetEdge(name string) error {
  37859. return fmt.Errorf("unknown UsageTotal edge %s", name)
  37860. }
  37861. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  37862. type WhatsappMutation struct {
  37863. config
  37864. op Op
  37865. typ string
  37866. id *uint64
  37867. created_at *time.Time
  37868. updated_at *time.Time
  37869. status *uint8
  37870. addstatus *int8
  37871. deleted_at *time.Time
  37872. wa_id *string
  37873. wa_name *string
  37874. callback *string
  37875. account *string
  37876. cc *string
  37877. phone *string
  37878. cc_phone *string
  37879. phone_name *string
  37880. phone_status *int8
  37881. addphone_status *int8
  37882. organization_id *uint64
  37883. addorganization_id *int64
  37884. api_base *string
  37885. api_key *string
  37886. allow_list *[]string
  37887. appendallow_list []string
  37888. group_allow_list *[]string
  37889. appendgroup_allow_list []string
  37890. block_list *[]string
  37891. appendblock_list []string
  37892. group_block_list *[]string
  37893. appendgroup_block_list []string
  37894. clearedFields map[string]struct{}
  37895. agent *uint64
  37896. clearedagent bool
  37897. done bool
  37898. oldValue func(context.Context) (*Whatsapp, error)
  37899. predicates []predicate.Whatsapp
  37900. }
  37901. var _ ent.Mutation = (*WhatsappMutation)(nil)
  37902. // whatsappOption allows management of the mutation configuration using functional options.
  37903. type whatsappOption func(*WhatsappMutation)
  37904. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  37905. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  37906. m := &WhatsappMutation{
  37907. config: c,
  37908. op: op,
  37909. typ: TypeWhatsapp,
  37910. clearedFields: make(map[string]struct{}),
  37911. }
  37912. for _, opt := range opts {
  37913. opt(m)
  37914. }
  37915. return m
  37916. }
  37917. // withWhatsappID sets the ID field of the mutation.
  37918. func withWhatsappID(id uint64) whatsappOption {
  37919. return func(m *WhatsappMutation) {
  37920. var (
  37921. err error
  37922. once sync.Once
  37923. value *Whatsapp
  37924. )
  37925. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  37926. once.Do(func() {
  37927. if m.done {
  37928. err = errors.New("querying old values post mutation is not allowed")
  37929. } else {
  37930. value, err = m.Client().Whatsapp.Get(ctx, id)
  37931. }
  37932. })
  37933. return value, err
  37934. }
  37935. m.id = &id
  37936. }
  37937. }
  37938. // withWhatsapp sets the old Whatsapp of the mutation.
  37939. func withWhatsapp(node *Whatsapp) whatsappOption {
  37940. return func(m *WhatsappMutation) {
  37941. m.oldValue = func(context.Context) (*Whatsapp, error) {
  37942. return node, nil
  37943. }
  37944. m.id = &node.ID
  37945. }
  37946. }
  37947. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37948. // executed in a transaction (ent.Tx), a transactional client is returned.
  37949. func (m WhatsappMutation) Client() *Client {
  37950. client := &Client{config: m.config}
  37951. client.init()
  37952. return client
  37953. }
  37954. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37955. // it returns an error otherwise.
  37956. func (m WhatsappMutation) Tx() (*Tx, error) {
  37957. if _, ok := m.driver.(*txDriver); !ok {
  37958. return nil, errors.New("ent: mutation is not running in a transaction")
  37959. }
  37960. tx := &Tx{config: m.config}
  37961. tx.init()
  37962. return tx, nil
  37963. }
  37964. // SetID sets the value of the id field. Note that this
  37965. // operation is only accepted on creation of Whatsapp entities.
  37966. func (m *WhatsappMutation) SetID(id uint64) {
  37967. m.id = &id
  37968. }
  37969. // ID returns the ID value in the mutation. Note that the ID is only available
  37970. // if it was provided to the builder or after it was returned from the database.
  37971. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  37972. if m.id == nil {
  37973. return
  37974. }
  37975. return *m.id, true
  37976. }
  37977. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37978. // That means, if the mutation is applied within a transaction with an isolation level such
  37979. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37980. // or updated by the mutation.
  37981. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  37982. switch {
  37983. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37984. id, exists := m.ID()
  37985. if exists {
  37986. return []uint64{id}, nil
  37987. }
  37988. fallthrough
  37989. case m.op.Is(OpUpdate | OpDelete):
  37990. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  37991. default:
  37992. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37993. }
  37994. }
  37995. // SetCreatedAt sets the "created_at" field.
  37996. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  37997. m.created_at = &t
  37998. }
  37999. // CreatedAt returns the value of the "created_at" field in the mutation.
  38000. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  38001. v := m.created_at
  38002. if v == nil {
  38003. return
  38004. }
  38005. return *v, true
  38006. }
  38007. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  38008. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38010. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38011. if !m.op.Is(OpUpdateOne) {
  38012. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38013. }
  38014. if m.id == nil || m.oldValue == nil {
  38015. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38016. }
  38017. oldValue, err := m.oldValue(ctx)
  38018. if err != nil {
  38019. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38020. }
  38021. return oldValue.CreatedAt, nil
  38022. }
  38023. // ResetCreatedAt resets all changes to the "created_at" field.
  38024. func (m *WhatsappMutation) ResetCreatedAt() {
  38025. m.created_at = nil
  38026. }
  38027. // SetUpdatedAt sets the "updated_at" field.
  38028. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  38029. m.updated_at = &t
  38030. }
  38031. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38032. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  38033. v := m.updated_at
  38034. if v == nil {
  38035. return
  38036. }
  38037. return *v, true
  38038. }
  38039. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  38040. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38042. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38043. if !m.op.Is(OpUpdateOne) {
  38044. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38045. }
  38046. if m.id == nil || m.oldValue == nil {
  38047. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38048. }
  38049. oldValue, err := m.oldValue(ctx)
  38050. if err != nil {
  38051. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38052. }
  38053. return oldValue.UpdatedAt, nil
  38054. }
  38055. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38056. func (m *WhatsappMutation) ResetUpdatedAt() {
  38057. m.updated_at = nil
  38058. }
  38059. // SetStatus sets the "status" field.
  38060. func (m *WhatsappMutation) SetStatus(u uint8) {
  38061. m.status = &u
  38062. m.addstatus = nil
  38063. }
  38064. // Status returns the value of the "status" field in the mutation.
  38065. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  38066. v := m.status
  38067. if v == nil {
  38068. return
  38069. }
  38070. return *v, true
  38071. }
  38072. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  38073. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38075. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38076. if !m.op.Is(OpUpdateOne) {
  38077. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38078. }
  38079. if m.id == nil || m.oldValue == nil {
  38080. return v, errors.New("OldStatus requires an ID field in the mutation")
  38081. }
  38082. oldValue, err := m.oldValue(ctx)
  38083. if err != nil {
  38084. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38085. }
  38086. return oldValue.Status, nil
  38087. }
  38088. // AddStatus adds u to the "status" field.
  38089. func (m *WhatsappMutation) AddStatus(u int8) {
  38090. if m.addstatus != nil {
  38091. *m.addstatus += u
  38092. } else {
  38093. m.addstatus = &u
  38094. }
  38095. }
  38096. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38097. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  38098. v := m.addstatus
  38099. if v == nil {
  38100. return
  38101. }
  38102. return *v, true
  38103. }
  38104. // ClearStatus clears the value of the "status" field.
  38105. func (m *WhatsappMutation) ClearStatus() {
  38106. m.status = nil
  38107. m.addstatus = nil
  38108. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  38109. }
  38110. // StatusCleared returns if the "status" field was cleared in this mutation.
  38111. func (m *WhatsappMutation) StatusCleared() bool {
  38112. _, ok := m.clearedFields[whatsapp.FieldStatus]
  38113. return ok
  38114. }
  38115. // ResetStatus resets all changes to the "status" field.
  38116. func (m *WhatsappMutation) ResetStatus() {
  38117. m.status = nil
  38118. m.addstatus = nil
  38119. delete(m.clearedFields, whatsapp.FieldStatus)
  38120. }
  38121. // SetDeletedAt sets the "deleted_at" field.
  38122. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  38123. m.deleted_at = &t
  38124. }
  38125. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38126. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  38127. v := m.deleted_at
  38128. if v == nil {
  38129. return
  38130. }
  38131. return *v, true
  38132. }
  38133. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  38134. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38136. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38137. if !m.op.Is(OpUpdateOne) {
  38138. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38139. }
  38140. if m.id == nil || m.oldValue == nil {
  38141. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38142. }
  38143. oldValue, err := m.oldValue(ctx)
  38144. if err != nil {
  38145. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38146. }
  38147. return oldValue.DeletedAt, nil
  38148. }
  38149. // ClearDeletedAt clears the value of the "deleted_at" field.
  38150. func (m *WhatsappMutation) ClearDeletedAt() {
  38151. m.deleted_at = nil
  38152. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  38153. }
  38154. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38155. func (m *WhatsappMutation) DeletedAtCleared() bool {
  38156. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  38157. return ok
  38158. }
  38159. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38160. func (m *WhatsappMutation) ResetDeletedAt() {
  38161. m.deleted_at = nil
  38162. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  38163. }
  38164. // SetWaID sets the "wa_id" field.
  38165. func (m *WhatsappMutation) SetWaID(s string) {
  38166. m.wa_id = &s
  38167. }
  38168. // WaID returns the value of the "wa_id" field in the mutation.
  38169. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  38170. v := m.wa_id
  38171. if v == nil {
  38172. return
  38173. }
  38174. return *v, true
  38175. }
  38176. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  38177. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38179. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  38180. if !m.op.Is(OpUpdateOne) {
  38181. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38182. }
  38183. if m.id == nil || m.oldValue == nil {
  38184. return v, errors.New("OldWaID requires an ID field in the mutation")
  38185. }
  38186. oldValue, err := m.oldValue(ctx)
  38187. if err != nil {
  38188. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38189. }
  38190. return oldValue.WaID, nil
  38191. }
  38192. // ClearWaID clears the value of the "wa_id" field.
  38193. func (m *WhatsappMutation) ClearWaID() {
  38194. m.wa_id = nil
  38195. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  38196. }
  38197. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38198. func (m *WhatsappMutation) WaIDCleared() bool {
  38199. _, ok := m.clearedFields[whatsapp.FieldWaID]
  38200. return ok
  38201. }
  38202. // ResetWaID resets all changes to the "wa_id" field.
  38203. func (m *WhatsappMutation) ResetWaID() {
  38204. m.wa_id = nil
  38205. delete(m.clearedFields, whatsapp.FieldWaID)
  38206. }
  38207. // SetWaName sets the "wa_name" field.
  38208. func (m *WhatsappMutation) SetWaName(s string) {
  38209. m.wa_name = &s
  38210. }
  38211. // WaName returns the value of the "wa_name" field in the mutation.
  38212. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  38213. v := m.wa_name
  38214. if v == nil {
  38215. return
  38216. }
  38217. return *v, true
  38218. }
  38219. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  38220. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38222. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  38223. if !m.op.Is(OpUpdateOne) {
  38224. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38225. }
  38226. if m.id == nil || m.oldValue == nil {
  38227. return v, errors.New("OldWaName requires an ID field in the mutation")
  38228. }
  38229. oldValue, err := m.oldValue(ctx)
  38230. if err != nil {
  38231. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38232. }
  38233. return oldValue.WaName, nil
  38234. }
  38235. // ClearWaName clears the value of the "wa_name" field.
  38236. func (m *WhatsappMutation) ClearWaName() {
  38237. m.wa_name = nil
  38238. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  38239. }
  38240. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38241. func (m *WhatsappMutation) WaNameCleared() bool {
  38242. _, ok := m.clearedFields[whatsapp.FieldWaName]
  38243. return ok
  38244. }
  38245. // ResetWaName resets all changes to the "wa_name" field.
  38246. func (m *WhatsappMutation) ResetWaName() {
  38247. m.wa_name = nil
  38248. delete(m.clearedFields, whatsapp.FieldWaName)
  38249. }
  38250. // SetCallback sets the "callback" field.
  38251. func (m *WhatsappMutation) SetCallback(s string) {
  38252. m.callback = &s
  38253. }
  38254. // Callback returns the value of the "callback" field in the mutation.
  38255. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  38256. v := m.callback
  38257. if v == nil {
  38258. return
  38259. }
  38260. return *v, true
  38261. }
  38262. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  38263. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38265. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  38266. if !m.op.Is(OpUpdateOne) {
  38267. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  38268. }
  38269. if m.id == nil || m.oldValue == nil {
  38270. return v, errors.New("OldCallback requires an ID field in the mutation")
  38271. }
  38272. oldValue, err := m.oldValue(ctx)
  38273. if err != nil {
  38274. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  38275. }
  38276. return oldValue.Callback, nil
  38277. }
  38278. // ClearCallback clears the value of the "callback" field.
  38279. func (m *WhatsappMutation) ClearCallback() {
  38280. m.callback = nil
  38281. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  38282. }
  38283. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  38284. func (m *WhatsappMutation) CallbackCleared() bool {
  38285. _, ok := m.clearedFields[whatsapp.FieldCallback]
  38286. return ok
  38287. }
  38288. // ResetCallback resets all changes to the "callback" field.
  38289. func (m *WhatsappMutation) ResetCallback() {
  38290. m.callback = nil
  38291. delete(m.clearedFields, whatsapp.FieldCallback)
  38292. }
  38293. // SetAgentID sets the "agent_id" field.
  38294. func (m *WhatsappMutation) SetAgentID(u uint64) {
  38295. m.agent = &u
  38296. }
  38297. // AgentID returns the value of the "agent_id" field in the mutation.
  38298. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  38299. v := m.agent
  38300. if v == nil {
  38301. return
  38302. }
  38303. return *v, true
  38304. }
  38305. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  38306. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38308. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  38309. if !m.op.Is(OpUpdateOne) {
  38310. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  38311. }
  38312. if m.id == nil || m.oldValue == nil {
  38313. return v, errors.New("OldAgentID requires an ID field in the mutation")
  38314. }
  38315. oldValue, err := m.oldValue(ctx)
  38316. if err != nil {
  38317. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  38318. }
  38319. return oldValue.AgentID, nil
  38320. }
  38321. // ResetAgentID resets all changes to the "agent_id" field.
  38322. func (m *WhatsappMutation) ResetAgentID() {
  38323. m.agent = nil
  38324. }
  38325. // SetAccount sets the "account" field.
  38326. func (m *WhatsappMutation) SetAccount(s string) {
  38327. m.account = &s
  38328. }
  38329. // Account returns the value of the "account" field in the mutation.
  38330. func (m *WhatsappMutation) Account() (r string, exists bool) {
  38331. v := m.account
  38332. if v == nil {
  38333. return
  38334. }
  38335. return *v, true
  38336. }
  38337. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  38338. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38340. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  38341. if !m.op.Is(OpUpdateOne) {
  38342. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  38343. }
  38344. if m.id == nil || m.oldValue == nil {
  38345. return v, errors.New("OldAccount requires an ID field in the mutation")
  38346. }
  38347. oldValue, err := m.oldValue(ctx)
  38348. if err != nil {
  38349. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  38350. }
  38351. return oldValue.Account, nil
  38352. }
  38353. // ClearAccount clears the value of the "account" field.
  38354. func (m *WhatsappMutation) ClearAccount() {
  38355. m.account = nil
  38356. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  38357. }
  38358. // AccountCleared returns if the "account" field was cleared in this mutation.
  38359. func (m *WhatsappMutation) AccountCleared() bool {
  38360. _, ok := m.clearedFields[whatsapp.FieldAccount]
  38361. return ok
  38362. }
  38363. // ResetAccount resets all changes to the "account" field.
  38364. func (m *WhatsappMutation) ResetAccount() {
  38365. m.account = nil
  38366. delete(m.clearedFields, whatsapp.FieldAccount)
  38367. }
  38368. // SetCc sets the "cc" field.
  38369. func (m *WhatsappMutation) SetCc(s string) {
  38370. m.cc = &s
  38371. }
  38372. // Cc returns the value of the "cc" field in the mutation.
  38373. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  38374. v := m.cc
  38375. if v == nil {
  38376. return
  38377. }
  38378. return *v, true
  38379. }
  38380. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  38381. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38383. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  38384. if !m.op.Is(OpUpdateOne) {
  38385. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  38386. }
  38387. if m.id == nil || m.oldValue == nil {
  38388. return v, errors.New("OldCc requires an ID field in the mutation")
  38389. }
  38390. oldValue, err := m.oldValue(ctx)
  38391. if err != nil {
  38392. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  38393. }
  38394. return oldValue.Cc, nil
  38395. }
  38396. // ResetCc resets all changes to the "cc" field.
  38397. func (m *WhatsappMutation) ResetCc() {
  38398. m.cc = nil
  38399. }
  38400. // SetPhone sets the "phone" field.
  38401. func (m *WhatsappMutation) SetPhone(s string) {
  38402. m.phone = &s
  38403. }
  38404. // Phone returns the value of the "phone" field in the mutation.
  38405. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  38406. v := m.phone
  38407. if v == nil {
  38408. return
  38409. }
  38410. return *v, true
  38411. }
  38412. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  38413. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38415. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  38416. if !m.op.Is(OpUpdateOne) {
  38417. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  38418. }
  38419. if m.id == nil || m.oldValue == nil {
  38420. return v, errors.New("OldPhone requires an ID field in the mutation")
  38421. }
  38422. oldValue, err := m.oldValue(ctx)
  38423. if err != nil {
  38424. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  38425. }
  38426. return oldValue.Phone, nil
  38427. }
  38428. // ResetPhone resets all changes to the "phone" field.
  38429. func (m *WhatsappMutation) ResetPhone() {
  38430. m.phone = nil
  38431. }
  38432. // SetCcPhone sets the "cc_phone" field.
  38433. func (m *WhatsappMutation) SetCcPhone(s string) {
  38434. m.cc_phone = &s
  38435. }
  38436. // CcPhone returns the value of the "cc_phone" field in the mutation.
  38437. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  38438. v := m.cc_phone
  38439. if v == nil {
  38440. return
  38441. }
  38442. return *v, true
  38443. }
  38444. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  38445. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38447. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  38448. if !m.op.Is(OpUpdateOne) {
  38449. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  38450. }
  38451. if m.id == nil || m.oldValue == nil {
  38452. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  38453. }
  38454. oldValue, err := m.oldValue(ctx)
  38455. if err != nil {
  38456. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  38457. }
  38458. return oldValue.CcPhone, nil
  38459. }
  38460. // ResetCcPhone resets all changes to the "cc_phone" field.
  38461. func (m *WhatsappMutation) ResetCcPhone() {
  38462. m.cc_phone = nil
  38463. }
  38464. // SetPhoneName sets the "phone_name" field.
  38465. func (m *WhatsappMutation) SetPhoneName(s string) {
  38466. m.phone_name = &s
  38467. }
  38468. // PhoneName returns the value of the "phone_name" field in the mutation.
  38469. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  38470. v := m.phone_name
  38471. if v == nil {
  38472. return
  38473. }
  38474. return *v, true
  38475. }
  38476. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  38477. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38479. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  38480. if !m.op.Is(OpUpdateOne) {
  38481. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  38482. }
  38483. if m.id == nil || m.oldValue == nil {
  38484. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  38485. }
  38486. oldValue, err := m.oldValue(ctx)
  38487. if err != nil {
  38488. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  38489. }
  38490. return oldValue.PhoneName, nil
  38491. }
  38492. // ResetPhoneName resets all changes to the "phone_name" field.
  38493. func (m *WhatsappMutation) ResetPhoneName() {
  38494. m.phone_name = nil
  38495. }
  38496. // SetPhoneStatus sets the "phone_status" field.
  38497. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  38498. m.phone_status = &i
  38499. m.addphone_status = nil
  38500. }
  38501. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  38502. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  38503. v := m.phone_status
  38504. if v == nil {
  38505. return
  38506. }
  38507. return *v, true
  38508. }
  38509. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  38510. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38512. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  38513. if !m.op.Is(OpUpdateOne) {
  38514. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  38515. }
  38516. if m.id == nil || m.oldValue == nil {
  38517. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  38518. }
  38519. oldValue, err := m.oldValue(ctx)
  38520. if err != nil {
  38521. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  38522. }
  38523. return oldValue.PhoneStatus, nil
  38524. }
  38525. // AddPhoneStatus adds i to the "phone_status" field.
  38526. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  38527. if m.addphone_status != nil {
  38528. *m.addphone_status += i
  38529. } else {
  38530. m.addphone_status = &i
  38531. }
  38532. }
  38533. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  38534. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  38535. v := m.addphone_status
  38536. if v == nil {
  38537. return
  38538. }
  38539. return *v, true
  38540. }
  38541. // ResetPhoneStatus resets all changes to the "phone_status" field.
  38542. func (m *WhatsappMutation) ResetPhoneStatus() {
  38543. m.phone_status = nil
  38544. m.addphone_status = nil
  38545. }
  38546. // SetOrganizationID sets the "organization_id" field.
  38547. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  38548. m.organization_id = &u
  38549. m.addorganization_id = nil
  38550. }
  38551. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38552. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  38553. v := m.organization_id
  38554. if v == nil {
  38555. return
  38556. }
  38557. return *v, true
  38558. }
  38559. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  38560. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38562. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38563. if !m.op.Is(OpUpdateOne) {
  38564. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38565. }
  38566. if m.id == nil || m.oldValue == nil {
  38567. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38568. }
  38569. oldValue, err := m.oldValue(ctx)
  38570. if err != nil {
  38571. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38572. }
  38573. return oldValue.OrganizationID, nil
  38574. }
  38575. // AddOrganizationID adds u to the "organization_id" field.
  38576. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  38577. if m.addorganization_id != nil {
  38578. *m.addorganization_id += u
  38579. } else {
  38580. m.addorganization_id = &u
  38581. }
  38582. }
  38583. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38584. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  38585. v := m.addorganization_id
  38586. if v == nil {
  38587. return
  38588. }
  38589. return *v, true
  38590. }
  38591. // ClearOrganizationID clears the value of the "organization_id" field.
  38592. func (m *WhatsappMutation) ClearOrganizationID() {
  38593. m.organization_id = nil
  38594. m.addorganization_id = nil
  38595. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  38596. }
  38597. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38598. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  38599. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  38600. return ok
  38601. }
  38602. // ResetOrganizationID resets all changes to the "organization_id" field.
  38603. func (m *WhatsappMutation) ResetOrganizationID() {
  38604. m.organization_id = nil
  38605. m.addorganization_id = nil
  38606. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  38607. }
  38608. // SetAPIBase sets the "api_base" field.
  38609. func (m *WhatsappMutation) SetAPIBase(s string) {
  38610. m.api_base = &s
  38611. }
  38612. // APIBase returns the value of the "api_base" field in the mutation.
  38613. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  38614. v := m.api_base
  38615. if v == nil {
  38616. return
  38617. }
  38618. return *v, true
  38619. }
  38620. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  38621. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38623. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38624. if !m.op.Is(OpUpdateOne) {
  38625. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38626. }
  38627. if m.id == nil || m.oldValue == nil {
  38628. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38629. }
  38630. oldValue, err := m.oldValue(ctx)
  38631. if err != nil {
  38632. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38633. }
  38634. return oldValue.APIBase, nil
  38635. }
  38636. // ClearAPIBase clears the value of the "api_base" field.
  38637. func (m *WhatsappMutation) ClearAPIBase() {
  38638. m.api_base = nil
  38639. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  38640. }
  38641. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38642. func (m *WhatsappMutation) APIBaseCleared() bool {
  38643. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  38644. return ok
  38645. }
  38646. // ResetAPIBase resets all changes to the "api_base" field.
  38647. func (m *WhatsappMutation) ResetAPIBase() {
  38648. m.api_base = nil
  38649. delete(m.clearedFields, whatsapp.FieldAPIBase)
  38650. }
  38651. // SetAPIKey sets the "api_key" field.
  38652. func (m *WhatsappMutation) SetAPIKey(s string) {
  38653. m.api_key = &s
  38654. }
  38655. // APIKey returns the value of the "api_key" field in the mutation.
  38656. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  38657. v := m.api_key
  38658. if v == nil {
  38659. return
  38660. }
  38661. return *v, true
  38662. }
  38663. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  38664. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38666. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38667. if !m.op.Is(OpUpdateOne) {
  38668. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38669. }
  38670. if m.id == nil || m.oldValue == nil {
  38671. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38672. }
  38673. oldValue, err := m.oldValue(ctx)
  38674. if err != nil {
  38675. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38676. }
  38677. return oldValue.APIKey, nil
  38678. }
  38679. // ClearAPIKey clears the value of the "api_key" field.
  38680. func (m *WhatsappMutation) ClearAPIKey() {
  38681. m.api_key = nil
  38682. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  38683. }
  38684. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38685. func (m *WhatsappMutation) APIKeyCleared() bool {
  38686. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  38687. return ok
  38688. }
  38689. // ResetAPIKey resets all changes to the "api_key" field.
  38690. func (m *WhatsappMutation) ResetAPIKey() {
  38691. m.api_key = nil
  38692. delete(m.clearedFields, whatsapp.FieldAPIKey)
  38693. }
  38694. // SetAllowList sets the "allow_list" field.
  38695. func (m *WhatsappMutation) SetAllowList(s []string) {
  38696. m.allow_list = &s
  38697. m.appendallow_list = nil
  38698. }
  38699. // AllowList returns the value of the "allow_list" field in the mutation.
  38700. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  38701. v := m.allow_list
  38702. if v == nil {
  38703. return
  38704. }
  38705. return *v, true
  38706. }
  38707. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  38708. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38710. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38711. if !m.op.Is(OpUpdateOne) {
  38712. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38713. }
  38714. if m.id == nil || m.oldValue == nil {
  38715. return v, errors.New("OldAllowList requires an ID field in the mutation")
  38716. }
  38717. oldValue, err := m.oldValue(ctx)
  38718. if err != nil {
  38719. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  38720. }
  38721. return oldValue.AllowList, nil
  38722. }
  38723. // AppendAllowList adds s to the "allow_list" field.
  38724. func (m *WhatsappMutation) AppendAllowList(s []string) {
  38725. m.appendallow_list = append(m.appendallow_list, s...)
  38726. }
  38727. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  38728. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  38729. if len(m.appendallow_list) == 0 {
  38730. return nil, false
  38731. }
  38732. return m.appendallow_list, true
  38733. }
  38734. // ClearAllowList clears the value of the "allow_list" field.
  38735. func (m *WhatsappMutation) ClearAllowList() {
  38736. m.allow_list = nil
  38737. m.appendallow_list = nil
  38738. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  38739. }
  38740. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  38741. func (m *WhatsappMutation) AllowListCleared() bool {
  38742. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  38743. return ok
  38744. }
  38745. // ResetAllowList resets all changes to the "allow_list" field.
  38746. func (m *WhatsappMutation) ResetAllowList() {
  38747. m.allow_list = nil
  38748. m.appendallow_list = nil
  38749. delete(m.clearedFields, whatsapp.FieldAllowList)
  38750. }
  38751. // SetGroupAllowList sets the "group_allow_list" field.
  38752. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  38753. m.group_allow_list = &s
  38754. m.appendgroup_allow_list = nil
  38755. }
  38756. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  38757. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  38758. v := m.group_allow_list
  38759. if v == nil {
  38760. return
  38761. }
  38762. return *v, true
  38763. }
  38764. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  38765. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38767. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  38768. if !m.op.Is(OpUpdateOne) {
  38769. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  38770. }
  38771. if m.id == nil || m.oldValue == nil {
  38772. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  38773. }
  38774. oldValue, err := m.oldValue(ctx)
  38775. if err != nil {
  38776. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  38777. }
  38778. return oldValue.GroupAllowList, nil
  38779. }
  38780. // AppendGroupAllowList adds s to the "group_allow_list" field.
  38781. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  38782. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  38783. }
  38784. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  38785. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  38786. if len(m.appendgroup_allow_list) == 0 {
  38787. return nil, false
  38788. }
  38789. return m.appendgroup_allow_list, true
  38790. }
  38791. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  38792. func (m *WhatsappMutation) ClearGroupAllowList() {
  38793. m.group_allow_list = nil
  38794. m.appendgroup_allow_list = nil
  38795. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  38796. }
  38797. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  38798. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  38799. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  38800. return ok
  38801. }
  38802. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  38803. func (m *WhatsappMutation) ResetGroupAllowList() {
  38804. m.group_allow_list = nil
  38805. m.appendgroup_allow_list = nil
  38806. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  38807. }
  38808. // SetBlockList sets the "block_list" field.
  38809. func (m *WhatsappMutation) SetBlockList(s []string) {
  38810. m.block_list = &s
  38811. m.appendblock_list = nil
  38812. }
  38813. // BlockList returns the value of the "block_list" field in the mutation.
  38814. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  38815. v := m.block_list
  38816. if v == nil {
  38817. return
  38818. }
  38819. return *v, true
  38820. }
  38821. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  38822. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38824. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38825. if !m.op.Is(OpUpdateOne) {
  38826. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38827. }
  38828. if m.id == nil || m.oldValue == nil {
  38829. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38830. }
  38831. oldValue, err := m.oldValue(ctx)
  38832. if err != nil {
  38833. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38834. }
  38835. return oldValue.BlockList, nil
  38836. }
  38837. // AppendBlockList adds s to the "block_list" field.
  38838. func (m *WhatsappMutation) AppendBlockList(s []string) {
  38839. m.appendblock_list = append(m.appendblock_list, s...)
  38840. }
  38841. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38842. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  38843. if len(m.appendblock_list) == 0 {
  38844. return nil, false
  38845. }
  38846. return m.appendblock_list, true
  38847. }
  38848. // ClearBlockList clears the value of the "block_list" field.
  38849. func (m *WhatsappMutation) ClearBlockList() {
  38850. m.block_list = nil
  38851. m.appendblock_list = nil
  38852. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  38853. }
  38854. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  38855. func (m *WhatsappMutation) BlockListCleared() bool {
  38856. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  38857. return ok
  38858. }
  38859. // ResetBlockList resets all changes to the "block_list" field.
  38860. func (m *WhatsappMutation) ResetBlockList() {
  38861. m.block_list = nil
  38862. m.appendblock_list = nil
  38863. delete(m.clearedFields, whatsapp.FieldBlockList)
  38864. }
  38865. // SetGroupBlockList sets the "group_block_list" field.
  38866. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  38867. m.group_block_list = &s
  38868. m.appendgroup_block_list = nil
  38869. }
  38870. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38871. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  38872. v := m.group_block_list
  38873. if v == nil {
  38874. return
  38875. }
  38876. return *v, true
  38877. }
  38878. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  38879. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38881. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38882. if !m.op.Is(OpUpdateOne) {
  38883. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38884. }
  38885. if m.id == nil || m.oldValue == nil {
  38886. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38887. }
  38888. oldValue, err := m.oldValue(ctx)
  38889. if err != nil {
  38890. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38891. }
  38892. return oldValue.GroupBlockList, nil
  38893. }
  38894. // AppendGroupBlockList adds s to the "group_block_list" field.
  38895. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  38896. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38897. }
  38898. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38899. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  38900. if len(m.appendgroup_block_list) == 0 {
  38901. return nil, false
  38902. }
  38903. return m.appendgroup_block_list, true
  38904. }
  38905. // ClearGroupBlockList clears the value of the "group_block_list" field.
  38906. func (m *WhatsappMutation) ClearGroupBlockList() {
  38907. m.group_block_list = nil
  38908. m.appendgroup_block_list = nil
  38909. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  38910. }
  38911. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  38912. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  38913. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  38914. return ok
  38915. }
  38916. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38917. func (m *WhatsappMutation) ResetGroupBlockList() {
  38918. m.group_block_list = nil
  38919. m.appendgroup_block_list = nil
  38920. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  38921. }
  38922. // ClearAgent clears the "agent" edge to the Agent entity.
  38923. func (m *WhatsappMutation) ClearAgent() {
  38924. m.clearedagent = true
  38925. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  38926. }
  38927. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38928. func (m *WhatsappMutation) AgentCleared() bool {
  38929. return m.clearedagent
  38930. }
  38931. // AgentIDs returns the "agent" edge IDs in the mutation.
  38932. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38933. // AgentID instead. It exists only for internal usage by the builders.
  38934. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  38935. if id := m.agent; id != nil {
  38936. ids = append(ids, *id)
  38937. }
  38938. return
  38939. }
  38940. // ResetAgent resets all changes to the "agent" edge.
  38941. func (m *WhatsappMutation) ResetAgent() {
  38942. m.agent = nil
  38943. m.clearedagent = false
  38944. }
  38945. // Where appends a list predicates to the WhatsappMutation builder.
  38946. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  38947. m.predicates = append(m.predicates, ps...)
  38948. }
  38949. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  38950. // users can use type-assertion to append predicates that do not depend on any generated package.
  38951. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  38952. p := make([]predicate.Whatsapp, len(ps))
  38953. for i := range ps {
  38954. p[i] = ps[i]
  38955. }
  38956. m.Where(p...)
  38957. }
  38958. // Op returns the operation name.
  38959. func (m *WhatsappMutation) Op() Op {
  38960. return m.op
  38961. }
  38962. // SetOp allows setting the mutation operation.
  38963. func (m *WhatsappMutation) SetOp(op Op) {
  38964. m.op = op
  38965. }
  38966. // Type returns the node type of this mutation (Whatsapp).
  38967. func (m *WhatsappMutation) Type() string {
  38968. return m.typ
  38969. }
  38970. // Fields returns all fields that were changed during this mutation. Note that in
  38971. // order to get all numeric fields that were incremented/decremented, call
  38972. // AddedFields().
  38973. func (m *WhatsappMutation) Fields() []string {
  38974. fields := make([]string, 0, 21)
  38975. if m.created_at != nil {
  38976. fields = append(fields, whatsapp.FieldCreatedAt)
  38977. }
  38978. if m.updated_at != nil {
  38979. fields = append(fields, whatsapp.FieldUpdatedAt)
  38980. }
  38981. if m.status != nil {
  38982. fields = append(fields, whatsapp.FieldStatus)
  38983. }
  38984. if m.deleted_at != nil {
  38985. fields = append(fields, whatsapp.FieldDeletedAt)
  38986. }
  38987. if m.wa_id != nil {
  38988. fields = append(fields, whatsapp.FieldWaID)
  38989. }
  38990. if m.wa_name != nil {
  38991. fields = append(fields, whatsapp.FieldWaName)
  38992. }
  38993. if m.callback != nil {
  38994. fields = append(fields, whatsapp.FieldCallback)
  38995. }
  38996. if m.agent != nil {
  38997. fields = append(fields, whatsapp.FieldAgentID)
  38998. }
  38999. if m.account != nil {
  39000. fields = append(fields, whatsapp.FieldAccount)
  39001. }
  39002. if m.cc != nil {
  39003. fields = append(fields, whatsapp.FieldCc)
  39004. }
  39005. if m.phone != nil {
  39006. fields = append(fields, whatsapp.FieldPhone)
  39007. }
  39008. if m.cc_phone != nil {
  39009. fields = append(fields, whatsapp.FieldCcPhone)
  39010. }
  39011. if m.phone_name != nil {
  39012. fields = append(fields, whatsapp.FieldPhoneName)
  39013. }
  39014. if m.phone_status != nil {
  39015. fields = append(fields, whatsapp.FieldPhoneStatus)
  39016. }
  39017. if m.organization_id != nil {
  39018. fields = append(fields, whatsapp.FieldOrganizationID)
  39019. }
  39020. if m.api_base != nil {
  39021. fields = append(fields, whatsapp.FieldAPIBase)
  39022. }
  39023. if m.api_key != nil {
  39024. fields = append(fields, whatsapp.FieldAPIKey)
  39025. }
  39026. if m.allow_list != nil {
  39027. fields = append(fields, whatsapp.FieldAllowList)
  39028. }
  39029. if m.group_allow_list != nil {
  39030. fields = append(fields, whatsapp.FieldGroupAllowList)
  39031. }
  39032. if m.block_list != nil {
  39033. fields = append(fields, whatsapp.FieldBlockList)
  39034. }
  39035. if m.group_block_list != nil {
  39036. fields = append(fields, whatsapp.FieldGroupBlockList)
  39037. }
  39038. return fields
  39039. }
  39040. // Field returns the value of a field with the given name. The second boolean
  39041. // return value indicates that this field was not set, or was not defined in the
  39042. // schema.
  39043. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  39044. switch name {
  39045. case whatsapp.FieldCreatedAt:
  39046. return m.CreatedAt()
  39047. case whatsapp.FieldUpdatedAt:
  39048. return m.UpdatedAt()
  39049. case whatsapp.FieldStatus:
  39050. return m.Status()
  39051. case whatsapp.FieldDeletedAt:
  39052. return m.DeletedAt()
  39053. case whatsapp.FieldWaID:
  39054. return m.WaID()
  39055. case whatsapp.FieldWaName:
  39056. return m.WaName()
  39057. case whatsapp.FieldCallback:
  39058. return m.Callback()
  39059. case whatsapp.FieldAgentID:
  39060. return m.AgentID()
  39061. case whatsapp.FieldAccount:
  39062. return m.Account()
  39063. case whatsapp.FieldCc:
  39064. return m.Cc()
  39065. case whatsapp.FieldPhone:
  39066. return m.Phone()
  39067. case whatsapp.FieldCcPhone:
  39068. return m.CcPhone()
  39069. case whatsapp.FieldPhoneName:
  39070. return m.PhoneName()
  39071. case whatsapp.FieldPhoneStatus:
  39072. return m.PhoneStatus()
  39073. case whatsapp.FieldOrganizationID:
  39074. return m.OrganizationID()
  39075. case whatsapp.FieldAPIBase:
  39076. return m.APIBase()
  39077. case whatsapp.FieldAPIKey:
  39078. return m.APIKey()
  39079. case whatsapp.FieldAllowList:
  39080. return m.AllowList()
  39081. case whatsapp.FieldGroupAllowList:
  39082. return m.GroupAllowList()
  39083. case whatsapp.FieldBlockList:
  39084. return m.BlockList()
  39085. case whatsapp.FieldGroupBlockList:
  39086. return m.GroupBlockList()
  39087. }
  39088. return nil, false
  39089. }
  39090. // OldField returns the old value of the field from the database. An error is
  39091. // returned if the mutation operation is not UpdateOne, or the query to the
  39092. // database failed.
  39093. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39094. switch name {
  39095. case whatsapp.FieldCreatedAt:
  39096. return m.OldCreatedAt(ctx)
  39097. case whatsapp.FieldUpdatedAt:
  39098. return m.OldUpdatedAt(ctx)
  39099. case whatsapp.FieldStatus:
  39100. return m.OldStatus(ctx)
  39101. case whatsapp.FieldDeletedAt:
  39102. return m.OldDeletedAt(ctx)
  39103. case whatsapp.FieldWaID:
  39104. return m.OldWaID(ctx)
  39105. case whatsapp.FieldWaName:
  39106. return m.OldWaName(ctx)
  39107. case whatsapp.FieldCallback:
  39108. return m.OldCallback(ctx)
  39109. case whatsapp.FieldAgentID:
  39110. return m.OldAgentID(ctx)
  39111. case whatsapp.FieldAccount:
  39112. return m.OldAccount(ctx)
  39113. case whatsapp.FieldCc:
  39114. return m.OldCc(ctx)
  39115. case whatsapp.FieldPhone:
  39116. return m.OldPhone(ctx)
  39117. case whatsapp.FieldCcPhone:
  39118. return m.OldCcPhone(ctx)
  39119. case whatsapp.FieldPhoneName:
  39120. return m.OldPhoneName(ctx)
  39121. case whatsapp.FieldPhoneStatus:
  39122. return m.OldPhoneStatus(ctx)
  39123. case whatsapp.FieldOrganizationID:
  39124. return m.OldOrganizationID(ctx)
  39125. case whatsapp.FieldAPIBase:
  39126. return m.OldAPIBase(ctx)
  39127. case whatsapp.FieldAPIKey:
  39128. return m.OldAPIKey(ctx)
  39129. case whatsapp.FieldAllowList:
  39130. return m.OldAllowList(ctx)
  39131. case whatsapp.FieldGroupAllowList:
  39132. return m.OldGroupAllowList(ctx)
  39133. case whatsapp.FieldBlockList:
  39134. return m.OldBlockList(ctx)
  39135. case whatsapp.FieldGroupBlockList:
  39136. return m.OldGroupBlockList(ctx)
  39137. }
  39138. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  39139. }
  39140. // SetField sets the value of a field with the given name. It returns an error if
  39141. // the field is not defined in the schema, or if the type mismatched the field
  39142. // type.
  39143. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  39144. switch name {
  39145. case whatsapp.FieldCreatedAt:
  39146. v, ok := value.(time.Time)
  39147. if !ok {
  39148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39149. }
  39150. m.SetCreatedAt(v)
  39151. return nil
  39152. case whatsapp.FieldUpdatedAt:
  39153. v, ok := value.(time.Time)
  39154. if !ok {
  39155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39156. }
  39157. m.SetUpdatedAt(v)
  39158. return nil
  39159. case whatsapp.FieldStatus:
  39160. v, ok := value.(uint8)
  39161. if !ok {
  39162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39163. }
  39164. m.SetStatus(v)
  39165. return nil
  39166. case whatsapp.FieldDeletedAt:
  39167. v, ok := value.(time.Time)
  39168. if !ok {
  39169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39170. }
  39171. m.SetDeletedAt(v)
  39172. return nil
  39173. case whatsapp.FieldWaID:
  39174. v, ok := value.(string)
  39175. if !ok {
  39176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39177. }
  39178. m.SetWaID(v)
  39179. return nil
  39180. case whatsapp.FieldWaName:
  39181. v, ok := value.(string)
  39182. if !ok {
  39183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39184. }
  39185. m.SetWaName(v)
  39186. return nil
  39187. case whatsapp.FieldCallback:
  39188. v, ok := value.(string)
  39189. if !ok {
  39190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39191. }
  39192. m.SetCallback(v)
  39193. return nil
  39194. case whatsapp.FieldAgentID:
  39195. v, ok := value.(uint64)
  39196. if !ok {
  39197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39198. }
  39199. m.SetAgentID(v)
  39200. return nil
  39201. case whatsapp.FieldAccount:
  39202. v, ok := value.(string)
  39203. if !ok {
  39204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39205. }
  39206. m.SetAccount(v)
  39207. return nil
  39208. case whatsapp.FieldCc:
  39209. v, ok := value.(string)
  39210. if !ok {
  39211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39212. }
  39213. m.SetCc(v)
  39214. return nil
  39215. case whatsapp.FieldPhone:
  39216. v, ok := value.(string)
  39217. if !ok {
  39218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39219. }
  39220. m.SetPhone(v)
  39221. return nil
  39222. case whatsapp.FieldCcPhone:
  39223. v, ok := value.(string)
  39224. if !ok {
  39225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39226. }
  39227. m.SetCcPhone(v)
  39228. return nil
  39229. case whatsapp.FieldPhoneName:
  39230. v, ok := value.(string)
  39231. if !ok {
  39232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39233. }
  39234. m.SetPhoneName(v)
  39235. return nil
  39236. case whatsapp.FieldPhoneStatus:
  39237. v, ok := value.(int8)
  39238. if !ok {
  39239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39240. }
  39241. m.SetPhoneStatus(v)
  39242. return nil
  39243. case whatsapp.FieldOrganizationID:
  39244. v, ok := value.(uint64)
  39245. if !ok {
  39246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39247. }
  39248. m.SetOrganizationID(v)
  39249. return nil
  39250. case whatsapp.FieldAPIBase:
  39251. v, ok := value.(string)
  39252. if !ok {
  39253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39254. }
  39255. m.SetAPIBase(v)
  39256. return nil
  39257. case whatsapp.FieldAPIKey:
  39258. v, ok := value.(string)
  39259. if !ok {
  39260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39261. }
  39262. m.SetAPIKey(v)
  39263. return nil
  39264. case whatsapp.FieldAllowList:
  39265. v, ok := value.([]string)
  39266. if !ok {
  39267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39268. }
  39269. m.SetAllowList(v)
  39270. return nil
  39271. case whatsapp.FieldGroupAllowList:
  39272. v, ok := value.([]string)
  39273. if !ok {
  39274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39275. }
  39276. m.SetGroupAllowList(v)
  39277. return nil
  39278. case whatsapp.FieldBlockList:
  39279. v, ok := value.([]string)
  39280. if !ok {
  39281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39282. }
  39283. m.SetBlockList(v)
  39284. return nil
  39285. case whatsapp.FieldGroupBlockList:
  39286. v, ok := value.([]string)
  39287. if !ok {
  39288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39289. }
  39290. m.SetGroupBlockList(v)
  39291. return nil
  39292. }
  39293. return fmt.Errorf("unknown Whatsapp field %s", name)
  39294. }
  39295. // AddedFields returns all numeric fields that were incremented/decremented during
  39296. // this mutation.
  39297. func (m *WhatsappMutation) AddedFields() []string {
  39298. var fields []string
  39299. if m.addstatus != nil {
  39300. fields = append(fields, whatsapp.FieldStatus)
  39301. }
  39302. if m.addphone_status != nil {
  39303. fields = append(fields, whatsapp.FieldPhoneStatus)
  39304. }
  39305. if m.addorganization_id != nil {
  39306. fields = append(fields, whatsapp.FieldOrganizationID)
  39307. }
  39308. return fields
  39309. }
  39310. // AddedField returns the numeric value that was incremented/decremented on a field
  39311. // with the given name. The second boolean return value indicates that this field
  39312. // was not set, or was not defined in the schema.
  39313. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  39314. switch name {
  39315. case whatsapp.FieldStatus:
  39316. return m.AddedStatus()
  39317. case whatsapp.FieldPhoneStatus:
  39318. return m.AddedPhoneStatus()
  39319. case whatsapp.FieldOrganizationID:
  39320. return m.AddedOrganizationID()
  39321. }
  39322. return nil, false
  39323. }
  39324. // AddField adds the value to the field with the given name. It returns an error if
  39325. // the field is not defined in the schema, or if the type mismatched the field
  39326. // type.
  39327. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  39328. switch name {
  39329. case whatsapp.FieldStatus:
  39330. v, ok := value.(int8)
  39331. if !ok {
  39332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39333. }
  39334. m.AddStatus(v)
  39335. return nil
  39336. case whatsapp.FieldPhoneStatus:
  39337. v, ok := value.(int8)
  39338. if !ok {
  39339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39340. }
  39341. m.AddPhoneStatus(v)
  39342. return nil
  39343. case whatsapp.FieldOrganizationID:
  39344. v, ok := value.(int64)
  39345. if !ok {
  39346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39347. }
  39348. m.AddOrganizationID(v)
  39349. return nil
  39350. }
  39351. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  39352. }
  39353. // ClearedFields returns all nullable fields that were cleared during this
  39354. // mutation.
  39355. func (m *WhatsappMutation) ClearedFields() []string {
  39356. var fields []string
  39357. if m.FieldCleared(whatsapp.FieldStatus) {
  39358. fields = append(fields, whatsapp.FieldStatus)
  39359. }
  39360. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  39361. fields = append(fields, whatsapp.FieldDeletedAt)
  39362. }
  39363. if m.FieldCleared(whatsapp.FieldWaID) {
  39364. fields = append(fields, whatsapp.FieldWaID)
  39365. }
  39366. if m.FieldCleared(whatsapp.FieldWaName) {
  39367. fields = append(fields, whatsapp.FieldWaName)
  39368. }
  39369. if m.FieldCleared(whatsapp.FieldCallback) {
  39370. fields = append(fields, whatsapp.FieldCallback)
  39371. }
  39372. if m.FieldCleared(whatsapp.FieldAccount) {
  39373. fields = append(fields, whatsapp.FieldAccount)
  39374. }
  39375. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  39376. fields = append(fields, whatsapp.FieldOrganizationID)
  39377. }
  39378. if m.FieldCleared(whatsapp.FieldAPIBase) {
  39379. fields = append(fields, whatsapp.FieldAPIBase)
  39380. }
  39381. if m.FieldCleared(whatsapp.FieldAPIKey) {
  39382. fields = append(fields, whatsapp.FieldAPIKey)
  39383. }
  39384. if m.FieldCleared(whatsapp.FieldAllowList) {
  39385. fields = append(fields, whatsapp.FieldAllowList)
  39386. }
  39387. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  39388. fields = append(fields, whatsapp.FieldGroupAllowList)
  39389. }
  39390. if m.FieldCleared(whatsapp.FieldBlockList) {
  39391. fields = append(fields, whatsapp.FieldBlockList)
  39392. }
  39393. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  39394. fields = append(fields, whatsapp.FieldGroupBlockList)
  39395. }
  39396. return fields
  39397. }
  39398. // FieldCleared returns a boolean indicating if a field with the given name was
  39399. // cleared in this mutation.
  39400. func (m *WhatsappMutation) FieldCleared(name string) bool {
  39401. _, ok := m.clearedFields[name]
  39402. return ok
  39403. }
  39404. // ClearField clears the value of the field with the given name. It returns an
  39405. // error if the field is not defined in the schema.
  39406. func (m *WhatsappMutation) ClearField(name string) error {
  39407. switch name {
  39408. case whatsapp.FieldStatus:
  39409. m.ClearStatus()
  39410. return nil
  39411. case whatsapp.FieldDeletedAt:
  39412. m.ClearDeletedAt()
  39413. return nil
  39414. case whatsapp.FieldWaID:
  39415. m.ClearWaID()
  39416. return nil
  39417. case whatsapp.FieldWaName:
  39418. m.ClearWaName()
  39419. return nil
  39420. case whatsapp.FieldCallback:
  39421. m.ClearCallback()
  39422. return nil
  39423. case whatsapp.FieldAccount:
  39424. m.ClearAccount()
  39425. return nil
  39426. case whatsapp.FieldOrganizationID:
  39427. m.ClearOrganizationID()
  39428. return nil
  39429. case whatsapp.FieldAPIBase:
  39430. m.ClearAPIBase()
  39431. return nil
  39432. case whatsapp.FieldAPIKey:
  39433. m.ClearAPIKey()
  39434. return nil
  39435. case whatsapp.FieldAllowList:
  39436. m.ClearAllowList()
  39437. return nil
  39438. case whatsapp.FieldGroupAllowList:
  39439. m.ClearGroupAllowList()
  39440. return nil
  39441. case whatsapp.FieldBlockList:
  39442. m.ClearBlockList()
  39443. return nil
  39444. case whatsapp.FieldGroupBlockList:
  39445. m.ClearGroupBlockList()
  39446. return nil
  39447. }
  39448. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  39449. }
  39450. // ResetField resets all changes in the mutation for the field with the given name.
  39451. // It returns an error if the field is not defined in the schema.
  39452. func (m *WhatsappMutation) ResetField(name string) error {
  39453. switch name {
  39454. case whatsapp.FieldCreatedAt:
  39455. m.ResetCreatedAt()
  39456. return nil
  39457. case whatsapp.FieldUpdatedAt:
  39458. m.ResetUpdatedAt()
  39459. return nil
  39460. case whatsapp.FieldStatus:
  39461. m.ResetStatus()
  39462. return nil
  39463. case whatsapp.FieldDeletedAt:
  39464. m.ResetDeletedAt()
  39465. return nil
  39466. case whatsapp.FieldWaID:
  39467. m.ResetWaID()
  39468. return nil
  39469. case whatsapp.FieldWaName:
  39470. m.ResetWaName()
  39471. return nil
  39472. case whatsapp.FieldCallback:
  39473. m.ResetCallback()
  39474. return nil
  39475. case whatsapp.FieldAgentID:
  39476. m.ResetAgentID()
  39477. return nil
  39478. case whatsapp.FieldAccount:
  39479. m.ResetAccount()
  39480. return nil
  39481. case whatsapp.FieldCc:
  39482. m.ResetCc()
  39483. return nil
  39484. case whatsapp.FieldPhone:
  39485. m.ResetPhone()
  39486. return nil
  39487. case whatsapp.FieldCcPhone:
  39488. m.ResetCcPhone()
  39489. return nil
  39490. case whatsapp.FieldPhoneName:
  39491. m.ResetPhoneName()
  39492. return nil
  39493. case whatsapp.FieldPhoneStatus:
  39494. m.ResetPhoneStatus()
  39495. return nil
  39496. case whatsapp.FieldOrganizationID:
  39497. m.ResetOrganizationID()
  39498. return nil
  39499. case whatsapp.FieldAPIBase:
  39500. m.ResetAPIBase()
  39501. return nil
  39502. case whatsapp.FieldAPIKey:
  39503. m.ResetAPIKey()
  39504. return nil
  39505. case whatsapp.FieldAllowList:
  39506. m.ResetAllowList()
  39507. return nil
  39508. case whatsapp.FieldGroupAllowList:
  39509. m.ResetGroupAllowList()
  39510. return nil
  39511. case whatsapp.FieldBlockList:
  39512. m.ResetBlockList()
  39513. return nil
  39514. case whatsapp.FieldGroupBlockList:
  39515. m.ResetGroupBlockList()
  39516. return nil
  39517. }
  39518. return fmt.Errorf("unknown Whatsapp field %s", name)
  39519. }
  39520. // AddedEdges returns all edge names that were set/added in this mutation.
  39521. func (m *WhatsappMutation) AddedEdges() []string {
  39522. edges := make([]string, 0, 1)
  39523. if m.agent != nil {
  39524. edges = append(edges, whatsapp.EdgeAgent)
  39525. }
  39526. return edges
  39527. }
  39528. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39529. // name in this mutation.
  39530. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  39531. switch name {
  39532. case whatsapp.EdgeAgent:
  39533. if id := m.agent; id != nil {
  39534. return []ent.Value{*id}
  39535. }
  39536. }
  39537. return nil
  39538. }
  39539. // RemovedEdges returns all edge names that were removed in this mutation.
  39540. func (m *WhatsappMutation) RemovedEdges() []string {
  39541. edges := make([]string, 0, 1)
  39542. return edges
  39543. }
  39544. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39545. // the given name in this mutation.
  39546. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  39547. return nil
  39548. }
  39549. // ClearedEdges returns all edge names that were cleared in this mutation.
  39550. func (m *WhatsappMutation) ClearedEdges() []string {
  39551. edges := make([]string, 0, 1)
  39552. if m.clearedagent {
  39553. edges = append(edges, whatsapp.EdgeAgent)
  39554. }
  39555. return edges
  39556. }
  39557. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39558. // was cleared in this mutation.
  39559. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  39560. switch name {
  39561. case whatsapp.EdgeAgent:
  39562. return m.clearedagent
  39563. }
  39564. return false
  39565. }
  39566. // ClearEdge clears the value of the edge with the given name. It returns an error
  39567. // if that edge is not defined in the schema.
  39568. func (m *WhatsappMutation) ClearEdge(name string) error {
  39569. switch name {
  39570. case whatsapp.EdgeAgent:
  39571. m.ClearAgent()
  39572. return nil
  39573. }
  39574. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  39575. }
  39576. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39577. // It returns an error if the edge is not defined in the schema.
  39578. func (m *WhatsappMutation) ResetEdge(name string) error {
  39579. switch name {
  39580. case whatsapp.EdgeAgent:
  39581. m.ResetAgent()
  39582. return nil
  39583. }
  39584. return fmt.Errorf("unknown Whatsapp edge %s", name)
  39585. }
  39586. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  39587. type WhatsappChannelMutation struct {
  39588. config
  39589. op Op
  39590. typ string
  39591. id *uint64
  39592. created_at *time.Time
  39593. updated_at *time.Time
  39594. status *uint8
  39595. addstatus *int8
  39596. deleted_at *time.Time
  39597. ak *string
  39598. sk *string
  39599. wa_id *string
  39600. wa_name *string
  39601. waba_id *uint64
  39602. addwaba_id *int64
  39603. business_id *uint64
  39604. addbusiness_id *int64
  39605. organization_id *uint64
  39606. addorganization_id *int64
  39607. verify_account *string
  39608. clearedFields map[string]struct{}
  39609. done bool
  39610. oldValue func(context.Context) (*WhatsappChannel, error)
  39611. predicates []predicate.WhatsappChannel
  39612. }
  39613. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  39614. // whatsappchannelOption allows management of the mutation configuration using functional options.
  39615. type whatsappchannelOption func(*WhatsappChannelMutation)
  39616. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  39617. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  39618. m := &WhatsappChannelMutation{
  39619. config: c,
  39620. op: op,
  39621. typ: TypeWhatsappChannel,
  39622. clearedFields: make(map[string]struct{}),
  39623. }
  39624. for _, opt := range opts {
  39625. opt(m)
  39626. }
  39627. return m
  39628. }
  39629. // withWhatsappChannelID sets the ID field of the mutation.
  39630. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  39631. return func(m *WhatsappChannelMutation) {
  39632. var (
  39633. err error
  39634. once sync.Once
  39635. value *WhatsappChannel
  39636. )
  39637. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  39638. once.Do(func() {
  39639. if m.done {
  39640. err = errors.New("querying old values post mutation is not allowed")
  39641. } else {
  39642. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  39643. }
  39644. })
  39645. return value, err
  39646. }
  39647. m.id = &id
  39648. }
  39649. }
  39650. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  39651. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  39652. return func(m *WhatsappChannelMutation) {
  39653. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  39654. return node, nil
  39655. }
  39656. m.id = &node.ID
  39657. }
  39658. }
  39659. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39660. // executed in a transaction (ent.Tx), a transactional client is returned.
  39661. func (m WhatsappChannelMutation) Client() *Client {
  39662. client := &Client{config: m.config}
  39663. client.init()
  39664. return client
  39665. }
  39666. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39667. // it returns an error otherwise.
  39668. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  39669. if _, ok := m.driver.(*txDriver); !ok {
  39670. return nil, errors.New("ent: mutation is not running in a transaction")
  39671. }
  39672. tx := &Tx{config: m.config}
  39673. tx.init()
  39674. return tx, nil
  39675. }
  39676. // SetID sets the value of the id field. Note that this
  39677. // operation is only accepted on creation of WhatsappChannel entities.
  39678. func (m *WhatsappChannelMutation) SetID(id uint64) {
  39679. m.id = &id
  39680. }
  39681. // ID returns the ID value in the mutation. Note that the ID is only available
  39682. // if it was provided to the builder or after it was returned from the database.
  39683. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  39684. if m.id == nil {
  39685. return
  39686. }
  39687. return *m.id, true
  39688. }
  39689. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39690. // That means, if the mutation is applied within a transaction with an isolation level such
  39691. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39692. // or updated by the mutation.
  39693. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  39694. switch {
  39695. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39696. id, exists := m.ID()
  39697. if exists {
  39698. return []uint64{id}, nil
  39699. }
  39700. fallthrough
  39701. case m.op.Is(OpUpdate | OpDelete):
  39702. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  39703. default:
  39704. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39705. }
  39706. }
  39707. // SetCreatedAt sets the "created_at" field.
  39708. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  39709. m.created_at = &t
  39710. }
  39711. // CreatedAt returns the value of the "created_at" field in the mutation.
  39712. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  39713. v := m.created_at
  39714. if v == nil {
  39715. return
  39716. }
  39717. return *v, true
  39718. }
  39719. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  39720. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39722. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39723. if !m.op.Is(OpUpdateOne) {
  39724. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39725. }
  39726. if m.id == nil || m.oldValue == nil {
  39727. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39728. }
  39729. oldValue, err := m.oldValue(ctx)
  39730. if err != nil {
  39731. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39732. }
  39733. return oldValue.CreatedAt, nil
  39734. }
  39735. // ResetCreatedAt resets all changes to the "created_at" field.
  39736. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  39737. m.created_at = nil
  39738. }
  39739. // SetUpdatedAt sets the "updated_at" field.
  39740. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  39741. m.updated_at = &t
  39742. }
  39743. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39744. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  39745. v := m.updated_at
  39746. if v == nil {
  39747. return
  39748. }
  39749. return *v, true
  39750. }
  39751. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  39752. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39754. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39755. if !m.op.Is(OpUpdateOne) {
  39756. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39757. }
  39758. if m.id == nil || m.oldValue == nil {
  39759. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39760. }
  39761. oldValue, err := m.oldValue(ctx)
  39762. if err != nil {
  39763. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39764. }
  39765. return oldValue.UpdatedAt, nil
  39766. }
  39767. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39768. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  39769. m.updated_at = nil
  39770. }
  39771. // SetStatus sets the "status" field.
  39772. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  39773. m.status = &u
  39774. m.addstatus = nil
  39775. }
  39776. // Status returns the value of the "status" field in the mutation.
  39777. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  39778. v := m.status
  39779. if v == nil {
  39780. return
  39781. }
  39782. return *v, true
  39783. }
  39784. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  39785. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39787. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39788. if !m.op.Is(OpUpdateOne) {
  39789. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39790. }
  39791. if m.id == nil || m.oldValue == nil {
  39792. return v, errors.New("OldStatus requires an ID field in the mutation")
  39793. }
  39794. oldValue, err := m.oldValue(ctx)
  39795. if err != nil {
  39796. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39797. }
  39798. return oldValue.Status, nil
  39799. }
  39800. // AddStatus adds u to the "status" field.
  39801. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  39802. if m.addstatus != nil {
  39803. *m.addstatus += u
  39804. } else {
  39805. m.addstatus = &u
  39806. }
  39807. }
  39808. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39809. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  39810. v := m.addstatus
  39811. if v == nil {
  39812. return
  39813. }
  39814. return *v, true
  39815. }
  39816. // ClearStatus clears the value of the "status" field.
  39817. func (m *WhatsappChannelMutation) ClearStatus() {
  39818. m.status = nil
  39819. m.addstatus = nil
  39820. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  39821. }
  39822. // StatusCleared returns if the "status" field was cleared in this mutation.
  39823. func (m *WhatsappChannelMutation) StatusCleared() bool {
  39824. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  39825. return ok
  39826. }
  39827. // ResetStatus resets all changes to the "status" field.
  39828. func (m *WhatsappChannelMutation) ResetStatus() {
  39829. m.status = nil
  39830. m.addstatus = nil
  39831. delete(m.clearedFields, whatsappchannel.FieldStatus)
  39832. }
  39833. // SetDeletedAt sets the "deleted_at" field.
  39834. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  39835. m.deleted_at = &t
  39836. }
  39837. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39838. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  39839. v := m.deleted_at
  39840. if v == nil {
  39841. return
  39842. }
  39843. return *v, true
  39844. }
  39845. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  39846. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39848. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39849. if !m.op.Is(OpUpdateOne) {
  39850. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39851. }
  39852. if m.id == nil || m.oldValue == nil {
  39853. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39854. }
  39855. oldValue, err := m.oldValue(ctx)
  39856. if err != nil {
  39857. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39858. }
  39859. return oldValue.DeletedAt, nil
  39860. }
  39861. // ClearDeletedAt clears the value of the "deleted_at" field.
  39862. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  39863. m.deleted_at = nil
  39864. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  39865. }
  39866. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39867. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  39868. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  39869. return ok
  39870. }
  39871. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39872. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  39873. m.deleted_at = nil
  39874. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  39875. }
  39876. // SetAk sets the "ak" field.
  39877. func (m *WhatsappChannelMutation) SetAk(s string) {
  39878. m.ak = &s
  39879. }
  39880. // Ak returns the value of the "ak" field in the mutation.
  39881. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  39882. v := m.ak
  39883. if v == nil {
  39884. return
  39885. }
  39886. return *v, true
  39887. }
  39888. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  39889. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39891. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  39892. if !m.op.Is(OpUpdateOne) {
  39893. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  39894. }
  39895. if m.id == nil || m.oldValue == nil {
  39896. return v, errors.New("OldAk requires an ID field in the mutation")
  39897. }
  39898. oldValue, err := m.oldValue(ctx)
  39899. if err != nil {
  39900. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  39901. }
  39902. return oldValue.Ak, nil
  39903. }
  39904. // ClearAk clears the value of the "ak" field.
  39905. func (m *WhatsappChannelMutation) ClearAk() {
  39906. m.ak = nil
  39907. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  39908. }
  39909. // AkCleared returns if the "ak" field was cleared in this mutation.
  39910. func (m *WhatsappChannelMutation) AkCleared() bool {
  39911. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  39912. return ok
  39913. }
  39914. // ResetAk resets all changes to the "ak" field.
  39915. func (m *WhatsappChannelMutation) ResetAk() {
  39916. m.ak = nil
  39917. delete(m.clearedFields, whatsappchannel.FieldAk)
  39918. }
  39919. // SetSk sets the "sk" field.
  39920. func (m *WhatsappChannelMutation) SetSk(s string) {
  39921. m.sk = &s
  39922. }
  39923. // Sk returns the value of the "sk" field in the mutation.
  39924. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  39925. v := m.sk
  39926. if v == nil {
  39927. return
  39928. }
  39929. return *v, true
  39930. }
  39931. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  39932. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39934. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  39935. if !m.op.Is(OpUpdateOne) {
  39936. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  39937. }
  39938. if m.id == nil || m.oldValue == nil {
  39939. return v, errors.New("OldSk requires an ID field in the mutation")
  39940. }
  39941. oldValue, err := m.oldValue(ctx)
  39942. if err != nil {
  39943. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  39944. }
  39945. return oldValue.Sk, nil
  39946. }
  39947. // ResetSk resets all changes to the "sk" field.
  39948. func (m *WhatsappChannelMutation) ResetSk() {
  39949. m.sk = nil
  39950. }
  39951. // SetWaID sets the "wa_id" field.
  39952. func (m *WhatsappChannelMutation) SetWaID(s string) {
  39953. m.wa_id = &s
  39954. }
  39955. // WaID returns the value of the "wa_id" field in the mutation.
  39956. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  39957. v := m.wa_id
  39958. if v == nil {
  39959. return
  39960. }
  39961. return *v, true
  39962. }
  39963. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  39964. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39966. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  39967. if !m.op.Is(OpUpdateOne) {
  39968. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  39969. }
  39970. if m.id == nil || m.oldValue == nil {
  39971. return v, errors.New("OldWaID requires an ID field in the mutation")
  39972. }
  39973. oldValue, err := m.oldValue(ctx)
  39974. if err != nil {
  39975. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  39976. }
  39977. return oldValue.WaID, nil
  39978. }
  39979. // ClearWaID clears the value of the "wa_id" field.
  39980. func (m *WhatsappChannelMutation) ClearWaID() {
  39981. m.wa_id = nil
  39982. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  39983. }
  39984. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  39985. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  39986. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  39987. return ok
  39988. }
  39989. // ResetWaID resets all changes to the "wa_id" field.
  39990. func (m *WhatsappChannelMutation) ResetWaID() {
  39991. m.wa_id = nil
  39992. delete(m.clearedFields, whatsappchannel.FieldWaID)
  39993. }
  39994. // SetWaName sets the "wa_name" field.
  39995. func (m *WhatsappChannelMutation) SetWaName(s string) {
  39996. m.wa_name = &s
  39997. }
  39998. // WaName returns the value of the "wa_name" field in the mutation.
  39999. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  40000. v := m.wa_name
  40001. if v == nil {
  40002. return
  40003. }
  40004. return *v, true
  40005. }
  40006. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  40007. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40009. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  40010. if !m.op.Is(OpUpdateOne) {
  40011. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  40012. }
  40013. if m.id == nil || m.oldValue == nil {
  40014. return v, errors.New("OldWaName requires an ID field in the mutation")
  40015. }
  40016. oldValue, err := m.oldValue(ctx)
  40017. if err != nil {
  40018. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  40019. }
  40020. return oldValue.WaName, nil
  40021. }
  40022. // ClearWaName clears the value of the "wa_name" field.
  40023. func (m *WhatsappChannelMutation) ClearWaName() {
  40024. m.wa_name = nil
  40025. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  40026. }
  40027. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  40028. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  40029. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  40030. return ok
  40031. }
  40032. // ResetWaName resets all changes to the "wa_name" field.
  40033. func (m *WhatsappChannelMutation) ResetWaName() {
  40034. m.wa_name = nil
  40035. delete(m.clearedFields, whatsappchannel.FieldWaName)
  40036. }
  40037. // SetWabaID sets the "waba_id" field.
  40038. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  40039. m.waba_id = &u
  40040. m.addwaba_id = nil
  40041. }
  40042. // WabaID returns the value of the "waba_id" field in the mutation.
  40043. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  40044. v := m.waba_id
  40045. if v == nil {
  40046. return
  40047. }
  40048. return *v, true
  40049. }
  40050. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  40051. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40053. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  40054. if !m.op.Is(OpUpdateOne) {
  40055. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  40056. }
  40057. if m.id == nil || m.oldValue == nil {
  40058. return v, errors.New("OldWabaID requires an ID field in the mutation")
  40059. }
  40060. oldValue, err := m.oldValue(ctx)
  40061. if err != nil {
  40062. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  40063. }
  40064. return oldValue.WabaID, nil
  40065. }
  40066. // AddWabaID adds u to the "waba_id" field.
  40067. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  40068. if m.addwaba_id != nil {
  40069. *m.addwaba_id += u
  40070. } else {
  40071. m.addwaba_id = &u
  40072. }
  40073. }
  40074. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  40075. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  40076. v := m.addwaba_id
  40077. if v == nil {
  40078. return
  40079. }
  40080. return *v, true
  40081. }
  40082. // ResetWabaID resets all changes to the "waba_id" field.
  40083. func (m *WhatsappChannelMutation) ResetWabaID() {
  40084. m.waba_id = nil
  40085. m.addwaba_id = nil
  40086. }
  40087. // SetBusinessID sets the "business_id" field.
  40088. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  40089. m.business_id = &u
  40090. m.addbusiness_id = nil
  40091. }
  40092. // BusinessID returns the value of the "business_id" field in the mutation.
  40093. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  40094. v := m.business_id
  40095. if v == nil {
  40096. return
  40097. }
  40098. return *v, true
  40099. }
  40100. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  40101. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40103. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  40104. if !m.op.Is(OpUpdateOne) {
  40105. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  40106. }
  40107. if m.id == nil || m.oldValue == nil {
  40108. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  40109. }
  40110. oldValue, err := m.oldValue(ctx)
  40111. if err != nil {
  40112. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  40113. }
  40114. return oldValue.BusinessID, nil
  40115. }
  40116. // AddBusinessID adds u to the "business_id" field.
  40117. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  40118. if m.addbusiness_id != nil {
  40119. *m.addbusiness_id += u
  40120. } else {
  40121. m.addbusiness_id = &u
  40122. }
  40123. }
  40124. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  40125. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  40126. v := m.addbusiness_id
  40127. if v == nil {
  40128. return
  40129. }
  40130. return *v, true
  40131. }
  40132. // ResetBusinessID resets all changes to the "business_id" field.
  40133. func (m *WhatsappChannelMutation) ResetBusinessID() {
  40134. m.business_id = nil
  40135. m.addbusiness_id = nil
  40136. }
  40137. // SetOrganizationID sets the "organization_id" field.
  40138. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  40139. m.organization_id = &u
  40140. m.addorganization_id = nil
  40141. }
  40142. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40143. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  40144. v := m.organization_id
  40145. if v == nil {
  40146. return
  40147. }
  40148. return *v, true
  40149. }
  40150. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  40151. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40153. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40154. if !m.op.Is(OpUpdateOne) {
  40155. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40156. }
  40157. if m.id == nil || m.oldValue == nil {
  40158. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40159. }
  40160. oldValue, err := m.oldValue(ctx)
  40161. if err != nil {
  40162. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40163. }
  40164. return oldValue.OrganizationID, nil
  40165. }
  40166. // AddOrganizationID adds u to the "organization_id" field.
  40167. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  40168. if m.addorganization_id != nil {
  40169. *m.addorganization_id += u
  40170. } else {
  40171. m.addorganization_id = &u
  40172. }
  40173. }
  40174. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40175. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  40176. v := m.addorganization_id
  40177. if v == nil {
  40178. return
  40179. }
  40180. return *v, true
  40181. }
  40182. // ClearOrganizationID clears the value of the "organization_id" field.
  40183. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  40184. m.organization_id = nil
  40185. m.addorganization_id = nil
  40186. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  40187. }
  40188. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40189. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  40190. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  40191. return ok
  40192. }
  40193. // ResetOrganizationID resets all changes to the "organization_id" field.
  40194. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  40195. m.organization_id = nil
  40196. m.addorganization_id = nil
  40197. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  40198. }
  40199. // SetVerifyAccount sets the "verify_account" field.
  40200. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  40201. m.verify_account = &s
  40202. }
  40203. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  40204. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  40205. v := m.verify_account
  40206. if v == nil {
  40207. return
  40208. }
  40209. return *v, true
  40210. }
  40211. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  40212. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40214. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  40215. if !m.op.Is(OpUpdateOne) {
  40216. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  40217. }
  40218. if m.id == nil || m.oldValue == nil {
  40219. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  40220. }
  40221. oldValue, err := m.oldValue(ctx)
  40222. if err != nil {
  40223. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  40224. }
  40225. return oldValue.VerifyAccount, nil
  40226. }
  40227. // ResetVerifyAccount resets all changes to the "verify_account" field.
  40228. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  40229. m.verify_account = nil
  40230. }
  40231. // Where appends a list predicates to the WhatsappChannelMutation builder.
  40232. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  40233. m.predicates = append(m.predicates, ps...)
  40234. }
  40235. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  40236. // users can use type-assertion to append predicates that do not depend on any generated package.
  40237. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  40238. p := make([]predicate.WhatsappChannel, len(ps))
  40239. for i := range ps {
  40240. p[i] = ps[i]
  40241. }
  40242. m.Where(p...)
  40243. }
  40244. // Op returns the operation name.
  40245. func (m *WhatsappChannelMutation) Op() Op {
  40246. return m.op
  40247. }
  40248. // SetOp allows setting the mutation operation.
  40249. func (m *WhatsappChannelMutation) SetOp(op Op) {
  40250. m.op = op
  40251. }
  40252. // Type returns the node type of this mutation (WhatsappChannel).
  40253. func (m *WhatsappChannelMutation) Type() string {
  40254. return m.typ
  40255. }
  40256. // Fields returns all fields that were changed during this mutation. Note that in
  40257. // order to get all numeric fields that were incremented/decremented, call
  40258. // AddedFields().
  40259. func (m *WhatsappChannelMutation) Fields() []string {
  40260. fields := make([]string, 0, 12)
  40261. if m.created_at != nil {
  40262. fields = append(fields, whatsappchannel.FieldCreatedAt)
  40263. }
  40264. if m.updated_at != nil {
  40265. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  40266. }
  40267. if m.status != nil {
  40268. fields = append(fields, whatsappchannel.FieldStatus)
  40269. }
  40270. if m.deleted_at != nil {
  40271. fields = append(fields, whatsappchannel.FieldDeletedAt)
  40272. }
  40273. if m.ak != nil {
  40274. fields = append(fields, whatsappchannel.FieldAk)
  40275. }
  40276. if m.sk != nil {
  40277. fields = append(fields, whatsappchannel.FieldSk)
  40278. }
  40279. if m.wa_id != nil {
  40280. fields = append(fields, whatsappchannel.FieldWaID)
  40281. }
  40282. if m.wa_name != nil {
  40283. fields = append(fields, whatsappchannel.FieldWaName)
  40284. }
  40285. if m.waba_id != nil {
  40286. fields = append(fields, whatsappchannel.FieldWabaID)
  40287. }
  40288. if m.business_id != nil {
  40289. fields = append(fields, whatsappchannel.FieldBusinessID)
  40290. }
  40291. if m.organization_id != nil {
  40292. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40293. }
  40294. if m.verify_account != nil {
  40295. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  40296. }
  40297. return fields
  40298. }
  40299. // Field returns the value of a field with the given name. The second boolean
  40300. // return value indicates that this field was not set, or was not defined in the
  40301. // schema.
  40302. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  40303. switch name {
  40304. case whatsappchannel.FieldCreatedAt:
  40305. return m.CreatedAt()
  40306. case whatsappchannel.FieldUpdatedAt:
  40307. return m.UpdatedAt()
  40308. case whatsappchannel.FieldStatus:
  40309. return m.Status()
  40310. case whatsappchannel.FieldDeletedAt:
  40311. return m.DeletedAt()
  40312. case whatsappchannel.FieldAk:
  40313. return m.Ak()
  40314. case whatsappchannel.FieldSk:
  40315. return m.Sk()
  40316. case whatsappchannel.FieldWaID:
  40317. return m.WaID()
  40318. case whatsappchannel.FieldWaName:
  40319. return m.WaName()
  40320. case whatsappchannel.FieldWabaID:
  40321. return m.WabaID()
  40322. case whatsappchannel.FieldBusinessID:
  40323. return m.BusinessID()
  40324. case whatsappchannel.FieldOrganizationID:
  40325. return m.OrganizationID()
  40326. case whatsappchannel.FieldVerifyAccount:
  40327. return m.VerifyAccount()
  40328. }
  40329. return nil, false
  40330. }
  40331. // OldField returns the old value of the field from the database. An error is
  40332. // returned if the mutation operation is not UpdateOne, or the query to the
  40333. // database failed.
  40334. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40335. switch name {
  40336. case whatsappchannel.FieldCreatedAt:
  40337. return m.OldCreatedAt(ctx)
  40338. case whatsappchannel.FieldUpdatedAt:
  40339. return m.OldUpdatedAt(ctx)
  40340. case whatsappchannel.FieldStatus:
  40341. return m.OldStatus(ctx)
  40342. case whatsappchannel.FieldDeletedAt:
  40343. return m.OldDeletedAt(ctx)
  40344. case whatsappchannel.FieldAk:
  40345. return m.OldAk(ctx)
  40346. case whatsappchannel.FieldSk:
  40347. return m.OldSk(ctx)
  40348. case whatsappchannel.FieldWaID:
  40349. return m.OldWaID(ctx)
  40350. case whatsappchannel.FieldWaName:
  40351. return m.OldWaName(ctx)
  40352. case whatsappchannel.FieldWabaID:
  40353. return m.OldWabaID(ctx)
  40354. case whatsappchannel.FieldBusinessID:
  40355. return m.OldBusinessID(ctx)
  40356. case whatsappchannel.FieldOrganizationID:
  40357. return m.OldOrganizationID(ctx)
  40358. case whatsappchannel.FieldVerifyAccount:
  40359. return m.OldVerifyAccount(ctx)
  40360. }
  40361. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  40362. }
  40363. // SetField sets the value of a field with the given name. It returns an error if
  40364. // the field is not defined in the schema, or if the type mismatched the field
  40365. // type.
  40366. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  40367. switch name {
  40368. case whatsappchannel.FieldCreatedAt:
  40369. v, ok := value.(time.Time)
  40370. if !ok {
  40371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40372. }
  40373. m.SetCreatedAt(v)
  40374. return nil
  40375. case whatsappchannel.FieldUpdatedAt:
  40376. v, ok := value.(time.Time)
  40377. if !ok {
  40378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40379. }
  40380. m.SetUpdatedAt(v)
  40381. return nil
  40382. case whatsappchannel.FieldStatus:
  40383. v, ok := value.(uint8)
  40384. if !ok {
  40385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40386. }
  40387. m.SetStatus(v)
  40388. return nil
  40389. case whatsappchannel.FieldDeletedAt:
  40390. v, ok := value.(time.Time)
  40391. if !ok {
  40392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40393. }
  40394. m.SetDeletedAt(v)
  40395. return nil
  40396. case whatsappchannel.FieldAk:
  40397. v, ok := value.(string)
  40398. if !ok {
  40399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40400. }
  40401. m.SetAk(v)
  40402. return nil
  40403. case whatsappchannel.FieldSk:
  40404. v, ok := value.(string)
  40405. if !ok {
  40406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40407. }
  40408. m.SetSk(v)
  40409. return nil
  40410. case whatsappchannel.FieldWaID:
  40411. v, ok := value.(string)
  40412. if !ok {
  40413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40414. }
  40415. m.SetWaID(v)
  40416. return nil
  40417. case whatsappchannel.FieldWaName:
  40418. v, ok := value.(string)
  40419. if !ok {
  40420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40421. }
  40422. m.SetWaName(v)
  40423. return nil
  40424. case whatsappchannel.FieldWabaID:
  40425. v, ok := value.(uint64)
  40426. if !ok {
  40427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40428. }
  40429. m.SetWabaID(v)
  40430. return nil
  40431. case whatsappchannel.FieldBusinessID:
  40432. v, ok := value.(uint64)
  40433. if !ok {
  40434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40435. }
  40436. m.SetBusinessID(v)
  40437. return nil
  40438. case whatsappchannel.FieldOrganizationID:
  40439. v, ok := value.(uint64)
  40440. if !ok {
  40441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40442. }
  40443. m.SetOrganizationID(v)
  40444. return nil
  40445. case whatsappchannel.FieldVerifyAccount:
  40446. v, ok := value.(string)
  40447. if !ok {
  40448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40449. }
  40450. m.SetVerifyAccount(v)
  40451. return nil
  40452. }
  40453. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40454. }
  40455. // AddedFields returns all numeric fields that were incremented/decremented during
  40456. // this mutation.
  40457. func (m *WhatsappChannelMutation) AddedFields() []string {
  40458. var fields []string
  40459. if m.addstatus != nil {
  40460. fields = append(fields, whatsappchannel.FieldStatus)
  40461. }
  40462. if m.addwaba_id != nil {
  40463. fields = append(fields, whatsappchannel.FieldWabaID)
  40464. }
  40465. if m.addbusiness_id != nil {
  40466. fields = append(fields, whatsappchannel.FieldBusinessID)
  40467. }
  40468. if m.addorganization_id != nil {
  40469. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40470. }
  40471. return fields
  40472. }
  40473. // AddedField returns the numeric value that was incremented/decremented on a field
  40474. // with the given name. The second boolean return value indicates that this field
  40475. // was not set, or was not defined in the schema.
  40476. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  40477. switch name {
  40478. case whatsappchannel.FieldStatus:
  40479. return m.AddedStatus()
  40480. case whatsappchannel.FieldWabaID:
  40481. return m.AddedWabaID()
  40482. case whatsappchannel.FieldBusinessID:
  40483. return m.AddedBusinessID()
  40484. case whatsappchannel.FieldOrganizationID:
  40485. return m.AddedOrganizationID()
  40486. }
  40487. return nil, false
  40488. }
  40489. // AddField adds the value to the field with the given name. It returns an error if
  40490. // the field is not defined in the schema, or if the type mismatched the field
  40491. // type.
  40492. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  40493. switch name {
  40494. case whatsappchannel.FieldStatus:
  40495. v, ok := value.(int8)
  40496. if !ok {
  40497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40498. }
  40499. m.AddStatus(v)
  40500. return nil
  40501. case whatsappchannel.FieldWabaID:
  40502. v, ok := value.(int64)
  40503. if !ok {
  40504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40505. }
  40506. m.AddWabaID(v)
  40507. return nil
  40508. case whatsappchannel.FieldBusinessID:
  40509. v, ok := value.(int64)
  40510. if !ok {
  40511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40512. }
  40513. m.AddBusinessID(v)
  40514. return nil
  40515. case whatsappchannel.FieldOrganizationID:
  40516. v, ok := value.(int64)
  40517. if !ok {
  40518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40519. }
  40520. m.AddOrganizationID(v)
  40521. return nil
  40522. }
  40523. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  40524. }
  40525. // ClearedFields returns all nullable fields that were cleared during this
  40526. // mutation.
  40527. func (m *WhatsappChannelMutation) ClearedFields() []string {
  40528. var fields []string
  40529. if m.FieldCleared(whatsappchannel.FieldStatus) {
  40530. fields = append(fields, whatsappchannel.FieldStatus)
  40531. }
  40532. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  40533. fields = append(fields, whatsappchannel.FieldDeletedAt)
  40534. }
  40535. if m.FieldCleared(whatsappchannel.FieldAk) {
  40536. fields = append(fields, whatsappchannel.FieldAk)
  40537. }
  40538. if m.FieldCleared(whatsappchannel.FieldWaID) {
  40539. fields = append(fields, whatsappchannel.FieldWaID)
  40540. }
  40541. if m.FieldCleared(whatsappchannel.FieldWaName) {
  40542. fields = append(fields, whatsappchannel.FieldWaName)
  40543. }
  40544. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  40545. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40546. }
  40547. return fields
  40548. }
  40549. // FieldCleared returns a boolean indicating if a field with the given name was
  40550. // cleared in this mutation.
  40551. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  40552. _, ok := m.clearedFields[name]
  40553. return ok
  40554. }
  40555. // ClearField clears the value of the field with the given name. It returns an
  40556. // error if the field is not defined in the schema.
  40557. func (m *WhatsappChannelMutation) ClearField(name string) error {
  40558. switch name {
  40559. case whatsappchannel.FieldStatus:
  40560. m.ClearStatus()
  40561. return nil
  40562. case whatsappchannel.FieldDeletedAt:
  40563. m.ClearDeletedAt()
  40564. return nil
  40565. case whatsappchannel.FieldAk:
  40566. m.ClearAk()
  40567. return nil
  40568. case whatsappchannel.FieldWaID:
  40569. m.ClearWaID()
  40570. return nil
  40571. case whatsappchannel.FieldWaName:
  40572. m.ClearWaName()
  40573. return nil
  40574. case whatsappchannel.FieldOrganizationID:
  40575. m.ClearOrganizationID()
  40576. return nil
  40577. }
  40578. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  40579. }
  40580. // ResetField resets all changes in the mutation for the field with the given name.
  40581. // It returns an error if the field is not defined in the schema.
  40582. func (m *WhatsappChannelMutation) ResetField(name string) error {
  40583. switch name {
  40584. case whatsappchannel.FieldCreatedAt:
  40585. m.ResetCreatedAt()
  40586. return nil
  40587. case whatsappchannel.FieldUpdatedAt:
  40588. m.ResetUpdatedAt()
  40589. return nil
  40590. case whatsappchannel.FieldStatus:
  40591. m.ResetStatus()
  40592. return nil
  40593. case whatsappchannel.FieldDeletedAt:
  40594. m.ResetDeletedAt()
  40595. return nil
  40596. case whatsappchannel.FieldAk:
  40597. m.ResetAk()
  40598. return nil
  40599. case whatsappchannel.FieldSk:
  40600. m.ResetSk()
  40601. return nil
  40602. case whatsappchannel.FieldWaID:
  40603. m.ResetWaID()
  40604. return nil
  40605. case whatsappchannel.FieldWaName:
  40606. m.ResetWaName()
  40607. return nil
  40608. case whatsappchannel.FieldWabaID:
  40609. m.ResetWabaID()
  40610. return nil
  40611. case whatsappchannel.FieldBusinessID:
  40612. m.ResetBusinessID()
  40613. return nil
  40614. case whatsappchannel.FieldOrganizationID:
  40615. m.ResetOrganizationID()
  40616. return nil
  40617. case whatsappchannel.FieldVerifyAccount:
  40618. m.ResetVerifyAccount()
  40619. return nil
  40620. }
  40621. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40622. }
  40623. // AddedEdges returns all edge names that were set/added in this mutation.
  40624. func (m *WhatsappChannelMutation) AddedEdges() []string {
  40625. edges := make([]string, 0, 0)
  40626. return edges
  40627. }
  40628. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40629. // name in this mutation.
  40630. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  40631. return nil
  40632. }
  40633. // RemovedEdges returns all edge names that were removed in this mutation.
  40634. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  40635. edges := make([]string, 0, 0)
  40636. return edges
  40637. }
  40638. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40639. // the given name in this mutation.
  40640. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  40641. return nil
  40642. }
  40643. // ClearedEdges returns all edge names that were cleared in this mutation.
  40644. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  40645. edges := make([]string, 0, 0)
  40646. return edges
  40647. }
  40648. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40649. // was cleared in this mutation.
  40650. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  40651. return false
  40652. }
  40653. // ClearEdge clears the value of the edge with the given name. It returns an error
  40654. // if that edge is not defined in the schema.
  40655. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  40656. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  40657. }
  40658. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40659. // It returns an error if the edge is not defined in the schema.
  40660. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  40661. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  40662. }
  40663. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  40664. type WorkExperienceMutation struct {
  40665. config
  40666. op Op
  40667. typ string
  40668. id *uint64
  40669. created_at *time.Time
  40670. updated_at *time.Time
  40671. deleted_at *time.Time
  40672. start_date *time.Time
  40673. end_date *time.Time
  40674. company *string
  40675. experience *string
  40676. organization_id *uint64
  40677. addorganization_id *int64
  40678. clearedFields map[string]struct{}
  40679. employee *uint64
  40680. clearedemployee bool
  40681. done bool
  40682. oldValue func(context.Context) (*WorkExperience, error)
  40683. predicates []predicate.WorkExperience
  40684. }
  40685. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  40686. // workexperienceOption allows management of the mutation configuration using functional options.
  40687. type workexperienceOption func(*WorkExperienceMutation)
  40688. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  40689. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  40690. m := &WorkExperienceMutation{
  40691. config: c,
  40692. op: op,
  40693. typ: TypeWorkExperience,
  40694. clearedFields: make(map[string]struct{}),
  40695. }
  40696. for _, opt := range opts {
  40697. opt(m)
  40698. }
  40699. return m
  40700. }
  40701. // withWorkExperienceID sets the ID field of the mutation.
  40702. func withWorkExperienceID(id uint64) workexperienceOption {
  40703. return func(m *WorkExperienceMutation) {
  40704. var (
  40705. err error
  40706. once sync.Once
  40707. value *WorkExperience
  40708. )
  40709. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  40710. once.Do(func() {
  40711. if m.done {
  40712. err = errors.New("querying old values post mutation is not allowed")
  40713. } else {
  40714. value, err = m.Client().WorkExperience.Get(ctx, id)
  40715. }
  40716. })
  40717. return value, err
  40718. }
  40719. m.id = &id
  40720. }
  40721. }
  40722. // withWorkExperience sets the old WorkExperience of the mutation.
  40723. func withWorkExperience(node *WorkExperience) workexperienceOption {
  40724. return func(m *WorkExperienceMutation) {
  40725. m.oldValue = func(context.Context) (*WorkExperience, error) {
  40726. return node, nil
  40727. }
  40728. m.id = &node.ID
  40729. }
  40730. }
  40731. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40732. // executed in a transaction (ent.Tx), a transactional client is returned.
  40733. func (m WorkExperienceMutation) Client() *Client {
  40734. client := &Client{config: m.config}
  40735. client.init()
  40736. return client
  40737. }
  40738. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40739. // it returns an error otherwise.
  40740. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  40741. if _, ok := m.driver.(*txDriver); !ok {
  40742. return nil, errors.New("ent: mutation is not running in a transaction")
  40743. }
  40744. tx := &Tx{config: m.config}
  40745. tx.init()
  40746. return tx, nil
  40747. }
  40748. // SetID sets the value of the id field. Note that this
  40749. // operation is only accepted on creation of WorkExperience entities.
  40750. func (m *WorkExperienceMutation) SetID(id uint64) {
  40751. m.id = &id
  40752. }
  40753. // ID returns the ID value in the mutation. Note that the ID is only available
  40754. // if it was provided to the builder or after it was returned from the database.
  40755. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  40756. if m.id == nil {
  40757. return
  40758. }
  40759. return *m.id, true
  40760. }
  40761. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40762. // That means, if the mutation is applied within a transaction with an isolation level such
  40763. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40764. // or updated by the mutation.
  40765. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  40766. switch {
  40767. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40768. id, exists := m.ID()
  40769. if exists {
  40770. return []uint64{id}, nil
  40771. }
  40772. fallthrough
  40773. case m.op.Is(OpUpdate | OpDelete):
  40774. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  40775. default:
  40776. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40777. }
  40778. }
  40779. // SetCreatedAt sets the "created_at" field.
  40780. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  40781. m.created_at = &t
  40782. }
  40783. // CreatedAt returns the value of the "created_at" field in the mutation.
  40784. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  40785. v := m.created_at
  40786. if v == nil {
  40787. return
  40788. }
  40789. return *v, true
  40790. }
  40791. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  40792. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40794. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40795. if !m.op.Is(OpUpdateOne) {
  40796. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40797. }
  40798. if m.id == nil || m.oldValue == nil {
  40799. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40800. }
  40801. oldValue, err := m.oldValue(ctx)
  40802. if err != nil {
  40803. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40804. }
  40805. return oldValue.CreatedAt, nil
  40806. }
  40807. // ResetCreatedAt resets all changes to the "created_at" field.
  40808. func (m *WorkExperienceMutation) ResetCreatedAt() {
  40809. m.created_at = nil
  40810. }
  40811. // SetUpdatedAt sets the "updated_at" field.
  40812. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  40813. m.updated_at = &t
  40814. }
  40815. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40816. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  40817. v := m.updated_at
  40818. if v == nil {
  40819. return
  40820. }
  40821. return *v, true
  40822. }
  40823. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  40824. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40826. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40827. if !m.op.Is(OpUpdateOne) {
  40828. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40829. }
  40830. if m.id == nil || m.oldValue == nil {
  40831. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40832. }
  40833. oldValue, err := m.oldValue(ctx)
  40834. if err != nil {
  40835. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40836. }
  40837. return oldValue.UpdatedAt, nil
  40838. }
  40839. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40840. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  40841. m.updated_at = nil
  40842. }
  40843. // SetDeletedAt sets the "deleted_at" field.
  40844. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  40845. m.deleted_at = &t
  40846. }
  40847. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40848. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  40849. v := m.deleted_at
  40850. if v == nil {
  40851. return
  40852. }
  40853. return *v, true
  40854. }
  40855. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  40856. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40858. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40859. if !m.op.Is(OpUpdateOne) {
  40860. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40861. }
  40862. if m.id == nil || m.oldValue == nil {
  40863. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40864. }
  40865. oldValue, err := m.oldValue(ctx)
  40866. if err != nil {
  40867. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40868. }
  40869. return oldValue.DeletedAt, nil
  40870. }
  40871. // ClearDeletedAt clears the value of the "deleted_at" field.
  40872. func (m *WorkExperienceMutation) ClearDeletedAt() {
  40873. m.deleted_at = nil
  40874. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  40875. }
  40876. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40877. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  40878. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  40879. return ok
  40880. }
  40881. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40882. func (m *WorkExperienceMutation) ResetDeletedAt() {
  40883. m.deleted_at = nil
  40884. delete(m.clearedFields, workexperience.FieldDeletedAt)
  40885. }
  40886. // SetEmployeeID sets the "employee_id" field.
  40887. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  40888. m.employee = &u
  40889. }
  40890. // EmployeeID returns the value of the "employee_id" field in the mutation.
  40891. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  40892. v := m.employee
  40893. if v == nil {
  40894. return
  40895. }
  40896. return *v, true
  40897. }
  40898. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  40899. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40901. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  40902. if !m.op.Is(OpUpdateOne) {
  40903. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  40904. }
  40905. if m.id == nil || m.oldValue == nil {
  40906. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  40907. }
  40908. oldValue, err := m.oldValue(ctx)
  40909. if err != nil {
  40910. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  40911. }
  40912. return oldValue.EmployeeID, nil
  40913. }
  40914. // ResetEmployeeID resets all changes to the "employee_id" field.
  40915. func (m *WorkExperienceMutation) ResetEmployeeID() {
  40916. m.employee = nil
  40917. }
  40918. // SetStartDate sets the "start_date" field.
  40919. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  40920. m.start_date = &t
  40921. }
  40922. // StartDate returns the value of the "start_date" field in the mutation.
  40923. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  40924. v := m.start_date
  40925. if v == nil {
  40926. return
  40927. }
  40928. return *v, true
  40929. }
  40930. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  40931. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40933. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  40934. if !m.op.Is(OpUpdateOne) {
  40935. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  40936. }
  40937. if m.id == nil || m.oldValue == nil {
  40938. return v, errors.New("OldStartDate requires an ID field in the mutation")
  40939. }
  40940. oldValue, err := m.oldValue(ctx)
  40941. if err != nil {
  40942. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  40943. }
  40944. return oldValue.StartDate, nil
  40945. }
  40946. // ResetStartDate resets all changes to the "start_date" field.
  40947. func (m *WorkExperienceMutation) ResetStartDate() {
  40948. m.start_date = nil
  40949. }
  40950. // SetEndDate sets the "end_date" field.
  40951. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  40952. m.end_date = &t
  40953. }
  40954. // EndDate returns the value of the "end_date" field in the mutation.
  40955. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  40956. v := m.end_date
  40957. if v == nil {
  40958. return
  40959. }
  40960. return *v, true
  40961. }
  40962. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  40963. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40965. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  40966. if !m.op.Is(OpUpdateOne) {
  40967. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  40968. }
  40969. if m.id == nil || m.oldValue == nil {
  40970. return v, errors.New("OldEndDate requires an ID field in the mutation")
  40971. }
  40972. oldValue, err := m.oldValue(ctx)
  40973. if err != nil {
  40974. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  40975. }
  40976. return oldValue.EndDate, nil
  40977. }
  40978. // ResetEndDate resets all changes to the "end_date" field.
  40979. func (m *WorkExperienceMutation) ResetEndDate() {
  40980. m.end_date = nil
  40981. }
  40982. // SetCompany sets the "company" field.
  40983. func (m *WorkExperienceMutation) SetCompany(s string) {
  40984. m.company = &s
  40985. }
  40986. // Company returns the value of the "company" field in the mutation.
  40987. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  40988. v := m.company
  40989. if v == nil {
  40990. return
  40991. }
  40992. return *v, true
  40993. }
  40994. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  40995. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40997. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  40998. if !m.op.Is(OpUpdateOne) {
  40999. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  41000. }
  41001. if m.id == nil || m.oldValue == nil {
  41002. return v, errors.New("OldCompany requires an ID field in the mutation")
  41003. }
  41004. oldValue, err := m.oldValue(ctx)
  41005. if err != nil {
  41006. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  41007. }
  41008. return oldValue.Company, nil
  41009. }
  41010. // ResetCompany resets all changes to the "company" field.
  41011. func (m *WorkExperienceMutation) ResetCompany() {
  41012. m.company = nil
  41013. }
  41014. // SetExperience sets the "experience" field.
  41015. func (m *WorkExperienceMutation) SetExperience(s string) {
  41016. m.experience = &s
  41017. }
  41018. // Experience returns the value of the "experience" field in the mutation.
  41019. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  41020. v := m.experience
  41021. if v == nil {
  41022. return
  41023. }
  41024. return *v, true
  41025. }
  41026. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  41027. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41029. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  41030. if !m.op.Is(OpUpdateOne) {
  41031. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  41032. }
  41033. if m.id == nil || m.oldValue == nil {
  41034. return v, errors.New("OldExperience requires an ID field in the mutation")
  41035. }
  41036. oldValue, err := m.oldValue(ctx)
  41037. if err != nil {
  41038. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  41039. }
  41040. return oldValue.Experience, nil
  41041. }
  41042. // ResetExperience resets all changes to the "experience" field.
  41043. func (m *WorkExperienceMutation) ResetExperience() {
  41044. m.experience = nil
  41045. }
  41046. // SetOrganizationID sets the "organization_id" field.
  41047. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  41048. m.organization_id = &u
  41049. m.addorganization_id = nil
  41050. }
  41051. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41052. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  41053. v := m.organization_id
  41054. if v == nil {
  41055. return
  41056. }
  41057. return *v, true
  41058. }
  41059. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  41060. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41062. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41063. if !m.op.Is(OpUpdateOne) {
  41064. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41065. }
  41066. if m.id == nil || m.oldValue == nil {
  41067. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41068. }
  41069. oldValue, err := m.oldValue(ctx)
  41070. if err != nil {
  41071. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41072. }
  41073. return oldValue.OrganizationID, nil
  41074. }
  41075. // AddOrganizationID adds u to the "organization_id" field.
  41076. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  41077. if m.addorganization_id != nil {
  41078. *m.addorganization_id += u
  41079. } else {
  41080. m.addorganization_id = &u
  41081. }
  41082. }
  41083. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41084. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  41085. v := m.addorganization_id
  41086. if v == nil {
  41087. return
  41088. }
  41089. return *v, true
  41090. }
  41091. // ResetOrganizationID resets all changes to the "organization_id" field.
  41092. func (m *WorkExperienceMutation) ResetOrganizationID() {
  41093. m.organization_id = nil
  41094. m.addorganization_id = nil
  41095. }
  41096. // ClearEmployee clears the "employee" edge to the Employee entity.
  41097. func (m *WorkExperienceMutation) ClearEmployee() {
  41098. m.clearedemployee = true
  41099. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  41100. }
  41101. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  41102. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  41103. return m.clearedemployee
  41104. }
  41105. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  41106. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41107. // EmployeeID instead. It exists only for internal usage by the builders.
  41108. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  41109. if id := m.employee; id != nil {
  41110. ids = append(ids, *id)
  41111. }
  41112. return
  41113. }
  41114. // ResetEmployee resets all changes to the "employee" edge.
  41115. func (m *WorkExperienceMutation) ResetEmployee() {
  41116. m.employee = nil
  41117. m.clearedemployee = false
  41118. }
  41119. // Where appends a list predicates to the WorkExperienceMutation builder.
  41120. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  41121. m.predicates = append(m.predicates, ps...)
  41122. }
  41123. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  41124. // users can use type-assertion to append predicates that do not depend on any generated package.
  41125. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  41126. p := make([]predicate.WorkExperience, len(ps))
  41127. for i := range ps {
  41128. p[i] = ps[i]
  41129. }
  41130. m.Where(p...)
  41131. }
  41132. // Op returns the operation name.
  41133. func (m *WorkExperienceMutation) Op() Op {
  41134. return m.op
  41135. }
  41136. // SetOp allows setting the mutation operation.
  41137. func (m *WorkExperienceMutation) SetOp(op Op) {
  41138. m.op = op
  41139. }
  41140. // Type returns the node type of this mutation (WorkExperience).
  41141. func (m *WorkExperienceMutation) Type() string {
  41142. return m.typ
  41143. }
  41144. // Fields returns all fields that were changed during this mutation. Note that in
  41145. // order to get all numeric fields that were incremented/decremented, call
  41146. // AddedFields().
  41147. func (m *WorkExperienceMutation) Fields() []string {
  41148. fields := make([]string, 0, 9)
  41149. if m.created_at != nil {
  41150. fields = append(fields, workexperience.FieldCreatedAt)
  41151. }
  41152. if m.updated_at != nil {
  41153. fields = append(fields, workexperience.FieldUpdatedAt)
  41154. }
  41155. if m.deleted_at != nil {
  41156. fields = append(fields, workexperience.FieldDeletedAt)
  41157. }
  41158. if m.employee != nil {
  41159. fields = append(fields, workexperience.FieldEmployeeID)
  41160. }
  41161. if m.start_date != nil {
  41162. fields = append(fields, workexperience.FieldStartDate)
  41163. }
  41164. if m.end_date != nil {
  41165. fields = append(fields, workexperience.FieldEndDate)
  41166. }
  41167. if m.company != nil {
  41168. fields = append(fields, workexperience.FieldCompany)
  41169. }
  41170. if m.experience != nil {
  41171. fields = append(fields, workexperience.FieldExperience)
  41172. }
  41173. if m.organization_id != nil {
  41174. fields = append(fields, workexperience.FieldOrganizationID)
  41175. }
  41176. return fields
  41177. }
  41178. // Field returns the value of a field with the given name. The second boolean
  41179. // return value indicates that this field was not set, or was not defined in the
  41180. // schema.
  41181. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  41182. switch name {
  41183. case workexperience.FieldCreatedAt:
  41184. return m.CreatedAt()
  41185. case workexperience.FieldUpdatedAt:
  41186. return m.UpdatedAt()
  41187. case workexperience.FieldDeletedAt:
  41188. return m.DeletedAt()
  41189. case workexperience.FieldEmployeeID:
  41190. return m.EmployeeID()
  41191. case workexperience.FieldStartDate:
  41192. return m.StartDate()
  41193. case workexperience.FieldEndDate:
  41194. return m.EndDate()
  41195. case workexperience.FieldCompany:
  41196. return m.Company()
  41197. case workexperience.FieldExperience:
  41198. return m.Experience()
  41199. case workexperience.FieldOrganizationID:
  41200. return m.OrganizationID()
  41201. }
  41202. return nil, false
  41203. }
  41204. // OldField returns the old value of the field from the database. An error is
  41205. // returned if the mutation operation is not UpdateOne, or the query to the
  41206. // database failed.
  41207. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41208. switch name {
  41209. case workexperience.FieldCreatedAt:
  41210. return m.OldCreatedAt(ctx)
  41211. case workexperience.FieldUpdatedAt:
  41212. return m.OldUpdatedAt(ctx)
  41213. case workexperience.FieldDeletedAt:
  41214. return m.OldDeletedAt(ctx)
  41215. case workexperience.FieldEmployeeID:
  41216. return m.OldEmployeeID(ctx)
  41217. case workexperience.FieldStartDate:
  41218. return m.OldStartDate(ctx)
  41219. case workexperience.FieldEndDate:
  41220. return m.OldEndDate(ctx)
  41221. case workexperience.FieldCompany:
  41222. return m.OldCompany(ctx)
  41223. case workexperience.FieldExperience:
  41224. return m.OldExperience(ctx)
  41225. case workexperience.FieldOrganizationID:
  41226. return m.OldOrganizationID(ctx)
  41227. }
  41228. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  41229. }
  41230. // SetField sets the value of a field with the given name. It returns an error if
  41231. // the field is not defined in the schema, or if the type mismatched the field
  41232. // type.
  41233. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  41234. switch name {
  41235. case workexperience.FieldCreatedAt:
  41236. v, ok := value.(time.Time)
  41237. if !ok {
  41238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41239. }
  41240. m.SetCreatedAt(v)
  41241. return nil
  41242. case workexperience.FieldUpdatedAt:
  41243. v, ok := value.(time.Time)
  41244. if !ok {
  41245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41246. }
  41247. m.SetUpdatedAt(v)
  41248. return nil
  41249. case workexperience.FieldDeletedAt:
  41250. v, ok := value.(time.Time)
  41251. if !ok {
  41252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41253. }
  41254. m.SetDeletedAt(v)
  41255. return nil
  41256. case workexperience.FieldEmployeeID:
  41257. v, ok := value.(uint64)
  41258. if !ok {
  41259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41260. }
  41261. m.SetEmployeeID(v)
  41262. return nil
  41263. case workexperience.FieldStartDate:
  41264. v, ok := value.(time.Time)
  41265. if !ok {
  41266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41267. }
  41268. m.SetStartDate(v)
  41269. return nil
  41270. case workexperience.FieldEndDate:
  41271. v, ok := value.(time.Time)
  41272. if !ok {
  41273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41274. }
  41275. m.SetEndDate(v)
  41276. return nil
  41277. case workexperience.FieldCompany:
  41278. v, ok := value.(string)
  41279. if !ok {
  41280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41281. }
  41282. m.SetCompany(v)
  41283. return nil
  41284. case workexperience.FieldExperience:
  41285. v, ok := value.(string)
  41286. if !ok {
  41287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41288. }
  41289. m.SetExperience(v)
  41290. return nil
  41291. case workexperience.FieldOrganizationID:
  41292. v, ok := value.(uint64)
  41293. if !ok {
  41294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41295. }
  41296. m.SetOrganizationID(v)
  41297. return nil
  41298. }
  41299. return fmt.Errorf("unknown WorkExperience field %s", name)
  41300. }
  41301. // AddedFields returns all numeric fields that were incremented/decremented during
  41302. // this mutation.
  41303. func (m *WorkExperienceMutation) AddedFields() []string {
  41304. var fields []string
  41305. if m.addorganization_id != nil {
  41306. fields = append(fields, workexperience.FieldOrganizationID)
  41307. }
  41308. return fields
  41309. }
  41310. // AddedField returns the numeric value that was incremented/decremented on a field
  41311. // with the given name. The second boolean return value indicates that this field
  41312. // was not set, or was not defined in the schema.
  41313. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  41314. switch name {
  41315. case workexperience.FieldOrganizationID:
  41316. return m.AddedOrganizationID()
  41317. }
  41318. return nil, false
  41319. }
  41320. // AddField adds the value to the field with the given name. It returns an error if
  41321. // the field is not defined in the schema, or if the type mismatched the field
  41322. // type.
  41323. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  41324. switch name {
  41325. case workexperience.FieldOrganizationID:
  41326. v, ok := value.(int64)
  41327. if !ok {
  41328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41329. }
  41330. m.AddOrganizationID(v)
  41331. return nil
  41332. }
  41333. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  41334. }
  41335. // ClearedFields returns all nullable fields that were cleared during this
  41336. // mutation.
  41337. func (m *WorkExperienceMutation) ClearedFields() []string {
  41338. var fields []string
  41339. if m.FieldCleared(workexperience.FieldDeletedAt) {
  41340. fields = append(fields, workexperience.FieldDeletedAt)
  41341. }
  41342. return fields
  41343. }
  41344. // FieldCleared returns a boolean indicating if a field with the given name was
  41345. // cleared in this mutation.
  41346. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  41347. _, ok := m.clearedFields[name]
  41348. return ok
  41349. }
  41350. // ClearField clears the value of the field with the given name. It returns an
  41351. // error if the field is not defined in the schema.
  41352. func (m *WorkExperienceMutation) ClearField(name string) error {
  41353. switch name {
  41354. case workexperience.FieldDeletedAt:
  41355. m.ClearDeletedAt()
  41356. return nil
  41357. }
  41358. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  41359. }
  41360. // ResetField resets all changes in the mutation for the field with the given name.
  41361. // It returns an error if the field is not defined in the schema.
  41362. func (m *WorkExperienceMutation) ResetField(name string) error {
  41363. switch name {
  41364. case workexperience.FieldCreatedAt:
  41365. m.ResetCreatedAt()
  41366. return nil
  41367. case workexperience.FieldUpdatedAt:
  41368. m.ResetUpdatedAt()
  41369. return nil
  41370. case workexperience.FieldDeletedAt:
  41371. m.ResetDeletedAt()
  41372. return nil
  41373. case workexperience.FieldEmployeeID:
  41374. m.ResetEmployeeID()
  41375. return nil
  41376. case workexperience.FieldStartDate:
  41377. m.ResetStartDate()
  41378. return nil
  41379. case workexperience.FieldEndDate:
  41380. m.ResetEndDate()
  41381. return nil
  41382. case workexperience.FieldCompany:
  41383. m.ResetCompany()
  41384. return nil
  41385. case workexperience.FieldExperience:
  41386. m.ResetExperience()
  41387. return nil
  41388. case workexperience.FieldOrganizationID:
  41389. m.ResetOrganizationID()
  41390. return nil
  41391. }
  41392. return fmt.Errorf("unknown WorkExperience field %s", name)
  41393. }
  41394. // AddedEdges returns all edge names that were set/added in this mutation.
  41395. func (m *WorkExperienceMutation) AddedEdges() []string {
  41396. edges := make([]string, 0, 1)
  41397. if m.employee != nil {
  41398. edges = append(edges, workexperience.EdgeEmployee)
  41399. }
  41400. return edges
  41401. }
  41402. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41403. // name in this mutation.
  41404. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  41405. switch name {
  41406. case workexperience.EdgeEmployee:
  41407. if id := m.employee; id != nil {
  41408. return []ent.Value{*id}
  41409. }
  41410. }
  41411. return nil
  41412. }
  41413. // RemovedEdges returns all edge names that were removed in this mutation.
  41414. func (m *WorkExperienceMutation) RemovedEdges() []string {
  41415. edges := make([]string, 0, 1)
  41416. return edges
  41417. }
  41418. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41419. // the given name in this mutation.
  41420. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  41421. return nil
  41422. }
  41423. // ClearedEdges returns all edge names that were cleared in this mutation.
  41424. func (m *WorkExperienceMutation) ClearedEdges() []string {
  41425. edges := make([]string, 0, 1)
  41426. if m.clearedemployee {
  41427. edges = append(edges, workexperience.EdgeEmployee)
  41428. }
  41429. return edges
  41430. }
  41431. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41432. // was cleared in this mutation.
  41433. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  41434. switch name {
  41435. case workexperience.EdgeEmployee:
  41436. return m.clearedemployee
  41437. }
  41438. return false
  41439. }
  41440. // ClearEdge clears the value of the edge with the given name. It returns an error
  41441. // if that edge is not defined in the schema.
  41442. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  41443. switch name {
  41444. case workexperience.EdgeEmployee:
  41445. m.ClearEmployee()
  41446. return nil
  41447. }
  41448. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  41449. }
  41450. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41451. // It returns an error if the edge is not defined in the schema.
  41452. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  41453. switch name {
  41454. case workexperience.EdgeEmployee:
  41455. m.ResetEmployee()
  41456. return nil
  41457. }
  41458. return fmt.Errorf("unknown WorkExperience edge %s", name)
  41459. }
  41460. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  41461. type WpChatroomMutation struct {
  41462. config
  41463. op Op
  41464. typ string
  41465. id *uint64
  41466. created_at *time.Time
  41467. updated_at *time.Time
  41468. status *uint8
  41469. addstatus *int8
  41470. wx_wxid *string
  41471. chatroom_id *string
  41472. nickname *string
  41473. owner *string
  41474. avatar *string
  41475. member_list *[]string
  41476. appendmember_list []string
  41477. clearedFields map[string]struct{}
  41478. done bool
  41479. oldValue func(context.Context) (*WpChatroom, error)
  41480. predicates []predicate.WpChatroom
  41481. }
  41482. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  41483. // wpchatroomOption allows management of the mutation configuration using functional options.
  41484. type wpchatroomOption func(*WpChatroomMutation)
  41485. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  41486. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  41487. m := &WpChatroomMutation{
  41488. config: c,
  41489. op: op,
  41490. typ: TypeWpChatroom,
  41491. clearedFields: make(map[string]struct{}),
  41492. }
  41493. for _, opt := range opts {
  41494. opt(m)
  41495. }
  41496. return m
  41497. }
  41498. // withWpChatroomID sets the ID field of the mutation.
  41499. func withWpChatroomID(id uint64) wpchatroomOption {
  41500. return func(m *WpChatroomMutation) {
  41501. var (
  41502. err error
  41503. once sync.Once
  41504. value *WpChatroom
  41505. )
  41506. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  41507. once.Do(func() {
  41508. if m.done {
  41509. err = errors.New("querying old values post mutation is not allowed")
  41510. } else {
  41511. value, err = m.Client().WpChatroom.Get(ctx, id)
  41512. }
  41513. })
  41514. return value, err
  41515. }
  41516. m.id = &id
  41517. }
  41518. }
  41519. // withWpChatroom sets the old WpChatroom of the mutation.
  41520. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  41521. return func(m *WpChatroomMutation) {
  41522. m.oldValue = func(context.Context) (*WpChatroom, error) {
  41523. return node, nil
  41524. }
  41525. m.id = &node.ID
  41526. }
  41527. }
  41528. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41529. // executed in a transaction (ent.Tx), a transactional client is returned.
  41530. func (m WpChatroomMutation) Client() *Client {
  41531. client := &Client{config: m.config}
  41532. client.init()
  41533. return client
  41534. }
  41535. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41536. // it returns an error otherwise.
  41537. func (m WpChatroomMutation) Tx() (*Tx, error) {
  41538. if _, ok := m.driver.(*txDriver); !ok {
  41539. return nil, errors.New("ent: mutation is not running in a transaction")
  41540. }
  41541. tx := &Tx{config: m.config}
  41542. tx.init()
  41543. return tx, nil
  41544. }
  41545. // SetID sets the value of the id field. Note that this
  41546. // operation is only accepted on creation of WpChatroom entities.
  41547. func (m *WpChatroomMutation) SetID(id uint64) {
  41548. m.id = &id
  41549. }
  41550. // ID returns the ID value in the mutation. Note that the ID is only available
  41551. // if it was provided to the builder or after it was returned from the database.
  41552. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  41553. if m.id == nil {
  41554. return
  41555. }
  41556. return *m.id, true
  41557. }
  41558. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41559. // That means, if the mutation is applied within a transaction with an isolation level such
  41560. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41561. // or updated by the mutation.
  41562. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  41563. switch {
  41564. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41565. id, exists := m.ID()
  41566. if exists {
  41567. return []uint64{id}, nil
  41568. }
  41569. fallthrough
  41570. case m.op.Is(OpUpdate | OpDelete):
  41571. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  41572. default:
  41573. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41574. }
  41575. }
  41576. // SetCreatedAt sets the "created_at" field.
  41577. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  41578. m.created_at = &t
  41579. }
  41580. // CreatedAt returns the value of the "created_at" field in the mutation.
  41581. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  41582. v := m.created_at
  41583. if v == nil {
  41584. return
  41585. }
  41586. return *v, true
  41587. }
  41588. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  41589. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41591. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41592. if !m.op.Is(OpUpdateOne) {
  41593. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41594. }
  41595. if m.id == nil || m.oldValue == nil {
  41596. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41597. }
  41598. oldValue, err := m.oldValue(ctx)
  41599. if err != nil {
  41600. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41601. }
  41602. return oldValue.CreatedAt, nil
  41603. }
  41604. // ResetCreatedAt resets all changes to the "created_at" field.
  41605. func (m *WpChatroomMutation) ResetCreatedAt() {
  41606. m.created_at = nil
  41607. }
  41608. // SetUpdatedAt sets the "updated_at" field.
  41609. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  41610. m.updated_at = &t
  41611. }
  41612. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41613. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  41614. v := m.updated_at
  41615. if v == nil {
  41616. return
  41617. }
  41618. return *v, true
  41619. }
  41620. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  41621. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41623. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41624. if !m.op.Is(OpUpdateOne) {
  41625. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41626. }
  41627. if m.id == nil || m.oldValue == nil {
  41628. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41629. }
  41630. oldValue, err := m.oldValue(ctx)
  41631. if err != nil {
  41632. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41633. }
  41634. return oldValue.UpdatedAt, nil
  41635. }
  41636. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41637. func (m *WpChatroomMutation) ResetUpdatedAt() {
  41638. m.updated_at = nil
  41639. }
  41640. // SetStatus sets the "status" field.
  41641. func (m *WpChatroomMutation) SetStatus(u uint8) {
  41642. m.status = &u
  41643. m.addstatus = nil
  41644. }
  41645. // Status returns the value of the "status" field in the mutation.
  41646. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  41647. v := m.status
  41648. if v == nil {
  41649. return
  41650. }
  41651. return *v, true
  41652. }
  41653. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  41654. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41656. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41657. if !m.op.Is(OpUpdateOne) {
  41658. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41659. }
  41660. if m.id == nil || m.oldValue == nil {
  41661. return v, errors.New("OldStatus requires an ID field in the mutation")
  41662. }
  41663. oldValue, err := m.oldValue(ctx)
  41664. if err != nil {
  41665. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41666. }
  41667. return oldValue.Status, nil
  41668. }
  41669. // AddStatus adds u to the "status" field.
  41670. func (m *WpChatroomMutation) AddStatus(u int8) {
  41671. if m.addstatus != nil {
  41672. *m.addstatus += u
  41673. } else {
  41674. m.addstatus = &u
  41675. }
  41676. }
  41677. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41678. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  41679. v := m.addstatus
  41680. if v == nil {
  41681. return
  41682. }
  41683. return *v, true
  41684. }
  41685. // ClearStatus clears the value of the "status" field.
  41686. func (m *WpChatroomMutation) ClearStatus() {
  41687. m.status = nil
  41688. m.addstatus = nil
  41689. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  41690. }
  41691. // StatusCleared returns if the "status" field was cleared in this mutation.
  41692. func (m *WpChatroomMutation) StatusCleared() bool {
  41693. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  41694. return ok
  41695. }
  41696. // ResetStatus resets all changes to the "status" field.
  41697. func (m *WpChatroomMutation) ResetStatus() {
  41698. m.status = nil
  41699. m.addstatus = nil
  41700. delete(m.clearedFields, wpchatroom.FieldStatus)
  41701. }
  41702. // SetWxWxid sets the "wx_wxid" field.
  41703. func (m *WpChatroomMutation) SetWxWxid(s string) {
  41704. m.wx_wxid = &s
  41705. }
  41706. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  41707. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  41708. v := m.wx_wxid
  41709. if v == nil {
  41710. return
  41711. }
  41712. return *v, true
  41713. }
  41714. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  41715. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41717. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  41718. if !m.op.Is(OpUpdateOne) {
  41719. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  41720. }
  41721. if m.id == nil || m.oldValue == nil {
  41722. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  41723. }
  41724. oldValue, err := m.oldValue(ctx)
  41725. if err != nil {
  41726. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  41727. }
  41728. return oldValue.WxWxid, nil
  41729. }
  41730. // ResetWxWxid resets all changes to the "wx_wxid" field.
  41731. func (m *WpChatroomMutation) ResetWxWxid() {
  41732. m.wx_wxid = nil
  41733. }
  41734. // SetChatroomID sets the "chatroom_id" field.
  41735. func (m *WpChatroomMutation) SetChatroomID(s string) {
  41736. m.chatroom_id = &s
  41737. }
  41738. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  41739. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  41740. v := m.chatroom_id
  41741. if v == nil {
  41742. return
  41743. }
  41744. return *v, true
  41745. }
  41746. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  41747. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41749. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  41750. if !m.op.Is(OpUpdateOne) {
  41751. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  41752. }
  41753. if m.id == nil || m.oldValue == nil {
  41754. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  41755. }
  41756. oldValue, err := m.oldValue(ctx)
  41757. if err != nil {
  41758. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  41759. }
  41760. return oldValue.ChatroomID, nil
  41761. }
  41762. // ResetChatroomID resets all changes to the "chatroom_id" field.
  41763. func (m *WpChatroomMutation) ResetChatroomID() {
  41764. m.chatroom_id = nil
  41765. }
  41766. // SetNickname sets the "nickname" field.
  41767. func (m *WpChatroomMutation) SetNickname(s string) {
  41768. m.nickname = &s
  41769. }
  41770. // Nickname returns the value of the "nickname" field in the mutation.
  41771. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  41772. v := m.nickname
  41773. if v == nil {
  41774. return
  41775. }
  41776. return *v, true
  41777. }
  41778. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  41779. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41781. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  41782. if !m.op.Is(OpUpdateOne) {
  41783. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41784. }
  41785. if m.id == nil || m.oldValue == nil {
  41786. return v, errors.New("OldNickname requires an ID field in the mutation")
  41787. }
  41788. oldValue, err := m.oldValue(ctx)
  41789. if err != nil {
  41790. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41791. }
  41792. return oldValue.Nickname, nil
  41793. }
  41794. // ResetNickname resets all changes to the "nickname" field.
  41795. func (m *WpChatroomMutation) ResetNickname() {
  41796. m.nickname = nil
  41797. }
  41798. // SetOwner sets the "owner" field.
  41799. func (m *WpChatroomMutation) SetOwner(s string) {
  41800. m.owner = &s
  41801. }
  41802. // Owner returns the value of the "owner" field in the mutation.
  41803. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  41804. v := m.owner
  41805. if v == nil {
  41806. return
  41807. }
  41808. return *v, true
  41809. }
  41810. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  41811. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41813. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  41814. if !m.op.Is(OpUpdateOne) {
  41815. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  41816. }
  41817. if m.id == nil || m.oldValue == nil {
  41818. return v, errors.New("OldOwner requires an ID field in the mutation")
  41819. }
  41820. oldValue, err := m.oldValue(ctx)
  41821. if err != nil {
  41822. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  41823. }
  41824. return oldValue.Owner, nil
  41825. }
  41826. // ResetOwner resets all changes to the "owner" field.
  41827. func (m *WpChatroomMutation) ResetOwner() {
  41828. m.owner = nil
  41829. }
  41830. // SetAvatar sets the "avatar" field.
  41831. func (m *WpChatroomMutation) SetAvatar(s string) {
  41832. m.avatar = &s
  41833. }
  41834. // Avatar returns the value of the "avatar" field in the mutation.
  41835. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  41836. v := m.avatar
  41837. if v == nil {
  41838. return
  41839. }
  41840. return *v, true
  41841. }
  41842. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  41843. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41845. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41846. if !m.op.Is(OpUpdateOne) {
  41847. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41848. }
  41849. if m.id == nil || m.oldValue == nil {
  41850. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41851. }
  41852. oldValue, err := m.oldValue(ctx)
  41853. if err != nil {
  41854. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41855. }
  41856. return oldValue.Avatar, nil
  41857. }
  41858. // ResetAvatar resets all changes to the "avatar" field.
  41859. func (m *WpChatroomMutation) ResetAvatar() {
  41860. m.avatar = nil
  41861. }
  41862. // SetMemberList sets the "member_list" field.
  41863. func (m *WpChatroomMutation) SetMemberList(s []string) {
  41864. m.member_list = &s
  41865. m.appendmember_list = nil
  41866. }
  41867. // MemberList returns the value of the "member_list" field in the mutation.
  41868. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  41869. v := m.member_list
  41870. if v == nil {
  41871. return
  41872. }
  41873. return *v, true
  41874. }
  41875. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  41876. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41878. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  41879. if !m.op.Is(OpUpdateOne) {
  41880. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  41881. }
  41882. if m.id == nil || m.oldValue == nil {
  41883. return v, errors.New("OldMemberList requires an ID field in the mutation")
  41884. }
  41885. oldValue, err := m.oldValue(ctx)
  41886. if err != nil {
  41887. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  41888. }
  41889. return oldValue.MemberList, nil
  41890. }
  41891. // AppendMemberList adds s to the "member_list" field.
  41892. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  41893. m.appendmember_list = append(m.appendmember_list, s...)
  41894. }
  41895. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  41896. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  41897. if len(m.appendmember_list) == 0 {
  41898. return nil, false
  41899. }
  41900. return m.appendmember_list, true
  41901. }
  41902. // ResetMemberList resets all changes to the "member_list" field.
  41903. func (m *WpChatroomMutation) ResetMemberList() {
  41904. m.member_list = nil
  41905. m.appendmember_list = nil
  41906. }
  41907. // Where appends a list predicates to the WpChatroomMutation builder.
  41908. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  41909. m.predicates = append(m.predicates, ps...)
  41910. }
  41911. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  41912. // users can use type-assertion to append predicates that do not depend on any generated package.
  41913. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  41914. p := make([]predicate.WpChatroom, len(ps))
  41915. for i := range ps {
  41916. p[i] = ps[i]
  41917. }
  41918. m.Where(p...)
  41919. }
  41920. // Op returns the operation name.
  41921. func (m *WpChatroomMutation) Op() Op {
  41922. return m.op
  41923. }
  41924. // SetOp allows setting the mutation operation.
  41925. func (m *WpChatroomMutation) SetOp(op Op) {
  41926. m.op = op
  41927. }
  41928. // Type returns the node type of this mutation (WpChatroom).
  41929. func (m *WpChatroomMutation) Type() string {
  41930. return m.typ
  41931. }
  41932. // Fields returns all fields that were changed during this mutation. Note that in
  41933. // order to get all numeric fields that were incremented/decremented, call
  41934. // AddedFields().
  41935. func (m *WpChatroomMutation) Fields() []string {
  41936. fields := make([]string, 0, 9)
  41937. if m.created_at != nil {
  41938. fields = append(fields, wpchatroom.FieldCreatedAt)
  41939. }
  41940. if m.updated_at != nil {
  41941. fields = append(fields, wpchatroom.FieldUpdatedAt)
  41942. }
  41943. if m.status != nil {
  41944. fields = append(fields, wpchatroom.FieldStatus)
  41945. }
  41946. if m.wx_wxid != nil {
  41947. fields = append(fields, wpchatroom.FieldWxWxid)
  41948. }
  41949. if m.chatroom_id != nil {
  41950. fields = append(fields, wpchatroom.FieldChatroomID)
  41951. }
  41952. if m.nickname != nil {
  41953. fields = append(fields, wpchatroom.FieldNickname)
  41954. }
  41955. if m.owner != nil {
  41956. fields = append(fields, wpchatroom.FieldOwner)
  41957. }
  41958. if m.avatar != nil {
  41959. fields = append(fields, wpchatroom.FieldAvatar)
  41960. }
  41961. if m.member_list != nil {
  41962. fields = append(fields, wpchatroom.FieldMemberList)
  41963. }
  41964. return fields
  41965. }
  41966. // Field returns the value of a field with the given name. The second boolean
  41967. // return value indicates that this field was not set, or was not defined in the
  41968. // schema.
  41969. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  41970. switch name {
  41971. case wpchatroom.FieldCreatedAt:
  41972. return m.CreatedAt()
  41973. case wpchatroom.FieldUpdatedAt:
  41974. return m.UpdatedAt()
  41975. case wpchatroom.FieldStatus:
  41976. return m.Status()
  41977. case wpchatroom.FieldWxWxid:
  41978. return m.WxWxid()
  41979. case wpchatroom.FieldChatroomID:
  41980. return m.ChatroomID()
  41981. case wpchatroom.FieldNickname:
  41982. return m.Nickname()
  41983. case wpchatroom.FieldOwner:
  41984. return m.Owner()
  41985. case wpchatroom.FieldAvatar:
  41986. return m.Avatar()
  41987. case wpchatroom.FieldMemberList:
  41988. return m.MemberList()
  41989. }
  41990. return nil, false
  41991. }
  41992. // OldField returns the old value of the field from the database. An error is
  41993. // returned if the mutation operation is not UpdateOne, or the query to the
  41994. // database failed.
  41995. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41996. switch name {
  41997. case wpchatroom.FieldCreatedAt:
  41998. return m.OldCreatedAt(ctx)
  41999. case wpchatroom.FieldUpdatedAt:
  42000. return m.OldUpdatedAt(ctx)
  42001. case wpchatroom.FieldStatus:
  42002. return m.OldStatus(ctx)
  42003. case wpchatroom.FieldWxWxid:
  42004. return m.OldWxWxid(ctx)
  42005. case wpchatroom.FieldChatroomID:
  42006. return m.OldChatroomID(ctx)
  42007. case wpchatroom.FieldNickname:
  42008. return m.OldNickname(ctx)
  42009. case wpchatroom.FieldOwner:
  42010. return m.OldOwner(ctx)
  42011. case wpchatroom.FieldAvatar:
  42012. return m.OldAvatar(ctx)
  42013. case wpchatroom.FieldMemberList:
  42014. return m.OldMemberList(ctx)
  42015. }
  42016. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  42017. }
  42018. // SetField sets the value of a field with the given name. It returns an error if
  42019. // the field is not defined in the schema, or if the type mismatched the field
  42020. // type.
  42021. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  42022. switch name {
  42023. case wpchatroom.FieldCreatedAt:
  42024. v, ok := value.(time.Time)
  42025. if !ok {
  42026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42027. }
  42028. m.SetCreatedAt(v)
  42029. return nil
  42030. case wpchatroom.FieldUpdatedAt:
  42031. v, ok := value.(time.Time)
  42032. if !ok {
  42033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42034. }
  42035. m.SetUpdatedAt(v)
  42036. return nil
  42037. case wpchatroom.FieldStatus:
  42038. v, ok := value.(uint8)
  42039. if !ok {
  42040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42041. }
  42042. m.SetStatus(v)
  42043. return nil
  42044. case wpchatroom.FieldWxWxid:
  42045. v, ok := value.(string)
  42046. if !ok {
  42047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42048. }
  42049. m.SetWxWxid(v)
  42050. return nil
  42051. case wpchatroom.FieldChatroomID:
  42052. v, ok := value.(string)
  42053. if !ok {
  42054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42055. }
  42056. m.SetChatroomID(v)
  42057. return nil
  42058. case wpchatroom.FieldNickname:
  42059. v, ok := value.(string)
  42060. if !ok {
  42061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42062. }
  42063. m.SetNickname(v)
  42064. return nil
  42065. case wpchatroom.FieldOwner:
  42066. v, ok := value.(string)
  42067. if !ok {
  42068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42069. }
  42070. m.SetOwner(v)
  42071. return nil
  42072. case wpchatroom.FieldAvatar:
  42073. v, ok := value.(string)
  42074. if !ok {
  42075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42076. }
  42077. m.SetAvatar(v)
  42078. return nil
  42079. case wpchatroom.FieldMemberList:
  42080. v, ok := value.([]string)
  42081. if !ok {
  42082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42083. }
  42084. m.SetMemberList(v)
  42085. return nil
  42086. }
  42087. return fmt.Errorf("unknown WpChatroom field %s", name)
  42088. }
  42089. // AddedFields returns all numeric fields that were incremented/decremented during
  42090. // this mutation.
  42091. func (m *WpChatroomMutation) AddedFields() []string {
  42092. var fields []string
  42093. if m.addstatus != nil {
  42094. fields = append(fields, wpchatroom.FieldStatus)
  42095. }
  42096. return fields
  42097. }
  42098. // AddedField returns the numeric value that was incremented/decremented on a field
  42099. // with the given name. The second boolean return value indicates that this field
  42100. // was not set, or was not defined in the schema.
  42101. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  42102. switch name {
  42103. case wpchatroom.FieldStatus:
  42104. return m.AddedStatus()
  42105. }
  42106. return nil, false
  42107. }
  42108. // AddField adds the value to the field with the given name. It returns an error if
  42109. // the field is not defined in the schema, or if the type mismatched the field
  42110. // type.
  42111. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  42112. switch name {
  42113. case wpchatroom.FieldStatus:
  42114. v, ok := value.(int8)
  42115. if !ok {
  42116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42117. }
  42118. m.AddStatus(v)
  42119. return nil
  42120. }
  42121. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  42122. }
  42123. // ClearedFields returns all nullable fields that were cleared during this
  42124. // mutation.
  42125. func (m *WpChatroomMutation) ClearedFields() []string {
  42126. var fields []string
  42127. if m.FieldCleared(wpchatroom.FieldStatus) {
  42128. fields = append(fields, wpchatroom.FieldStatus)
  42129. }
  42130. return fields
  42131. }
  42132. // FieldCleared returns a boolean indicating if a field with the given name was
  42133. // cleared in this mutation.
  42134. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  42135. _, ok := m.clearedFields[name]
  42136. return ok
  42137. }
  42138. // ClearField clears the value of the field with the given name. It returns an
  42139. // error if the field is not defined in the schema.
  42140. func (m *WpChatroomMutation) ClearField(name string) error {
  42141. switch name {
  42142. case wpchatroom.FieldStatus:
  42143. m.ClearStatus()
  42144. return nil
  42145. }
  42146. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  42147. }
  42148. // ResetField resets all changes in the mutation for the field with the given name.
  42149. // It returns an error if the field is not defined in the schema.
  42150. func (m *WpChatroomMutation) ResetField(name string) error {
  42151. switch name {
  42152. case wpchatroom.FieldCreatedAt:
  42153. m.ResetCreatedAt()
  42154. return nil
  42155. case wpchatroom.FieldUpdatedAt:
  42156. m.ResetUpdatedAt()
  42157. return nil
  42158. case wpchatroom.FieldStatus:
  42159. m.ResetStatus()
  42160. return nil
  42161. case wpchatroom.FieldWxWxid:
  42162. m.ResetWxWxid()
  42163. return nil
  42164. case wpchatroom.FieldChatroomID:
  42165. m.ResetChatroomID()
  42166. return nil
  42167. case wpchatroom.FieldNickname:
  42168. m.ResetNickname()
  42169. return nil
  42170. case wpchatroom.FieldOwner:
  42171. m.ResetOwner()
  42172. return nil
  42173. case wpchatroom.FieldAvatar:
  42174. m.ResetAvatar()
  42175. return nil
  42176. case wpchatroom.FieldMemberList:
  42177. m.ResetMemberList()
  42178. return nil
  42179. }
  42180. return fmt.Errorf("unknown WpChatroom field %s", name)
  42181. }
  42182. // AddedEdges returns all edge names that were set/added in this mutation.
  42183. func (m *WpChatroomMutation) AddedEdges() []string {
  42184. edges := make([]string, 0, 0)
  42185. return edges
  42186. }
  42187. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42188. // name in this mutation.
  42189. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  42190. return nil
  42191. }
  42192. // RemovedEdges returns all edge names that were removed in this mutation.
  42193. func (m *WpChatroomMutation) RemovedEdges() []string {
  42194. edges := make([]string, 0, 0)
  42195. return edges
  42196. }
  42197. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42198. // the given name in this mutation.
  42199. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  42200. return nil
  42201. }
  42202. // ClearedEdges returns all edge names that were cleared in this mutation.
  42203. func (m *WpChatroomMutation) ClearedEdges() []string {
  42204. edges := make([]string, 0, 0)
  42205. return edges
  42206. }
  42207. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42208. // was cleared in this mutation.
  42209. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  42210. return false
  42211. }
  42212. // ClearEdge clears the value of the edge with the given name. It returns an error
  42213. // if that edge is not defined in the schema.
  42214. func (m *WpChatroomMutation) ClearEdge(name string) error {
  42215. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  42216. }
  42217. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42218. // It returns an error if the edge is not defined in the schema.
  42219. func (m *WpChatroomMutation) ResetEdge(name string) error {
  42220. return fmt.Errorf("unknown WpChatroom edge %s", name)
  42221. }
  42222. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  42223. type WpChatroomMemberMutation struct {
  42224. config
  42225. op Op
  42226. typ string
  42227. id *uint64
  42228. created_at *time.Time
  42229. updated_at *time.Time
  42230. status *uint8
  42231. addstatus *int8
  42232. wx_wxid *string
  42233. wxid *string
  42234. nickname *string
  42235. avatar *string
  42236. clearedFields map[string]struct{}
  42237. done bool
  42238. oldValue func(context.Context) (*WpChatroomMember, error)
  42239. predicates []predicate.WpChatroomMember
  42240. }
  42241. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  42242. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  42243. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  42244. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  42245. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  42246. m := &WpChatroomMemberMutation{
  42247. config: c,
  42248. op: op,
  42249. typ: TypeWpChatroomMember,
  42250. clearedFields: make(map[string]struct{}),
  42251. }
  42252. for _, opt := range opts {
  42253. opt(m)
  42254. }
  42255. return m
  42256. }
  42257. // withWpChatroomMemberID sets the ID field of the mutation.
  42258. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  42259. return func(m *WpChatroomMemberMutation) {
  42260. var (
  42261. err error
  42262. once sync.Once
  42263. value *WpChatroomMember
  42264. )
  42265. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  42266. once.Do(func() {
  42267. if m.done {
  42268. err = errors.New("querying old values post mutation is not allowed")
  42269. } else {
  42270. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  42271. }
  42272. })
  42273. return value, err
  42274. }
  42275. m.id = &id
  42276. }
  42277. }
  42278. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  42279. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  42280. return func(m *WpChatroomMemberMutation) {
  42281. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  42282. return node, nil
  42283. }
  42284. m.id = &node.ID
  42285. }
  42286. }
  42287. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42288. // executed in a transaction (ent.Tx), a transactional client is returned.
  42289. func (m WpChatroomMemberMutation) Client() *Client {
  42290. client := &Client{config: m.config}
  42291. client.init()
  42292. return client
  42293. }
  42294. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42295. // it returns an error otherwise.
  42296. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  42297. if _, ok := m.driver.(*txDriver); !ok {
  42298. return nil, errors.New("ent: mutation is not running in a transaction")
  42299. }
  42300. tx := &Tx{config: m.config}
  42301. tx.init()
  42302. return tx, nil
  42303. }
  42304. // SetID sets the value of the id field. Note that this
  42305. // operation is only accepted on creation of WpChatroomMember entities.
  42306. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  42307. m.id = &id
  42308. }
  42309. // ID returns the ID value in the mutation. Note that the ID is only available
  42310. // if it was provided to the builder or after it was returned from the database.
  42311. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  42312. if m.id == nil {
  42313. return
  42314. }
  42315. return *m.id, true
  42316. }
  42317. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42318. // That means, if the mutation is applied within a transaction with an isolation level such
  42319. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42320. // or updated by the mutation.
  42321. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  42322. switch {
  42323. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42324. id, exists := m.ID()
  42325. if exists {
  42326. return []uint64{id}, nil
  42327. }
  42328. fallthrough
  42329. case m.op.Is(OpUpdate | OpDelete):
  42330. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  42331. default:
  42332. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42333. }
  42334. }
  42335. // SetCreatedAt sets the "created_at" field.
  42336. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  42337. m.created_at = &t
  42338. }
  42339. // CreatedAt returns the value of the "created_at" field in the mutation.
  42340. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  42341. v := m.created_at
  42342. if v == nil {
  42343. return
  42344. }
  42345. return *v, true
  42346. }
  42347. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  42348. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42350. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42351. if !m.op.Is(OpUpdateOne) {
  42352. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42353. }
  42354. if m.id == nil || m.oldValue == nil {
  42355. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42356. }
  42357. oldValue, err := m.oldValue(ctx)
  42358. if err != nil {
  42359. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42360. }
  42361. return oldValue.CreatedAt, nil
  42362. }
  42363. // ResetCreatedAt resets all changes to the "created_at" field.
  42364. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  42365. m.created_at = nil
  42366. }
  42367. // SetUpdatedAt sets the "updated_at" field.
  42368. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  42369. m.updated_at = &t
  42370. }
  42371. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42372. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  42373. v := m.updated_at
  42374. if v == nil {
  42375. return
  42376. }
  42377. return *v, true
  42378. }
  42379. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  42380. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42382. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42383. if !m.op.Is(OpUpdateOne) {
  42384. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42385. }
  42386. if m.id == nil || m.oldValue == nil {
  42387. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42388. }
  42389. oldValue, err := m.oldValue(ctx)
  42390. if err != nil {
  42391. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42392. }
  42393. return oldValue.UpdatedAt, nil
  42394. }
  42395. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42396. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  42397. m.updated_at = nil
  42398. }
  42399. // SetStatus sets the "status" field.
  42400. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  42401. m.status = &u
  42402. m.addstatus = nil
  42403. }
  42404. // Status returns the value of the "status" field in the mutation.
  42405. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  42406. v := m.status
  42407. if v == nil {
  42408. return
  42409. }
  42410. return *v, true
  42411. }
  42412. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  42413. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42415. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42416. if !m.op.Is(OpUpdateOne) {
  42417. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42418. }
  42419. if m.id == nil || m.oldValue == nil {
  42420. return v, errors.New("OldStatus requires an ID field in the mutation")
  42421. }
  42422. oldValue, err := m.oldValue(ctx)
  42423. if err != nil {
  42424. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42425. }
  42426. return oldValue.Status, nil
  42427. }
  42428. // AddStatus adds u to the "status" field.
  42429. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  42430. if m.addstatus != nil {
  42431. *m.addstatus += u
  42432. } else {
  42433. m.addstatus = &u
  42434. }
  42435. }
  42436. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42437. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  42438. v := m.addstatus
  42439. if v == nil {
  42440. return
  42441. }
  42442. return *v, true
  42443. }
  42444. // ClearStatus clears the value of the "status" field.
  42445. func (m *WpChatroomMemberMutation) ClearStatus() {
  42446. m.status = nil
  42447. m.addstatus = nil
  42448. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  42449. }
  42450. // StatusCleared returns if the "status" field was cleared in this mutation.
  42451. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  42452. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  42453. return ok
  42454. }
  42455. // ResetStatus resets all changes to the "status" field.
  42456. func (m *WpChatroomMemberMutation) ResetStatus() {
  42457. m.status = nil
  42458. m.addstatus = nil
  42459. delete(m.clearedFields, wpchatroommember.FieldStatus)
  42460. }
  42461. // SetWxWxid sets the "wx_wxid" field.
  42462. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  42463. m.wx_wxid = &s
  42464. }
  42465. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  42466. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  42467. v := m.wx_wxid
  42468. if v == nil {
  42469. return
  42470. }
  42471. return *v, true
  42472. }
  42473. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  42474. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42476. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  42477. if !m.op.Is(OpUpdateOne) {
  42478. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  42479. }
  42480. if m.id == nil || m.oldValue == nil {
  42481. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  42482. }
  42483. oldValue, err := m.oldValue(ctx)
  42484. if err != nil {
  42485. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  42486. }
  42487. return oldValue.WxWxid, nil
  42488. }
  42489. // ResetWxWxid resets all changes to the "wx_wxid" field.
  42490. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  42491. m.wx_wxid = nil
  42492. }
  42493. // SetWxid sets the "wxid" field.
  42494. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  42495. m.wxid = &s
  42496. }
  42497. // Wxid returns the value of the "wxid" field in the mutation.
  42498. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  42499. v := m.wxid
  42500. if v == nil {
  42501. return
  42502. }
  42503. return *v, true
  42504. }
  42505. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  42506. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42508. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  42509. if !m.op.Is(OpUpdateOne) {
  42510. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  42511. }
  42512. if m.id == nil || m.oldValue == nil {
  42513. return v, errors.New("OldWxid requires an ID field in the mutation")
  42514. }
  42515. oldValue, err := m.oldValue(ctx)
  42516. if err != nil {
  42517. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  42518. }
  42519. return oldValue.Wxid, nil
  42520. }
  42521. // ResetWxid resets all changes to the "wxid" field.
  42522. func (m *WpChatroomMemberMutation) ResetWxid() {
  42523. m.wxid = nil
  42524. }
  42525. // SetNickname sets the "nickname" field.
  42526. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  42527. m.nickname = &s
  42528. }
  42529. // Nickname returns the value of the "nickname" field in the mutation.
  42530. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  42531. v := m.nickname
  42532. if v == nil {
  42533. return
  42534. }
  42535. return *v, true
  42536. }
  42537. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  42538. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42540. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  42541. if !m.op.Is(OpUpdateOne) {
  42542. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42543. }
  42544. if m.id == nil || m.oldValue == nil {
  42545. return v, errors.New("OldNickname requires an ID field in the mutation")
  42546. }
  42547. oldValue, err := m.oldValue(ctx)
  42548. if err != nil {
  42549. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42550. }
  42551. return oldValue.Nickname, nil
  42552. }
  42553. // ResetNickname resets all changes to the "nickname" field.
  42554. func (m *WpChatroomMemberMutation) ResetNickname() {
  42555. m.nickname = nil
  42556. }
  42557. // SetAvatar sets the "avatar" field.
  42558. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  42559. m.avatar = &s
  42560. }
  42561. // Avatar returns the value of the "avatar" field in the mutation.
  42562. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  42563. v := m.avatar
  42564. if v == nil {
  42565. return
  42566. }
  42567. return *v, true
  42568. }
  42569. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  42570. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42572. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42573. if !m.op.Is(OpUpdateOne) {
  42574. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42575. }
  42576. if m.id == nil || m.oldValue == nil {
  42577. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42578. }
  42579. oldValue, err := m.oldValue(ctx)
  42580. if err != nil {
  42581. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42582. }
  42583. return oldValue.Avatar, nil
  42584. }
  42585. // ResetAvatar resets all changes to the "avatar" field.
  42586. func (m *WpChatroomMemberMutation) ResetAvatar() {
  42587. m.avatar = nil
  42588. }
  42589. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  42590. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  42591. m.predicates = append(m.predicates, ps...)
  42592. }
  42593. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  42594. // users can use type-assertion to append predicates that do not depend on any generated package.
  42595. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  42596. p := make([]predicate.WpChatroomMember, len(ps))
  42597. for i := range ps {
  42598. p[i] = ps[i]
  42599. }
  42600. m.Where(p...)
  42601. }
  42602. // Op returns the operation name.
  42603. func (m *WpChatroomMemberMutation) Op() Op {
  42604. return m.op
  42605. }
  42606. // SetOp allows setting the mutation operation.
  42607. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  42608. m.op = op
  42609. }
  42610. // Type returns the node type of this mutation (WpChatroomMember).
  42611. func (m *WpChatroomMemberMutation) Type() string {
  42612. return m.typ
  42613. }
  42614. // Fields returns all fields that were changed during this mutation. Note that in
  42615. // order to get all numeric fields that were incremented/decremented, call
  42616. // AddedFields().
  42617. func (m *WpChatroomMemberMutation) Fields() []string {
  42618. fields := make([]string, 0, 7)
  42619. if m.created_at != nil {
  42620. fields = append(fields, wpchatroommember.FieldCreatedAt)
  42621. }
  42622. if m.updated_at != nil {
  42623. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  42624. }
  42625. if m.status != nil {
  42626. fields = append(fields, wpchatroommember.FieldStatus)
  42627. }
  42628. if m.wx_wxid != nil {
  42629. fields = append(fields, wpchatroommember.FieldWxWxid)
  42630. }
  42631. if m.wxid != nil {
  42632. fields = append(fields, wpchatroommember.FieldWxid)
  42633. }
  42634. if m.nickname != nil {
  42635. fields = append(fields, wpchatroommember.FieldNickname)
  42636. }
  42637. if m.avatar != nil {
  42638. fields = append(fields, wpchatroommember.FieldAvatar)
  42639. }
  42640. return fields
  42641. }
  42642. // Field returns the value of a field with the given name. The second boolean
  42643. // return value indicates that this field was not set, or was not defined in the
  42644. // schema.
  42645. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  42646. switch name {
  42647. case wpchatroommember.FieldCreatedAt:
  42648. return m.CreatedAt()
  42649. case wpchatroommember.FieldUpdatedAt:
  42650. return m.UpdatedAt()
  42651. case wpchatroommember.FieldStatus:
  42652. return m.Status()
  42653. case wpchatroommember.FieldWxWxid:
  42654. return m.WxWxid()
  42655. case wpchatroommember.FieldWxid:
  42656. return m.Wxid()
  42657. case wpchatroommember.FieldNickname:
  42658. return m.Nickname()
  42659. case wpchatroommember.FieldAvatar:
  42660. return m.Avatar()
  42661. }
  42662. return nil, false
  42663. }
  42664. // OldField returns the old value of the field from the database. An error is
  42665. // returned if the mutation operation is not UpdateOne, or the query to the
  42666. // database failed.
  42667. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42668. switch name {
  42669. case wpchatroommember.FieldCreatedAt:
  42670. return m.OldCreatedAt(ctx)
  42671. case wpchatroommember.FieldUpdatedAt:
  42672. return m.OldUpdatedAt(ctx)
  42673. case wpchatroommember.FieldStatus:
  42674. return m.OldStatus(ctx)
  42675. case wpchatroommember.FieldWxWxid:
  42676. return m.OldWxWxid(ctx)
  42677. case wpchatroommember.FieldWxid:
  42678. return m.OldWxid(ctx)
  42679. case wpchatroommember.FieldNickname:
  42680. return m.OldNickname(ctx)
  42681. case wpchatroommember.FieldAvatar:
  42682. return m.OldAvatar(ctx)
  42683. }
  42684. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  42685. }
  42686. // SetField sets the value of a field with the given name. It returns an error if
  42687. // the field is not defined in the schema, or if the type mismatched the field
  42688. // type.
  42689. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  42690. switch name {
  42691. case wpchatroommember.FieldCreatedAt:
  42692. v, ok := value.(time.Time)
  42693. if !ok {
  42694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42695. }
  42696. m.SetCreatedAt(v)
  42697. return nil
  42698. case wpchatroommember.FieldUpdatedAt:
  42699. v, ok := value.(time.Time)
  42700. if !ok {
  42701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42702. }
  42703. m.SetUpdatedAt(v)
  42704. return nil
  42705. case wpchatroommember.FieldStatus:
  42706. v, ok := value.(uint8)
  42707. if !ok {
  42708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42709. }
  42710. m.SetStatus(v)
  42711. return nil
  42712. case wpchatroommember.FieldWxWxid:
  42713. v, ok := value.(string)
  42714. if !ok {
  42715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42716. }
  42717. m.SetWxWxid(v)
  42718. return nil
  42719. case wpchatroommember.FieldWxid:
  42720. v, ok := value.(string)
  42721. if !ok {
  42722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42723. }
  42724. m.SetWxid(v)
  42725. return nil
  42726. case wpchatroommember.FieldNickname:
  42727. v, ok := value.(string)
  42728. if !ok {
  42729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42730. }
  42731. m.SetNickname(v)
  42732. return nil
  42733. case wpchatroommember.FieldAvatar:
  42734. v, ok := value.(string)
  42735. if !ok {
  42736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42737. }
  42738. m.SetAvatar(v)
  42739. return nil
  42740. }
  42741. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  42742. }
  42743. // AddedFields returns all numeric fields that were incremented/decremented during
  42744. // this mutation.
  42745. func (m *WpChatroomMemberMutation) AddedFields() []string {
  42746. var fields []string
  42747. if m.addstatus != nil {
  42748. fields = append(fields, wpchatroommember.FieldStatus)
  42749. }
  42750. return fields
  42751. }
  42752. // AddedField returns the numeric value that was incremented/decremented on a field
  42753. // with the given name. The second boolean return value indicates that this field
  42754. // was not set, or was not defined in the schema.
  42755. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  42756. switch name {
  42757. case wpchatroommember.FieldStatus:
  42758. return m.AddedStatus()
  42759. }
  42760. return nil, false
  42761. }
  42762. // AddField adds the value to the field with the given name. It returns an error if
  42763. // the field is not defined in the schema, or if the type mismatched the field
  42764. // type.
  42765. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  42766. switch name {
  42767. case wpchatroommember.FieldStatus:
  42768. v, ok := value.(int8)
  42769. if !ok {
  42770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42771. }
  42772. m.AddStatus(v)
  42773. return nil
  42774. }
  42775. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  42776. }
  42777. // ClearedFields returns all nullable fields that were cleared during this
  42778. // mutation.
  42779. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  42780. var fields []string
  42781. if m.FieldCleared(wpchatroommember.FieldStatus) {
  42782. fields = append(fields, wpchatroommember.FieldStatus)
  42783. }
  42784. return fields
  42785. }
  42786. // FieldCleared returns a boolean indicating if a field with the given name was
  42787. // cleared in this mutation.
  42788. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  42789. _, ok := m.clearedFields[name]
  42790. return ok
  42791. }
  42792. // ClearField clears the value of the field with the given name. It returns an
  42793. // error if the field is not defined in the schema.
  42794. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  42795. switch name {
  42796. case wpchatroommember.FieldStatus:
  42797. m.ClearStatus()
  42798. return nil
  42799. }
  42800. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  42801. }
  42802. // ResetField resets all changes in the mutation for the field with the given name.
  42803. // It returns an error if the field is not defined in the schema.
  42804. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  42805. switch name {
  42806. case wpchatroommember.FieldCreatedAt:
  42807. m.ResetCreatedAt()
  42808. return nil
  42809. case wpchatroommember.FieldUpdatedAt:
  42810. m.ResetUpdatedAt()
  42811. return nil
  42812. case wpchatroommember.FieldStatus:
  42813. m.ResetStatus()
  42814. return nil
  42815. case wpchatroommember.FieldWxWxid:
  42816. m.ResetWxWxid()
  42817. return nil
  42818. case wpchatroommember.FieldWxid:
  42819. m.ResetWxid()
  42820. return nil
  42821. case wpchatroommember.FieldNickname:
  42822. m.ResetNickname()
  42823. return nil
  42824. case wpchatroommember.FieldAvatar:
  42825. m.ResetAvatar()
  42826. return nil
  42827. }
  42828. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  42829. }
  42830. // AddedEdges returns all edge names that were set/added in this mutation.
  42831. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  42832. edges := make([]string, 0, 0)
  42833. return edges
  42834. }
  42835. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42836. // name in this mutation.
  42837. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  42838. return nil
  42839. }
  42840. // RemovedEdges returns all edge names that were removed in this mutation.
  42841. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  42842. edges := make([]string, 0, 0)
  42843. return edges
  42844. }
  42845. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42846. // the given name in this mutation.
  42847. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  42848. return nil
  42849. }
  42850. // ClearedEdges returns all edge names that were cleared in this mutation.
  42851. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  42852. edges := make([]string, 0, 0)
  42853. return edges
  42854. }
  42855. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42856. // was cleared in this mutation.
  42857. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  42858. return false
  42859. }
  42860. // ClearEdge clears the value of the edge with the given name. It returns an error
  42861. // if that edge is not defined in the schema.
  42862. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  42863. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  42864. }
  42865. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42866. // It returns an error if the edge is not defined in the schema.
  42867. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  42868. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  42869. }
  42870. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  42871. type WxMutation struct {
  42872. config
  42873. op Op
  42874. typ string
  42875. id *uint64
  42876. created_at *time.Time
  42877. updated_at *time.Time
  42878. status *uint8
  42879. addstatus *int8
  42880. deleted_at *time.Time
  42881. port *string
  42882. process_id *string
  42883. callback *string
  42884. wxid *string
  42885. account *string
  42886. nickname *string
  42887. tel *string
  42888. head_big *string
  42889. organization_id *uint64
  42890. addorganization_id *int64
  42891. api_base *string
  42892. api_key *string
  42893. allow_list *[]string
  42894. appendallow_list []string
  42895. group_allow_list *[]string
  42896. appendgroup_allow_list []string
  42897. block_list *[]string
  42898. appendblock_list []string
  42899. group_block_list *[]string
  42900. appendgroup_block_list []string
  42901. ctype *uint64
  42902. addctype *int64
  42903. clearedFields map[string]struct{}
  42904. server *uint64
  42905. clearedserver bool
  42906. agent *uint64
  42907. clearedagent bool
  42908. done bool
  42909. oldValue func(context.Context) (*Wx, error)
  42910. predicates []predicate.Wx
  42911. }
  42912. var _ ent.Mutation = (*WxMutation)(nil)
  42913. // wxOption allows management of the mutation configuration using functional options.
  42914. type wxOption func(*WxMutation)
  42915. // newWxMutation creates new mutation for the Wx entity.
  42916. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  42917. m := &WxMutation{
  42918. config: c,
  42919. op: op,
  42920. typ: TypeWx,
  42921. clearedFields: make(map[string]struct{}),
  42922. }
  42923. for _, opt := range opts {
  42924. opt(m)
  42925. }
  42926. return m
  42927. }
  42928. // withWxID sets the ID field of the mutation.
  42929. func withWxID(id uint64) wxOption {
  42930. return func(m *WxMutation) {
  42931. var (
  42932. err error
  42933. once sync.Once
  42934. value *Wx
  42935. )
  42936. m.oldValue = func(ctx context.Context) (*Wx, error) {
  42937. once.Do(func() {
  42938. if m.done {
  42939. err = errors.New("querying old values post mutation is not allowed")
  42940. } else {
  42941. value, err = m.Client().Wx.Get(ctx, id)
  42942. }
  42943. })
  42944. return value, err
  42945. }
  42946. m.id = &id
  42947. }
  42948. }
  42949. // withWx sets the old Wx of the mutation.
  42950. func withWx(node *Wx) wxOption {
  42951. return func(m *WxMutation) {
  42952. m.oldValue = func(context.Context) (*Wx, error) {
  42953. return node, nil
  42954. }
  42955. m.id = &node.ID
  42956. }
  42957. }
  42958. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42959. // executed in a transaction (ent.Tx), a transactional client is returned.
  42960. func (m WxMutation) Client() *Client {
  42961. client := &Client{config: m.config}
  42962. client.init()
  42963. return client
  42964. }
  42965. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42966. // it returns an error otherwise.
  42967. func (m WxMutation) Tx() (*Tx, error) {
  42968. if _, ok := m.driver.(*txDriver); !ok {
  42969. return nil, errors.New("ent: mutation is not running in a transaction")
  42970. }
  42971. tx := &Tx{config: m.config}
  42972. tx.init()
  42973. return tx, nil
  42974. }
  42975. // SetID sets the value of the id field. Note that this
  42976. // operation is only accepted on creation of Wx entities.
  42977. func (m *WxMutation) SetID(id uint64) {
  42978. m.id = &id
  42979. }
  42980. // ID returns the ID value in the mutation. Note that the ID is only available
  42981. // if it was provided to the builder or after it was returned from the database.
  42982. func (m *WxMutation) ID() (id uint64, exists bool) {
  42983. if m.id == nil {
  42984. return
  42985. }
  42986. return *m.id, true
  42987. }
  42988. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42989. // That means, if the mutation is applied within a transaction with an isolation level such
  42990. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42991. // or updated by the mutation.
  42992. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  42993. switch {
  42994. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42995. id, exists := m.ID()
  42996. if exists {
  42997. return []uint64{id}, nil
  42998. }
  42999. fallthrough
  43000. case m.op.Is(OpUpdate | OpDelete):
  43001. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  43002. default:
  43003. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43004. }
  43005. }
  43006. // SetCreatedAt sets the "created_at" field.
  43007. func (m *WxMutation) SetCreatedAt(t time.Time) {
  43008. m.created_at = &t
  43009. }
  43010. // CreatedAt returns the value of the "created_at" field in the mutation.
  43011. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  43012. v := m.created_at
  43013. if v == nil {
  43014. return
  43015. }
  43016. return *v, true
  43017. }
  43018. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  43019. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43021. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43022. if !m.op.Is(OpUpdateOne) {
  43023. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43024. }
  43025. if m.id == nil || m.oldValue == nil {
  43026. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43027. }
  43028. oldValue, err := m.oldValue(ctx)
  43029. if err != nil {
  43030. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43031. }
  43032. return oldValue.CreatedAt, nil
  43033. }
  43034. // ResetCreatedAt resets all changes to the "created_at" field.
  43035. func (m *WxMutation) ResetCreatedAt() {
  43036. m.created_at = nil
  43037. }
  43038. // SetUpdatedAt sets the "updated_at" field.
  43039. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  43040. m.updated_at = &t
  43041. }
  43042. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43043. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  43044. v := m.updated_at
  43045. if v == nil {
  43046. return
  43047. }
  43048. return *v, true
  43049. }
  43050. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  43051. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43053. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43054. if !m.op.Is(OpUpdateOne) {
  43055. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43056. }
  43057. if m.id == nil || m.oldValue == nil {
  43058. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43059. }
  43060. oldValue, err := m.oldValue(ctx)
  43061. if err != nil {
  43062. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43063. }
  43064. return oldValue.UpdatedAt, nil
  43065. }
  43066. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43067. func (m *WxMutation) ResetUpdatedAt() {
  43068. m.updated_at = nil
  43069. }
  43070. // SetStatus sets the "status" field.
  43071. func (m *WxMutation) SetStatus(u uint8) {
  43072. m.status = &u
  43073. m.addstatus = nil
  43074. }
  43075. // Status returns the value of the "status" field in the mutation.
  43076. func (m *WxMutation) Status() (r uint8, exists bool) {
  43077. v := m.status
  43078. if v == nil {
  43079. return
  43080. }
  43081. return *v, true
  43082. }
  43083. // OldStatus returns the old "status" 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) OldStatus(ctx context.Context) (v uint8, err error) {
  43087. if !m.op.Is(OpUpdateOne) {
  43088. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43089. }
  43090. if m.id == nil || m.oldValue == nil {
  43091. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  43096. }
  43097. return oldValue.Status, nil
  43098. }
  43099. // AddStatus adds u to the "status" field.
  43100. func (m *WxMutation) AddStatus(u int8) {
  43101. if m.addstatus != nil {
  43102. *m.addstatus += u
  43103. } else {
  43104. m.addstatus = &u
  43105. }
  43106. }
  43107. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43108. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  43109. v := m.addstatus
  43110. if v == nil {
  43111. return
  43112. }
  43113. return *v, true
  43114. }
  43115. // ClearStatus clears the value of the "status" field.
  43116. func (m *WxMutation) ClearStatus() {
  43117. m.status = nil
  43118. m.addstatus = nil
  43119. m.clearedFields[wx.FieldStatus] = struct{}{}
  43120. }
  43121. // StatusCleared returns if the "status" field was cleared in this mutation.
  43122. func (m *WxMutation) StatusCleared() bool {
  43123. _, ok := m.clearedFields[wx.FieldStatus]
  43124. return ok
  43125. }
  43126. // ResetStatus resets all changes to the "status" field.
  43127. func (m *WxMutation) ResetStatus() {
  43128. m.status = nil
  43129. m.addstatus = nil
  43130. delete(m.clearedFields, wx.FieldStatus)
  43131. }
  43132. // SetDeletedAt sets the "deleted_at" field.
  43133. func (m *WxMutation) SetDeletedAt(t time.Time) {
  43134. m.deleted_at = &t
  43135. }
  43136. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43137. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  43138. v := m.deleted_at
  43139. if v == nil {
  43140. return
  43141. }
  43142. return *v, true
  43143. }
  43144. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  43145. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43147. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43148. if !m.op.Is(OpUpdateOne) {
  43149. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43150. }
  43151. if m.id == nil || m.oldValue == nil {
  43152. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43153. }
  43154. oldValue, err := m.oldValue(ctx)
  43155. if err != nil {
  43156. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43157. }
  43158. return oldValue.DeletedAt, nil
  43159. }
  43160. // ClearDeletedAt clears the value of the "deleted_at" field.
  43161. func (m *WxMutation) ClearDeletedAt() {
  43162. m.deleted_at = nil
  43163. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  43164. }
  43165. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43166. func (m *WxMutation) DeletedAtCleared() bool {
  43167. _, ok := m.clearedFields[wx.FieldDeletedAt]
  43168. return ok
  43169. }
  43170. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43171. func (m *WxMutation) ResetDeletedAt() {
  43172. m.deleted_at = nil
  43173. delete(m.clearedFields, wx.FieldDeletedAt)
  43174. }
  43175. // SetServerID sets the "server_id" field.
  43176. func (m *WxMutation) SetServerID(u uint64) {
  43177. m.server = &u
  43178. }
  43179. // ServerID returns the value of the "server_id" field in the mutation.
  43180. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  43181. v := m.server
  43182. if v == nil {
  43183. return
  43184. }
  43185. return *v, true
  43186. }
  43187. // OldServerID returns the old "server_id" field's value of the Wx entity.
  43188. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43190. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  43191. if !m.op.Is(OpUpdateOne) {
  43192. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  43193. }
  43194. if m.id == nil || m.oldValue == nil {
  43195. return v, errors.New("OldServerID requires an ID field in the mutation")
  43196. }
  43197. oldValue, err := m.oldValue(ctx)
  43198. if err != nil {
  43199. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  43200. }
  43201. return oldValue.ServerID, nil
  43202. }
  43203. // ClearServerID clears the value of the "server_id" field.
  43204. func (m *WxMutation) ClearServerID() {
  43205. m.server = nil
  43206. m.clearedFields[wx.FieldServerID] = struct{}{}
  43207. }
  43208. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  43209. func (m *WxMutation) ServerIDCleared() bool {
  43210. _, ok := m.clearedFields[wx.FieldServerID]
  43211. return ok
  43212. }
  43213. // ResetServerID resets all changes to the "server_id" field.
  43214. func (m *WxMutation) ResetServerID() {
  43215. m.server = nil
  43216. delete(m.clearedFields, wx.FieldServerID)
  43217. }
  43218. // SetPort sets the "port" field.
  43219. func (m *WxMutation) SetPort(s string) {
  43220. m.port = &s
  43221. }
  43222. // Port returns the value of the "port" field in the mutation.
  43223. func (m *WxMutation) Port() (r string, exists bool) {
  43224. v := m.port
  43225. if v == nil {
  43226. return
  43227. }
  43228. return *v, true
  43229. }
  43230. // OldPort returns the old "port" field's value of the Wx entity.
  43231. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43233. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  43234. if !m.op.Is(OpUpdateOne) {
  43235. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  43236. }
  43237. if m.id == nil || m.oldValue == nil {
  43238. return v, errors.New("OldPort requires an ID field in the mutation")
  43239. }
  43240. oldValue, err := m.oldValue(ctx)
  43241. if err != nil {
  43242. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  43243. }
  43244. return oldValue.Port, nil
  43245. }
  43246. // ResetPort resets all changes to the "port" field.
  43247. func (m *WxMutation) ResetPort() {
  43248. m.port = nil
  43249. }
  43250. // SetProcessID sets the "process_id" field.
  43251. func (m *WxMutation) SetProcessID(s string) {
  43252. m.process_id = &s
  43253. }
  43254. // ProcessID returns the value of the "process_id" field in the mutation.
  43255. func (m *WxMutation) ProcessID() (r string, exists bool) {
  43256. v := m.process_id
  43257. if v == nil {
  43258. return
  43259. }
  43260. return *v, true
  43261. }
  43262. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  43263. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43265. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  43266. if !m.op.Is(OpUpdateOne) {
  43267. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  43268. }
  43269. if m.id == nil || m.oldValue == nil {
  43270. return v, errors.New("OldProcessID requires an ID field in the mutation")
  43271. }
  43272. oldValue, err := m.oldValue(ctx)
  43273. if err != nil {
  43274. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  43275. }
  43276. return oldValue.ProcessID, nil
  43277. }
  43278. // ResetProcessID resets all changes to the "process_id" field.
  43279. func (m *WxMutation) ResetProcessID() {
  43280. m.process_id = nil
  43281. }
  43282. // SetCallback sets the "callback" field.
  43283. func (m *WxMutation) SetCallback(s string) {
  43284. m.callback = &s
  43285. }
  43286. // Callback returns the value of the "callback" field in the mutation.
  43287. func (m *WxMutation) Callback() (r string, exists bool) {
  43288. v := m.callback
  43289. if v == nil {
  43290. return
  43291. }
  43292. return *v, true
  43293. }
  43294. // OldCallback returns the old "callback" field's value of the Wx entity.
  43295. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43297. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  43298. if !m.op.Is(OpUpdateOne) {
  43299. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  43300. }
  43301. if m.id == nil || m.oldValue == nil {
  43302. return v, errors.New("OldCallback requires an ID field in the mutation")
  43303. }
  43304. oldValue, err := m.oldValue(ctx)
  43305. if err != nil {
  43306. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  43307. }
  43308. return oldValue.Callback, nil
  43309. }
  43310. // ResetCallback resets all changes to the "callback" field.
  43311. func (m *WxMutation) ResetCallback() {
  43312. m.callback = nil
  43313. }
  43314. // SetWxid sets the "wxid" field.
  43315. func (m *WxMutation) SetWxid(s string) {
  43316. m.wxid = &s
  43317. }
  43318. // Wxid returns the value of the "wxid" field in the mutation.
  43319. func (m *WxMutation) Wxid() (r string, exists bool) {
  43320. v := m.wxid
  43321. if v == nil {
  43322. return
  43323. }
  43324. return *v, true
  43325. }
  43326. // OldWxid returns the old "wxid" field's value of the Wx entity.
  43327. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43329. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  43330. if !m.op.Is(OpUpdateOne) {
  43331. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43332. }
  43333. if m.id == nil || m.oldValue == nil {
  43334. return v, errors.New("OldWxid requires an ID field in the mutation")
  43335. }
  43336. oldValue, err := m.oldValue(ctx)
  43337. if err != nil {
  43338. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43339. }
  43340. return oldValue.Wxid, nil
  43341. }
  43342. // ResetWxid resets all changes to the "wxid" field.
  43343. func (m *WxMutation) ResetWxid() {
  43344. m.wxid = nil
  43345. }
  43346. // SetAccount sets the "account" field.
  43347. func (m *WxMutation) SetAccount(s string) {
  43348. m.account = &s
  43349. }
  43350. // Account returns the value of the "account" field in the mutation.
  43351. func (m *WxMutation) Account() (r string, exists bool) {
  43352. v := m.account
  43353. if v == nil {
  43354. return
  43355. }
  43356. return *v, true
  43357. }
  43358. // OldAccount returns the old "account" field's value of the Wx entity.
  43359. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43361. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  43362. if !m.op.Is(OpUpdateOne) {
  43363. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43364. }
  43365. if m.id == nil || m.oldValue == nil {
  43366. return v, errors.New("OldAccount requires an ID field in the mutation")
  43367. }
  43368. oldValue, err := m.oldValue(ctx)
  43369. if err != nil {
  43370. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  43371. }
  43372. return oldValue.Account, nil
  43373. }
  43374. // ResetAccount resets all changes to the "account" field.
  43375. func (m *WxMutation) ResetAccount() {
  43376. m.account = nil
  43377. }
  43378. // SetNickname sets the "nickname" field.
  43379. func (m *WxMutation) SetNickname(s string) {
  43380. m.nickname = &s
  43381. }
  43382. // Nickname returns the value of the "nickname" field in the mutation.
  43383. func (m *WxMutation) Nickname() (r string, exists bool) {
  43384. v := m.nickname
  43385. if v == nil {
  43386. return
  43387. }
  43388. return *v, true
  43389. }
  43390. // OldNickname returns the old "nickname" field's value of the Wx entity.
  43391. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43393. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  43394. if !m.op.Is(OpUpdateOne) {
  43395. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43396. }
  43397. if m.id == nil || m.oldValue == nil {
  43398. return v, errors.New("OldNickname requires an ID field in the mutation")
  43399. }
  43400. oldValue, err := m.oldValue(ctx)
  43401. if err != nil {
  43402. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43403. }
  43404. return oldValue.Nickname, nil
  43405. }
  43406. // ResetNickname resets all changes to the "nickname" field.
  43407. func (m *WxMutation) ResetNickname() {
  43408. m.nickname = nil
  43409. }
  43410. // SetTel sets the "tel" field.
  43411. func (m *WxMutation) SetTel(s string) {
  43412. m.tel = &s
  43413. }
  43414. // Tel returns the value of the "tel" field in the mutation.
  43415. func (m *WxMutation) Tel() (r string, exists bool) {
  43416. v := m.tel
  43417. if v == nil {
  43418. return
  43419. }
  43420. return *v, true
  43421. }
  43422. // OldTel returns the old "tel" field's value of the Wx entity.
  43423. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43425. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  43426. if !m.op.Is(OpUpdateOne) {
  43427. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  43428. }
  43429. if m.id == nil || m.oldValue == nil {
  43430. return v, errors.New("OldTel requires an ID field in the mutation")
  43431. }
  43432. oldValue, err := m.oldValue(ctx)
  43433. if err != nil {
  43434. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  43435. }
  43436. return oldValue.Tel, nil
  43437. }
  43438. // ResetTel resets all changes to the "tel" field.
  43439. func (m *WxMutation) ResetTel() {
  43440. m.tel = nil
  43441. }
  43442. // SetHeadBig sets the "head_big" field.
  43443. func (m *WxMutation) SetHeadBig(s string) {
  43444. m.head_big = &s
  43445. }
  43446. // HeadBig returns the value of the "head_big" field in the mutation.
  43447. func (m *WxMutation) HeadBig() (r string, exists bool) {
  43448. v := m.head_big
  43449. if v == nil {
  43450. return
  43451. }
  43452. return *v, true
  43453. }
  43454. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  43455. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43457. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  43458. if !m.op.Is(OpUpdateOne) {
  43459. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  43460. }
  43461. if m.id == nil || m.oldValue == nil {
  43462. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  43463. }
  43464. oldValue, err := m.oldValue(ctx)
  43465. if err != nil {
  43466. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  43467. }
  43468. return oldValue.HeadBig, nil
  43469. }
  43470. // ResetHeadBig resets all changes to the "head_big" field.
  43471. func (m *WxMutation) ResetHeadBig() {
  43472. m.head_big = nil
  43473. }
  43474. // SetOrganizationID sets the "organization_id" field.
  43475. func (m *WxMutation) SetOrganizationID(u uint64) {
  43476. m.organization_id = &u
  43477. m.addorganization_id = nil
  43478. }
  43479. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43480. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  43481. v := m.organization_id
  43482. if v == nil {
  43483. return
  43484. }
  43485. return *v, true
  43486. }
  43487. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  43488. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43490. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43491. if !m.op.Is(OpUpdateOne) {
  43492. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43493. }
  43494. if m.id == nil || m.oldValue == nil {
  43495. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43496. }
  43497. oldValue, err := m.oldValue(ctx)
  43498. if err != nil {
  43499. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43500. }
  43501. return oldValue.OrganizationID, nil
  43502. }
  43503. // AddOrganizationID adds u to the "organization_id" field.
  43504. func (m *WxMutation) AddOrganizationID(u int64) {
  43505. if m.addorganization_id != nil {
  43506. *m.addorganization_id += u
  43507. } else {
  43508. m.addorganization_id = &u
  43509. }
  43510. }
  43511. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43512. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  43513. v := m.addorganization_id
  43514. if v == nil {
  43515. return
  43516. }
  43517. return *v, true
  43518. }
  43519. // ClearOrganizationID clears the value of the "organization_id" field.
  43520. func (m *WxMutation) ClearOrganizationID() {
  43521. m.organization_id = nil
  43522. m.addorganization_id = nil
  43523. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  43524. }
  43525. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  43526. func (m *WxMutation) OrganizationIDCleared() bool {
  43527. _, ok := m.clearedFields[wx.FieldOrganizationID]
  43528. return ok
  43529. }
  43530. // ResetOrganizationID resets all changes to the "organization_id" field.
  43531. func (m *WxMutation) ResetOrganizationID() {
  43532. m.organization_id = nil
  43533. m.addorganization_id = nil
  43534. delete(m.clearedFields, wx.FieldOrganizationID)
  43535. }
  43536. // SetAgentID sets the "agent_id" field.
  43537. func (m *WxMutation) SetAgentID(u uint64) {
  43538. m.agent = &u
  43539. }
  43540. // AgentID returns the value of the "agent_id" field in the mutation.
  43541. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  43542. v := m.agent
  43543. if v == nil {
  43544. return
  43545. }
  43546. return *v, true
  43547. }
  43548. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  43549. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43551. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  43552. if !m.op.Is(OpUpdateOne) {
  43553. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  43554. }
  43555. if m.id == nil || m.oldValue == nil {
  43556. return v, errors.New("OldAgentID requires an ID field in the mutation")
  43557. }
  43558. oldValue, err := m.oldValue(ctx)
  43559. if err != nil {
  43560. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  43561. }
  43562. return oldValue.AgentID, nil
  43563. }
  43564. // ResetAgentID resets all changes to the "agent_id" field.
  43565. func (m *WxMutation) ResetAgentID() {
  43566. m.agent = nil
  43567. }
  43568. // SetAPIBase sets the "api_base" field.
  43569. func (m *WxMutation) SetAPIBase(s string) {
  43570. m.api_base = &s
  43571. }
  43572. // APIBase returns the value of the "api_base" field in the mutation.
  43573. func (m *WxMutation) APIBase() (r string, exists bool) {
  43574. v := m.api_base
  43575. if v == nil {
  43576. return
  43577. }
  43578. return *v, true
  43579. }
  43580. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  43581. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43583. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43584. if !m.op.Is(OpUpdateOne) {
  43585. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43586. }
  43587. if m.id == nil || m.oldValue == nil {
  43588. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43589. }
  43590. oldValue, err := m.oldValue(ctx)
  43591. if err != nil {
  43592. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43593. }
  43594. return oldValue.APIBase, nil
  43595. }
  43596. // ClearAPIBase clears the value of the "api_base" field.
  43597. func (m *WxMutation) ClearAPIBase() {
  43598. m.api_base = nil
  43599. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  43600. }
  43601. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43602. func (m *WxMutation) APIBaseCleared() bool {
  43603. _, ok := m.clearedFields[wx.FieldAPIBase]
  43604. return ok
  43605. }
  43606. // ResetAPIBase resets all changes to the "api_base" field.
  43607. func (m *WxMutation) ResetAPIBase() {
  43608. m.api_base = nil
  43609. delete(m.clearedFields, wx.FieldAPIBase)
  43610. }
  43611. // SetAPIKey sets the "api_key" field.
  43612. func (m *WxMutation) SetAPIKey(s string) {
  43613. m.api_key = &s
  43614. }
  43615. // APIKey returns the value of the "api_key" field in the mutation.
  43616. func (m *WxMutation) APIKey() (r string, exists bool) {
  43617. v := m.api_key
  43618. if v == nil {
  43619. return
  43620. }
  43621. return *v, true
  43622. }
  43623. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  43624. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43626. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43627. if !m.op.Is(OpUpdateOne) {
  43628. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43629. }
  43630. if m.id == nil || m.oldValue == nil {
  43631. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43632. }
  43633. oldValue, err := m.oldValue(ctx)
  43634. if err != nil {
  43635. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43636. }
  43637. return oldValue.APIKey, nil
  43638. }
  43639. // ClearAPIKey clears the value of the "api_key" field.
  43640. func (m *WxMutation) ClearAPIKey() {
  43641. m.api_key = nil
  43642. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  43643. }
  43644. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43645. func (m *WxMutation) APIKeyCleared() bool {
  43646. _, ok := m.clearedFields[wx.FieldAPIKey]
  43647. return ok
  43648. }
  43649. // ResetAPIKey resets all changes to the "api_key" field.
  43650. func (m *WxMutation) ResetAPIKey() {
  43651. m.api_key = nil
  43652. delete(m.clearedFields, wx.FieldAPIKey)
  43653. }
  43654. // SetAllowList sets the "allow_list" field.
  43655. func (m *WxMutation) SetAllowList(s []string) {
  43656. m.allow_list = &s
  43657. m.appendallow_list = nil
  43658. }
  43659. // AllowList returns the value of the "allow_list" field in the mutation.
  43660. func (m *WxMutation) AllowList() (r []string, exists bool) {
  43661. v := m.allow_list
  43662. if v == nil {
  43663. return
  43664. }
  43665. return *v, true
  43666. }
  43667. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  43668. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43670. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  43671. if !m.op.Is(OpUpdateOne) {
  43672. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  43673. }
  43674. if m.id == nil || m.oldValue == nil {
  43675. return v, errors.New("OldAllowList requires an ID field in the mutation")
  43676. }
  43677. oldValue, err := m.oldValue(ctx)
  43678. if err != nil {
  43679. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  43680. }
  43681. return oldValue.AllowList, nil
  43682. }
  43683. // AppendAllowList adds s to the "allow_list" field.
  43684. func (m *WxMutation) AppendAllowList(s []string) {
  43685. m.appendallow_list = append(m.appendallow_list, s...)
  43686. }
  43687. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  43688. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  43689. if len(m.appendallow_list) == 0 {
  43690. return nil, false
  43691. }
  43692. return m.appendallow_list, true
  43693. }
  43694. // ResetAllowList resets all changes to the "allow_list" field.
  43695. func (m *WxMutation) ResetAllowList() {
  43696. m.allow_list = nil
  43697. m.appendallow_list = nil
  43698. }
  43699. // SetGroupAllowList sets the "group_allow_list" field.
  43700. func (m *WxMutation) SetGroupAllowList(s []string) {
  43701. m.group_allow_list = &s
  43702. m.appendgroup_allow_list = nil
  43703. }
  43704. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  43705. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  43706. v := m.group_allow_list
  43707. if v == nil {
  43708. return
  43709. }
  43710. return *v, true
  43711. }
  43712. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  43713. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43715. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  43716. if !m.op.Is(OpUpdateOne) {
  43717. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  43718. }
  43719. if m.id == nil || m.oldValue == nil {
  43720. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  43721. }
  43722. oldValue, err := m.oldValue(ctx)
  43723. if err != nil {
  43724. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  43725. }
  43726. return oldValue.GroupAllowList, nil
  43727. }
  43728. // AppendGroupAllowList adds s to the "group_allow_list" field.
  43729. func (m *WxMutation) AppendGroupAllowList(s []string) {
  43730. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  43731. }
  43732. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  43733. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  43734. if len(m.appendgroup_allow_list) == 0 {
  43735. return nil, false
  43736. }
  43737. return m.appendgroup_allow_list, true
  43738. }
  43739. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  43740. func (m *WxMutation) ResetGroupAllowList() {
  43741. m.group_allow_list = nil
  43742. m.appendgroup_allow_list = nil
  43743. }
  43744. // SetBlockList sets the "block_list" field.
  43745. func (m *WxMutation) SetBlockList(s []string) {
  43746. m.block_list = &s
  43747. m.appendblock_list = nil
  43748. }
  43749. // BlockList returns the value of the "block_list" field in the mutation.
  43750. func (m *WxMutation) BlockList() (r []string, exists bool) {
  43751. v := m.block_list
  43752. if v == nil {
  43753. return
  43754. }
  43755. return *v, true
  43756. }
  43757. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  43758. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43760. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  43761. if !m.op.Is(OpUpdateOne) {
  43762. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  43763. }
  43764. if m.id == nil || m.oldValue == nil {
  43765. return v, errors.New("OldBlockList requires an ID field in the mutation")
  43766. }
  43767. oldValue, err := m.oldValue(ctx)
  43768. if err != nil {
  43769. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  43770. }
  43771. return oldValue.BlockList, nil
  43772. }
  43773. // AppendBlockList adds s to the "block_list" field.
  43774. func (m *WxMutation) AppendBlockList(s []string) {
  43775. m.appendblock_list = append(m.appendblock_list, s...)
  43776. }
  43777. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  43778. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  43779. if len(m.appendblock_list) == 0 {
  43780. return nil, false
  43781. }
  43782. return m.appendblock_list, true
  43783. }
  43784. // ResetBlockList resets all changes to the "block_list" field.
  43785. func (m *WxMutation) ResetBlockList() {
  43786. m.block_list = nil
  43787. m.appendblock_list = nil
  43788. }
  43789. // SetGroupBlockList sets the "group_block_list" field.
  43790. func (m *WxMutation) SetGroupBlockList(s []string) {
  43791. m.group_block_list = &s
  43792. m.appendgroup_block_list = nil
  43793. }
  43794. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  43795. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  43796. v := m.group_block_list
  43797. if v == nil {
  43798. return
  43799. }
  43800. return *v, true
  43801. }
  43802. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  43803. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43805. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  43806. if !m.op.Is(OpUpdateOne) {
  43807. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  43808. }
  43809. if m.id == nil || m.oldValue == nil {
  43810. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  43811. }
  43812. oldValue, err := m.oldValue(ctx)
  43813. if err != nil {
  43814. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  43815. }
  43816. return oldValue.GroupBlockList, nil
  43817. }
  43818. // AppendGroupBlockList adds s to the "group_block_list" field.
  43819. func (m *WxMutation) AppendGroupBlockList(s []string) {
  43820. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  43821. }
  43822. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  43823. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  43824. if len(m.appendgroup_block_list) == 0 {
  43825. return nil, false
  43826. }
  43827. return m.appendgroup_block_list, true
  43828. }
  43829. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  43830. func (m *WxMutation) ResetGroupBlockList() {
  43831. m.group_block_list = nil
  43832. m.appendgroup_block_list = nil
  43833. }
  43834. // SetCtype sets the "ctype" field.
  43835. func (m *WxMutation) SetCtype(u uint64) {
  43836. m.ctype = &u
  43837. m.addctype = nil
  43838. }
  43839. // Ctype returns the value of the "ctype" field in the mutation.
  43840. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  43841. v := m.ctype
  43842. if v == nil {
  43843. return
  43844. }
  43845. return *v, true
  43846. }
  43847. // OldCtype returns the old "ctype" field's value of the Wx entity.
  43848. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43850. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  43851. if !m.op.Is(OpUpdateOne) {
  43852. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  43853. }
  43854. if m.id == nil || m.oldValue == nil {
  43855. return v, errors.New("OldCtype requires an ID field in the mutation")
  43856. }
  43857. oldValue, err := m.oldValue(ctx)
  43858. if err != nil {
  43859. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  43860. }
  43861. return oldValue.Ctype, nil
  43862. }
  43863. // AddCtype adds u to the "ctype" field.
  43864. func (m *WxMutation) AddCtype(u int64) {
  43865. if m.addctype != nil {
  43866. *m.addctype += u
  43867. } else {
  43868. m.addctype = &u
  43869. }
  43870. }
  43871. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  43872. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  43873. v := m.addctype
  43874. if v == nil {
  43875. return
  43876. }
  43877. return *v, true
  43878. }
  43879. // ClearCtype clears the value of the "ctype" field.
  43880. func (m *WxMutation) ClearCtype() {
  43881. m.ctype = nil
  43882. m.addctype = nil
  43883. m.clearedFields[wx.FieldCtype] = struct{}{}
  43884. }
  43885. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  43886. func (m *WxMutation) CtypeCleared() bool {
  43887. _, ok := m.clearedFields[wx.FieldCtype]
  43888. return ok
  43889. }
  43890. // ResetCtype resets all changes to the "ctype" field.
  43891. func (m *WxMutation) ResetCtype() {
  43892. m.ctype = nil
  43893. m.addctype = nil
  43894. delete(m.clearedFields, wx.FieldCtype)
  43895. }
  43896. // ClearServer clears the "server" edge to the Server entity.
  43897. func (m *WxMutation) ClearServer() {
  43898. m.clearedserver = true
  43899. m.clearedFields[wx.FieldServerID] = struct{}{}
  43900. }
  43901. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  43902. func (m *WxMutation) ServerCleared() bool {
  43903. return m.ServerIDCleared() || m.clearedserver
  43904. }
  43905. // ServerIDs returns the "server" edge IDs in the mutation.
  43906. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43907. // ServerID instead. It exists only for internal usage by the builders.
  43908. func (m *WxMutation) ServerIDs() (ids []uint64) {
  43909. if id := m.server; id != nil {
  43910. ids = append(ids, *id)
  43911. }
  43912. return
  43913. }
  43914. // ResetServer resets all changes to the "server" edge.
  43915. func (m *WxMutation) ResetServer() {
  43916. m.server = nil
  43917. m.clearedserver = false
  43918. }
  43919. // ClearAgent clears the "agent" edge to the Agent entity.
  43920. func (m *WxMutation) ClearAgent() {
  43921. m.clearedagent = true
  43922. m.clearedFields[wx.FieldAgentID] = struct{}{}
  43923. }
  43924. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  43925. func (m *WxMutation) AgentCleared() bool {
  43926. return m.clearedagent
  43927. }
  43928. // AgentIDs returns the "agent" edge IDs in the mutation.
  43929. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43930. // AgentID instead. It exists only for internal usage by the builders.
  43931. func (m *WxMutation) AgentIDs() (ids []uint64) {
  43932. if id := m.agent; id != nil {
  43933. ids = append(ids, *id)
  43934. }
  43935. return
  43936. }
  43937. // ResetAgent resets all changes to the "agent" edge.
  43938. func (m *WxMutation) ResetAgent() {
  43939. m.agent = nil
  43940. m.clearedagent = false
  43941. }
  43942. // Where appends a list predicates to the WxMutation builder.
  43943. func (m *WxMutation) Where(ps ...predicate.Wx) {
  43944. m.predicates = append(m.predicates, ps...)
  43945. }
  43946. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  43947. // users can use type-assertion to append predicates that do not depend on any generated package.
  43948. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  43949. p := make([]predicate.Wx, len(ps))
  43950. for i := range ps {
  43951. p[i] = ps[i]
  43952. }
  43953. m.Where(p...)
  43954. }
  43955. // Op returns the operation name.
  43956. func (m *WxMutation) Op() Op {
  43957. return m.op
  43958. }
  43959. // SetOp allows setting the mutation operation.
  43960. func (m *WxMutation) SetOp(op Op) {
  43961. m.op = op
  43962. }
  43963. // Type returns the node type of this mutation (Wx).
  43964. func (m *WxMutation) Type() string {
  43965. return m.typ
  43966. }
  43967. // Fields returns all fields that were changed during this mutation. Note that in
  43968. // order to get all numeric fields that were incremented/decremented, call
  43969. // AddedFields().
  43970. func (m *WxMutation) Fields() []string {
  43971. fields := make([]string, 0, 22)
  43972. if m.created_at != nil {
  43973. fields = append(fields, wx.FieldCreatedAt)
  43974. }
  43975. if m.updated_at != nil {
  43976. fields = append(fields, wx.FieldUpdatedAt)
  43977. }
  43978. if m.status != nil {
  43979. fields = append(fields, wx.FieldStatus)
  43980. }
  43981. if m.deleted_at != nil {
  43982. fields = append(fields, wx.FieldDeletedAt)
  43983. }
  43984. if m.server != nil {
  43985. fields = append(fields, wx.FieldServerID)
  43986. }
  43987. if m.port != nil {
  43988. fields = append(fields, wx.FieldPort)
  43989. }
  43990. if m.process_id != nil {
  43991. fields = append(fields, wx.FieldProcessID)
  43992. }
  43993. if m.callback != nil {
  43994. fields = append(fields, wx.FieldCallback)
  43995. }
  43996. if m.wxid != nil {
  43997. fields = append(fields, wx.FieldWxid)
  43998. }
  43999. if m.account != nil {
  44000. fields = append(fields, wx.FieldAccount)
  44001. }
  44002. if m.nickname != nil {
  44003. fields = append(fields, wx.FieldNickname)
  44004. }
  44005. if m.tel != nil {
  44006. fields = append(fields, wx.FieldTel)
  44007. }
  44008. if m.head_big != nil {
  44009. fields = append(fields, wx.FieldHeadBig)
  44010. }
  44011. if m.organization_id != nil {
  44012. fields = append(fields, wx.FieldOrganizationID)
  44013. }
  44014. if m.agent != nil {
  44015. fields = append(fields, wx.FieldAgentID)
  44016. }
  44017. if m.api_base != nil {
  44018. fields = append(fields, wx.FieldAPIBase)
  44019. }
  44020. if m.api_key != nil {
  44021. fields = append(fields, wx.FieldAPIKey)
  44022. }
  44023. if m.allow_list != nil {
  44024. fields = append(fields, wx.FieldAllowList)
  44025. }
  44026. if m.group_allow_list != nil {
  44027. fields = append(fields, wx.FieldGroupAllowList)
  44028. }
  44029. if m.block_list != nil {
  44030. fields = append(fields, wx.FieldBlockList)
  44031. }
  44032. if m.group_block_list != nil {
  44033. fields = append(fields, wx.FieldGroupBlockList)
  44034. }
  44035. if m.ctype != nil {
  44036. fields = append(fields, wx.FieldCtype)
  44037. }
  44038. return fields
  44039. }
  44040. // Field returns the value of a field with the given name. The second boolean
  44041. // return value indicates that this field was not set, or was not defined in the
  44042. // schema.
  44043. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  44044. switch name {
  44045. case wx.FieldCreatedAt:
  44046. return m.CreatedAt()
  44047. case wx.FieldUpdatedAt:
  44048. return m.UpdatedAt()
  44049. case wx.FieldStatus:
  44050. return m.Status()
  44051. case wx.FieldDeletedAt:
  44052. return m.DeletedAt()
  44053. case wx.FieldServerID:
  44054. return m.ServerID()
  44055. case wx.FieldPort:
  44056. return m.Port()
  44057. case wx.FieldProcessID:
  44058. return m.ProcessID()
  44059. case wx.FieldCallback:
  44060. return m.Callback()
  44061. case wx.FieldWxid:
  44062. return m.Wxid()
  44063. case wx.FieldAccount:
  44064. return m.Account()
  44065. case wx.FieldNickname:
  44066. return m.Nickname()
  44067. case wx.FieldTel:
  44068. return m.Tel()
  44069. case wx.FieldHeadBig:
  44070. return m.HeadBig()
  44071. case wx.FieldOrganizationID:
  44072. return m.OrganizationID()
  44073. case wx.FieldAgentID:
  44074. return m.AgentID()
  44075. case wx.FieldAPIBase:
  44076. return m.APIBase()
  44077. case wx.FieldAPIKey:
  44078. return m.APIKey()
  44079. case wx.FieldAllowList:
  44080. return m.AllowList()
  44081. case wx.FieldGroupAllowList:
  44082. return m.GroupAllowList()
  44083. case wx.FieldBlockList:
  44084. return m.BlockList()
  44085. case wx.FieldGroupBlockList:
  44086. return m.GroupBlockList()
  44087. case wx.FieldCtype:
  44088. return m.Ctype()
  44089. }
  44090. return nil, false
  44091. }
  44092. // OldField returns the old value of the field from the database. An error is
  44093. // returned if the mutation operation is not UpdateOne, or the query to the
  44094. // database failed.
  44095. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44096. switch name {
  44097. case wx.FieldCreatedAt:
  44098. return m.OldCreatedAt(ctx)
  44099. case wx.FieldUpdatedAt:
  44100. return m.OldUpdatedAt(ctx)
  44101. case wx.FieldStatus:
  44102. return m.OldStatus(ctx)
  44103. case wx.FieldDeletedAt:
  44104. return m.OldDeletedAt(ctx)
  44105. case wx.FieldServerID:
  44106. return m.OldServerID(ctx)
  44107. case wx.FieldPort:
  44108. return m.OldPort(ctx)
  44109. case wx.FieldProcessID:
  44110. return m.OldProcessID(ctx)
  44111. case wx.FieldCallback:
  44112. return m.OldCallback(ctx)
  44113. case wx.FieldWxid:
  44114. return m.OldWxid(ctx)
  44115. case wx.FieldAccount:
  44116. return m.OldAccount(ctx)
  44117. case wx.FieldNickname:
  44118. return m.OldNickname(ctx)
  44119. case wx.FieldTel:
  44120. return m.OldTel(ctx)
  44121. case wx.FieldHeadBig:
  44122. return m.OldHeadBig(ctx)
  44123. case wx.FieldOrganizationID:
  44124. return m.OldOrganizationID(ctx)
  44125. case wx.FieldAgentID:
  44126. return m.OldAgentID(ctx)
  44127. case wx.FieldAPIBase:
  44128. return m.OldAPIBase(ctx)
  44129. case wx.FieldAPIKey:
  44130. return m.OldAPIKey(ctx)
  44131. case wx.FieldAllowList:
  44132. return m.OldAllowList(ctx)
  44133. case wx.FieldGroupAllowList:
  44134. return m.OldGroupAllowList(ctx)
  44135. case wx.FieldBlockList:
  44136. return m.OldBlockList(ctx)
  44137. case wx.FieldGroupBlockList:
  44138. return m.OldGroupBlockList(ctx)
  44139. case wx.FieldCtype:
  44140. return m.OldCtype(ctx)
  44141. }
  44142. return nil, fmt.Errorf("unknown Wx field %s", name)
  44143. }
  44144. // SetField sets the value of a field with the given name. It returns an error if
  44145. // the field is not defined in the schema, or if the type mismatched the field
  44146. // type.
  44147. func (m *WxMutation) SetField(name string, value ent.Value) error {
  44148. switch name {
  44149. case wx.FieldCreatedAt:
  44150. v, ok := value.(time.Time)
  44151. if !ok {
  44152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44153. }
  44154. m.SetCreatedAt(v)
  44155. return nil
  44156. case wx.FieldUpdatedAt:
  44157. v, ok := value.(time.Time)
  44158. if !ok {
  44159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44160. }
  44161. m.SetUpdatedAt(v)
  44162. return nil
  44163. case wx.FieldStatus:
  44164. v, ok := value.(uint8)
  44165. if !ok {
  44166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44167. }
  44168. m.SetStatus(v)
  44169. return nil
  44170. case wx.FieldDeletedAt:
  44171. v, ok := value.(time.Time)
  44172. if !ok {
  44173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44174. }
  44175. m.SetDeletedAt(v)
  44176. return nil
  44177. case wx.FieldServerID:
  44178. v, ok := value.(uint64)
  44179. if !ok {
  44180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44181. }
  44182. m.SetServerID(v)
  44183. return nil
  44184. case wx.FieldPort:
  44185. v, ok := value.(string)
  44186. if !ok {
  44187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44188. }
  44189. m.SetPort(v)
  44190. return nil
  44191. case wx.FieldProcessID:
  44192. v, ok := value.(string)
  44193. if !ok {
  44194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44195. }
  44196. m.SetProcessID(v)
  44197. return nil
  44198. case wx.FieldCallback:
  44199. v, ok := value.(string)
  44200. if !ok {
  44201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44202. }
  44203. m.SetCallback(v)
  44204. return nil
  44205. case wx.FieldWxid:
  44206. v, ok := value.(string)
  44207. if !ok {
  44208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44209. }
  44210. m.SetWxid(v)
  44211. return nil
  44212. case wx.FieldAccount:
  44213. v, ok := value.(string)
  44214. if !ok {
  44215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44216. }
  44217. m.SetAccount(v)
  44218. return nil
  44219. case wx.FieldNickname:
  44220. v, ok := value.(string)
  44221. if !ok {
  44222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44223. }
  44224. m.SetNickname(v)
  44225. return nil
  44226. case wx.FieldTel:
  44227. v, ok := value.(string)
  44228. if !ok {
  44229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44230. }
  44231. m.SetTel(v)
  44232. return nil
  44233. case wx.FieldHeadBig:
  44234. v, ok := value.(string)
  44235. if !ok {
  44236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44237. }
  44238. m.SetHeadBig(v)
  44239. return nil
  44240. case wx.FieldOrganizationID:
  44241. v, ok := value.(uint64)
  44242. if !ok {
  44243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44244. }
  44245. m.SetOrganizationID(v)
  44246. return nil
  44247. case wx.FieldAgentID:
  44248. v, ok := value.(uint64)
  44249. if !ok {
  44250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44251. }
  44252. m.SetAgentID(v)
  44253. return nil
  44254. case wx.FieldAPIBase:
  44255. v, ok := value.(string)
  44256. if !ok {
  44257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44258. }
  44259. m.SetAPIBase(v)
  44260. return nil
  44261. case wx.FieldAPIKey:
  44262. v, ok := value.(string)
  44263. if !ok {
  44264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44265. }
  44266. m.SetAPIKey(v)
  44267. return nil
  44268. case wx.FieldAllowList:
  44269. v, ok := value.([]string)
  44270. if !ok {
  44271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44272. }
  44273. m.SetAllowList(v)
  44274. return nil
  44275. case wx.FieldGroupAllowList:
  44276. v, ok := value.([]string)
  44277. if !ok {
  44278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44279. }
  44280. m.SetGroupAllowList(v)
  44281. return nil
  44282. case wx.FieldBlockList:
  44283. v, ok := value.([]string)
  44284. if !ok {
  44285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44286. }
  44287. m.SetBlockList(v)
  44288. return nil
  44289. case wx.FieldGroupBlockList:
  44290. v, ok := value.([]string)
  44291. if !ok {
  44292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44293. }
  44294. m.SetGroupBlockList(v)
  44295. return nil
  44296. case wx.FieldCtype:
  44297. v, ok := value.(uint64)
  44298. if !ok {
  44299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44300. }
  44301. m.SetCtype(v)
  44302. return nil
  44303. }
  44304. return fmt.Errorf("unknown Wx field %s", name)
  44305. }
  44306. // AddedFields returns all numeric fields that were incremented/decremented during
  44307. // this mutation.
  44308. func (m *WxMutation) AddedFields() []string {
  44309. var fields []string
  44310. if m.addstatus != nil {
  44311. fields = append(fields, wx.FieldStatus)
  44312. }
  44313. if m.addorganization_id != nil {
  44314. fields = append(fields, wx.FieldOrganizationID)
  44315. }
  44316. if m.addctype != nil {
  44317. fields = append(fields, wx.FieldCtype)
  44318. }
  44319. return fields
  44320. }
  44321. // AddedField returns the numeric value that was incremented/decremented on a field
  44322. // with the given name. The second boolean return value indicates that this field
  44323. // was not set, or was not defined in the schema.
  44324. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  44325. switch name {
  44326. case wx.FieldStatus:
  44327. return m.AddedStatus()
  44328. case wx.FieldOrganizationID:
  44329. return m.AddedOrganizationID()
  44330. case wx.FieldCtype:
  44331. return m.AddedCtype()
  44332. }
  44333. return nil, false
  44334. }
  44335. // AddField adds the value to the field with the given name. It returns an error if
  44336. // the field is not defined in the schema, or if the type mismatched the field
  44337. // type.
  44338. func (m *WxMutation) AddField(name string, value ent.Value) error {
  44339. switch name {
  44340. case wx.FieldStatus:
  44341. v, ok := value.(int8)
  44342. if !ok {
  44343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44344. }
  44345. m.AddStatus(v)
  44346. return nil
  44347. case wx.FieldOrganizationID:
  44348. v, ok := value.(int64)
  44349. if !ok {
  44350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44351. }
  44352. m.AddOrganizationID(v)
  44353. return nil
  44354. case wx.FieldCtype:
  44355. v, ok := value.(int64)
  44356. if !ok {
  44357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44358. }
  44359. m.AddCtype(v)
  44360. return nil
  44361. }
  44362. return fmt.Errorf("unknown Wx numeric field %s", name)
  44363. }
  44364. // ClearedFields returns all nullable fields that were cleared during this
  44365. // mutation.
  44366. func (m *WxMutation) ClearedFields() []string {
  44367. var fields []string
  44368. if m.FieldCleared(wx.FieldStatus) {
  44369. fields = append(fields, wx.FieldStatus)
  44370. }
  44371. if m.FieldCleared(wx.FieldDeletedAt) {
  44372. fields = append(fields, wx.FieldDeletedAt)
  44373. }
  44374. if m.FieldCleared(wx.FieldServerID) {
  44375. fields = append(fields, wx.FieldServerID)
  44376. }
  44377. if m.FieldCleared(wx.FieldOrganizationID) {
  44378. fields = append(fields, wx.FieldOrganizationID)
  44379. }
  44380. if m.FieldCleared(wx.FieldAPIBase) {
  44381. fields = append(fields, wx.FieldAPIBase)
  44382. }
  44383. if m.FieldCleared(wx.FieldAPIKey) {
  44384. fields = append(fields, wx.FieldAPIKey)
  44385. }
  44386. if m.FieldCleared(wx.FieldCtype) {
  44387. fields = append(fields, wx.FieldCtype)
  44388. }
  44389. return fields
  44390. }
  44391. // FieldCleared returns a boolean indicating if a field with the given name was
  44392. // cleared in this mutation.
  44393. func (m *WxMutation) FieldCleared(name string) bool {
  44394. _, ok := m.clearedFields[name]
  44395. return ok
  44396. }
  44397. // ClearField clears the value of the field with the given name. It returns an
  44398. // error if the field is not defined in the schema.
  44399. func (m *WxMutation) ClearField(name string) error {
  44400. switch name {
  44401. case wx.FieldStatus:
  44402. m.ClearStatus()
  44403. return nil
  44404. case wx.FieldDeletedAt:
  44405. m.ClearDeletedAt()
  44406. return nil
  44407. case wx.FieldServerID:
  44408. m.ClearServerID()
  44409. return nil
  44410. case wx.FieldOrganizationID:
  44411. m.ClearOrganizationID()
  44412. return nil
  44413. case wx.FieldAPIBase:
  44414. m.ClearAPIBase()
  44415. return nil
  44416. case wx.FieldAPIKey:
  44417. m.ClearAPIKey()
  44418. return nil
  44419. case wx.FieldCtype:
  44420. m.ClearCtype()
  44421. return nil
  44422. }
  44423. return fmt.Errorf("unknown Wx nullable field %s", name)
  44424. }
  44425. // ResetField resets all changes in the mutation for the field with the given name.
  44426. // It returns an error if the field is not defined in the schema.
  44427. func (m *WxMutation) ResetField(name string) error {
  44428. switch name {
  44429. case wx.FieldCreatedAt:
  44430. m.ResetCreatedAt()
  44431. return nil
  44432. case wx.FieldUpdatedAt:
  44433. m.ResetUpdatedAt()
  44434. return nil
  44435. case wx.FieldStatus:
  44436. m.ResetStatus()
  44437. return nil
  44438. case wx.FieldDeletedAt:
  44439. m.ResetDeletedAt()
  44440. return nil
  44441. case wx.FieldServerID:
  44442. m.ResetServerID()
  44443. return nil
  44444. case wx.FieldPort:
  44445. m.ResetPort()
  44446. return nil
  44447. case wx.FieldProcessID:
  44448. m.ResetProcessID()
  44449. return nil
  44450. case wx.FieldCallback:
  44451. m.ResetCallback()
  44452. return nil
  44453. case wx.FieldWxid:
  44454. m.ResetWxid()
  44455. return nil
  44456. case wx.FieldAccount:
  44457. m.ResetAccount()
  44458. return nil
  44459. case wx.FieldNickname:
  44460. m.ResetNickname()
  44461. return nil
  44462. case wx.FieldTel:
  44463. m.ResetTel()
  44464. return nil
  44465. case wx.FieldHeadBig:
  44466. m.ResetHeadBig()
  44467. return nil
  44468. case wx.FieldOrganizationID:
  44469. m.ResetOrganizationID()
  44470. return nil
  44471. case wx.FieldAgentID:
  44472. m.ResetAgentID()
  44473. return nil
  44474. case wx.FieldAPIBase:
  44475. m.ResetAPIBase()
  44476. return nil
  44477. case wx.FieldAPIKey:
  44478. m.ResetAPIKey()
  44479. return nil
  44480. case wx.FieldAllowList:
  44481. m.ResetAllowList()
  44482. return nil
  44483. case wx.FieldGroupAllowList:
  44484. m.ResetGroupAllowList()
  44485. return nil
  44486. case wx.FieldBlockList:
  44487. m.ResetBlockList()
  44488. return nil
  44489. case wx.FieldGroupBlockList:
  44490. m.ResetGroupBlockList()
  44491. return nil
  44492. case wx.FieldCtype:
  44493. m.ResetCtype()
  44494. return nil
  44495. }
  44496. return fmt.Errorf("unknown Wx field %s", name)
  44497. }
  44498. // AddedEdges returns all edge names that were set/added in this mutation.
  44499. func (m *WxMutation) AddedEdges() []string {
  44500. edges := make([]string, 0, 2)
  44501. if m.server != nil {
  44502. edges = append(edges, wx.EdgeServer)
  44503. }
  44504. if m.agent != nil {
  44505. edges = append(edges, wx.EdgeAgent)
  44506. }
  44507. return edges
  44508. }
  44509. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44510. // name in this mutation.
  44511. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  44512. switch name {
  44513. case wx.EdgeServer:
  44514. if id := m.server; id != nil {
  44515. return []ent.Value{*id}
  44516. }
  44517. case wx.EdgeAgent:
  44518. if id := m.agent; id != nil {
  44519. return []ent.Value{*id}
  44520. }
  44521. }
  44522. return nil
  44523. }
  44524. // RemovedEdges returns all edge names that were removed in this mutation.
  44525. func (m *WxMutation) RemovedEdges() []string {
  44526. edges := make([]string, 0, 2)
  44527. return edges
  44528. }
  44529. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44530. // the given name in this mutation.
  44531. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  44532. return nil
  44533. }
  44534. // ClearedEdges returns all edge names that were cleared in this mutation.
  44535. func (m *WxMutation) ClearedEdges() []string {
  44536. edges := make([]string, 0, 2)
  44537. if m.clearedserver {
  44538. edges = append(edges, wx.EdgeServer)
  44539. }
  44540. if m.clearedagent {
  44541. edges = append(edges, wx.EdgeAgent)
  44542. }
  44543. return edges
  44544. }
  44545. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44546. // was cleared in this mutation.
  44547. func (m *WxMutation) EdgeCleared(name string) bool {
  44548. switch name {
  44549. case wx.EdgeServer:
  44550. return m.clearedserver
  44551. case wx.EdgeAgent:
  44552. return m.clearedagent
  44553. }
  44554. return false
  44555. }
  44556. // ClearEdge clears the value of the edge with the given name. It returns an error
  44557. // if that edge is not defined in the schema.
  44558. func (m *WxMutation) ClearEdge(name string) error {
  44559. switch name {
  44560. case wx.EdgeServer:
  44561. m.ClearServer()
  44562. return nil
  44563. case wx.EdgeAgent:
  44564. m.ClearAgent()
  44565. return nil
  44566. }
  44567. return fmt.Errorf("unknown Wx unique edge %s", name)
  44568. }
  44569. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44570. // It returns an error if the edge is not defined in the schema.
  44571. func (m *WxMutation) ResetEdge(name string) error {
  44572. switch name {
  44573. case wx.EdgeServer:
  44574. m.ResetServer()
  44575. return nil
  44576. case wx.EdgeAgent:
  44577. m.ResetAgent()
  44578. return nil
  44579. }
  44580. return fmt.Errorf("unknown Wx edge %s", name)
  44581. }
  44582. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  44583. type WxCardMutation struct {
  44584. config
  44585. op Op
  44586. typ string
  44587. id *uint64
  44588. created_at *time.Time
  44589. updated_at *time.Time
  44590. deleted_at *time.Time
  44591. user_id *uint64
  44592. adduser_id *int64
  44593. wx_user_id *uint64
  44594. addwx_user_id *int64
  44595. avatar *string
  44596. logo *string
  44597. name *string
  44598. company *string
  44599. address *string
  44600. phone *string
  44601. official_account *string
  44602. wechat_account *string
  44603. email *string
  44604. api_base *string
  44605. api_key *string
  44606. ai_info *string
  44607. intro *string
  44608. clearedFields map[string]struct{}
  44609. done bool
  44610. oldValue func(context.Context) (*WxCard, error)
  44611. predicates []predicate.WxCard
  44612. }
  44613. var _ ent.Mutation = (*WxCardMutation)(nil)
  44614. // wxcardOption allows management of the mutation configuration using functional options.
  44615. type wxcardOption func(*WxCardMutation)
  44616. // newWxCardMutation creates new mutation for the WxCard entity.
  44617. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  44618. m := &WxCardMutation{
  44619. config: c,
  44620. op: op,
  44621. typ: TypeWxCard,
  44622. clearedFields: make(map[string]struct{}),
  44623. }
  44624. for _, opt := range opts {
  44625. opt(m)
  44626. }
  44627. return m
  44628. }
  44629. // withWxCardID sets the ID field of the mutation.
  44630. func withWxCardID(id uint64) wxcardOption {
  44631. return func(m *WxCardMutation) {
  44632. var (
  44633. err error
  44634. once sync.Once
  44635. value *WxCard
  44636. )
  44637. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  44638. once.Do(func() {
  44639. if m.done {
  44640. err = errors.New("querying old values post mutation is not allowed")
  44641. } else {
  44642. value, err = m.Client().WxCard.Get(ctx, id)
  44643. }
  44644. })
  44645. return value, err
  44646. }
  44647. m.id = &id
  44648. }
  44649. }
  44650. // withWxCard sets the old WxCard of the mutation.
  44651. func withWxCard(node *WxCard) wxcardOption {
  44652. return func(m *WxCardMutation) {
  44653. m.oldValue = func(context.Context) (*WxCard, error) {
  44654. return node, nil
  44655. }
  44656. m.id = &node.ID
  44657. }
  44658. }
  44659. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44660. // executed in a transaction (ent.Tx), a transactional client is returned.
  44661. func (m WxCardMutation) Client() *Client {
  44662. client := &Client{config: m.config}
  44663. client.init()
  44664. return client
  44665. }
  44666. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44667. // it returns an error otherwise.
  44668. func (m WxCardMutation) Tx() (*Tx, error) {
  44669. if _, ok := m.driver.(*txDriver); !ok {
  44670. return nil, errors.New("ent: mutation is not running in a transaction")
  44671. }
  44672. tx := &Tx{config: m.config}
  44673. tx.init()
  44674. return tx, nil
  44675. }
  44676. // SetID sets the value of the id field. Note that this
  44677. // operation is only accepted on creation of WxCard entities.
  44678. func (m *WxCardMutation) SetID(id uint64) {
  44679. m.id = &id
  44680. }
  44681. // ID returns the ID value in the mutation. Note that the ID is only available
  44682. // if it was provided to the builder or after it was returned from the database.
  44683. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  44684. if m.id == nil {
  44685. return
  44686. }
  44687. return *m.id, true
  44688. }
  44689. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44690. // That means, if the mutation is applied within a transaction with an isolation level such
  44691. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44692. // or updated by the mutation.
  44693. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  44694. switch {
  44695. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44696. id, exists := m.ID()
  44697. if exists {
  44698. return []uint64{id}, nil
  44699. }
  44700. fallthrough
  44701. case m.op.Is(OpUpdate | OpDelete):
  44702. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  44703. default:
  44704. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44705. }
  44706. }
  44707. // SetCreatedAt sets the "created_at" field.
  44708. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  44709. m.created_at = &t
  44710. }
  44711. // CreatedAt returns the value of the "created_at" field in the mutation.
  44712. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  44713. v := m.created_at
  44714. if v == nil {
  44715. return
  44716. }
  44717. return *v, true
  44718. }
  44719. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  44720. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44722. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44723. if !m.op.Is(OpUpdateOne) {
  44724. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44725. }
  44726. if m.id == nil || m.oldValue == nil {
  44727. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44728. }
  44729. oldValue, err := m.oldValue(ctx)
  44730. if err != nil {
  44731. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44732. }
  44733. return oldValue.CreatedAt, nil
  44734. }
  44735. // ResetCreatedAt resets all changes to the "created_at" field.
  44736. func (m *WxCardMutation) ResetCreatedAt() {
  44737. m.created_at = nil
  44738. }
  44739. // SetUpdatedAt sets the "updated_at" field.
  44740. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  44741. m.updated_at = &t
  44742. }
  44743. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44744. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  44745. v := m.updated_at
  44746. if v == nil {
  44747. return
  44748. }
  44749. return *v, true
  44750. }
  44751. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  44752. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44754. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44755. if !m.op.Is(OpUpdateOne) {
  44756. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44757. }
  44758. if m.id == nil || m.oldValue == nil {
  44759. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44760. }
  44761. oldValue, err := m.oldValue(ctx)
  44762. if err != nil {
  44763. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44764. }
  44765. return oldValue.UpdatedAt, nil
  44766. }
  44767. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44768. func (m *WxCardMutation) ResetUpdatedAt() {
  44769. m.updated_at = nil
  44770. }
  44771. // SetDeletedAt sets the "deleted_at" field.
  44772. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  44773. m.deleted_at = &t
  44774. }
  44775. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44776. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  44777. v := m.deleted_at
  44778. if v == nil {
  44779. return
  44780. }
  44781. return *v, true
  44782. }
  44783. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  44784. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44786. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44787. if !m.op.Is(OpUpdateOne) {
  44788. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44789. }
  44790. if m.id == nil || m.oldValue == nil {
  44791. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44792. }
  44793. oldValue, err := m.oldValue(ctx)
  44794. if err != nil {
  44795. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44796. }
  44797. return oldValue.DeletedAt, nil
  44798. }
  44799. // ClearDeletedAt clears the value of the "deleted_at" field.
  44800. func (m *WxCardMutation) ClearDeletedAt() {
  44801. m.deleted_at = nil
  44802. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  44803. }
  44804. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44805. func (m *WxCardMutation) DeletedAtCleared() bool {
  44806. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  44807. return ok
  44808. }
  44809. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44810. func (m *WxCardMutation) ResetDeletedAt() {
  44811. m.deleted_at = nil
  44812. delete(m.clearedFields, wxcard.FieldDeletedAt)
  44813. }
  44814. // SetUserID sets the "user_id" field.
  44815. func (m *WxCardMutation) SetUserID(u uint64) {
  44816. m.user_id = &u
  44817. m.adduser_id = nil
  44818. }
  44819. // UserID returns the value of the "user_id" field in the mutation.
  44820. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  44821. v := m.user_id
  44822. if v == nil {
  44823. return
  44824. }
  44825. return *v, true
  44826. }
  44827. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  44828. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44830. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  44831. if !m.op.Is(OpUpdateOne) {
  44832. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  44833. }
  44834. if m.id == nil || m.oldValue == nil {
  44835. return v, errors.New("OldUserID requires an ID field in the mutation")
  44836. }
  44837. oldValue, err := m.oldValue(ctx)
  44838. if err != nil {
  44839. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  44840. }
  44841. return oldValue.UserID, nil
  44842. }
  44843. // AddUserID adds u to the "user_id" field.
  44844. func (m *WxCardMutation) AddUserID(u int64) {
  44845. if m.adduser_id != nil {
  44846. *m.adduser_id += u
  44847. } else {
  44848. m.adduser_id = &u
  44849. }
  44850. }
  44851. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44852. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  44853. v := m.adduser_id
  44854. if v == nil {
  44855. return
  44856. }
  44857. return *v, true
  44858. }
  44859. // ClearUserID clears the value of the "user_id" field.
  44860. func (m *WxCardMutation) ClearUserID() {
  44861. m.user_id = nil
  44862. m.adduser_id = nil
  44863. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  44864. }
  44865. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44866. func (m *WxCardMutation) UserIDCleared() bool {
  44867. _, ok := m.clearedFields[wxcard.FieldUserID]
  44868. return ok
  44869. }
  44870. // ResetUserID resets all changes to the "user_id" field.
  44871. func (m *WxCardMutation) ResetUserID() {
  44872. m.user_id = nil
  44873. m.adduser_id = nil
  44874. delete(m.clearedFields, wxcard.FieldUserID)
  44875. }
  44876. // SetWxUserID sets the "wx_user_id" field.
  44877. func (m *WxCardMutation) SetWxUserID(u uint64) {
  44878. m.wx_user_id = &u
  44879. m.addwx_user_id = nil
  44880. }
  44881. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  44882. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  44883. v := m.wx_user_id
  44884. if v == nil {
  44885. return
  44886. }
  44887. return *v, true
  44888. }
  44889. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  44890. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44892. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  44893. if !m.op.Is(OpUpdateOne) {
  44894. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  44895. }
  44896. if m.id == nil || m.oldValue == nil {
  44897. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  44898. }
  44899. oldValue, err := m.oldValue(ctx)
  44900. if err != nil {
  44901. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  44902. }
  44903. return oldValue.WxUserID, nil
  44904. }
  44905. // AddWxUserID adds u to the "wx_user_id" field.
  44906. func (m *WxCardMutation) AddWxUserID(u int64) {
  44907. if m.addwx_user_id != nil {
  44908. *m.addwx_user_id += u
  44909. } else {
  44910. m.addwx_user_id = &u
  44911. }
  44912. }
  44913. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  44914. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  44915. v := m.addwx_user_id
  44916. if v == nil {
  44917. return
  44918. }
  44919. return *v, true
  44920. }
  44921. // ClearWxUserID clears the value of the "wx_user_id" field.
  44922. func (m *WxCardMutation) ClearWxUserID() {
  44923. m.wx_user_id = nil
  44924. m.addwx_user_id = nil
  44925. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  44926. }
  44927. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  44928. func (m *WxCardMutation) WxUserIDCleared() bool {
  44929. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  44930. return ok
  44931. }
  44932. // ResetWxUserID resets all changes to the "wx_user_id" field.
  44933. func (m *WxCardMutation) ResetWxUserID() {
  44934. m.wx_user_id = nil
  44935. m.addwx_user_id = nil
  44936. delete(m.clearedFields, wxcard.FieldWxUserID)
  44937. }
  44938. // SetAvatar sets the "avatar" field.
  44939. func (m *WxCardMutation) SetAvatar(s string) {
  44940. m.avatar = &s
  44941. }
  44942. // Avatar returns the value of the "avatar" field in the mutation.
  44943. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  44944. v := m.avatar
  44945. if v == nil {
  44946. return
  44947. }
  44948. return *v, true
  44949. }
  44950. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  44951. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44953. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44954. if !m.op.Is(OpUpdateOne) {
  44955. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44956. }
  44957. if m.id == nil || m.oldValue == nil {
  44958. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44959. }
  44960. oldValue, err := m.oldValue(ctx)
  44961. if err != nil {
  44962. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44963. }
  44964. return oldValue.Avatar, nil
  44965. }
  44966. // ResetAvatar resets all changes to the "avatar" field.
  44967. func (m *WxCardMutation) ResetAvatar() {
  44968. m.avatar = nil
  44969. }
  44970. // SetLogo sets the "logo" field.
  44971. func (m *WxCardMutation) SetLogo(s string) {
  44972. m.logo = &s
  44973. }
  44974. // Logo returns the value of the "logo" field in the mutation.
  44975. func (m *WxCardMutation) Logo() (r string, exists bool) {
  44976. v := m.logo
  44977. if v == nil {
  44978. return
  44979. }
  44980. return *v, true
  44981. }
  44982. // OldLogo returns the old "logo" field's value of the WxCard entity.
  44983. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44985. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  44986. if !m.op.Is(OpUpdateOne) {
  44987. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  44988. }
  44989. if m.id == nil || m.oldValue == nil {
  44990. return v, errors.New("OldLogo requires an ID field in the mutation")
  44991. }
  44992. oldValue, err := m.oldValue(ctx)
  44993. if err != nil {
  44994. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  44995. }
  44996. return oldValue.Logo, nil
  44997. }
  44998. // ResetLogo resets all changes to the "logo" field.
  44999. func (m *WxCardMutation) ResetLogo() {
  45000. m.logo = nil
  45001. }
  45002. // SetName sets the "name" field.
  45003. func (m *WxCardMutation) SetName(s string) {
  45004. m.name = &s
  45005. }
  45006. // Name returns the value of the "name" field in the mutation.
  45007. func (m *WxCardMutation) Name() (r string, exists bool) {
  45008. v := m.name
  45009. if v == nil {
  45010. return
  45011. }
  45012. return *v, true
  45013. }
  45014. // OldName returns the old "name" field's value of the WxCard entity.
  45015. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45017. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  45018. if !m.op.Is(OpUpdateOne) {
  45019. return v, errors.New("OldName is only allowed on UpdateOne operations")
  45020. }
  45021. if m.id == nil || m.oldValue == nil {
  45022. return v, errors.New("OldName requires an ID field in the mutation")
  45023. }
  45024. oldValue, err := m.oldValue(ctx)
  45025. if err != nil {
  45026. return v, fmt.Errorf("querying old value for OldName: %w", err)
  45027. }
  45028. return oldValue.Name, nil
  45029. }
  45030. // ResetName resets all changes to the "name" field.
  45031. func (m *WxCardMutation) ResetName() {
  45032. m.name = nil
  45033. }
  45034. // SetCompany sets the "company" field.
  45035. func (m *WxCardMutation) SetCompany(s string) {
  45036. m.company = &s
  45037. }
  45038. // Company returns the value of the "company" field in the mutation.
  45039. func (m *WxCardMutation) Company() (r string, exists bool) {
  45040. v := m.company
  45041. if v == nil {
  45042. return
  45043. }
  45044. return *v, true
  45045. }
  45046. // OldCompany returns the old "company" field's value of the WxCard entity.
  45047. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45049. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  45050. if !m.op.Is(OpUpdateOne) {
  45051. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  45052. }
  45053. if m.id == nil || m.oldValue == nil {
  45054. return v, errors.New("OldCompany requires an ID field in the mutation")
  45055. }
  45056. oldValue, err := m.oldValue(ctx)
  45057. if err != nil {
  45058. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  45059. }
  45060. return oldValue.Company, nil
  45061. }
  45062. // ResetCompany resets all changes to the "company" field.
  45063. func (m *WxCardMutation) ResetCompany() {
  45064. m.company = nil
  45065. }
  45066. // SetAddress sets the "address" field.
  45067. func (m *WxCardMutation) SetAddress(s string) {
  45068. m.address = &s
  45069. }
  45070. // Address returns the value of the "address" field in the mutation.
  45071. func (m *WxCardMutation) Address() (r string, exists bool) {
  45072. v := m.address
  45073. if v == nil {
  45074. return
  45075. }
  45076. return *v, true
  45077. }
  45078. // OldAddress returns the old "address" field's value of the WxCard entity.
  45079. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45081. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  45082. if !m.op.Is(OpUpdateOne) {
  45083. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  45084. }
  45085. if m.id == nil || m.oldValue == nil {
  45086. return v, errors.New("OldAddress requires an ID field in the mutation")
  45087. }
  45088. oldValue, err := m.oldValue(ctx)
  45089. if err != nil {
  45090. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  45091. }
  45092. return oldValue.Address, nil
  45093. }
  45094. // ResetAddress resets all changes to the "address" field.
  45095. func (m *WxCardMutation) ResetAddress() {
  45096. m.address = nil
  45097. }
  45098. // SetPhone sets the "phone" field.
  45099. func (m *WxCardMutation) SetPhone(s string) {
  45100. m.phone = &s
  45101. }
  45102. // Phone returns the value of the "phone" field in the mutation.
  45103. func (m *WxCardMutation) Phone() (r string, exists bool) {
  45104. v := m.phone
  45105. if v == nil {
  45106. return
  45107. }
  45108. return *v, true
  45109. }
  45110. // OldPhone returns the old "phone" field's value of the WxCard entity.
  45111. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45113. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  45114. if !m.op.Is(OpUpdateOne) {
  45115. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  45116. }
  45117. if m.id == nil || m.oldValue == nil {
  45118. return v, errors.New("OldPhone requires an ID field in the mutation")
  45119. }
  45120. oldValue, err := m.oldValue(ctx)
  45121. if err != nil {
  45122. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  45123. }
  45124. return oldValue.Phone, nil
  45125. }
  45126. // ResetPhone resets all changes to the "phone" field.
  45127. func (m *WxCardMutation) ResetPhone() {
  45128. m.phone = nil
  45129. }
  45130. // SetOfficialAccount sets the "official_account" field.
  45131. func (m *WxCardMutation) SetOfficialAccount(s string) {
  45132. m.official_account = &s
  45133. }
  45134. // OfficialAccount returns the value of the "official_account" field in the mutation.
  45135. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  45136. v := m.official_account
  45137. if v == nil {
  45138. return
  45139. }
  45140. return *v, true
  45141. }
  45142. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  45143. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45145. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  45146. if !m.op.Is(OpUpdateOne) {
  45147. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  45148. }
  45149. if m.id == nil || m.oldValue == nil {
  45150. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  45151. }
  45152. oldValue, err := m.oldValue(ctx)
  45153. if err != nil {
  45154. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  45155. }
  45156. return oldValue.OfficialAccount, nil
  45157. }
  45158. // ResetOfficialAccount resets all changes to the "official_account" field.
  45159. func (m *WxCardMutation) ResetOfficialAccount() {
  45160. m.official_account = nil
  45161. }
  45162. // SetWechatAccount sets the "wechat_account" field.
  45163. func (m *WxCardMutation) SetWechatAccount(s string) {
  45164. m.wechat_account = &s
  45165. }
  45166. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  45167. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  45168. v := m.wechat_account
  45169. if v == nil {
  45170. return
  45171. }
  45172. return *v, true
  45173. }
  45174. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  45175. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45177. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  45178. if !m.op.Is(OpUpdateOne) {
  45179. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  45180. }
  45181. if m.id == nil || m.oldValue == nil {
  45182. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  45183. }
  45184. oldValue, err := m.oldValue(ctx)
  45185. if err != nil {
  45186. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  45187. }
  45188. return oldValue.WechatAccount, nil
  45189. }
  45190. // ResetWechatAccount resets all changes to the "wechat_account" field.
  45191. func (m *WxCardMutation) ResetWechatAccount() {
  45192. m.wechat_account = nil
  45193. }
  45194. // SetEmail sets the "email" field.
  45195. func (m *WxCardMutation) SetEmail(s string) {
  45196. m.email = &s
  45197. }
  45198. // Email returns the value of the "email" field in the mutation.
  45199. func (m *WxCardMutation) Email() (r string, exists bool) {
  45200. v := m.email
  45201. if v == nil {
  45202. return
  45203. }
  45204. return *v, true
  45205. }
  45206. // OldEmail returns the old "email" field's value of the WxCard entity.
  45207. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45209. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  45210. if !m.op.Is(OpUpdateOne) {
  45211. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  45212. }
  45213. if m.id == nil || m.oldValue == nil {
  45214. return v, errors.New("OldEmail requires an ID field in the mutation")
  45215. }
  45216. oldValue, err := m.oldValue(ctx)
  45217. if err != nil {
  45218. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  45219. }
  45220. return oldValue.Email, nil
  45221. }
  45222. // ClearEmail clears the value of the "email" field.
  45223. func (m *WxCardMutation) ClearEmail() {
  45224. m.email = nil
  45225. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  45226. }
  45227. // EmailCleared returns if the "email" field was cleared in this mutation.
  45228. func (m *WxCardMutation) EmailCleared() bool {
  45229. _, ok := m.clearedFields[wxcard.FieldEmail]
  45230. return ok
  45231. }
  45232. // ResetEmail resets all changes to the "email" field.
  45233. func (m *WxCardMutation) ResetEmail() {
  45234. m.email = nil
  45235. delete(m.clearedFields, wxcard.FieldEmail)
  45236. }
  45237. // SetAPIBase sets the "api_base" field.
  45238. func (m *WxCardMutation) SetAPIBase(s string) {
  45239. m.api_base = &s
  45240. }
  45241. // APIBase returns the value of the "api_base" field in the mutation.
  45242. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  45243. v := m.api_base
  45244. if v == nil {
  45245. return
  45246. }
  45247. return *v, true
  45248. }
  45249. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  45250. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45252. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  45253. if !m.op.Is(OpUpdateOne) {
  45254. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  45255. }
  45256. if m.id == nil || m.oldValue == nil {
  45257. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  45258. }
  45259. oldValue, err := m.oldValue(ctx)
  45260. if err != nil {
  45261. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  45262. }
  45263. return oldValue.APIBase, nil
  45264. }
  45265. // ClearAPIBase clears the value of the "api_base" field.
  45266. func (m *WxCardMutation) ClearAPIBase() {
  45267. m.api_base = nil
  45268. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  45269. }
  45270. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  45271. func (m *WxCardMutation) APIBaseCleared() bool {
  45272. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  45273. return ok
  45274. }
  45275. // ResetAPIBase resets all changes to the "api_base" field.
  45276. func (m *WxCardMutation) ResetAPIBase() {
  45277. m.api_base = nil
  45278. delete(m.clearedFields, wxcard.FieldAPIBase)
  45279. }
  45280. // SetAPIKey sets the "api_key" field.
  45281. func (m *WxCardMutation) SetAPIKey(s string) {
  45282. m.api_key = &s
  45283. }
  45284. // APIKey returns the value of the "api_key" field in the mutation.
  45285. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  45286. v := m.api_key
  45287. if v == nil {
  45288. return
  45289. }
  45290. return *v, true
  45291. }
  45292. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  45293. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45295. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  45296. if !m.op.Is(OpUpdateOne) {
  45297. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  45298. }
  45299. if m.id == nil || m.oldValue == nil {
  45300. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  45301. }
  45302. oldValue, err := m.oldValue(ctx)
  45303. if err != nil {
  45304. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  45305. }
  45306. return oldValue.APIKey, nil
  45307. }
  45308. // ClearAPIKey clears the value of the "api_key" field.
  45309. func (m *WxCardMutation) ClearAPIKey() {
  45310. m.api_key = nil
  45311. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  45312. }
  45313. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  45314. func (m *WxCardMutation) APIKeyCleared() bool {
  45315. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  45316. return ok
  45317. }
  45318. // ResetAPIKey resets all changes to the "api_key" field.
  45319. func (m *WxCardMutation) ResetAPIKey() {
  45320. m.api_key = nil
  45321. delete(m.clearedFields, wxcard.FieldAPIKey)
  45322. }
  45323. // SetAiInfo sets the "ai_info" field.
  45324. func (m *WxCardMutation) SetAiInfo(s string) {
  45325. m.ai_info = &s
  45326. }
  45327. // AiInfo returns the value of the "ai_info" field in the mutation.
  45328. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  45329. v := m.ai_info
  45330. if v == nil {
  45331. return
  45332. }
  45333. return *v, true
  45334. }
  45335. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  45336. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45338. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  45339. if !m.op.Is(OpUpdateOne) {
  45340. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  45341. }
  45342. if m.id == nil || m.oldValue == nil {
  45343. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  45344. }
  45345. oldValue, err := m.oldValue(ctx)
  45346. if err != nil {
  45347. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  45348. }
  45349. return oldValue.AiInfo, nil
  45350. }
  45351. // ClearAiInfo clears the value of the "ai_info" field.
  45352. func (m *WxCardMutation) ClearAiInfo() {
  45353. m.ai_info = nil
  45354. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  45355. }
  45356. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  45357. func (m *WxCardMutation) AiInfoCleared() bool {
  45358. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  45359. return ok
  45360. }
  45361. // ResetAiInfo resets all changes to the "ai_info" field.
  45362. func (m *WxCardMutation) ResetAiInfo() {
  45363. m.ai_info = nil
  45364. delete(m.clearedFields, wxcard.FieldAiInfo)
  45365. }
  45366. // SetIntro sets the "intro" field.
  45367. func (m *WxCardMutation) SetIntro(s string) {
  45368. m.intro = &s
  45369. }
  45370. // Intro returns the value of the "intro" field in the mutation.
  45371. func (m *WxCardMutation) Intro() (r string, exists bool) {
  45372. v := m.intro
  45373. if v == nil {
  45374. return
  45375. }
  45376. return *v, true
  45377. }
  45378. // OldIntro returns the old "intro" field's value of the WxCard entity.
  45379. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45381. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  45382. if !m.op.Is(OpUpdateOne) {
  45383. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  45384. }
  45385. if m.id == nil || m.oldValue == nil {
  45386. return v, errors.New("OldIntro requires an ID field in the mutation")
  45387. }
  45388. oldValue, err := m.oldValue(ctx)
  45389. if err != nil {
  45390. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  45391. }
  45392. return oldValue.Intro, nil
  45393. }
  45394. // ClearIntro clears the value of the "intro" field.
  45395. func (m *WxCardMutation) ClearIntro() {
  45396. m.intro = nil
  45397. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  45398. }
  45399. // IntroCleared returns if the "intro" field was cleared in this mutation.
  45400. func (m *WxCardMutation) IntroCleared() bool {
  45401. _, ok := m.clearedFields[wxcard.FieldIntro]
  45402. return ok
  45403. }
  45404. // ResetIntro resets all changes to the "intro" field.
  45405. func (m *WxCardMutation) ResetIntro() {
  45406. m.intro = nil
  45407. delete(m.clearedFields, wxcard.FieldIntro)
  45408. }
  45409. // Where appends a list predicates to the WxCardMutation builder.
  45410. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  45411. m.predicates = append(m.predicates, ps...)
  45412. }
  45413. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  45414. // users can use type-assertion to append predicates that do not depend on any generated package.
  45415. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  45416. p := make([]predicate.WxCard, len(ps))
  45417. for i := range ps {
  45418. p[i] = ps[i]
  45419. }
  45420. m.Where(p...)
  45421. }
  45422. // Op returns the operation name.
  45423. func (m *WxCardMutation) Op() Op {
  45424. return m.op
  45425. }
  45426. // SetOp allows setting the mutation operation.
  45427. func (m *WxCardMutation) SetOp(op Op) {
  45428. m.op = op
  45429. }
  45430. // Type returns the node type of this mutation (WxCard).
  45431. func (m *WxCardMutation) Type() string {
  45432. return m.typ
  45433. }
  45434. // Fields returns all fields that were changed during this mutation. Note that in
  45435. // order to get all numeric fields that were incremented/decremented, call
  45436. // AddedFields().
  45437. func (m *WxCardMutation) Fields() []string {
  45438. fields := make([]string, 0, 18)
  45439. if m.created_at != nil {
  45440. fields = append(fields, wxcard.FieldCreatedAt)
  45441. }
  45442. if m.updated_at != nil {
  45443. fields = append(fields, wxcard.FieldUpdatedAt)
  45444. }
  45445. if m.deleted_at != nil {
  45446. fields = append(fields, wxcard.FieldDeletedAt)
  45447. }
  45448. if m.user_id != nil {
  45449. fields = append(fields, wxcard.FieldUserID)
  45450. }
  45451. if m.wx_user_id != nil {
  45452. fields = append(fields, wxcard.FieldWxUserID)
  45453. }
  45454. if m.avatar != nil {
  45455. fields = append(fields, wxcard.FieldAvatar)
  45456. }
  45457. if m.logo != nil {
  45458. fields = append(fields, wxcard.FieldLogo)
  45459. }
  45460. if m.name != nil {
  45461. fields = append(fields, wxcard.FieldName)
  45462. }
  45463. if m.company != nil {
  45464. fields = append(fields, wxcard.FieldCompany)
  45465. }
  45466. if m.address != nil {
  45467. fields = append(fields, wxcard.FieldAddress)
  45468. }
  45469. if m.phone != nil {
  45470. fields = append(fields, wxcard.FieldPhone)
  45471. }
  45472. if m.official_account != nil {
  45473. fields = append(fields, wxcard.FieldOfficialAccount)
  45474. }
  45475. if m.wechat_account != nil {
  45476. fields = append(fields, wxcard.FieldWechatAccount)
  45477. }
  45478. if m.email != nil {
  45479. fields = append(fields, wxcard.FieldEmail)
  45480. }
  45481. if m.api_base != nil {
  45482. fields = append(fields, wxcard.FieldAPIBase)
  45483. }
  45484. if m.api_key != nil {
  45485. fields = append(fields, wxcard.FieldAPIKey)
  45486. }
  45487. if m.ai_info != nil {
  45488. fields = append(fields, wxcard.FieldAiInfo)
  45489. }
  45490. if m.intro != nil {
  45491. fields = append(fields, wxcard.FieldIntro)
  45492. }
  45493. return fields
  45494. }
  45495. // Field returns the value of a field with the given name. The second boolean
  45496. // return value indicates that this field was not set, or was not defined in the
  45497. // schema.
  45498. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  45499. switch name {
  45500. case wxcard.FieldCreatedAt:
  45501. return m.CreatedAt()
  45502. case wxcard.FieldUpdatedAt:
  45503. return m.UpdatedAt()
  45504. case wxcard.FieldDeletedAt:
  45505. return m.DeletedAt()
  45506. case wxcard.FieldUserID:
  45507. return m.UserID()
  45508. case wxcard.FieldWxUserID:
  45509. return m.WxUserID()
  45510. case wxcard.FieldAvatar:
  45511. return m.Avatar()
  45512. case wxcard.FieldLogo:
  45513. return m.Logo()
  45514. case wxcard.FieldName:
  45515. return m.Name()
  45516. case wxcard.FieldCompany:
  45517. return m.Company()
  45518. case wxcard.FieldAddress:
  45519. return m.Address()
  45520. case wxcard.FieldPhone:
  45521. return m.Phone()
  45522. case wxcard.FieldOfficialAccount:
  45523. return m.OfficialAccount()
  45524. case wxcard.FieldWechatAccount:
  45525. return m.WechatAccount()
  45526. case wxcard.FieldEmail:
  45527. return m.Email()
  45528. case wxcard.FieldAPIBase:
  45529. return m.APIBase()
  45530. case wxcard.FieldAPIKey:
  45531. return m.APIKey()
  45532. case wxcard.FieldAiInfo:
  45533. return m.AiInfo()
  45534. case wxcard.FieldIntro:
  45535. return m.Intro()
  45536. }
  45537. return nil, false
  45538. }
  45539. // OldField returns the old value of the field from the database. An error is
  45540. // returned if the mutation operation is not UpdateOne, or the query to the
  45541. // database failed.
  45542. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45543. switch name {
  45544. case wxcard.FieldCreatedAt:
  45545. return m.OldCreatedAt(ctx)
  45546. case wxcard.FieldUpdatedAt:
  45547. return m.OldUpdatedAt(ctx)
  45548. case wxcard.FieldDeletedAt:
  45549. return m.OldDeletedAt(ctx)
  45550. case wxcard.FieldUserID:
  45551. return m.OldUserID(ctx)
  45552. case wxcard.FieldWxUserID:
  45553. return m.OldWxUserID(ctx)
  45554. case wxcard.FieldAvatar:
  45555. return m.OldAvatar(ctx)
  45556. case wxcard.FieldLogo:
  45557. return m.OldLogo(ctx)
  45558. case wxcard.FieldName:
  45559. return m.OldName(ctx)
  45560. case wxcard.FieldCompany:
  45561. return m.OldCompany(ctx)
  45562. case wxcard.FieldAddress:
  45563. return m.OldAddress(ctx)
  45564. case wxcard.FieldPhone:
  45565. return m.OldPhone(ctx)
  45566. case wxcard.FieldOfficialAccount:
  45567. return m.OldOfficialAccount(ctx)
  45568. case wxcard.FieldWechatAccount:
  45569. return m.OldWechatAccount(ctx)
  45570. case wxcard.FieldEmail:
  45571. return m.OldEmail(ctx)
  45572. case wxcard.FieldAPIBase:
  45573. return m.OldAPIBase(ctx)
  45574. case wxcard.FieldAPIKey:
  45575. return m.OldAPIKey(ctx)
  45576. case wxcard.FieldAiInfo:
  45577. return m.OldAiInfo(ctx)
  45578. case wxcard.FieldIntro:
  45579. return m.OldIntro(ctx)
  45580. }
  45581. return nil, fmt.Errorf("unknown WxCard field %s", name)
  45582. }
  45583. // SetField sets the value of a field with the given name. It returns an error if
  45584. // the field is not defined in the schema, or if the type mismatched the field
  45585. // type.
  45586. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  45587. switch name {
  45588. case wxcard.FieldCreatedAt:
  45589. v, ok := value.(time.Time)
  45590. if !ok {
  45591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45592. }
  45593. m.SetCreatedAt(v)
  45594. return nil
  45595. case wxcard.FieldUpdatedAt:
  45596. v, ok := value.(time.Time)
  45597. if !ok {
  45598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45599. }
  45600. m.SetUpdatedAt(v)
  45601. return nil
  45602. case wxcard.FieldDeletedAt:
  45603. v, ok := value.(time.Time)
  45604. if !ok {
  45605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45606. }
  45607. m.SetDeletedAt(v)
  45608. return nil
  45609. case wxcard.FieldUserID:
  45610. v, ok := value.(uint64)
  45611. if !ok {
  45612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45613. }
  45614. m.SetUserID(v)
  45615. return nil
  45616. case wxcard.FieldWxUserID:
  45617. v, ok := value.(uint64)
  45618. if !ok {
  45619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45620. }
  45621. m.SetWxUserID(v)
  45622. return nil
  45623. case wxcard.FieldAvatar:
  45624. v, ok := value.(string)
  45625. if !ok {
  45626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45627. }
  45628. m.SetAvatar(v)
  45629. return nil
  45630. case wxcard.FieldLogo:
  45631. v, ok := value.(string)
  45632. if !ok {
  45633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45634. }
  45635. m.SetLogo(v)
  45636. return nil
  45637. case wxcard.FieldName:
  45638. v, ok := value.(string)
  45639. if !ok {
  45640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45641. }
  45642. m.SetName(v)
  45643. return nil
  45644. case wxcard.FieldCompany:
  45645. v, ok := value.(string)
  45646. if !ok {
  45647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45648. }
  45649. m.SetCompany(v)
  45650. return nil
  45651. case wxcard.FieldAddress:
  45652. v, ok := value.(string)
  45653. if !ok {
  45654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45655. }
  45656. m.SetAddress(v)
  45657. return nil
  45658. case wxcard.FieldPhone:
  45659. v, ok := value.(string)
  45660. if !ok {
  45661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45662. }
  45663. m.SetPhone(v)
  45664. return nil
  45665. case wxcard.FieldOfficialAccount:
  45666. v, ok := value.(string)
  45667. if !ok {
  45668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45669. }
  45670. m.SetOfficialAccount(v)
  45671. return nil
  45672. case wxcard.FieldWechatAccount:
  45673. v, ok := value.(string)
  45674. if !ok {
  45675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45676. }
  45677. m.SetWechatAccount(v)
  45678. return nil
  45679. case wxcard.FieldEmail:
  45680. v, ok := value.(string)
  45681. if !ok {
  45682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45683. }
  45684. m.SetEmail(v)
  45685. return nil
  45686. case wxcard.FieldAPIBase:
  45687. v, ok := value.(string)
  45688. if !ok {
  45689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45690. }
  45691. m.SetAPIBase(v)
  45692. return nil
  45693. case wxcard.FieldAPIKey:
  45694. v, ok := value.(string)
  45695. if !ok {
  45696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45697. }
  45698. m.SetAPIKey(v)
  45699. return nil
  45700. case wxcard.FieldAiInfo:
  45701. v, ok := value.(string)
  45702. if !ok {
  45703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45704. }
  45705. m.SetAiInfo(v)
  45706. return nil
  45707. case wxcard.FieldIntro:
  45708. v, ok := value.(string)
  45709. if !ok {
  45710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45711. }
  45712. m.SetIntro(v)
  45713. return nil
  45714. }
  45715. return fmt.Errorf("unknown WxCard field %s", name)
  45716. }
  45717. // AddedFields returns all numeric fields that were incremented/decremented during
  45718. // this mutation.
  45719. func (m *WxCardMutation) AddedFields() []string {
  45720. var fields []string
  45721. if m.adduser_id != nil {
  45722. fields = append(fields, wxcard.FieldUserID)
  45723. }
  45724. if m.addwx_user_id != nil {
  45725. fields = append(fields, wxcard.FieldWxUserID)
  45726. }
  45727. return fields
  45728. }
  45729. // AddedField returns the numeric value that was incremented/decremented on a field
  45730. // with the given name. The second boolean return value indicates that this field
  45731. // was not set, or was not defined in the schema.
  45732. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  45733. switch name {
  45734. case wxcard.FieldUserID:
  45735. return m.AddedUserID()
  45736. case wxcard.FieldWxUserID:
  45737. return m.AddedWxUserID()
  45738. }
  45739. return nil, false
  45740. }
  45741. // AddField adds the value to the field with the given name. It returns an error if
  45742. // the field is not defined in the schema, or if the type mismatched the field
  45743. // type.
  45744. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  45745. switch name {
  45746. case wxcard.FieldUserID:
  45747. v, ok := value.(int64)
  45748. if !ok {
  45749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45750. }
  45751. m.AddUserID(v)
  45752. return nil
  45753. case wxcard.FieldWxUserID:
  45754. v, ok := value.(int64)
  45755. if !ok {
  45756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45757. }
  45758. m.AddWxUserID(v)
  45759. return nil
  45760. }
  45761. return fmt.Errorf("unknown WxCard numeric field %s", name)
  45762. }
  45763. // ClearedFields returns all nullable fields that were cleared during this
  45764. // mutation.
  45765. func (m *WxCardMutation) ClearedFields() []string {
  45766. var fields []string
  45767. if m.FieldCleared(wxcard.FieldDeletedAt) {
  45768. fields = append(fields, wxcard.FieldDeletedAt)
  45769. }
  45770. if m.FieldCleared(wxcard.FieldUserID) {
  45771. fields = append(fields, wxcard.FieldUserID)
  45772. }
  45773. if m.FieldCleared(wxcard.FieldWxUserID) {
  45774. fields = append(fields, wxcard.FieldWxUserID)
  45775. }
  45776. if m.FieldCleared(wxcard.FieldEmail) {
  45777. fields = append(fields, wxcard.FieldEmail)
  45778. }
  45779. if m.FieldCleared(wxcard.FieldAPIBase) {
  45780. fields = append(fields, wxcard.FieldAPIBase)
  45781. }
  45782. if m.FieldCleared(wxcard.FieldAPIKey) {
  45783. fields = append(fields, wxcard.FieldAPIKey)
  45784. }
  45785. if m.FieldCleared(wxcard.FieldAiInfo) {
  45786. fields = append(fields, wxcard.FieldAiInfo)
  45787. }
  45788. if m.FieldCleared(wxcard.FieldIntro) {
  45789. fields = append(fields, wxcard.FieldIntro)
  45790. }
  45791. return fields
  45792. }
  45793. // FieldCleared returns a boolean indicating if a field with the given name was
  45794. // cleared in this mutation.
  45795. func (m *WxCardMutation) FieldCleared(name string) bool {
  45796. _, ok := m.clearedFields[name]
  45797. return ok
  45798. }
  45799. // ClearField clears the value of the field with the given name. It returns an
  45800. // error if the field is not defined in the schema.
  45801. func (m *WxCardMutation) ClearField(name string) error {
  45802. switch name {
  45803. case wxcard.FieldDeletedAt:
  45804. m.ClearDeletedAt()
  45805. return nil
  45806. case wxcard.FieldUserID:
  45807. m.ClearUserID()
  45808. return nil
  45809. case wxcard.FieldWxUserID:
  45810. m.ClearWxUserID()
  45811. return nil
  45812. case wxcard.FieldEmail:
  45813. m.ClearEmail()
  45814. return nil
  45815. case wxcard.FieldAPIBase:
  45816. m.ClearAPIBase()
  45817. return nil
  45818. case wxcard.FieldAPIKey:
  45819. m.ClearAPIKey()
  45820. return nil
  45821. case wxcard.FieldAiInfo:
  45822. m.ClearAiInfo()
  45823. return nil
  45824. case wxcard.FieldIntro:
  45825. m.ClearIntro()
  45826. return nil
  45827. }
  45828. return fmt.Errorf("unknown WxCard nullable field %s", name)
  45829. }
  45830. // ResetField resets all changes in the mutation for the field with the given name.
  45831. // It returns an error if the field is not defined in the schema.
  45832. func (m *WxCardMutation) ResetField(name string) error {
  45833. switch name {
  45834. case wxcard.FieldCreatedAt:
  45835. m.ResetCreatedAt()
  45836. return nil
  45837. case wxcard.FieldUpdatedAt:
  45838. m.ResetUpdatedAt()
  45839. return nil
  45840. case wxcard.FieldDeletedAt:
  45841. m.ResetDeletedAt()
  45842. return nil
  45843. case wxcard.FieldUserID:
  45844. m.ResetUserID()
  45845. return nil
  45846. case wxcard.FieldWxUserID:
  45847. m.ResetWxUserID()
  45848. return nil
  45849. case wxcard.FieldAvatar:
  45850. m.ResetAvatar()
  45851. return nil
  45852. case wxcard.FieldLogo:
  45853. m.ResetLogo()
  45854. return nil
  45855. case wxcard.FieldName:
  45856. m.ResetName()
  45857. return nil
  45858. case wxcard.FieldCompany:
  45859. m.ResetCompany()
  45860. return nil
  45861. case wxcard.FieldAddress:
  45862. m.ResetAddress()
  45863. return nil
  45864. case wxcard.FieldPhone:
  45865. m.ResetPhone()
  45866. return nil
  45867. case wxcard.FieldOfficialAccount:
  45868. m.ResetOfficialAccount()
  45869. return nil
  45870. case wxcard.FieldWechatAccount:
  45871. m.ResetWechatAccount()
  45872. return nil
  45873. case wxcard.FieldEmail:
  45874. m.ResetEmail()
  45875. return nil
  45876. case wxcard.FieldAPIBase:
  45877. m.ResetAPIBase()
  45878. return nil
  45879. case wxcard.FieldAPIKey:
  45880. m.ResetAPIKey()
  45881. return nil
  45882. case wxcard.FieldAiInfo:
  45883. m.ResetAiInfo()
  45884. return nil
  45885. case wxcard.FieldIntro:
  45886. m.ResetIntro()
  45887. return nil
  45888. }
  45889. return fmt.Errorf("unknown WxCard field %s", name)
  45890. }
  45891. // AddedEdges returns all edge names that were set/added in this mutation.
  45892. func (m *WxCardMutation) AddedEdges() []string {
  45893. edges := make([]string, 0, 0)
  45894. return edges
  45895. }
  45896. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45897. // name in this mutation.
  45898. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  45899. return nil
  45900. }
  45901. // RemovedEdges returns all edge names that were removed in this mutation.
  45902. func (m *WxCardMutation) RemovedEdges() []string {
  45903. edges := make([]string, 0, 0)
  45904. return edges
  45905. }
  45906. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45907. // the given name in this mutation.
  45908. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  45909. return nil
  45910. }
  45911. // ClearedEdges returns all edge names that were cleared in this mutation.
  45912. func (m *WxCardMutation) ClearedEdges() []string {
  45913. edges := make([]string, 0, 0)
  45914. return edges
  45915. }
  45916. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45917. // was cleared in this mutation.
  45918. func (m *WxCardMutation) EdgeCleared(name string) bool {
  45919. return false
  45920. }
  45921. // ClearEdge clears the value of the edge with the given name. It returns an error
  45922. // if that edge is not defined in the schema.
  45923. func (m *WxCardMutation) ClearEdge(name string) error {
  45924. return fmt.Errorf("unknown WxCard unique edge %s", name)
  45925. }
  45926. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45927. // It returns an error if the edge is not defined in the schema.
  45928. func (m *WxCardMutation) ResetEdge(name string) error {
  45929. return fmt.Errorf("unknown WxCard edge %s", name)
  45930. }
  45931. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  45932. type WxCardUserMutation struct {
  45933. config
  45934. op Op
  45935. typ string
  45936. id *uint64
  45937. created_at *time.Time
  45938. updated_at *time.Time
  45939. deleted_at *time.Time
  45940. wxid *string
  45941. account *string
  45942. avatar *string
  45943. nickname *string
  45944. remark *string
  45945. phone *string
  45946. open_id *string
  45947. union_id *string
  45948. session_key *string
  45949. is_vip *int
  45950. addis_vip *int
  45951. clearedFields map[string]struct{}
  45952. done bool
  45953. oldValue func(context.Context) (*WxCardUser, error)
  45954. predicates []predicate.WxCardUser
  45955. }
  45956. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  45957. // wxcarduserOption allows management of the mutation configuration using functional options.
  45958. type wxcarduserOption func(*WxCardUserMutation)
  45959. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  45960. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  45961. m := &WxCardUserMutation{
  45962. config: c,
  45963. op: op,
  45964. typ: TypeWxCardUser,
  45965. clearedFields: make(map[string]struct{}),
  45966. }
  45967. for _, opt := range opts {
  45968. opt(m)
  45969. }
  45970. return m
  45971. }
  45972. // withWxCardUserID sets the ID field of the mutation.
  45973. func withWxCardUserID(id uint64) wxcarduserOption {
  45974. return func(m *WxCardUserMutation) {
  45975. var (
  45976. err error
  45977. once sync.Once
  45978. value *WxCardUser
  45979. )
  45980. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  45981. once.Do(func() {
  45982. if m.done {
  45983. err = errors.New("querying old values post mutation is not allowed")
  45984. } else {
  45985. value, err = m.Client().WxCardUser.Get(ctx, id)
  45986. }
  45987. })
  45988. return value, err
  45989. }
  45990. m.id = &id
  45991. }
  45992. }
  45993. // withWxCardUser sets the old WxCardUser of the mutation.
  45994. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  45995. return func(m *WxCardUserMutation) {
  45996. m.oldValue = func(context.Context) (*WxCardUser, error) {
  45997. return node, nil
  45998. }
  45999. m.id = &node.ID
  46000. }
  46001. }
  46002. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46003. // executed in a transaction (ent.Tx), a transactional client is returned.
  46004. func (m WxCardUserMutation) Client() *Client {
  46005. client := &Client{config: m.config}
  46006. client.init()
  46007. return client
  46008. }
  46009. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46010. // it returns an error otherwise.
  46011. func (m WxCardUserMutation) Tx() (*Tx, error) {
  46012. if _, ok := m.driver.(*txDriver); !ok {
  46013. return nil, errors.New("ent: mutation is not running in a transaction")
  46014. }
  46015. tx := &Tx{config: m.config}
  46016. tx.init()
  46017. return tx, nil
  46018. }
  46019. // SetID sets the value of the id field. Note that this
  46020. // operation is only accepted on creation of WxCardUser entities.
  46021. func (m *WxCardUserMutation) SetID(id uint64) {
  46022. m.id = &id
  46023. }
  46024. // ID returns the ID value in the mutation. Note that the ID is only available
  46025. // if it was provided to the builder or after it was returned from the database.
  46026. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  46027. if m.id == nil {
  46028. return
  46029. }
  46030. return *m.id, true
  46031. }
  46032. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46033. // That means, if the mutation is applied within a transaction with an isolation level such
  46034. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46035. // or updated by the mutation.
  46036. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  46037. switch {
  46038. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46039. id, exists := m.ID()
  46040. if exists {
  46041. return []uint64{id}, nil
  46042. }
  46043. fallthrough
  46044. case m.op.Is(OpUpdate | OpDelete):
  46045. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  46046. default:
  46047. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46048. }
  46049. }
  46050. // SetCreatedAt sets the "created_at" field.
  46051. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  46052. m.created_at = &t
  46053. }
  46054. // CreatedAt returns the value of the "created_at" field in the mutation.
  46055. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  46056. v := m.created_at
  46057. if v == nil {
  46058. return
  46059. }
  46060. return *v, true
  46061. }
  46062. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  46063. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46065. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46066. if !m.op.Is(OpUpdateOne) {
  46067. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46068. }
  46069. if m.id == nil || m.oldValue == nil {
  46070. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46071. }
  46072. oldValue, err := m.oldValue(ctx)
  46073. if err != nil {
  46074. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46075. }
  46076. return oldValue.CreatedAt, nil
  46077. }
  46078. // ResetCreatedAt resets all changes to the "created_at" field.
  46079. func (m *WxCardUserMutation) ResetCreatedAt() {
  46080. m.created_at = nil
  46081. }
  46082. // SetUpdatedAt sets the "updated_at" field.
  46083. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  46084. m.updated_at = &t
  46085. }
  46086. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46087. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  46088. v := m.updated_at
  46089. if v == nil {
  46090. return
  46091. }
  46092. return *v, true
  46093. }
  46094. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  46095. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46097. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46098. if !m.op.Is(OpUpdateOne) {
  46099. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46100. }
  46101. if m.id == nil || m.oldValue == nil {
  46102. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46103. }
  46104. oldValue, err := m.oldValue(ctx)
  46105. if err != nil {
  46106. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46107. }
  46108. return oldValue.UpdatedAt, nil
  46109. }
  46110. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46111. func (m *WxCardUserMutation) ResetUpdatedAt() {
  46112. m.updated_at = nil
  46113. }
  46114. // SetDeletedAt sets the "deleted_at" field.
  46115. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  46116. m.deleted_at = &t
  46117. }
  46118. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46119. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  46120. v := m.deleted_at
  46121. if v == nil {
  46122. return
  46123. }
  46124. return *v, true
  46125. }
  46126. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  46127. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46129. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46130. if !m.op.Is(OpUpdateOne) {
  46131. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46132. }
  46133. if m.id == nil || m.oldValue == nil {
  46134. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46135. }
  46136. oldValue, err := m.oldValue(ctx)
  46137. if err != nil {
  46138. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46139. }
  46140. return oldValue.DeletedAt, nil
  46141. }
  46142. // ClearDeletedAt clears the value of the "deleted_at" field.
  46143. func (m *WxCardUserMutation) ClearDeletedAt() {
  46144. m.deleted_at = nil
  46145. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  46146. }
  46147. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46148. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  46149. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  46150. return ok
  46151. }
  46152. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46153. func (m *WxCardUserMutation) ResetDeletedAt() {
  46154. m.deleted_at = nil
  46155. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  46156. }
  46157. // SetWxid sets the "wxid" field.
  46158. func (m *WxCardUserMutation) SetWxid(s string) {
  46159. m.wxid = &s
  46160. }
  46161. // Wxid returns the value of the "wxid" field in the mutation.
  46162. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  46163. v := m.wxid
  46164. if v == nil {
  46165. return
  46166. }
  46167. return *v, true
  46168. }
  46169. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  46170. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46172. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  46173. if !m.op.Is(OpUpdateOne) {
  46174. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46175. }
  46176. if m.id == nil || m.oldValue == nil {
  46177. return v, errors.New("OldWxid requires an ID field in the mutation")
  46178. }
  46179. oldValue, err := m.oldValue(ctx)
  46180. if err != nil {
  46181. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46182. }
  46183. return oldValue.Wxid, nil
  46184. }
  46185. // ResetWxid resets all changes to the "wxid" field.
  46186. func (m *WxCardUserMutation) ResetWxid() {
  46187. m.wxid = nil
  46188. }
  46189. // SetAccount sets the "account" field.
  46190. func (m *WxCardUserMutation) SetAccount(s string) {
  46191. m.account = &s
  46192. }
  46193. // Account returns the value of the "account" field in the mutation.
  46194. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  46195. v := m.account
  46196. if v == nil {
  46197. return
  46198. }
  46199. return *v, true
  46200. }
  46201. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  46202. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46204. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  46205. if !m.op.Is(OpUpdateOne) {
  46206. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  46207. }
  46208. if m.id == nil || m.oldValue == nil {
  46209. return v, errors.New("OldAccount requires an ID field in the mutation")
  46210. }
  46211. oldValue, err := m.oldValue(ctx)
  46212. if err != nil {
  46213. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  46214. }
  46215. return oldValue.Account, nil
  46216. }
  46217. // ResetAccount resets all changes to the "account" field.
  46218. func (m *WxCardUserMutation) ResetAccount() {
  46219. m.account = nil
  46220. }
  46221. // SetAvatar sets the "avatar" field.
  46222. func (m *WxCardUserMutation) SetAvatar(s string) {
  46223. m.avatar = &s
  46224. }
  46225. // Avatar returns the value of the "avatar" field in the mutation.
  46226. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  46227. v := m.avatar
  46228. if v == nil {
  46229. return
  46230. }
  46231. return *v, true
  46232. }
  46233. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  46234. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46236. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46237. if !m.op.Is(OpUpdateOne) {
  46238. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46239. }
  46240. if m.id == nil || m.oldValue == nil {
  46241. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46242. }
  46243. oldValue, err := m.oldValue(ctx)
  46244. if err != nil {
  46245. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46246. }
  46247. return oldValue.Avatar, nil
  46248. }
  46249. // ResetAvatar resets all changes to the "avatar" field.
  46250. func (m *WxCardUserMutation) ResetAvatar() {
  46251. m.avatar = nil
  46252. }
  46253. // SetNickname sets the "nickname" field.
  46254. func (m *WxCardUserMutation) SetNickname(s string) {
  46255. m.nickname = &s
  46256. }
  46257. // Nickname returns the value of the "nickname" field in the mutation.
  46258. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  46259. v := m.nickname
  46260. if v == nil {
  46261. return
  46262. }
  46263. return *v, true
  46264. }
  46265. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  46266. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46268. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  46269. if !m.op.Is(OpUpdateOne) {
  46270. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46271. }
  46272. if m.id == nil || m.oldValue == nil {
  46273. return v, errors.New("OldNickname requires an ID field in the mutation")
  46274. }
  46275. oldValue, err := m.oldValue(ctx)
  46276. if err != nil {
  46277. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46278. }
  46279. return oldValue.Nickname, nil
  46280. }
  46281. // ResetNickname resets all changes to the "nickname" field.
  46282. func (m *WxCardUserMutation) ResetNickname() {
  46283. m.nickname = nil
  46284. }
  46285. // SetRemark sets the "remark" field.
  46286. func (m *WxCardUserMutation) SetRemark(s string) {
  46287. m.remark = &s
  46288. }
  46289. // Remark returns the value of the "remark" field in the mutation.
  46290. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  46291. v := m.remark
  46292. if v == nil {
  46293. return
  46294. }
  46295. return *v, true
  46296. }
  46297. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  46298. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46300. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  46301. if !m.op.Is(OpUpdateOne) {
  46302. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  46303. }
  46304. if m.id == nil || m.oldValue == nil {
  46305. return v, errors.New("OldRemark requires an ID field in the mutation")
  46306. }
  46307. oldValue, err := m.oldValue(ctx)
  46308. if err != nil {
  46309. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  46310. }
  46311. return oldValue.Remark, nil
  46312. }
  46313. // ResetRemark resets all changes to the "remark" field.
  46314. func (m *WxCardUserMutation) ResetRemark() {
  46315. m.remark = nil
  46316. }
  46317. // SetPhone sets the "phone" field.
  46318. func (m *WxCardUserMutation) SetPhone(s string) {
  46319. m.phone = &s
  46320. }
  46321. // Phone returns the value of the "phone" field in the mutation.
  46322. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  46323. v := m.phone
  46324. if v == nil {
  46325. return
  46326. }
  46327. return *v, true
  46328. }
  46329. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  46330. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46332. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  46333. if !m.op.Is(OpUpdateOne) {
  46334. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  46335. }
  46336. if m.id == nil || m.oldValue == nil {
  46337. return v, errors.New("OldPhone requires an ID field in the mutation")
  46338. }
  46339. oldValue, err := m.oldValue(ctx)
  46340. if err != nil {
  46341. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  46342. }
  46343. return oldValue.Phone, nil
  46344. }
  46345. // ResetPhone resets all changes to the "phone" field.
  46346. func (m *WxCardUserMutation) ResetPhone() {
  46347. m.phone = nil
  46348. }
  46349. // SetOpenID sets the "open_id" field.
  46350. func (m *WxCardUserMutation) SetOpenID(s string) {
  46351. m.open_id = &s
  46352. }
  46353. // OpenID returns the value of the "open_id" field in the mutation.
  46354. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  46355. v := m.open_id
  46356. if v == nil {
  46357. return
  46358. }
  46359. return *v, true
  46360. }
  46361. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  46362. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46364. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  46365. if !m.op.Is(OpUpdateOne) {
  46366. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  46367. }
  46368. if m.id == nil || m.oldValue == nil {
  46369. return v, errors.New("OldOpenID requires an ID field in the mutation")
  46370. }
  46371. oldValue, err := m.oldValue(ctx)
  46372. if err != nil {
  46373. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  46374. }
  46375. return oldValue.OpenID, nil
  46376. }
  46377. // ResetOpenID resets all changes to the "open_id" field.
  46378. func (m *WxCardUserMutation) ResetOpenID() {
  46379. m.open_id = nil
  46380. }
  46381. // SetUnionID sets the "union_id" field.
  46382. func (m *WxCardUserMutation) SetUnionID(s string) {
  46383. m.union_id = &s
  46384. }
  46385. // UnionID returns the value of the "union_id" field in the mutation.
  46386. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  46387. v := m.union_id
  46388. if v == nil {
  46389. return
  46390. }
  46391. return *v, true
  46392. }
  46393. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  46394. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46396. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  46397. if !m.op.Is(OpUpdateOne) {
  46398. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  46399. }
  46400. if m.id == nil || m.oldValue == nil {
  46401. return v, errors.New("OldUnionID requires an ID field in the mutation")
  46402. }
  46403. oldValue, err := m.oldValue(ctx)
  46404. if err != nil {
  46405. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  46406. }
  46407. return oldValue.UnionID, nil
  46408. }
  46409. // ResetUnionID resets all changes to the "union_id" field.
  46410. func (m *WxCardUserMutation) ResetUnionID() {
  46411. m.union_id = nil
  46412. }
  46413. // SetSessionKey sets the "session_key" field.
  46414. func (m *WxCardUserMutation) SetSessionKey(s string) {
  46415. m.session_key = &s
  46416. }
  46417. // SessionKey returns the value of the "session_key" field in the mutation.
  46418. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  46419. v := m.session_key
  46420. if v == nil {
  46421. return
  46422. }
  46423. return *v, true
  46424. }
  46425. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  46426. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46428. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  46429. if !m.op.Is(OpUpdateOne) {
  46430. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  46431. }
  46432. if m.id == nil || m.oldValue == nil {
  46433. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  46434. }
  46435. oldValue, err := m.oldValue(ctx)
  46436. if err != nil {
  46437. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  46438. }
  46439. return oldValue.SessionKey, nil
  46440. }
  46441. // ResetSessionKey resets all changes to the "session_key" field.
  46442. func (m *WxCardUserMutation) ResetSessionKey() {
  46443. m.session_key = nil
  46444. }
  46445. // SetIsVip sets the "is_vip" field.
  46446. func (m *WxCardUserMutation) SetIsVip(i int) {
  46447. m.is_vip = &i
  46448. m.addis_vip = nil
  46449. }
  46450. // IsVip returns the value of the "is_vip" field in the mutation.
  46451. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  46452. v := m.is_vip
  46453. if v == nil {
  46454. return
  46455. }
  46456. return *v, true
  46457. }
  46458. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  46459. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46461. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  46462. if !m.op.Is(OpUpdateOne) {
  46463. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  46464. }
  46465. if m.id == nil || m.oldValue == nil {
  46466. return v, errors.New("OldIsVip requires an ID field in the mutation")
  46467. }
  46468. oldValue, err := m.oldValue(ctx)
  46469. if err != nil {
  46470. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  46471. }
  46472. return oldValue.IsVip, nil
  46473. }
  46474. // AddIsVip adds i to the "is_vip" field.
  46475. func (m *WxCardUserMutation) AddIsVip(i int) {
  46476. if m.addis_vip != nil {
  46477. *m.addis_vip += i
  46478. } else {
  46479. m.addis_vip = &i
  46480. }
  46481. }
  46482. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  46483. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  46484. v := m.addis_vip
  46485. if v == nil {
  46486. return
  46487. }
  46488. return *v, true
  46489. }
  46490. // ResetIsVip resets all changes to the "is_vip" field.
  46491. func (m *WxCardUserMutation) ResetIsVip() {
  46492. m.is_vip = nil
  46493. m.addis_vip = nil
  46494. }
  46495. // Where appends a list predicates to the WxCardUserMutation builder.
  46496. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  46497. m.predicates = append(m.predicates, ps...)
  46498. }
  46499. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  46500. // users can use type-assertion to append predicates that do not depend on any generated package.
  46501. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  46502. p := make([]predicate.WxCardUser, len(ps))
  46503. for i := range ps {
  46504. p[i] = ps[i]
  46505. }
  46506. m.Where(p...)
  46507. }
  46508. // Op returns the operation name.
  46509. func (m *WxCardUserMutation) Op() Op {
  46510. return m.op
  46511. }
  46512. // SetOp allows setting the mutation operation.
  46513. func (m *WxCardUserMutation) SetOp(op Op) {
  46514. m.op = op
  46515. }
  46516. // Type returns the node type of this mutation (WxCardUser).
  46517. func (m *WxCardUserMutation) Type() string {
  46518. return m.typ
  46519. }
  46520. // Fields returns all fields that were changed during this mutation. Note that in
  46521. // order to get all numeric fields that were incremented/decremented, call
  46522. // AddedFields().
  46523. func (m *WxCardUserMutation) Fields() []string {
  46524. fields := make([]string, 0, 13)
  46525. if m.created_at != nil {
  46526. fields = append(fields, wxcarduser.FieldCreatedAt)
  46527. }
  46528. if m.updated_at != nil {
  46529. fields = append(fields, wxcarduser.FieldUpdatedAt)
  46530. }
  46531. if m.deleted_at != nil {
  46532. fields = append(fields, wxcarduser.FieldDeletedAt)
  46533. }
  46534. if m.wxid != nil {
  46535. fields = append(fields, wxcarduser.FieldWxid)
  46536. }
  46537. if m.account != nil {
  46538. fields = append(fields, wxcarduser.FieldAccount)
  46539. }
  46540. if m.avatar != nil {
  46541. fields = append(fields, wxcarduser.FieldAvatar)
  46542. }
  46543. if m.nickname != nil {
  46544. fields = append(fields, wxcarduser.FieldNickname)
  46545. }
  46546. if m.remark != nil {
  46547. fields = append(fields, wxcarduser.FieldRemark)
  46548. }
  46549. if m.phone != nil {
  46550. fields = append(fields, wxcarduser.FieldPhone)
  46551. }
  46552. if m.open_id != nil {
  46553. fields = append(fields, wxcarduser.FieldOpenID)
  46554. }
  46555. if m.union_id != nil {
  46556. fields = append(fields, wxcarduser.FieldUnionID)
  46557. }
  46558. if m.session_key != nil {
  46559. fields = append(fields, wxcarduser.FieldSessionKey)
  46560. }
  46561. if m.is_vip != nil {
  46562. fields = append(fields, wxcarduser.FieldIsVip)
  46563. }
  46564. return fields
  46565. }
  46566. // Field returns the value of a field with the given name. The second boolean
  46567. // return value indicates that this field was not set, or was not defined in the
  46568. // schema.
  46569. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  46570. switch name {
  46571. case wxcarduser.FieldCreatedAt:
  46572. return m.CreatedAt()
  46573. case wxcarduser.FieldUpdatedAt:
  46574. return m.UpdatedAt()
  46575. case wxcarduser.FieldDeletedAt:
  46576. return m.DeletedAt()
  46577. case wxcarduser.FieldWxid:
  46578. return m.Wxid()
  46579. case wxcarduser.FieldAccount:
  46580. return m.Account()
  46581. case wxcarduser.FieldAvatar:
  46582. return m.Avatar()
  46583. case wxcarduser.FieldNickname:
  46584. return m.Nickname()
  46585. case wxcarduser.FieldRemark:
  46586. return m.Remark()
  46587. case wxcarduser.FieldPhone:
  46588. return m.Phone()
  46589. case wxcarduser.FieldOpenID:
  46590. return m.OpenID()
  46591. case wxcarduser.FieldUnionID:
  46592. return m.UnionID()
  46593. case wxcarduser.FieldSessionKey:
  46594. return m.SessionKey()
  46595. case wxcarduser.FieldIsVip:
  46596. return m.IsVip()
  46597. }
  46598. return nil, false
  46599. }
  46600. // OldField returns the old value of the field from the database. An error is
  46601. // returned if the mutation operation is not UpdateOne, or the query to the
  46602. // database failed.
  46603. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46604. switch name {
  46605. case wxcarduser.FieldCreatedAt:
  46606. return m.OldCreatedAt(ctx)
  46607. case wxcarduser.FieldUpdatedAt:
  46608. return m.OldUpdatedAt(ctx)
  46609. case wxcarduser.FieldDeletedAt:
  46610. return m.OldDeletedAt(ctx)
  46611. case wxcarduser.FieldWxid:
  46612. return m.OldWxid(ctx)
  46613. case wxcarduser.FieldAccount:
  46614. return m.OldAccount(ctx)
  46615. case wxcarduser.FieldAvatar:
  46616. return m.OldAvatar(ctx)
  46617. case wxcarduser.FieldNickname:
  46618. return m.OldNickname(ctx)
  46619. case wxcarduser.FieldRemark:
  46620. return m.OldRemark(ctx)
  46621. case wxcarduser.FieldPhone:
  46622. return m.OldPhone(ctx)
  46623. case wxcarduser.FieldOpenID:
  46624. return m.OldOpenID(ctx)
  46625. case wxcarduser.FieldUnionID:
  46626. return m.OldUnionID(ctx)
  46627. case wxcarduser.FieldSessionKey:
  46628. return m.OldSessionKey(ctx)
  46629. case wxcarduser.FieldIsVip:
  46630. return m.OldIsVip(ctx)
  46631. }
  46632. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  46633. }
  46634. // SetField sets the value of a field with the given name. It returns an error if
  46635. // the field is not defined in the schema, or if the type mismatched the field
  46636. // type.
  46637. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  46638. switch name {
  46639. case wxcarduser.FieldCreatedAt:
  46640. v, ok := value.(time.Time)
  46641. if !ok {
  46642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46643. }
  46644. m.SetCreatedAt(v)
  46645. return nil
  46646. case wxcarduser.FieldUpdatedAt:
  46647. v, ok := value.(time.Time)
  46648. if !ok {
  46649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46650. }
  46651. m.SetUpdatedAt(v)
  46652. return nil
  46653. case wxcarduser.FieldDeletedAt:
  46654. v, ok := value.(time.Time)
  46655. if !ok {
  46656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46657. }
  46658. m.SetDeletedAt(v)
  46659. return nil
  46660. case wxcarduser.FieldWxid:
  46661. v, ok := value.(string)
  46662. if !ok {
  46663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46664. }
  46665. m.SetWxid(v)
  46666. return nil
  46667. case wxcarduser.FieldAccount:
  46668. v, ok := value.(string)
  46669. if !ok {
  46670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46671. }
  46672. m.SetAccount(v)
  46673. return nil
  46674. case wxcarduser.FieldAvatar:
  46675. v, ok := value.(string)
  46676. if !ok {
  46677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46678. }
  46679. m.SetAvatar(v)
  46680. return nil
  46681. case wxcarduser.FieldNickname:
  46682. v, ok := value.(string)
  46683. if !ok {
  46684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46685. }
  46686. m.SetNickname(v)
  46687. return nil
  46688. case wxcarduser.FieldRemark:
  46689. v, ok := value.(string)
  46690. if !ok {
  46691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46692. }
  46693. m.SetRemark(v)
  46694. return nil
  46695. case wxcarduser.FieldPhone:
  46696. v, ok := value.(string)
  46697. if !ok {
  46698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46699. }
  46700. m.SetPhone(v)
  46701. return nil
  46702. case wxcarduser.FieldOpenID:
  46703. v, ok := value.(string)
  46704. if !ok {
  46705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46706. }
  46707. m.SetOpenID(v)
  46708. return nil
  46709. case wxcarduser.FieldUnionID:
  46710. v, ok := value.(string)
  46711. if !ok {
  46712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46713. }
  46714. m.SetUnionID(v)
  46715. return nil
  46716. case wxcarduser.FieldSessionKey:
  46717. v, ok := value.(string)
  46718. if !ok {
  46719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46720. }
  46721. m.SetSessionKey(v)
  46722. return nil
  46723. case wxcarduser.FieldIsVip:
  46724. v, ok := value.(int)
  46725. if !ok {
  46726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46727. }
  46728. m.SetIsVip(v)
  46729. return nil
  46730. }
  46731. return fmt.Errorf("unknown WxCardUser field %s", name)
  46732. }
  46733. // AddedFields returns all numeric fields that were incremented/decremented during
  46734. // this mutation.
  46735. func (m *WxCardUserMutation) AddedFields() []string {
  46736. var fields []string
  46737. if m.addis_vip != nil {
  46738. fields = append(fields, wxcarduser.FieldIsVip)
  46739. }
  46740. return fields
  46741. }
  46742. // AddedField returns the numeric value that was incremented/decremented on a field
  46743. // with the given name. The second boolean return value indicates that this field
  46744. // was not set, or was not defined in the schema.
  46745. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  46746. switch name {
  46747. case wxcarduser.FieldIsVip:
  46748. return m.AddedIsVip()
  46749. }
  46750. return nil, false
  46751. }
  46752. // AddField adds the value to the field with the given name. It returns an error if
  46753. // the field is not defined in the schema, or if the type mismatched the field
  46754. // type.
  46755. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  46756. switch name {
  46757. case wxcarduser.FieldIsVip:
  46758. v, ok := value.(int)
  46759. if !ok {
  46760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46761. }
  46762. m.AddIsVip(v)
  46763. return nil
  46764. }
  46765. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  46766. }
  46767. // ClearedFields returns all nullable fields that were cleared during this
  46768. // mutation.
  46769. func (m *WxCardUserMutation) ClearedFields() []string {
  46770. var fields []string
  46771. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  46772. fields = append(fields, wxcarduser.FieldDeletedAt)
  46773. }
  46774. return fields
  46775. }
  46776. // FieldCleared returns a boolean indicating if a field with the given name was
  46777. // cleared in this mutation.
  46778. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  46779. _, ok := m.clearedFields[name]
  46780. return ok
  46781. }
  46782. // ClearField clears the value of the field with the given name. It returns an
  46783. // error if the field is not defined in the schema.
  46784. func (m *WxCardUserMutation) ClearField(name string) error {
  46785. switch name {
  46786. case wxcarduser.FieldDeletedAt:
  46787. m.ClearDeletedAt()
  46788. return nil
  46789. }
  46790. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  46791. }
  46792. // ResetField resets all changes in the mutation for the field with the given name.
  46793. // It returns an error if the field is not defined in the schema.
  46794. func (m *WxCardUserMutation) ResetField(name string) error {
  46795. switch name {
  46796. case wxcarduser.FieldCreatedAt:
  46797. m.ResetCreatedAt()
  46798. return nil
  46799. case wxcarduser.FieldUpdatedAt:
  46800. m.ResetUpdatedAt()
  46801. return nil
  46802. case wxcarduser.FieldDeletedAt:
  46803. m.ResetDeletedAt()
  46804. return nil
  46805. case wxcarduser.FieldWxid:
  46806. m.ResetWxid()
  46807. return nil
  46808. case wxcarduser.FieldAccount:
  46809. m.ResetAccount()
  46810. return nil
  46811. case wxcarduser.FieldAvatar:
  46812. m.ResetAvatar()
  46813. return nil
  46814. case wxcarduser.FieldNickname:
  46815. m.ResetNickname()
  46816. return nil
  46817. case wxcarduser.FieldRemark:
  46818. m.ResetRemark()
  46819. return nil
  46820. case wxcarduser.FieldPhone:
  46821. m.ResetPhone()
  46822. return nil
  46823. case wxcarduser.FieldOpenID:
  46824. m.ResetOpenID()
  46825. return nil
  46826. case wxcarduser.FieldUnionID:
  46827. m.ResetUnionID()
  46828. return nil
  46829. case wxcarduser.FieldSessionKey:
  46830. m.ResetSessionKey()
  46831. return nil
  46832. case wxcarduser.FieldIsVip:
  46833. m.ResetIsVip()
  46834. return nil
  46835. }
  46836. return fmt.Errorf("unknown WxCardUser field %s", name)
  46837. }
  46838. // AddedEdges returns all edge names that were set/added in this mutation.
  46839. func (m *WxCardUserMutation) AddedEdges() []string {
  46840. edges := make([]string, 0, 0)
  46841. return edges
  46842. }
  46843. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46844. // name in this mutation.
  46845. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  46846. return nil
  46847. }
  46848. // RemovedEdges returns all edge names that were removed in this mutation.
  46849. func (m *WxCardUserMutation) RemovedEdges() []string {
  46850. edges := make([]string, 0, 0)
  46851. return edges
  46852. }
  46853. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46854. // the given name in this mutation.
  46855. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  46856. return nil
  46857. }
  46858. // ClearedEdges returns all edge names that were cleared in this mutation.
  46859. func (m *WxCardUserMutation) ClearedEdges() []string {
  46860. edges := make([]string, 0, 0)
  46861. return edges
  46862. }
  46863. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46864. // was cleared in this mutation.
  46865. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  46866. return false
  46867. }
  46868. // ClearEdge clears the value of the edge with the given name. It returns an error
  46869. // if that edge is not defined in the schema.
  46870. func (m *WxCardUserMutation) ClearEdge(name string) error {
  46871. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  46872. }
  46873. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46874. // It returns an error if the edge is not defined in the schema.
  46875. func (m *WxCardUserMutation) ResetEdge(name string) error {
  46876. return fmt.Errorf("unknown WxCardUser edge %s", name)
  46877. }
  46878. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  46879. type WxCardVisitMutation struct {
  46880. config
  46881. op Op
  46882. typ string
  46883. id *uint64
  46884. created_at *time.Time
  46885. updated_at *time.Time
  46886. deleted_at *time.Time
  46887. user_id *uint64
  46888. adduser_id *int64
  46889. bot_id *uint64
  46890. addbot_id *int64
  46891. bot_type *uint8
  46892. addbot_type *int8
  46893. clearedFields map[string]struct{}
  46894. done bool
  46895. oldValue func(context.Context) (*WxCardVisit, error)
  46896. predicates []predicate.WxCardVisit
  46897. }
  46898. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  46899. // wxcardvisitOption allows management of the mutation configuration using functional options.
  46900. type wxcardvisitOption func(*WxCardVisitMutation)
  46901. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  46902. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  46903. m := &WxCardVisitMutation{
  46904. config: c,
  46905. op: op,
  46906. typ: TypeWxCardVisit,
  46907. clearedFields: make(map[string]struct{}),
  46908. }
  46909. for _, opt := range opts {
  46910. opt(m)
  46911. }
  46912. return m
  46913. }
  46914. // withWxCardVisitID sets the ID field of the mutation.
  46915. func withWxCardVisitID(id uint64) wxcardvisitOption {
  46916. return func(m *WxCardVisitMutation) {
  46917. var (
  46918. err error
  46919. once sync.Once
  46920. value *WxCardVisit
  46921. )
  46922. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  46923. once.Do(func() {
  46924. if m.done {
  46925. err = errors.New("querying old values post mutation is not allowed")
  46926. } else {
  46927. value, err = m.Client().WxCardVisit.Get(ctx, id)
  46928. }
  46929. })
  46930. return value, err
  46931. }
  46932. m.id = &id
  46933. }
  46934. }
  46935. // withWxCardVisit sets the old WxCardVisit of the mutation.
  46936. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  46937. return func(m *WxCardVisitMutation) {
  46938. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  46939. return node, nil
  46940. }
  46941. m.id = &node.ID
  46942. }
  46943. }
  46944. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46945. // executed in a transaction (ent.Tx), a transactional client is returned.
  46946. func (m WxCardVisitMutation) Client() *Client {
  46947. client := &Client{config: m.config}
  46948. client.init()
  46949. return client
  46950. }
  46951. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46952. // it returns an error otherwise.
  46953. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  46954. if _, ok := m.driver.(*txDriver); !ok {
  46955. return nil, errors.New("ent: mutation is not running in a transaction")
  46956. }
  46957. tx := &Tx{config: m.config}
  46958. tx.init()
  46959. return tx, nil
  46960. }
  46961. // SetID sets the value of the id field. Note that this
  46962. // operation is only accepted on creation of WxCardVisit entities.
  46963. func (m *WxCardVisitMutation) SetID(id uint64) {
  46964. m.id = &id
  46965. }
  46966. // ID returns the ID value in the mutation. Note that the ID is only available
  46967. // if it was provided to the builder or after it was returned from the database.
  46968. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  46969. if m.id == nil {
  46970. return
  46971. }
  46972. return *m.id, true
  46973. }
  46974. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46975. // That means, if the mutation is applied within a transaction with an isolation level such
  46976. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46977. // or updated by the mutation.
  46978. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  46979. switch {
  46980. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46981. id, exists := m.ID()
  46982. if exists {
  46983. return []uint64{id}, nil
  46984. }
  46985. fallthrough
  46986. case m.op.Is(OpUpdate | OpDelete):
  46987. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  46988. default:
  46989. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46990. }
  46991. }
  46992. // SetCreatedAt sets the "created_at" field.
  46993. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  46994. m.created_at = &t
  46995. }
  46996. // CreatedAt returns the value of the "created_at" field in the mutation.
  46997. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  46998. v := m.created_at
  46999. if v == nil {
  47000. return
  47001. }
  47002. return *v, true
  47003. }
  47004. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  47005. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47007. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47008. if !m.op.Is(OpUpdateOne) {
  47009. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47010. }
  47011. if m.id == nil || m.oldValue == nil {
  47012. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47013. }
  47014. oldValue, err := m.oldValue(ctx)
  47015. if err != nil {
  47016. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47017. }
  47018. return oldValue.CreatedAt, nil
  47019. }
  47020. // ResetCreatedAt resets all changes to the "created_at" field.
  47021. func (m *WxCardVisitMutation) ResetCreatedAt() {
  47022. m.created_at = nil
  47023. }
  47024. // SetUpdatedAt sets the "updated_at" field.
  47025. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  47026. m.updated_at = &t
  47027. }
  47028. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47029. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  47030. v := m.updated_at
  47031. if v == nil {
  47032. return
  47033. }
  47034. return *v, true
  47035. }
  47036. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  47037. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47039. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47040. if !m.op.Is(OpUpdateOne) {
  47041. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47042. }
  47043. if m.id == nil || m.oldValue == nil {
  47044. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47045. }
  47046. oldValue, err := m.oldValue(ctx)
  47047. if err != nil {
  47048. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47049. }
  47050. return oldValue.UpdatedAt, nil
  47051. }
  47052. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47053. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  47054. m.updated_at = nil
  47055. }
  47056. // SetDeletedAt sets the "deleted_at" field.
  47057. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  47058. m.deleted_at = &t
  47059. }
  47060. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47061. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  47062. v := m.deleted_at
  47063. if v == nil {
  47064. return
  47065. }
  47066. return *v, true
  47067. }
  47068. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  47069. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47071. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47072. if !m.op.Is(OpUpdateOne) {
  47073. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47074. }
  47075. if m.id == nil || m.oldValue == nil {
  47076. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47077. }
  47078. oldValue, err := m.oldValue(ctx)
  47079. if err != nil {
  47080. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47081. }
  47082. return oldValue.DeletedAt, nil
  47083. }
  47084. // ClearDeletedAt clears the value of the "deleted_at" field.
  47085. func (m *WxCardVisitMutation) ClearDeletedAt() {
  47086. m.deleted_at = nil
  47087. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  47088. }
  47089. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47090. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  47091. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  47092. return ok
  47093. }
  47094. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47095. func (m *WxCardVisitMutation) ResetDeletedAt() {
  47096. m.deleted_at = nil
  47097. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  47098. }
  47099. // SetUserID sets the "user_id" field.
  47100. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  47101. m.user_id = &u
  47102. m.adduser_id = nil
  47103. }
  47104. // UserID returns the value of the "user_id" field in the mutation.
  47105. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  47106. v := m.user_id
  47107. if v == nil {
  47108. return
  47109. }
  47110. return *v, true
  47111. }
  47112. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  47113. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47115. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  47116. if !m.op.Is(OpUpdateOne) {
  47117. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  47118. }
  47119. if m.id == nil || m.oldValue == nil {
  47120. return v, errors.New("OldUserID requires an ID field in the mutation")
  47121. }
  47122. oldValue, err := m.oldValue(ctx)
  47123. if err != nil {
  47124. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  47125. }
  47126. return oldValue.UserID, nil
  47127. }
  47128. // AddUserID adds u to the "user_id" field.
  47129. func (m *WxCardVisitMutation) AddUserID(u int64) {
  47130. if m.adduser_id != nil {
  47131. *m.adduser_id += u
  47132. } else {
  47133. m.adduser_id = &u
  47134. }
  47135. }
  47136. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  47137. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  47138. v := m.adduser_id
  47139. if v == nil {
  47140. return
  47141. }
  47142. return *v, true
  47143. }
  47144. // ClearUserID clears the value of the "user_id" field.
  47145. func (m *WxCardVisitMutation) ClearUserID() {
  47146. m.user_id = nil
  47147. m.adduser_id = nil
  47148. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  47149. }
  47150. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  47151. func (m *WxCardVisitMutation) UserIDCleared() bool {
  47152. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  47153. return ok
  47154. }
  47155. // ResetUserID resets all changes to the "user_id" field.
  47156. func (m *WxCardVisitMutation) ResetUserID() {
  47157. m.user_id = nil
  47158. m.adduser_id = nil
  47159. delete(m.clearedFields, wxcardvisit.FieldUserID)
  47160. }
  47161. // SetBotID sets the "bot_id" field.
  47162. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  47163. m.bot_id = &u
  47164. m.addbot_id = nil
  47165. }
  47166. // BotID returns the value of the "bot_id" field in the mutation.
  47167. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  47168. v := m.bot_id
  47169. if v == nil {
  47170. return
  47171. }
  47172. return *v, true
  47173. }
  47174. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  47175. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47177. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  47178. if !m.op.Is(OpUpdateOne) {
  47179. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  47180. }
  47181. if m.id == nil || m.oldValue == nil {
  47182. return v, errors.New("OldBotID requires an ID field in the mutation")
  47183. }
  47184. oldValue, err := m.oldValue(ctx)
  47185. if err != nil {
  47186. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  47187. }
  47188. return oldValue.BotID, nil
  47189. }
  47190. // AddBotID adds u to the "bot_id" field.
  47191. func (m *WxCardVisitMutation) AddBotID(u int64) {
  47192. if m.addbot_id != nil {
  47193. *m.addbot_id += u
  47194. } else {
  47195. m.addbot_id = &u
  47196. }
  47197. }
  47198. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  47199. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  47200. v := m.addbot_id
  47201. if v == nil {
  47202. return
  47203. }
  47204. return *v, true
  47205. }
  47206. // ResetBotID resets all changes to the "bot_id" field.
  47207. func (m *WxCardVisitMutation) ResetBotID() {
  47208. m.bot_id = nil
  47209. m.addbot_id = nil
  47210. }
  47211. // SetBotType sets the "bot_type" field.
  47212. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  47213. m.bot_type = &u
  47214. m.addbot_type = nil
  47215. }
  47216. // BotType returns the value of the "bot_type" field in the mutation.
  47217. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  47218. v := m.bot_type
  47219. if v == nil {
  47220. return
  47221. }
  47222. return *v, true
  47223. }
  47224. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  47225. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47227. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  47228. if !m.op.Is(OpUpdateOne) {
  47229. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  47230. }
  47231. if m.id == nil || m.oldValue == nil {
  47232. return v, errors.New("OldBotType requires an ID field in the mutation")
  47233. }
  47234. oldValue, err := m.oldValue(ctx)
  47235. if err != nil {
  47236. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  47237. }
  47238. return oldValue.BotType, nil
  47239. }
  47240. // AddBotType adds u to the "bot_type" field.
  47241. func (m *WxCardVisitMutation) AddBotType(u int8) {
  47242. if m.addbot_type != nil {
  47243. *m.addbot_type += u
  47244. } else {
  47245. m.addbot_type = &u
  47246. }
  47247. }
  47248. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  47249. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  47250. v := m.addbot_type
  47251. if v == nil {
  47252. return
  47253. }
  47254. return *v, true
  47255. }
  47256. // ResetBotType resets all changes to the "bot_type" field.
  47257. func (m *WxCardVisitMutation) ResetBotType() {
  47258. m.bot_type = nil
  47259. m.addbot_type = nil
  47260. }
  47261. // Where appends a list predicates to the WxCardVisitMutation builder.
  47262. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  47263. m.predicates = append(m.predicates, ps...)
  47264. }
  47265. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  47266. // users can use type-assertion to append predicates that do not depend on any generated package.
  47267. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  47268. p := make([]predicate.WxCardVisit, len(ps))
  47269. for i := range ps {
  47270. p[i] = ps[i]
  47271. }
  47272. m.Where(p...)
  47273. }
  47274. // Op returns the operation name.
  47275. func (m *WxCardVisitMutation) Op() Op {
  47276. return m.op
  47277. }
  47278. // SetOp allows setting the mutation operation.
  47279. func (m *WxCardVisitMutation) SetOp(op Op) {
  47280. m.op = op
  47281. }
  47282. // Type returns the node type of this mutation (WxCardVisit).
  47283. func (m *WxCardVisitMutation) Type() string {
  47284. return m.typ
  47285. }
  47286. // Fields returns all fields that were changed during this mutation. Note that in
  47287. // order to get all numeric fields that were incremented/decremented, call
  47288. // AddedFields().
  47289. func (m *WxCardVisitMutation) Fields() []string {
  47290. fields := make([]string, 0, 6)
  47291. if m.created_at != nil {
  47292. fields = append(fields, wxcardvisit.FieldCreatedAt)
  47293. }
  47294. if m.updated_at != nil {
  47295. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  47296. }
  47297. if m.deleted_at != nil {
  47298. fields = append(fields, wxcardvisit.FieldDeletedAt)
  47299. }
  47300. if m.user_id != nil {
  47301. fields = append(fields, wxcardvisit.FieldUserID)
  47302. }
  47303. if m.bot_id != nil {
  47304. fields = append(fields, wxcardvisit.FieldBotID)
  47305. }
  47306. if m.bot_type != nil {
  47307. fields = append(fields, wxcardvisit.FieldBotType)
  47308. }
  47309. return fields
  47310. }
  47311. // Field returns the value of a field with the given name. The second boolean
  47312. // return value indicates that this field was not set, or was not defined in the
  47313. // schema.
  47314. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  47315. switch name {
  47316. case wxcardvisit.FieldCreatedAt:
  47317. return m.CreatedAt()
  47318. case wxcardvisit.FieldUpdatedAt:
  47319. return m.UpdatedAt()
  47320. case wxcardvisit.FieldDeletedAt:
  47321. return m.DeletedAt()
  47322. case wxcardvisit.FieldUserID:
  47323. return m.UserID()
  47324. case wxcardvisit.FieldBotID:
  47325. return m.BotID()
  47326. case wxcardvisit.FieldBotType:
  47327. return m.BotType()
  47328. }
  47329. return nil, false
  47330. }
  47331. // OldField returns the old value of the field from the database. An error is
  47332. // returned if the mutation operation is not UpdateOne, or the query to the
  47333. // database failed.
  47334. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47335. switch name {
  47336. case wxcardvisit.FieldCreatedAt:
  47337. return m.OldCreatedAt(ctx)
  47338. case wxcardvisit.FieldUpdatedAt:
  47339. return m.OldUpdatedAt(ctx)
  47340. case wxcardvisit.FieldDeletedAt:
  47341. return m.OldDeletedAt(ctx)
  47342. case wxcardvisit.FieldUserID:
  47343. return m.OldUserID(ctx)
  47344. case wxcardvisit.FieldBotID:
  47345. return m.OldBotID(ctx)
  47346. case wxcardvisit.FieldBotType:
  47347. return m.OldBotType(ctx)
  47348. }
  47349. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  47350. }
  47351. // SetField sets the value of a field with the given name. It returns an error if
  47352. // the field is not defined in the schema, or if the type mismatched the field
  47353. // type.
  47354. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  47355. switch name {
  47356. case wxcardvisit.FieldCreatedAt:
  47357. v, ok := value.(time.Time)
  47358. if !ok {
  47359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47360. }
  47361. m.SetCreatedAt(v)
  47362. return nil
  47363. case wxcardvisit.FieldUpdatedAt:
  47364. v, ok := value.(time.Time)
  47365. if !ok {
  47366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47367. }
  47368. m.SetUpdatedAt(v)
  47369. return nil
  47370. case wxcardvisit.FieldDeletedAt:
  47371. v, ok := value.(time.Time)
  47372. if !ok {
  47373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47374. }
  47375. m.SetDeletedAt(v)
  47376. return nil
  47377. case wxcardvisit.FieldUserID:
  47378. v, ok := value.(uint64)
  47379. if !ok {
  47380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47381. }
  47382. m.SetUserID(v)
  47383. return nil
  47384. case wxcardvisit.FieldBotID:
  47385. v, ok := value.(uint64)
  47386. if !ok {
  47387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47388. }
  47389. m.SetBotID(v)
  47390. return nil
  47391. case wxcardvisit.FieldBotType:
  47392. v, ok := value.(uint8)
  47393. if !ok {
  47394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47395. }
  47396. m.SetBotType(v)
  47397. return nil
  47398. }
  47399. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47400. }
  47401. // AddedFields returns all numeric fields that were incremented/decremented during
  47402. // this mutation.
  47403. func (m *WxCardVisitMutation) AddedFields() []string {
  47404. var fields []string
  47405. if m.adduser_id != nil {
  47406. fields = append(fields, wxcardvisit.FieldUserID)
  47407. }
  47408. if m.addbot_id != nil {
  47409. fields = append(fields, wxcardvisit.FieldBotID)
  47410. }
  47411. if m.addbot_type != nil {
  47412. fields = append(fields, wxcardvisit.FieldBotType)
  47413. }
  47414. return fields
  47415. }
  47416. // AddedField returns the numeric value that was incremented/decremented on a field
  47417. // with the given name. The second boolean return value indicates that this field
  47418. // was not set, or was not defined in the schema.
  47419. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  47420. switch name {
  47421. case wxcardvisit.FieldUserID:
  47422. return m.AddedUserID()
  47423. case wxcardvisit.FieldBotID:
  47424. return m.AddedBotID()
  47425. case wxcardvisit.FieldBotType:
  47426. return m.AddedBotType()
  47427. }
  47428. return nil, false
  47429. }
  47430. // AddField adds the value to the field with the given name. It returns an error if
  47431. // the field is not defined in the schema, or if the type mismatched the field
  47432. // type.
  47433. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  47434. switch name {
  47435. case wxcardvisit.FieldUserID:
  47436. v, ok := value.(int64)
  47437. if !ok {
  47438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47439. }
  47440. m.AddUserID(v)
  47441. return nil
  47442. case wxcardvisit.FieldBotID:
  47443. v, ok := value.(int64)
  47444. if !ok {
  47445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47446. }
  47447. m.AddBotID(v)
  47448. return nil
  47449. case wxcardvisit.FieldBotType:
  47450. v, ok := value.(int8)
  47451. if !ok {
  47452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47453. }
  47454. m.AddBotType(v)
  47455. return nil
  47456. }
  47457. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  47458. }
  47459. // ClearedFields returns all nullable fields that were cleared during this
  47460. // mutation.
  47461. func (m *WxCardVisitMutation) ClearedFields() []string {
  47462. var fields []string
  47463. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  47464. fields = append(fields, wxcardvisit.FieldDeletedAt)
  47465. }
  47466. if m.FieldCleared(wxcardvisit.FieldUserID) {
  47467. fields = append(fields, wxcardvisit.FieldUserID)
  47468. }
  47469. return fields
  47470. }
  47471. // FieldCleared returns a boolean indicating if a field with the given name was
  47472. // cleared in this mutation.
  47473. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  47474. _, ok := m.clearedFields[name]
  47475. return ok
  47476. }
  47477. // ClearField clears the value of the field with the given name. It returns an
  47478. // error if the field is not defined in the schema.
  47479. func (m *WxCardVisitMutation) ClearField(name string) error {
  47480. switch name {
  47481. case wxcardvisit.FieldDeletedAt:
  47482. m.ClearDeletedAt()
  47483. return nil
  47484. case wxcardvisit.FieldUserID:
  47485. m.ClearUserID()
  47486. return nil
  47487. }
  47488. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  47489. }
  47490. // ResetField resets all changes in the mutation for the field with the given name.
  47491. // It returns an error if the field is not defined in the schema.
  47492. func (m *WxCardVisitMutation) ResetField(name string) error {
  47493. switch name {
  47494. case wxcardvisit.FieldCreatedAt:
  47495. m.ResetCreatedAt()
  47496. return nil
  47497. case wxcardvisit.FieldUpdatedAt:
  47498. m.ResetUpdatedAt()
  47499. return nil
  47500. case wxcardvisit.FieldDeletedAt:
  47501. m.ResetDeletedAt()
  47502. return nil
  47503. case wxcardvisit.FieldUserID:
  47504. m.ResetUserID()
  47505. return nil
  47506. case wxcardvisit.FieldBotID:
  47507. m.ResetBotID()
  47508. return nil
  47509. case wxcardvisit.FieldBotType:
  47510. m.ResetBotType()
  47511. return nil
  47512. }
  47513. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47514. }
  47515. // AddedEdges returns all edge names that were set/added in this mutation.
  47516. func (m *WxCardVisitMutation) AddedEdges() []string {
  47517. edges := make([]string, 0, 0)
  47518. return edges
  47519. }
  47520. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47521. // name in this mutation.
  47522. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  47523. return nil
  47524. }
  47525. // RemovedEdges returns all edge names that were removed in this mutation.
  47526. func (m *WxCardVisitMutation) RemovedEdges() []string {
  47527. edges := make([]string, 0, 0)
  47528. return edges
  47529. }
  47530. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47531. // the given name in this mutation.
  47532. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  47533. return nil
  47534. }
  47535. // ClearedEdges returns all edge names that were cleared in this mutation.
  47536. func (m *WxCardVisitMutation) ClearedEdges() []string {
  47537. edges := make([]string, 0, 0)
  47538. return edges
  47539. }
  47540. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47541. // was cleared in this mutation.
  47542. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  47543. return false
  47544. }
  47545. // ClearEdge clears the value of the edge with the given name. It returns an error
  47546. // if that edge is not defined in the schema.
  47547. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  47548. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  47549. }
  47550. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47551. // It returns an error if the edge is not defined in the schema.
  47552. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  47553. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  47554. }
  47555. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  47556. type XunjiMutation struct {
  47557. config
  47558. op Op
  47559. typ string
  47560. id *uint64
  47561. created_at *time.Time
  47562. updated_at *time.Time
  47563. status *uint8
  47564. addstatus *int8
  47565. deleted_at *time.Time
  47566. app_key *string
  47567. app_secret *string
  47568. token *string
  47569. encoding_key *string
  47570. organization_id *uint64
  47571. addorganization_id *int64
  47572. clearedFields map[string]struct{}
  47573. done bool
  47574. oldValue func(context.Context) (*Xunji, error)
  47575. predicates []predicate.Xunji
  47576. }
  47577. var _ ent.Mutation = (*XunjiMutation)(nil)
  47578. // xunjiOption allows management of the mutation configuration using functional options.
  47579. type xunjiOption func(*XunjiMutation)
  47580. // newXunjiMutation creates new mutation for the Xunji entity.
  47581. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  47582. m := &XunjiMutation{
  47583. config: c,
  47584. op: op,
  47585. typ: TypeXunji,
  47586. clearedFields: make(map[string]struct{}),
  47587. }
  47588. for _, opt := range opts {
  47589. opt(m)
  47590. }
  47591. return m
  47592. }
  47593. // withXunjiID sets the ID field of the mutation.
  47594. func withXunjiID(id uint64) xunjiOption {
  47595. return func(m *XunjiMutation) {
  47596. var (
  47597. err error
  47598. once sync.Once
  47599. value *Xunji
  47600. )
  47601. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  47602. once.Do(func() {
  47603. if m.done {
  47604. err = errors.New("querying old values post mutation is not allowed")
  47605. } else {
  47606. value, err = m.Client().Xunji.Get(ctx, id)
  47607. }
  47608. })
  47609. return value, err
  47610. }
  47611. m.id = &id
  47612. }
  47613. }
  47614. // withXunji sets the old Xunji of the mutation.
  47615. func withXunji(node *Xunji) xunjiOption {
  47616. return func(m *XunjiMutation) {
  47617. m.oldValue = func(context.Context) (*Xunji, error) {
  47618. return node, nil
  47619. }
  47620. m.id = &node.ID
  47621. }
  47622. }
  47623. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47624. // executed in a transaction (ent.Tx), a transactional client is returned.
  47625. func (m XunjiMutation) Client() *Client {
  47626. client := &Client{config: m.config}
  47627. client.init()
  47628. return client
  47629. }
  47630. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47631. // it returns an error otherwise.
  47632. func (m XunjiMutation) Tx() (*Tx, error) {
  47633. if _, ok := m.driver.(*txDriver); !ok {
  47634. return nil, errors.New("ent: mutation is not running in a transaction")
  47635. }
  47636. tx := &Tx{config: m.config}
  47637. tx.init()
  47638. return tx, nil
  47639. }
  47640. // SetID sets the value of the id field. Note that this
  47641. // operation is only accepted on creation of Xunji entities.
  47642. func (m *XunjiMutation) SetID(id uint64) {
  47643. m.id = &id
  47644. }
  47645. // ID returns the ID value in the mutation. Note that the ID is only available
  47646. // if it was provided to the builder or after it was returned from the database.
  47647. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  47648. if m.id == nil {
  47649. return
  47650. }
  47651. return *m.id, true
  47652. }
  47653. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47654. // That means, if the mutation is applied within a transaction with an isolation level such
  47655. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47656. // or updated by the mutation.
  47657. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  47658. switch {
  47659. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47660. id, exists := m.ID()
  47661. if exists {
  47662. return []uint64{id}, nil
  47663. }
  47664. fallthrough
  47665. case m.op.Is(OpUpdate | OpDelete):
  47666. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  47667. default:
  47668. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47669. }
  47670. }
  47671. // SetCreatedAt sets the "created_at" field.
  47672. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  47673. m.created_at = &t
  47674. }
  47675. // CreatedAt returns the value of the "created_at" field in the mutation.
  47676. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  47677. v := m.created_at
  47678. if v == nil {
  47679. return
  47680. }
  47681. return *v, true
  47682. }
  47683. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  47684. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47686. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47687. if !m.op.Is(OpUpdateOne) {
  47688. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47689. }
  47690. if m.id == nil || m.oldValue == nil {
  47691. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47692. }
  47693. oldValue, err := m.oldValue(ctx)
  47694. if err != nil {
  47695. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47696. }
  47697. return oldValue.CreatedAt, nil
  47698. }
  47699. // ResetCreatedAt resets all changes to the "created_at" field.
  47700. func (m *XunjiMutation) ResetCreatedAt() {
  47701. m.created_at = nil
  47702. }
  47703. // SetUpdatedAt sets the "updated_at" field.
  47704. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  47705. m.updated_at = &t
  47706. }
  47707. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47708. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  47709. v := m.updated_at
  47710. if v == nil {
  47711. return
  47712. }
  47713. return *v, true
  47714. }
  47715. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  47716. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47718. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47719. if !m.op.Is(OpUpdateOne) {
  47720. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47721. }
  47722. if m.id == nil || m.oldValue == nil {
  47723. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47724. }
  47725. oldValue, err := m.oldValue(ctx)
  47726. if err != nil {
  47727. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47728. }
  47729. return oldValue.UpdatedAt, nil
  47730. }
  47731. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47732. func (m *XunjiMutation) ResetUpdatedAt() {
  47733. m.updated_at = nil
  47734. }
  47735. // SetStatus sets the "status" field.
  47736. func (m *XunjiMutation) SetStatus(u uint8) {
  47737. m.status = &u
  47738. m.addstatus = nil
  47739. }
  47740. // Status returns the value of the "status" field in the mutation.
  47741. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  47742. v := m.status
  47743. if v == nil {
  47744. return
  47745. }
  47746. return *v, true
  47747. }
  47748. // OldStatus returns the old "status" field's value of the Xunji entity.
  47749. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47751. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  47752. if !m.op.Is(OpUpdateOne) {
  47753. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  47754. }
  47755. if m.id == nil || m.oldValue == nil {
  47756. return v, errors.New("OldStatus requires an ID field in the mutation")
  47757. }
  47758. oldValue, err := m.oldValue(ctx)
  47759. if err != nil {
  47760. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  47761. }
  47762. return oldValue.Status, nil
  47763. }
  47764. // AddStatus adds u to the "status" field.
  47765. func (m *XunjiMutation) AddStatus(u int8) {
  47766. if m.addstatus != nil {
  47767. *m.addstatus += u
  47768. } else {
  47769. m.addstatus = &u
  47770. }
  47771. }
  47772. // AddedStatus returns the value that was added to the "status" field in this mutation.
  47773. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  47774. v := m.addstatus
  47775. if v == nil {
  47776. return
  47777. }
  47778. return *v, true
  47779. }
  47780. // ClearStatus clears the value of the "status" field.
  47781. func (m *XunjiMutation) ClearStatus() {
  47782. m.status = nil
  47783. m.addstatus = nil
  47784. m.clearedFields[xunji.FieldStatus] = struct{}{}
  47785. }
  47786. // StatusCleared returns if the "status" field was cleared in this mutation.
  47787. func (m *XunjiMutation) StatusCleared() bool {
  47788. _, ok := m.clearedFields[xunji.FieldStatus]
  47789. return ok
  47790. }
  47791. // ResetStatus resets all changes to the "status" field.
  47792. func (m *XunjiMutation) ResetStatus() {
  47793. m.status = nil
  47794. m.addstatus = nil
  47795. delete(m.clearedFields, xunji.FieldStatus)
  47796. }
  47797. // SetDeletedAt sets the "deleted_at" field.
  47798. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  47799. m.deleted_at = &t
  47800. }
  47801. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47802. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  47803. v := m.deleted_at
  47804. if v == nil {
  47805. return
  47806. }
  47807. return *v, true
  47808. }
  47809. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  47810. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47812. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47813. if !m.op.Is(OpUpdateOne) {
  47814. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47815. }
  47816. if m.id == nil || m.oldValue == nil {
  47817. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47818. }
  47819. oldValue, err := m.oldValue(ctx)
  47820. if err != nil {
  47821. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47822. }
  47823. return oldValue.DeletedAt, nil
  47824. }
  47825. // ClearDeletedAt clears the value of the "deleted_at" field.
  47826. func (m *XunjiMutation) ClearDeletedAt() {
  47827. m.deleted_at = nil
  47828. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  47829. }
  47830. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47831. func (m *XunjiMutation) DeletedAtCleared() bool {
  47832. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  47833. return ok
  47834. }
  47835. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47836. func (m *XunjiMutation) ResetDeletedAt() {
  47837. m.deleted_at = nil
  47838. delete(m.clearedFields, xunji.FieldDeletedAt)
  47839. }
  47840. // SetAppKey sets the "app_key" field.
  47841. func (m *XunjiMutation) SetAppKey(s string) {
  47842. m.app_key = &s
  47843. }
  47844. // AppKey returns the value of the "app_key" field in the mutation.
  47845. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  47846. v := m.app_key
  47847. if v == nil {
  47848. return
  47849. }
  47850. return *v, true
  47851. }
  47852. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  47853. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47855. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  47856. if !m.op.Is(OpUpdateOne) {
  47857. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  47858. }
  47859. if m.id == nil || m.oldValue == nil {
  47860. return v, errors.New("OldAppKey requires an ID field in the mutation")
  47861. }
  47862. oldValue, err := m.oldValue(ctx)
  47863. if err != nil {
  47864. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  47865. }
  47866. return oldValue.AppKey, nil
  47867. }
  47868. // ClearAppKey clears the value of the "app_key" field.
  47869. func (m *XunjiMutation) ClearAppKey() {
  47870. m.app_key = nil
  47871. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  47872. }
  47873. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  47874. func (m *XunjiMutation) AppKeyCleared() bool {
  47875. _, ok := m.clearedFields[xunji.FieldAppKey]
  47876. return ok
  47877. }
  47878. // ResetAppKey resets all changes to the "app_key" field.
  47879. func (m *XunjiMutation) ResetAppKey() {
  47880. m.app_key = nil
  47881. delete(m.clearedFields, xunji.FieldAppKey)
  47882. }
  47883. // SetAppSecret sets the "app_secret" field.
  47884. func (m *XunjiMutation) SetAppSecret(s string) {
  47885. m.app_secret = &s
  47886. }
  47887. // AppSecret returns the value of the "app_secret" field in the mutation.
  47888. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  47889. v := m.app_secret
  47890. if v == nil {
  47891. return
  47892. }
  47893. return *v, true
  47894. }
  47895. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  47896. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47898. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  47899. if !m.op.Is(OpUpdateOne) {
  47900. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  47901. }
  47902. if m.id == nil || m.oldValue == nil {
  47903. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  47904. }
  47905. oldValue, err := m.oldValue(ctx)
  47906. if err != nil {
  47907. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  47908. }
  47909. return oldValue.AppSecret, nil
  47910. }
  47911. // ClearAppSecret clears the value of the "app_secret" field.
  47912. func (m *XunjiMutation) ClearAppSecret() {
  47913. m.app_secret = nil
  47914. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  47915. }
  47916. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  47917. func (m *XunjiMutation) AppSecretCleared() bool {
  47918. _, ok := m.clearedFields[xunji.FieldAppSecret]
  47919. return ok
  47920. }
  47921. // ResetAppSecret resets all changes to the "app_secret" field.
  47922. func (m *XunjiMutation) ResetAppSecret() {
  47923. m.app_secret = nil
  47924. delete(m.clearedFields, xunji.FieldAppSecret)
  47925. }
  47926. // SetToken sets the "token" field.
  47927. func (m *XunjiMutation) SetToken(s string) {
  47928. m.token = &s
  47929. }
  47930. // Token returns the value of the "token" field in the mutation.
  47931. func (m *XunjiMutation) Token() (r string, exists bool) {
  47932. v := m.token
  47933. if v == nil {
  47934. return
  47935. }
  47936. return *v, true
  47937. }
  47938. // OldToken returns the old "token" field's value of the Xunji entity.
  47939. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47941. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  47942. if !m.op.Is(OpUpdateOne) {
  47943. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  47944. }
  47945. if m.id == nil || m.oldValue == nil {
  47946. return v, errors.New("OldToken requires an ID field in the mutation")
  47947. }
  47948. oldValue, err := m.oldValue(ctx)
  47949. if err != nil {
  47950. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  47951. }
  47952. return oldValue.Token, nil
  47953. }
  47954. // ClearToken clears the value of the "token" field.
  47955. func (m *XunjiMutation) ClearToken() {
  47956. m.token = nil
  47957. m.clearedFields[xunji.FieldToken] = struct{}{}
  47958. }
  47959. // TokenCleared returns if the "token" field was cleared in this mutation.
  47960. func (m *XunjiMutation) TokenCleared() bool {
  47961. _, ok := m.clearedFields[xunji.FieldToken]
  47962. return ok
  47963. }
  47964. // ResetToken resets all changes to the "token" field.
  47965. func (m *XunjiMutation) ResetToken() {
  47966. m.token = nil
  47967. delete(m.clearedFields, xunji.FieldToken)
  47968. }
  47969. // SetEncodingKey sets the "encoding_key" field.
  47970. func (m *XunjiMutation) SetEncodingKey(s string) {
  47971. m.encoding_key = &s
  47972. }
  47973. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  47974. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  47975. v := m.encoding_key
  47976. if v == nil {
  47977. return
  47978. }
  47979. return *v, true
  47980. }
  47981. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  47982. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47984. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  47985. if !m.op.Is(OpUpdateOne) {
  47986. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  47987. }
  47988. if m.id == nil || m.oldValue == nil {
  47989. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  47990. }
  47991. oldValue, err := m.oldValue(ctx)
  47992. if err != nil {
  47993. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  47994. }
  47995. return oldValue.EncodingKey, nil
  47996. }
  47997. // ClearEncodingKey clears the value of the "encoding_key" field.
  47998. func (m *XunjiMutation) ClearEncodingKey() {
  47999. m.encoding_key = nil
  48000. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  48001. }
  48002. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  48003. func (m *XunjiMutation) EncodingKeyCleared() bool {
  48004. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  48005. return ok
  48006. }
  48007. // ResetEncodingKey resets all changes to the "encoding_key" field.
  48008. func (m *XunjiMutation) ResetEncodingKey() {
  48009. m.encoding_key = nil
  48010. delete(m.clearedFields, xunji.FieldEncodingKey)
  48011. }
  48012. // SetOrganizationID sets the "organization_id" field.
  48013. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  48014. m.organization_id = &u
  48015. m.addorganization_id = nil
  48016. }
  48017. // OrganizationID returns the value of the "organization_id" field in the mutation.
  48018. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  48019. v := m.organization_id
  48020. if v == nil {
  48021. return
  48022. }
  48023. return *v, true
  48024. }
  48025. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  48026. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48028. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  48029. if !m.op.Is(OpUpdateOne) {
  48030. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  48031. }
  48032. if m.id == nil || m.oldValue == nil {
  48033. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  48034. }
  48035. oldValue, err := m.oldValue(ctx)
  48036. if err != nil {
  48037. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  48038. }
  48039. return oldValue.OrganizationID, nil
  48040. }
  48041. // AddOrganizationID adds u to the "organization_id" field.
  48042. func (m *XunjiMutation) AddOrganizationID(u int64) {
  48043. if m.addorganization_id != nil {
  48044. *m.addorganization_id += u
  48045. } else {
  48046. m.addorganization_id = &u
  48047. }
  48048. }
  48049. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  48050. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  48051. v := m.addorganization_id
  48052. if v == nil {
  48053. return
  48054. }
  48055. return *v, true
  48056. }
  48057. // ResetOrganizationID resets all changes to the "organization_id" field.
  48058. func (m *XunjiMutation) ResetOrganizationID() {
  48059. m.organization_id = nil
  48060. m.addorganization_id = nil
  48061. }
  48062. // Where appends a list predicates to the XunjiMutation builder.
  48063. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  48064. m.predicates = append(m.predicates, ps...)
  48065. }
  48066. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  48067. // users can use type-assertion to append predicates that do not depend on any generated package.
  48068. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  48069. p := make([]predicate.Xunji, len(ps))
  48070. for i := range ps {
  48071. p[i] = ps[i]
  48072. }
  48073. m.Where(p...)
  48074. }
  48075. // Op returns the operation name.
  48076. func (m *XunjiMutation) Op() Op {
  48077. return m.op
  48078. }
  48079. // SetOp allows setting the mutation operation.
  48080. func (m *XunjiMutation) SetOp(op Op) {
  48081. m.op = op
  48082. }
  48083. // Type returns the node type of this mutation (Xunji).
  48084. func (m *XunjiMutation) Type() string {
  48085. return m.typ
  48086. }
  48087. // Fields returns all fields that were changed during this mutation. Note that in
  48088. // order to get all numeric fields that were incremented/decremented, call
  48089. // AddedFields().
  48090. func (m *XunjiMutation) Fields() []string {
  48091. fields := make([]string, 0, 9)
  48092. if m.created_at != nil {
  48093. fields = append(fields, xunji.FieldCreatedAt)
  48094. }
  48095. if m.updated_at != nil {
  48096. fields = append(fields, xunji.FieldUpdatedAt)
  48097. }
  48098. if m.status != nil {
  48099. fields = append(fields, xunji.FieldStatus)
  48100. }
  48101. if m.deleted_at != nil {
  48102. fields = append(fields, xunji.FieldDeletedAt)
  48103. }
  48104. if m.app_key != nil {
  48105. fields = append(fields, xunji.FieldAppKey)
  48106. }
  48107. if m.app_secret != nil {
  48108. fields = append(fields, xunji.FieldAppSecret)
  48109. }
  48110. if m.token != nil {
  48111. fields = append(fields, xunji.FieldToken)
  48112. }
  48113. if m.encoding_key != nil {
  48114. fields = append(fields, xunji.FieldEncodingKey)
  48115. }
  48116. if m.organization_id != nil {
  48117. fields = append(fields, xunji.FieldOrganizationID)
  48118. }
  48119. return fields
  48120. }
  48121. // Field returns the value of a field with the given name. The second boolean
  48122. // return value indicates that this field was not set, or was not defined in the
  48123. // schema.
  48124. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  48125. switch name {
  48126. case xunji.FieldCreatedAt:
  48127. return m.CreatedAt()
  48128. case xunji.FieldUpdatedAt:
  48129. return m.UpdatedAt()
  48130. case xunji.FieldStatus:
  48131. return m.Status()
  48132. case xunji.FieldDeletedAt:
  48133. return m.DeletedAt()
  48134. case xunji.FieldAppKey:
  48135. return m.AppKey()
  48136. case xunji.FieldAppSecret:
  48137. return m.AppSecret()
  48138. case xunji.FieldToken:
  48139. return m.Token()
  48140. case xunji.FieldEncodingKey:
  48141. return m.EncodingKey()
  48142. case xunji.FieldOrganizationID:
  48143. return m.OrganizationID()
  48144. }
  48145. return nil, false
  48146. }
  48147. // OldField returns the old value of the field from the database. An error is
  48148. // returned if the mutation operation is not UpdateOne, or the query to the
  48149. // database failed.
  48150. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48151. switch name {
  48152. case xunji.FieldCreatedAt:
  48153. return m.OldCreatedAt(ctx)
  48154. case xunji.FieldUpdatedAt:
  48155. return m.OldUpdatedAt(ctx)
  48156. case xunji.FieldStatus:
  48157. return m.OldStatus(ctx)
  48158. case xunji.FieldDeletedAt:
  48159. return m.OldDeletedAt(ctx)
  48160. case xunji.FieldAppKey:
  48161. return m.OldAppKey(ctx)
  48162. case xunji.FieldAppSecret:
  48163. return m.OldAppSecret(ctx)
  48164. case xunji.FieldToken:
  48165. return m.OldToken(ctx)
  48166. case xunji.FieldEncodingKey:
  48167. return m.OldEncodingKey(ctx)
  48168. case xunji.FieldOrganizationID:
  48169. return m.OldOrganizationID(ctx)
  48170. }
  48171. return nil, fmt.Errorf("unknown Xunji field %s", name)
  48172. }
  48173. // SetField sets the value of a field with the given name. It returns an error if
  48174. // the field is not defined in the schema, or if the type mismatched the field
  48175. // type.
  48176. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  48177. switch name {
  48178. case xunji.FieldCreatedAt:
  48179. v, ok := value.(time.Time)
  48180. if !ok {
  48181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48182. }
  48183. m.SetCreatedAt(v)
  48184. return nil
  48185. case xunji.FieldUpdatedAt:
  48186. v, ok := value.(time.Time)
  48187. if !ok {
  48188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48189. }
  48190. m.SetUpdatedAt(v)
  48191. return nil
  48192. case xunji.FieldStatus:
  48193. v, ok := value.(uint8)
  48194. if !ok {
  48195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48196. }
  48197. m.SetStatus(v)
  48198. return nil
  48199. case xunji.FieldDeletedAt:
  48200. v, ok := value.(time.Time)
  48201. if !ok {
  48202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48203. }
  48204. m.SetDeletedAt(v)
  48205. return nil
  48206. case xunji.FieldAppKey:
  48207. v, ok := value.(string)
  48208. if !ok {
  48209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48210. }
  48211. m.SetAppKey(v)
  48212. return nil
  48213. case xunji.FieldAppSecret:
  48214. v, ok := value.(string)
  48215. if !ok {
  48216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48217. }
  48218. m.SetAppSecret(v)
  48219. return nil
  48220. case xunji.FieldToken:
  48221. v, ok := value.(string)
  48222. if !ok {
  48223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48224. }
  48225. m.SetToken(v)
  48226. return nil
  48227. case xunji.FieldEncodingKey:
  48228. v, ok := value.(string)
  48229. if !ok {
  48230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48231. }
  48232. m.SetEncodingKey(v)
  48233. return nil
  48234. case xunji.FieldOrganizationID:
  48235. v, ok := value.(uint64)
  48236. if !ok {
  48237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48238. }
  48239. m.SetOrganizationID(v)
  48240. return nil
  48241. }
  48242. return fmt.Errorf("unknown Xunji field %s", name)
  48243. }
  48244. // AddedFields returns all numeric fields that were incremented/decremented during
  48245. // this mutation.
  48246. func (m *XunjiMutation) AddedFields() []string {
  48247. var fields []string
  48248. if m.addstatus != nil {
  48249. fields = append(fields, xunji.FieldStatus)
  48250. }
  48251. if m.addorganization_id != nil {
  48252. fields = append(fields, xunji.FieldOrganizationID)
  48253. }
  48254. return fields
  48255. }
  48256. // AddedField returns the numeric value that was incremented/decremented on a field
  48257. // with the given name. The second boolean return value indicates that this field
  48258. // was not set, or was not defined in the schema.
  48259. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  48260. switch name {
  48261. case xunji.FieldStatus:
  48262. return m.AddedStatus()
  48263. case xunji.FieldOrganizationID:
  48264. return m.AddedOrganizationID()
  48265. }
  48266. return nil, false
  48267. }
  48268. // AddField adds the value to the field with the given name. It returns an error if
  48269. // the field is not defined in the schema, or if the type mismatched the field
  48270. // type.
  48271. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  48272. switch name {
  48273. case xunji.FieldStatus:
  48274. v, ok := value.(int8)
  48275. if !ok {
  48276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48277. }
  48278. m.AddStatus(v)
  48279. return nil
  48280. case xunji.FieldOrganizationID:
  48281. v, ok := value.(int64)
  48282. if !ok {
  48283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48284. }
  48285. m.AddOrganizationID(v)
  48286. return nil
  48287. }
  48288. return fmt.Errorf("unknown Xunji numeric field %s", name)
  48289. }
  48290. // ClearedFields returns all nullable fields that were cleared during this
  48291. // mutation.
  48292. func (m *XunjiMutation) ClearedFields() []string {
  48293. var fields []string
  48294. if m.FieldCleared(xunji.FieldStatus) {
  48295. fields = append(fields, xunji.FieldStatus)
  48296. }
  48297. if m.FieldCleared(xunji.FieldDeletedAt) {
  48298. fields = append(fields, xunji.FieldDeletedAt)
  48299. }
  48300. if m.FieldCleared(xunji.FieldAppKey) {
  48301. fields = append(fields, xunji.FieldAppKey)
  48302. }
  48303. if m.FieldCleared(xunji.FieldAppSecret) {
  48304. fields = append(fields, xunji.FieldAppSecret)
  48305. }
  48306. if m.FieldCleared(xunji.FieldToken) {
  48307. fields = append(fields, xunji.FieldToken)
  48308. }
  48309. if m.FieldCleared(xunji.FieldEncodingKey) {
  48310. fields = append(fields, xunji.FieldEncodingKey)
  48311. }
  48312. return fields
  48313. }
  48314. // FieldCleared returns a boolean indicating if a field with the given name was
  48315. // cleared in this mutation.
  48316. func (m *XunjiMutation) FieldCleared(name string) bool {
  48317. _, ok := m.clearedFields[name]
  48318. return ok
  48319. }
  48320. // ClearField clears the value of the field with the given name. It returns an
  48321. // error if the field is not defined in the schema.
  48322. func (m *XunjiMutation) ClearField(name string) error {
  48323. switch name {
  48324. case xunji.FieldStatus:
  48325. m.ClearStatus()
  48326. return nil
  48327. case xunji.FieldDeletedAt:
  48328. m.ClearDeletedAt()
  48329. return nil
  48330. case xunji.FieldAppKey:
  48331. m.ClearAppKey()
  48332. return nil
  48333. case xunji.FieldAppSecret:
  48334. m.ClearAppSecret()
  48335. return nil
  48336. case xunji.FieldToken:
  48337. m.ClearToken()
  48338. return nil
  48339. case xunji.FieldEncodingKey:
  48340. m.ClearEncodingKey()
  48341. return nil
  48342. }
  48343. return fmt.Errorf("unknown Xunji nullable field %s", name)
  48344. }
  48345. // ResetField resets all changes in the mutation for the field with the given name.
  48346. // It returns an error if the field is not defined in the schema.
  48347. func (m *XunjiMutation) ResetField(name string) error {
  48348. switch name {
  48349. case xunji.FieldCreatedAt:
  48350. m.ResetCreatedAt()
  48351. return nil
  48352. case xunji.FieldUpdatedAt:
  48353. m.ResetUpdatedAt()
  48354. return nil
  48355. case xunji.FieldStatus:
  48356. m.ResetStatus()
  48357. return nil
  48358. case xunji.FieldDeletedAt:
  48359. m.ResetDeletedAt()
  48360. return nil
  48361. case xunji.FieldAppKey:
  48362. m.ResetAppKey()
  48363. return nil
  48364. case xunji.FieldAppSecret:
  48365. m.ResetAppSecret()
  48366. return nil
  48367. case xunji.FieldToken:
  48368. m.ResetToken()
  48369. return nil
  48370. case xunji.FieldEncodingKey:
  48371. m.ResetEncodingKey()
  48372. return nil
  48373. case xunji.FieldOrganizationID:
  48374. m.ResetOrganizationID()
  48375. return nil
  48376. }
  48377. return fmt.Errorf("unknown Xunji field %s", name)
  48378. }
  48379. // AddedEdges returns all edge names that were set/added in this mutation.
  48380. func (m *XunjiMutation) AddedEdges() []string {
  48381. edges := make([]string, 0, 0)
  48382. return edges
  48383. }
  48384. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48385. // name in this mutation.
  48386. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  48387. return nil
  48388. }
  48389. // RemovedEdges returns all edge names that were removed in this mutation.
  48390. func (m *XunjiMutation) RemovedEdges() []string {
  48391. edges := make([]string, 0, 0)
  48392. return edges
  48393. }
  48394. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48395. // the given name in this mutation.
  48396. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  48397. return nil
  48398. }
  48399. // ClearedEdges returns all edge names that were cleared in this mutation.
  48400. func (m *XunjiMutation) ClearedEdges() []string {
  48401. edges := make([]string, 0, 0)
  48402. return edges
  48403. }
  48404. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48405. // was cleared in this mutation.
  48406. func (m *XunjiMutation) EdgeCleared(name string) bool {
  48407. return false
  48408. }
  48409. // ClearEdge clears the value of the edge with the given name. It returns an error
  48410. // if that edge is not defined in the schema.
  48411. func (m *XunjiMutation) ClearEdge(name string) error {
  48412. return fmt.Errorf("unknown Xunji unique edge %s", name)
  48413. }
  48414. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48415. // It returns an error if the edge is not defined in the schema.
  48416. func (m *XunjiMutation) ResetEdge(name string) error {
  48417. return fmt.Errorf("unknown Xunji edge %s", name)
  48418. }
  48419. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  48420. type XunjiServiceMutation struct {
  48421. config
  48422. op Op
  48423. typ string
  48424. id *uint64
  48425. created_at *time.Time
  48426. updated_at *time.Time
  48427. status *uint8
  48428. addstatus *int8
  48429. deleted_at *time.Time
  48430. xunji_id *uint64
  48431. addxunji_id *int64
  48432. organization_id *uint64
  48433. addorganization_id *int64
  48434. wxid *string
  48435. api_base *string
  48436. api_key *string
  48437. clearedFields map[string]struct{}
  48438. agent *uint64
  48439. clearedagent bool
  48440. done bool
  48441. oldValue func(context.Context) (*XunjiService, error)
  48442. predicates []predicate.XunjiService
  48443. }
  48444. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  48445. // xunjiserviceOption allows management of the mutation configuration using functional options.
  48446. type xunjiserviceOption func(*XunjiServiceMutation)
  48447. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  48448. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  48449. m := &XunjiServiceMutation{
  48450. config: c,
  48451. op: op,
  48452. typ: TypeXunjiService,
  48453. clearedFields: make(map[string]struct{}),
  48454. }
  48455. for _, opt := range opts {
  48456. opt(m)
  48457. }
  48458. return m
  48459. }
  48460. // withXunjiServiceID sets the ID field of the mutation.
  48461. func withXunjiServiceID(id uint64) xunjiserviceOption {
  48462. return func(m *XunjiServiceMutation) {
  48463. var (
  48464. err error
  48465. once sync.Once
  48466. value *XunjiService
  48467. )
  48468. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  48469. once.Do(func() {
  48470. if m.done {
  48471. err = errors.New("querying old values post mutation is not allowed")
  48472. } else {
  48473. value, err = m.Client().XunjiService.Get(ctx, id)
  48474. }
  48475. })
  48476. return value, err
  48477. }
  48478. m.id = &id
  48479. }
  48480. }
  48481. // withXunjiService sets the old XunjiService of the mutation.
  48482. func withXunjiService(node *XunjiService) xunjiserviceOption {
  48483. return func(m *XunjiServiceMutation) {
  48484. m.oldValue = func(context.Context) (*XunjiService, error) {
  48485. return node, nil
  48486. }
  48487. m.id = &node.ID
  48488. }
  48489. }
  48490. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48491. // executed in a transaction (ent.Tx), a transactional client is returned.
  48492. func (m XunjiServiceMutation) Client() *Client {
  48493. client := &Client{config: m.config}
  48494. client.init()
  48495. return client
  48496. }
  48497. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48498. // it returns an error otherwise.
  48499. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  48500. if _, ok := m.driver.(*txDriver); !ok {
  48501. return nil, errors.New("ent: mutation is not running in a transaction")
  48502. }
  48503. tx := &Tx{config: m.config}
  48504. tx.init()
  48505. return tx, nil
  48506. }
  48507. // SetID sets the value of the id field. Note that this
  48508. // operation is only accepted on creation of XunjiService entities.
  48509. func (m *XunjiServiceMutation) SetID(id uint64) {
  48510. m.id = &id
  48511. }
  48512. // ID returns the ID value in the mutation. Note that the ID is only available
  48513. // if it was provided to the builder or after it was returned from the database.
  48514. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  48515. if m.id == nil {
  48516. return
  48517. }
  48518. return *m.id, true
  48519. }
  48520. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48521. // That means, if the mutation is applied within a transaction with an isolation level such
  48522. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48523. // or updated by the mutation.
  48524. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  48525. switch {
  48526. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48527. id, exists := m.ID()
  48528. if exists {
  48529. return []uint64{id}, nil
  48530. }
  48531. fallthrough
  48532. case m.op.Is(OpUpdate | OpDelete):
  48533. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  48534. default:
  48535. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48536. }
  48537. }
  48538. // SetCreatedAt sets the "created_at" field.
  48539. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  48540. m.created_at = &t
  48541. }
  48542. // CreatedAt returns the value of the "created_at" field in the mutation.
  48543. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  48544. v := m.created_at
  48545. if v == nil {
  48546. return
  48547. }
  48548. return *v, true
  48549. }
  48550. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  48551. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48553. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48554. if !m.op.Is(OpUpdateOne) {
  48555. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48556. }
  48557. if m.id == nil || m.oldValue == nil {
  48558. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48559. }
  48560. oldValue, err := m.oldValue(ctx)
  48561. if err != nil {
  48562. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48563. }
  48564. return oldValue.CreatedAt, nil
  48565. }
  48566. // ResetCreatedAt resets all changes to the "created_at" field.
  48567. func (m *XunjiServiceMutation) ResetCreatedAt() {
  48568. m.created_at = nil
  48569. }
  48570. // SetUpdatedAt sets the "updated_at" field.
  48571. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  48572. m.updated_at = &t
  48573. }
  48574. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48575. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  48576. v := m.updated_at
  48577. if v == nil {
  48578. return
  48579. }
  48580. return *v, true
  48581. }
  48582. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  48583. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48585. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48586. if !m.op.Is(OpUpdateOne) {
  48587. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48588. }
  48589. if m.id == nil || m.oldValue == nil {
  48590. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48591. }
  48592. oldValue, err := m.oldValue(ctx)
  48593. if err != nil {
  48594. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48595. }
  48596. return oldValue.UpdatedAt, nil
  48597. }
  48598. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48599. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  48600. m.updated_at = nil
  48601. }
  48602. // SetStatus sets the "status" field.
  48603. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  48604. m.status = &u
  48605. m.addstatus = nil
  48606. }
  48607. // Status returns the value of the "status" field in the mutation.
  48608. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  48609. v := m.status
  48610. if v == nil {
  48611. return
  48612. }
  48613. return *v, true
  48614. }
  48615. // OldStatus returns the old "status" field's value of the XunjiService entity.
  48616. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48618. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  48619. if !m.op.Is(OpUpdateOne) {
  48620. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  48621. }
  48622. if m.id == nil || m.oldValue == nil {
  48623. return v, errors.New("OldStatus requires an ID field in the mutation")
  48624. }
  48625. oldValue, err := m.oldValue(ctx)
  48626. if err != nil {
  48627. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  48628. }
  48629. return oldValue.Status, nil
  48630. }
  48631. // AddStatus adds u to the "status" field.
  48632. func (m *XunjiServiceMutation) AddStatus(u int8) {
  48633. if m.addstatus != nil {
  48634. *m.addstatus += u
  48635. } else {
  48636. m.addstatus = &u
  48637. }
  48638. }
  48639. // AddedStatus returns the value that was added to the "status" field in this mutation.
  48640. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  48641. v := m.addstatus
  48642. if v == nil {
  48643. return
  48644. }
  48645. return *v, true
  48646. }
  48647. // ClearStatus clears the value of the "status" field.
  48648. func (m *XunjiServiceMutation) ClearStatus() {
  48649. m.status = nil
  48650. m.addstatus = nil
  48651. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  48652. }
  48653. // StatusCleared returns if the "status" field was cleared in this mutation.
  48654. func (m *XunjiServiceMutation) StatusCleared() bool {
  48655. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  48656. return ok
  48657. }
  48658. // ResetStatus resets all changes to the "status" field.
  48659. func (m *XunjiServiceMutation) ResetStatus() {
  48660. m.status = nil
  48661. m.addstatus = nil
  48662. delete(m.clearedFields, xunjiservice.FieldStatus)
  48663. }
  48664. // SetDeletedAt sets the "deleted_at" field.
  48665. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  48666. m.deleted_at = &t
  48667. }
  48668. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48669. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  48670. v := m.deleted_at
  48671. if v == nil {
  48672. return
  48673. }
  48674. return *v, true
  48675. }
  48676. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  48677. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48679. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48680. if !m.op.Is(OpUpdateOne) {
  48681. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48682. }
  48683. if m.id == nil || m.oldValue == nil {
  48684. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48685. }
  48686. oldValue, err := m.oldValue(ctx)
  48687. if err != nil {
  48688. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48689. }
  48690. return oldValue.DeletedAt, nil
  48691. }
  48692. // ClearDeletedAt clears the value of the "deleted_at" field.
  48693. func (m *XunjiServiceMutation) ClearDeletedAt() {
  48694. m.deleted_at = nil
  48695. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  48696. }
  48697. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48698. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  48699. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  48700. return ok
  48701. }
  48702. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48703. func (m *XunjiServiceMutation) ResetDeletedAt() {
  48704. m.deleted_at = nil
  48705. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  48706. }
  48707. // SetXunjiID sets the "xunji_id" field.
  48708. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  48709. m.xunji_id = &u
  48710. m.addxunji_id = nil
  48711. }
  48712. // XunjiID returns the value of the "xunji_id" field in the mutation.
  48713. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  48714. v := m.xunji_id
  48715. if v == nil {
  48716. return
  48717. }
  48718. return *v, true
  48719. }
  48720. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  48721. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48723. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  48724. if !m.op.Is(OpUpdateOne) {
  48725. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  48726. }
  48727. if m.id == nil || m.oldValue == nil {
  48728. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  48729. }
  48730. oldValue, err := m.oldValue(ctx)
  48731. if err != nil {
  48732. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  48733. }
  48734. return oldValue.XunjiID, nil
  48735. }
  48736. // AddXunjiID adds u to the "xunji_id" field.
  48737. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  48738. if m.addxunji_id != nil {
  48739. *m.addxunji_id += u
  48740. } else {
  48741. m.addxunji_id = &u
  48742. }
  48743. }
  48744. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  48745. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  48746. v := m.addxunji_id
  48747. if v == nil {
  48748. return
  48749. }
  48750. return *v, true
  48751. }
  48752. // ResetXunjiID resets all changes to the "xunji_id" field.
  48753. func (m *XunjiServiceMutation) ResetXunjiID() {
  48754. m.xunji_id = nil
  48755. m.addxunji_id = nil
  48756. }
  48757. // SetAgentID sets the "agent_id" field.
  48758. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  48759. m.agent = &u
  48760. }
  48761. // AgentID returns the value of the "agent_id" field in the mutation.
  48762. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  48763. v := m.agent
  48764. if v == nil {
  48765. return
  48766. }
  48767. return *v, true
  48768. }
  48769. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  48770. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48772. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  48773. if !m.op.Is(OpUpdateOne) {
  48774. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  48775. }
  48776. if m.id == nil || m.oldValue == nil {
  48777. return v, errors.New("OldAgentID requires an ID field in the mutation")
  48778. }
  48779. oldValue, err := m.oldValue(ctx)
  48780. if err != nil {
  48781. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  48782. }
  48783. return oldValue.AgentID, nil
  48784. }
  48785. // ResetAgentID resets all changes to the "agent_id" field.
  48786. func (m *XunjiServiceMutation) ResetAgentID() {
  48787. m.agent = nil
  48788. }
  48789. // SetOrganizationID sets the "organization_id" field.
  48790. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  48791. m.organization_id = &u
  48792. m.addorganization_id = nil
  48793. }
  48794. // OrganizationID returns the value of the "organization_id" field in the mutation.
  48795. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  48796. v := m.organization_id
  48797. if v == nil {
  48798. return
  48799. }
  48800. return *v, true
  48801. }
  48802. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  48803. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48805. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  48806. if !m.op.Is(OpUpdateOne) {
  48807. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  48808. }
  48809. if m.id == nil || m.oldValue == nil {
  48810. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  48811. }
  48812. oldValue, err := m.oldValue(ctx)
  48813. if err != nil {
  48814. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  48815. }
  48816. return oldValue.OrganizationID, nil
  48817. }
  48818. // AddOrganizationID adds u to the "organization_id" field.
  48819. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  48820. if m.addorganization_id != nil {
  48821. *m.addorganization_id += u
  48822. } else {
  48823. m.addorganization_id = &u
  48824. }
  48825. }
  48826. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  48827. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  48828. v := m.addorganization_id
  48829. if v == nil {
  48830. return
  48831. }
  48832. return *v, true
  48833. }
  48834. // ResetOrganizationID resets all changes to the "organization_id" field.
  48835. func (m *XunjiServiceMutation) ResetOrganizationID() {
  48836. m.organization_id = nil
  48837. m.addorganization_id = nil
  48838. }
  48839. // SetWxid sets the "wxid" field.
  48840. func (m *XunjiServiceMutation) SetWxid(s string) {
  48841. m.wxid = &s
  48842. }
  48843. // Wxid returns the value of the "wxid" field in the mutation.
  48844. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  48845. v := m.wxid
  48846. if v == nil {
  48847. return
  48848. }
  48849. return *v, true
  48850. }
  48851. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  48852. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48854. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  48855. if !m.op.Is(OpUpdateOne) {
  48856. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  48857. }
  48858. if m.id == nil || m.oldValue == nil {
  48859. return v, errors.New("OldWxid requires an ID field in the mutation")
  48860. }
  48861. oldValue, err := m.oldValue(ctx)
  48862. if err != nil {
  48863. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  48864. }
  48865. return oldValue.Wxid, nil
  48866. }
  48867. // ResetWxid resets all changes to the "wxid" field.
  48868. func (m *XunjiServiceMutation) ResetWxid() {
  48869. m.wxid = nil
  48870. }
  48871. // SetAPIBase sets the "api_base" field.
  48872. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  48873. m.api_base = &s
  48874. }
  48875. // APIBase returns the value of the "api_base" field in the mutation.
  48876. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  48877. v := m.api_base
  48878. if v == nil {
  48879. return
  48880. }
  48881. return *v, true
  48882. }
  48883. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  48884. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48886. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  48887. if !m.op.Is(OpUpdateOne) {
  48888. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  48889. }
  48890. if m.id == nil || m.oldValue == nil {
  48891. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  48892. }
  48893. oldValue, err := m.oldValue(ctx)
  48894. if err != nil {
  48895. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  48896. }
  48897. return oldValue.APIBase, nil
  48898. }
  48899. // ClearAPIBase clears the value of the "api_base" field.
  48900. func (m *XunjiServiceMutation) ClearAPIBase() {
  48901. m.api_base = nil
  48902. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  48903. }
  48904. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  48905. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  48906. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  48907. return ok
  48908. }
  48909. // ResetAPIBase resets all changes to the "api_base" field.
  48910. func (m *XunjiServiceMutation) ResetAPIBase() {
  48911. m.api_base = nil
  48912. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  48913. }
  48914. // SetAPIKey sets the "api_key" field.
  48915. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  48916. m.api_key = &s
  48917. }
  48918. // APIKey returns the value of the "api_key" field in the mutation.
  48919. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  48920. v := m.api_key
  48921. if v == nil {
  48922. return
  48923. }
  48924. return *v, true
  48925. }
  48926. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  48927. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48929. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  48930. if !m.op.Is(OpUpdateOne) {
  48931. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  48932. }
  48933. if m.id == nil || m.oldValue == nil {
  48934. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  48935. }
  48936. oldValue, err := m.oldValue(ctx)
  48937. if err != nil {
  48938. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  48939. }
  48940. return oldValue.APIKey, nil
  48941. }
  48942. // ClearAPIKey clears the value of the "api_key" field.
  48943. func (m *XunjiServiceMutation) ClearAPIKey() {
  48944. m.api_key = nil
  48945. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  48946. }
  48947. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  48948. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  48949. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  48950. return ok
  48951. }
  48952. // ResetAPIKey resets all changes to the "api_key" field.
  48953. func (m *XunjiServiceMutation) ResetAPIKey() {
  48954. m.api_key = nil
  48955. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  48956. }
  48957. // ClearAgent clears the "agent" edge to the Agent entity.
  48958. func (m *XunjiServiceMutation) ClearAgent() {
  48959. m.clearedagent = true
  48960. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  48961. }
  48962. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  48963. func (m *XunjiServiceMutation) AgentCleared() bool {
  48964. return m.clearedagent
  48965. }
  48966. // AgentIDs returns the "agent" edge IDs in the mutation.
  48967. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  48968. // AgentID instead. It exists only for internal usage by the builders.
  48969. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  48970. if id := m.agent; id != nil {
  48971. ids = append(ids, *id)
  48972. }
  48973. return
  48974. }
  48975. // ResetAgent resets all changes to the "agent" edge.
  48976. func (m *XunjiServiceMutation) ResetAgent() {
  48977. m.agent = nil
  48978. m.clearedagent = false
  48979. }
  48980. // Where appends a list predicates to the XunjiServiceMutation builder.
  48981. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  48982. m.predicates = append(m.predicates, ps...)
  48983. }
  48984. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  48985. // users can use type-assertion to append predicates that do not depend on any generated package.
  48986. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  48987. p := make([]predicate.XunjiService, len(ps))
  48988. for i := range ps {
  48989. p[i] = ps[i]
  48990. }
  48991. m.Where(p...)
  48992. }
  48993. // Op returns the operation name.
  48994. func (m *XunjiServiceMutation) Op() Op {
  48995. return m.op
  48996. }
  48997. // SetOp allows setting the mutation operation.
  48998. func (m *XunjiServiceMutation) SetOp(op Op) {
  48999. m.op = op
  49000. }
  49001. // Type returns the node type of this mutation (XunjiService).
  49002. func (m *XunjiServiceMutation) Type() string {
  49003. return m.typ
  49004. }
  49005. // Fields returns all fields that were changed during this mutation. Note that in
  49006. // order to get all numeric fields that were incremented/decremented, call
  49007. // AddedFields().
  49008. func (m *XunjiServiceMutation) Fields() []string {
  49009. fields := make([]string, 0, 10)
  49010. if m.created_at != nil {
  49011. fields = append(fields, xunjiservice.FieldCreatedAt)
  49012. }
  49013. if m.updated_at != nil {
  49014. fields = append(fields, xunjiservice.FieldUpdatedAt)
  49015. }
  49016. if m.status != nil {
  49017. fields = append(fields, xunjiservice.FieldStatus)
  49018. }
  49019. if m.deleted_at != nil {
  49020. fields = append(fields, xunjiservice.FieldDeletedAt)
  49021. }
  49022. if m.xunji_id != nil {
  49023. fields = append(fields, xunjiservice.FieldXunjiID)
  49024. }
  49025. if m.agent != nil {
  49026. fields = append(fields, xunjiservice.FieldAgentID)
  49027. }
  49028. if m.organization_id != nil {
  49029. fields = append(fields, xunjiservice.FieldOrganizationID)
  49030. }
  49031. if m.wxid != nil {
  49032. fields = append(fields, xunjiservice.FieldWxid)
  49033. }
  49034. if m.api_base != nil {
  49035. fields = append(fields, xunjiservice.FieldAPIBase)
  49036. }
  49037. if m.api_key != nil {
  49038. fields = append(fields, xunjiservice.FieldAPIKey)
  49039. }
  49040. return fields
  49041. }
  49042. // Field returns the value of a field with the given name. The second boolean
  49043. // return value indicates that this field was not set, or was not defined in the
  49044. // schema.
  49045. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  49046. switch name {
  49047. case xunjiservice.FieldCreatedAt:
  49048. return m.CreatedAt()
  49049. case xunjiservice.FieldUpdatedAt:
  49050. return m.UpdatedAt()
  49051. case xunjiservice.FieldStatus:
  49052. return m.Status()
  49053. case xunjiservice.FieldDeletedAt:
  49054. return m.DeletedAt()
  49055. case xunjiservice.FieldXunjiID:
  49056. return m.XunjiID()
  49057. case xunjiservice.FieldAgentID:
  49058. return m.AgentID()
  49059. case xunjiservice.FieldOrganizationID:
  49060. return m.OrganizationID()
  49061. case xunjiservice.FieldWxid:
  49062. return m.Wxid()
  49063. case xunjiservice.FieldAPIBase:
  49064. return m.APIBase()
  49065. case xunjiservice.FieldAPIKey:
  49066. return m.APIKey()
  49067. }
  49068. return nil, false
  49069. }
  49070. // OldField returns the old value of the field from the database. An error is
  49071. // returned if the mutation operation is not UpdateOne, or the query to the
  49072. // database failed.
  49073. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49074. switch name {
  49075. case xunjiservice.FieldCreatedAt:
  49076. return m.OldCreatedAt(ctx)
  49077. case xunjiservice.FieldUpdatedAt:
  49078. return m.OldUpdatedAt(ctx)
  49079. case xunjiservice.FieldStatus:
  49080. return m.OldStatus(ctx)
  49081. case xunjiservice.FieldDeletedAt:
  49082. return m.OldDeletedAt(ctx)
  49083. case xunjiservice.FieldXunjiID:
  49084. return m.OldXunjiID(ctx)
  49085. case xunjiservice.FieldAgentID:
  49086. return m.OldAgentID(ctx)
  49087. case xunjiservice.FieldOrganizationID:
  49088. return m.OldOrganizationID(ctx)
  49089. case xunjiservice.FieldWxid:
  49090. return m.OldWxid(ctx)
  49091. case xunjiservice.FieldAPIBase:
  49092. return m.OldAPIBase(ctx)
  49093. case xunjiservice.FieldAPIKey:
  49094. return m.OldAPIKey(ctx)
  49095. }
  49096. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  49097. }
  49098. // SetField sets the value of a field with the given name. It returns an error if
  49099. // the field is not defined in the schema, or if the type mismatched the field
  49100. // type.
  49101. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  49102. switch name {
  49103. case xunjiservice.FieldCreatedAt:
  49104. v, ok := value.(time.Time)
  49105. if !ok {
  49106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49107. }
  49108. m.SetCreatedAt(v)
  49109. return nil
  49110. case xunjiservice.FieldUpdatedAt:
  49111. v, ok := value.(time.Time)
  49112. if !ok {
  49113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49114. }
  49115. m.SetUpdatedAt(v)
  49116. return nil
  49117. case xunjiservice.FieldStatus:
  49118. v, ok := value.(uint8)
  49119. if !ok {
  49120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49121. }
  49122. m.SetStatus(v)
  49123. return nil
  49124. case xunjiservice.FieldDeletedAt:
  49125. v, ok := value.(time.Time)
  49126. if !ok {
  49127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49128. }
  49129. m.SetDeletedAt(v)
  49130. return nil
  49131. case xunjiservice.FieldXunjiID:
  49132. v, ok := value.(uint64)
  49133. if !ok {
  49134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49135. }
  49136. m.SetXunjiID(v)
  49137. return nil
  49138. case xunjiservice.FieldAgentID:
  49139. v, ok := value.(uint64)
  49140. if !ok {
  49141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49142. }
  49143. m.SetAgentID(v)
  49144. return nil
  49145. case xunjiservice.FieldOrganizationID:
  49146. v, ok := value.(uint64)
  49147. if !ok {
  49148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49149. }
  49150. m.SetOrganizationID(v)
  49151. return nil
  49152. case xunjiservice.FieldWxid:
  49153. v, ok := value.(string)
  49154. if !ok {
  49155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49156. }
  49157. m.SetWxid(v)
  49158. return nil
  49159. case xunjiservice.FieldAPIBase:
  49160. v, ok := value.(string)
  49161. if !ok {
  49162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49163. }
  49164. m.SetAPIBase(v)
  49165. return nil
  49166. case xunjiservice.FieldAPIKey:
  49167. v, ok := value.(string)
  49168. if !ok {
  49169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49170. }
  49171. m.SetAPIKey(v)
  49172. return nil
  49173. }
  49174. return fmt.Errorf("unknown XunjiService field %s", name)
  49175. }
  49176. // AddedFields returns all numeric fields that were incremented/decremented during
  49177. // this mutation.
  49178. func (m *XunjiServiceMutation) AddedFields() []string {
  49179. var fields []string
  49180. if m.addstatus != nil {
  49181. fields = append(fields, xunjiservice.FieldStatus)
  49182. }
  49183. if m.addxunji_id != nil {
  49184. fields = append(fields, xunjiservice.FieldXunjiID)
  49185. }
  49186. if m.addorganization_id != nil {
  49187. fields = append(fields, xunjiservice.FieldOrganizationID)
  49188. }
  49189. return fields
  49190. }
  49191. // AddedField returns the numeric value that was incremented/decremented on a field
  49192. // with the given name. The second boolean return value indicates that this field
  49193. // was not set, or was not defined in the schema.
  49194. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  49195. switch name {
  49196. case xunjiservice.FieldStatus:
  49197. return m.AddedStatus()
  49198. case xunjiservice.FieldXunjiID:
  49199. return m.AddedXunjiID()
  49200. case xunjiservice.FieldOrganizationID:
  49201. return m.AddedOrganizationID()
  49202. }
  49203. return nil, false
  49204. }
  49205. // AddField adds the value to the field with the given name. It returns an error if
  49206. // the field is not defined in the schema, or if the type mismatched the field
  49207. // type.
  49208. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  49209. switch name {
  49210. case xunjiservice.FieldStatus:
  49211. v, ok := value.(int8)
  49212. if !ok {
  49213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49214. }
  49215. m.AddStatus(v)
  49216. return nil
  49217. case xunjiservice.FieldXunjiID:
  49218. v, ok := value.(int64)
  49219. if !ok {
  49220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49221. }
  49222. m.AddXunjiID(v)
  49223. return nil
  49224. case xunjiservice.FieldOrganizationID:
  49225. v, ok := value.(int64)
  49226. if !ok {
  49227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49228. }
  49229. m.AddOrganizationID(v)
  49230. return nil
  49231. }
  49232. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  49233. }
  49234. // ClearedFields returns all nullable fields that were cleared during this
  49235. // mutation.
  49236. func (m *XunjiServiceMutation) ClearedFields() []string {
  49237. var fields []string
  49238. if m.FieldCleared(xunjiservice.FieldStatus) {
  49239. fields = append(fields, xunjiservice.FieldStatus)
  49240. }
  49241. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  49242. fields = append(fields, xunjiservice.FieldDeletedAt)
  49243. }
  49244. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  49245. fields = append(fields, xunjiservice.FieldAPIBase)
  49246. }
  49247. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  49248. fields = append(fields, xunjiservice.FieldAPIKey)
  49249. }
  49250. return fields
  49251. }
  49252. // FieldCleared returns a boolean indicating if a field with the given name was
  49253. // cleared in this mutation.
  49254. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  49255. _, ok := m.clearedFields[name]
  49256. return ok
  49257. }
  49258. // ClearField clears the value of the field with the given name. It returns an
  49259. // error if the field is not defined in the schema.
  49260. func (m *XunjiServiceMutation) ClearField(name string) error {
  49261. switch name {
  49262. case xunjiservice.FieldStatus:
  49263. m.ClearStatus()
  49264. return nil
  49265. case xunjiservice.FieldDeletedAt:
  49266. m.ClearDeletedAt()
  49267. return nil
  49268. case xunjiservice.FieldAPIBase:
  49269. m.ClearAPIBase()
  49270. return nil
  49271. case xunjiservice.FieldAPIKey:
  49272. m.ClearAPIKey()
  49273. return nil
  49274. }
  49275. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  49276. }
  49277. // ResetField resets all changes in the mutation for the field with the given name.
  49278. // It returns an error if the field is not defined in the schema.
  49279. func (m *XunjiServiceMutation) ResetField(name string) error {
  49280. switch name {
  49281. case xunjiservice.FieldCreatedAt:
  49282. m.ResetCreatedAt()
  49283. return nil
  49284. case xunjiservice.FieldUpdatedAt:
  49285. m.ResetUpdatedAt()
  49286. return nil
  49287. case xunjiservice.FieldStatus:
  49288. m.ResetStatus()
  49289. return nil
  49290. case xunjiservice.FieldDeletedAt:
  49291. m.ResetDeletedAt()
  49292. return nil
  49293. case xunjiservice.FieldXunjiID:
  49294. m.ResetXunjiID()
  49295. return nil
  49296. case xunjiservice.FieldAgentID:
  49297. m.ResetAgentID()
  49298. return nil
  49299. case xunjiservice.FieldOrganizationID:
  49300. m.ResetOrganizationID()
  49301. return nil
  49302. case xunjiservice.FieldWxid:
  49303. m.ResetWxid()
  49304. return nil
  49305. case xunjiservice.FieldAPIBase:
  49306. m.ResetAPIBase()
  49307. return nil
  49308. case xunjiservice.FieldAPIKey:
  49309. m.ResetAPIKey()
  49310. return nil
  49311. }
  49312. return fmt.Errorf("unknown XunjiService field %s", name)
  49313. }
  49314. // AddedEdges returns all edge names that were set/added in this mutation.
  49315. func (m *XunjiServiceMutation) AddedEdges() []string {
  49316. edges := make([]string, 0, 1)
  49317. if m.agent != nil {
  49318. edges = append(edges, xunjiservice.EdgeAgent)
  49319. }
  49320. return edges
  49321. }
  49322. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49323. // name in this mutation.
  49324. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  49325. switch name {
  49326. case xunjiservice.EdgeAgent:
  49327. if id := m.agent; id != nil {
  49328. return []ent.Value{*id}
  49329. }
  49330. }
  49331. return nil
  49332. }
  49333. // RemovedEdges returns all edge names that were removed in this mutation.
  49334. func (m *XunjiServiceMutation) RemovedEdges() []string {
  49335. edges := make([]string, 0, 1)
  49336. return edges
  49337. }
  49338. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49339. // the given name in this mutation.
  49340. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  49341. return nil
  49342. }
  49343. // ClearedEdges returns all edge names that were cleared in this mutation.
  49344. func (m *XunjiServiceMutation) ClearedEdges() []string {
  49345. edges := make([]string, 0, 1)
  49346. if m.clearedagent {
  49347. edges = append(edges, xunjiservice.EdgeAgent)
  49348. }
  49349. return edges
  49350. }
  49351. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49352. // was cleared in this mutation.
  49353. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  49354. switch name {
  49355. case xunjiservice.EdgeAgent:
  49356. return m.clearedagent
  49357. }
  49358. return false
  49359. }
  49360. // ClearEdge clears the value of the edge with the given name. It returns an error
  49361. // if that edge is not defined in the schema.
  49362. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  49363. switch name {
  49364. case xunjiservice.EdgeAgent:
  49365. m.ClearAgent()
  49366. return nil
  49367. }
  49368. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  49369. }
  49370. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49371. // It returns an error if the edge is not defined in the schema.
  49372. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  49373. switch name {
  49374. case xunjiservice.EdgeAgent:
  49375. m.ResetAgent()
  49376. return nil
  49377. }
  49378. return fmt.Errorf("unknown XunjiService edge %s", name)
  49379. }