mutation.go 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065
  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 *string
  13744. status *int
  13745. addstatus *int
  13746. ntype *int
  13747. addntype *int
  13748. table *string
  13749. organization_id *uint64
  13750. addorganization_id *int64
  13751. nid *uint64
  13752. addnid *int64
  13753. reason *string
  13754. operator *string
  13755. clearedFields map[string]struct{}
  13756. done bool
  13757. oldValue func(context.Context) (*CreditUsage, error)
  13758. predicates []predicate.CreditUsage
  13759. }
  13760. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  13761. // creditusageOption allows management of the mutation configuration using functional options.
  13762. type creditusageOption func(*CreditUsageMutation)
  13763. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  13764. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  13765. m := &CreditUsageMutation{
  13766. config: c,
  13767. op: op,
  13768. typ: TypeCreditUsage,
  13769. clearedFields: make(map[string]struct{}),
  13770. }
  13771. for _, opt := range opts {
  13772. opt(m)
  13773. }
  13774. return m
  13775. }
  13776. // withCreditUsageID sets the ID field of the mutation.
  13777. func withCreditUsageID(id uint64) creditusageOption {
  13778. return func(m *CreditUsageMutation) {
  13779. var (
  13780. err error
  13781. once sync.Once
  13782. value *CreditUsage
  13783. )
  13784. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  13785. once.Do(func() {
  13786. if m.done {
  13787. err = errors.New("querying old values post mutation is not allowed")
  13788. } else {
  13789. value, err = m.Client().CreditUsage.Get(ctx, id)
  13790. }
  13791. })
  13792. return value, err
  13793. }
  13794. m.id = &id
  13795. }
  13796. }
  13797. // withCreditUsage sets the old CreditUsage of the mutation.
  13798. func withCreditUsage(node *CreditUsage) creditusageOption {
  13799. return func(m *CreditUsageMutation) {
  13800. m.oldValue = func(context.Context) (*CreditUsage, error) {
  13801. return node, nil
  13802. }
  13803. m.id = &node.ID
  13804. }
  13805. }
  13806. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13807. // executed in a transaction (ent.Tx), a transactional client is returned.
  13808. func (m CreditUsageMutation) Client() *Client {
  13809. client := &Client{config: m.config}
  13810. client.init()
  13811. return client
  13812. }
  13813. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13814. // it returns an error otherwise.
  13815. func (m CreditUsageMutation) Tx() (*Tx, error) {
  13816. if _, ok := m.driver.(*txDriver); !ok {
  13817. return nil, errors.New("ent: mutation is not running in a transaction")
  13818. }
  13819. tx := &Tx{config: m.config}
  13820. tx.init()
  13821. return tx, nil
  13822. }
  13823. // SetID sets the value of the id field. Note that this
  13824. // operation is only accepted on creation of CreditUsage entities.
  13825. func (m *CreditUsageMutation) SetID(id uint64) {
  13826. m.id = &id
  13827. }
  13828. // ID returns the ID value in the mutation. Note that the ID is only available
  13829. // if it was provided to the builder or after it was returned from the database.
  13830. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  13831. if m.id == nil {
  13832. return
  13833. }
  13834. return *m.id, true
  13835. }
  13836. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13837. // That means, if the mutation is applied within a transaction with an isolation level such
  13838. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13839. // or updated by the mutation.
  13840. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13841. switch {
  13842. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13843. id, exists := m.ID()
  13844. if exists {
  13845. return []uint64{id}, nil
  13846. }
  13847. fallthrough
  13848. case m.op.Is(OpUpdate | OpDelete):
  13849. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  13850. default:
  13851. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13852. }
  13853. }
  13854. // SetCreatedAt sets the "created_at" field.
  13855. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  13856. m.created_at = &t
  13857. }
  13858. // CreatedAt returns the value of the "created_at" field in the mutation.
  13859. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  13860. v := m.created_at
  13861. if v == nil {
  13862. return
  13863. }
  13864. return *v, true
  13865. }
  13866. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  13867. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13869. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13870. if !m.op.Is(OpUpdateOne) {
  13871. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13872. }
  13873. if m.id == nil || m.oldValue == nil {
  13874. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13875. }
  13876. oldValue, err := m.oldValue(ctx)
  13877. if err != nil {
  13878. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13879. }
  13880. return oldValue.CreatedAt, nil
  13881. }
  13882. // ResetCreatedAt resets all changes to the "created_at" field.
  13883. func (m *CreditUsageMutation) ResetCreatedAt() {
  13884. m.created_at = nil
  13885. }
  13886. // SetUpdatedAt sets the "updated_at" field.
  13887. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  13888. m.updated_at = &t
  13889. }
  13890. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13891. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  13892. v := m.updated_at
  13893. if v == nil {
  13894. return
  13895. }
  13896. return *v, true
  13897. }
  13898. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  13899. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13901. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13902. if !m.op.Is(OpUpdateOne) {
  13903. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13904. }
  13905. if m.id == nil || m.oldValue == nil {
  13906. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13907. }
  13908. oldValue, err := m.oldValue(ctx)
  13909. if err != nil {
  13910. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13911. }
  13912. return oldValue.UpdatedAt, nil
  13913. }
  13914. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13915. func (m *CreditUsageMutation) ResetUpdatedAt() {
  13916. m.updated_at = nil
  13917. }
  13918. // SetDeletedAt sets the "deleted_at" field.
  13919. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  13920. m.deleted_at = &t
  13921. }
  13922. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13923. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  13924. v := m.deleted_at
  13925. if v == nil {
  13926. return
  13927. }
  13928. return *v, true
  13929. }
  13930. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  13931. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13933. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13934. if !m.op.Is(OpUpdateOne) {
  13935. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13936. }
  13937. if m.id == nil || m.oldValue == nil {
  13938. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13939. }
  13940. oldValue, err := m.oldValue(ctx)
  13941. if err != nil {
  13942. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13943. }
  13944. return oldValue.DeletedAt, nil
  13945. }
  13946. // ClearDeletedAt clears the value of the "deleted_at" field.
  13947. func (m *CreditUsageMutation) ClearDeletedAt() {
  13948. m.deleted_at = nil
  13949. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  13950. }
  13951. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13952. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  13953. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  13954. return ok
  13955. }
  13956. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13957. func (m *CreditUsageMutation) ResetDeletedAt() {
  13958. m.deleted_at = nil
  13959. delete(m.clearedFields, creditusage.FieldDeletedAt)
  13960. }
  13961. // SetUserID sets the "user_id" field.
  13962. func (m *CreditUsageMutation) SetUserID(s string) {
  13963. m.user_id = &s
  13964. }
  13965. // UserID returns the value of the "user_id" field in the mutation.
  13966. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  13967. v := m.user_id
  13968. if v == nil {
  13969. return
  13970. }
  13971. return *v, true
  13972. }
  13973. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  13974. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13976. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  13977. if !m.op.Is(OpUpdateOne) {
  13978. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  13979. }
  13980. if m.id == nil || m.oldValue == nil {
  13981. return v, errors.New("OldUserID requires an ID field in the mutation")
  13982. }
  13983. oldValue, err := m.oldValue(ctx)
  13984. if err != nil {
  13985. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  13986. }
  13987. return oldValue.UserID, nil
  13988. }
  13989. // ClearUserID clears the value of the "user_id" field.
  13990. func (m *CreditUsageMutation) ClearUserID() {
  13991. m.user_id = nil
  13992. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  13993. }
  13994. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  13995. func (m *CreditUsageMutation) UserIDCleared() bool {
  13996. _, ok := m.clearedFields[creditusage.FieldUserID]
  13997. return ok
  13998. }
  13999. // ResetUserID resets all changes to the "user_id" field.
  14000. func (m *CreditUsageMutation) ResetUserID() {
  14001. m.user_id = nil
  14002. delete(m.clearedFields, creditusage.FieldUserID)
  14003. }
  14004. // SetNumber sets the "number" field.
  14005. func (m *CreditUsageMutation) SetNumber(f float64) {
  14006. m.number = &f
  14007. m.addnumber = nil
  14008. }
  14009. // Number returns the value of the "number" field in the mutation.
  14010. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  14011. v := m.number
  14012. if v == nil {
  14013. return
  14014. }
  14015. return *v, true
  14016. }
  14017. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  14018. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14020. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  14021. if !m.op.Is(OpUpdateOne) {
  14022. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  14023. }
  14024. if m.id == nil || m.oldValue == nil {
  14025. return v, errors.New("OldNumber requires an ID field in the mutation")
  14026. }
  14027. oldValue, err := m.oldValue(ctx)
  14028. if err != nil {
  14029. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  14030. }
  14031. return oldValue.Number, nil
  14032. }
  14033. // AddNumber adds f to the "number" field.
  14034. func (m *CreditUsageMutation) AddNumber(f float64) {
  14035. if m.addnumber != nil {
  14036. *m.addnumber += f
  14037. } else {
  14038. m.addnumber = &f
  14039. }
  14040. }
  14041. // AddedNumber returns the value that was added to the "number" field in this mutation.
  14042. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  14043. v := m.addnumber
  14044. if v == nil {
  14045. return
  14046. }
  14047. return *v, true
  14048. }
  14049. // ResetNumber resets all changes to the "number" field.
  14050. func (m *CreditUsageMutation) ResetNumber() {
  14051. m.number = nil
  14052. m.addnumber = nil
  14053. }
  14054. // SetPayNumber sets the "pay_number" field.
  14055. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  14056. m.pay_number = &f
  14057. m.addpay_number = nil
  14058. }
  14059. // PayNumber returns the value of the "pay_number" field in the mutation.
  14060. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  14061. v := m.pay_number
  14062. if v == nil {
  14063. return
  14064. }
  14065. return *v, true
  14066. }
  14067. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  14068. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14070. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  14071. if !m.op.Is(OpUpdateOne) {
  14072. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  14073. }
  14074. if m.id == nil || m.oldValue == nil {
  14075. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  14076. }
  14077. oldValue, err := m.oldValue(ctx)
  14078. if err != nil {
  14079. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  14080. }
  14081. return oldValue.PayNumber, nil
  14082. }
  14083. // AddPayNumber adds f to the "pay_number" field.
  14084. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  14085. if m.addpay_number != nil {
  14086. *m.addpay_number += f
  14087. } else {
  14088. m.addpay_number = &f
  14089. }
  14090. }
  14091. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  14092. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  14093. v := m.addpay_number
  14094. if v == nil {
  14095. return
  14096. }
  14097. return *v, true
  14098. }
  14099. // ClearPayNumber clears the value of the "pay_number" field.
  14100. func (m *CreditUsageMutation) ClearPayNumber() {
  14101. m.pay_number = nil
  14102. m.addpay_number = nil
  14103. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  14104. }
  14105. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  14106. func (m *CreditUsageMutation) PayNumberCleared() bool {
  14107. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  14108. return ok
  14109. }
  14110. // ResetPayNumber resets all changes to the "pay_number" field.
  14111. func (m *CreditUsageMutation) ResetPayNumber() {
  14112. m.pay_number = nil
  14113. m.addpay_number = nil
  14114. delete(m.clearedFields, creditusage.FieldPayNumber)
  14115. }
  14116. // SetBeforeNumber sets the "before_number" field.
  14117. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  14118. m.before_number = &f
  14119. m.addbefore_number = nil
  14120. }
  14121. // BeforeNumber returns the value of the "before_number" field in the mutation.
  14122. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  14123. v := m.before_number
  14124. if v == nil {
  14125. return
  14126. }
  14127. return *v, true
  14128. }
  14129. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  14130. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14132. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  14133. if !m.op.Is(OpUpdateOne) {
  14134. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  14135. }
  14136. if m.id == nil || m.oldValue == nil {
  14137. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  14138. }
  14139. oldValue, err := m.oldValue(ctx)
  14140. if err != nil {
  14141. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  14142. }
  14143. return oldValue.BeforeNumber, nil
  14144. }
  14145. // AddBeforeNumber adds f to the "before_number" field.
  14146. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  14147. if m.addbefore_number != nil {
  14148. *m.addbefore_number += f
  14149. } else {
  14150. m.addbefore_number = &f
  14151. }
  14152. }
  14153. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  14154. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  14155. v := m.addbefore_number
  14156. if v == nil {
  14157. return
  14158. }
  14159. return *v, true
  14160. }
  14161. // ClearBeforeNumber clears the value of the "before_number" field.
  14162. func (m *CreditUsageMutation) ClearBeforeNumber() {
  14163. m.before_number = nil
  14164. m.addbefore_number = nil
  14165. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  14166. }
  14167. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  14168. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  14169. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  14170. return ok
  14171. }
  14172. // ResetBeforeNumber resets all changes to the "before_number" field.
  14173. func (m *CreditUsageMutation) ResetBeforeNumber() {
  14174. m.before_number = nil
  14175. m.addbefore_number = nil
  14176. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  14177. }
  14178. // SetAfterNumber sets the "after_number" field.
  14179. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  14180. m.after_number = &f
  14181. m.addafter_number = nil
  14182. }
  14183. // AfterNumber returns the value of the "after_number" field in the mutation.
  14184. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  14185. v := m.after_number
  14186. if v == nil {
  14187. return
  14188. }
  14189. return *v, true
  14190. }
  14191. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  14192. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14194. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  14195. if !m.op.Is(OpUpdateOne) {
  14196. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  14197. }
  14198. if m.id == nil || m.oldValue == nil {
  14199. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  14200. }
  14201. oldValue, err := m.oldValue(ctx)
  14202. if err != nil {
  14203. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  14204. }
  14205. return oldValue.AfterNumber, nil
  14206. }
  14207. // AddAfterNumber adds f to the "after_number" field.
  14208. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  14209. if m.addafter_number != nil {
  14210. *m.addafter_number += f
  14211. } else {
  14212. m.addafter_number = &f
  14213. }
  14214. }
  14215. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  14216. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  14217. v := m.addafter_number
  14218. if v == nil {
  14219. return
  14220. }
  14221. return *v, true
  14222. }
  14223. // ClearAfterNumber clears the value of the "after_number" field.
  14224. func (m *CreditUsageMutation) ClearAfterNumber() {
  14225. m.after_number = nil
  14226. m.addafter_number = nil
  14227. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  14228. }
  14229. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  14230. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  14231. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  14232. return ok
  14233. }
  14234. // ResetAfterNumber resets all changes to the "after_number" field.
  14235. func (m *CreditUsageMutation) ResetAfterNumber() {
  14236. m.after_number = nil
  14237. m.addafter_number = nil
  14238. delete(m.clearedFields, creditusage.FieldAfterNumber)
  14239. }
  14240. // SetPayMethod sets the "pay_method" field.
  14241. func (m *CreditUsageMutation) SetPayMethod(s string) {
  14242. m.pay_method = &s
  14243. }
  14244. // PayMethod returns the value of the "pay_method" field in the mutation.
  14245. func (m *CreditUsageMutation) PayMethod() (r string, exists bool) {
  14246. v := m.pay_method
  14247. if v == nil {
  14248. return
  14249. }
  14250. return *v, true
  14251. }
  14252. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  14253. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14255. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v string, err error) {
  14256. if !m.op.Is(OpUpdateOne) {
  14257. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  14258. }
  14259. if m.id == nil || m.oldValue == nil {
  14260. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  14261. }
  14262. oldValue, err := m.oldValue(ctx)
  14263. if err != nil {
  14264. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  14265. }
  14266. return oldValue.PayMethod, nil
  14267. }
  14268. // ClearPayMethod clears the value of the "pay_method" field.
  14269. func (m *CreditUsageMutation) ClearPayMethod() {
  14270. m.pay_method = nil
  14271. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  14272. }
  14273. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  14274. func (m *CreditUsageMutation) PayMethodCleared() bool {
  14275. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  14276. return ok
  14277. }
  14278. // ResetPayMethod resets all changes to the "pay_method" field.
  14279. func (m *CreditUsageMutation) ResetPayMethod() {
  14280. m.pay_method = nil
  14281. delete(m.clearedFields, creditusage.FieldPayMethod)
  14282. }
  14283. // SetStatus sets the "status" field.
  14284. func (m *CreditUsageMutation) SetStatus(i int) {
  14285. m.status = &i
  14286. m.addstatus = nil
  14287. }
  14288. // Status returns the value of the "status" field in the mutation.
  14289. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  14290. v := m.status
  14291. if v == nil {
  14292. return
  14293. }
  14294. return *v, true
  14295. }
  14296. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  14297. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14299. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  14300. if !m.op.Is(OpUpdateOne) {
  14301. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14302. }
  14303. if m.id == nil || m.oldValue == nil {
  14304. return v, errors.New("OldStatus requires an ID field in the mutation")
  14305. }
  14306. oldValue, err := m.oldValue(ctx)
  14307. if err != nil {
  14308. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14309. }
  14310. return oldValue.Status, nil
  14311. }
  14312. // AddStatus adds i to the "status" field.
  14313. func (m *CreditUsageMutation) AddStatus(i int) {
  14314. if m.addstatus != nil {
  14315. *m.addstatus += i
  14316. } else {
  14317. m.addstatus = &i
  14318. }
  14319. }
  14320. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14321. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  14322. v := m.addstatus
  14323. if v == nil {
  14324. return
  14325. }
  14326. return *v, true
  14327. }
  14328. // ClearStatus clears the value of the "status" field.
  14329. func (m *CreditUsageMutation) ClearStatus() {
  14330. m.status = nil
  14331. m.addstatus = nil
  14332. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  14333. }
  14334. // StatusCleared returns if the "status" field was cleared in this mutation.
  14335. func (m *CreditUsageMutation) StatusCleared() bool {
  14336. _, ok := m.clearedFields[creditusage.FieldStatus]
  14337. return ok
  14338. }
  14339. // ResetStatus resets all changes to the "status" field.
  14340. func (m *CreditUsageMutation) ResetStatus() {
  14341. m.status = nil
  14342. m.addstatus = nil
  14343. delete(m.clearedFields, creditusage.FieldStatus)
  14344. }
  14345. // SetNtype sets the "ntype" field.
  14346. func (m *CreditUsageMutation) SetNtype(i int) {
  14347. m.ntype = &i
  14348. m.addntype = nil
  14349. }
  14350. // Ntype returns the value of the "ntype" field in the mutation.
  14351. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  14352. v := m.ntype
  14353. if v == nil {
  14354. return
  14355. }
  14356. return *v, true
  14357. }
  14358. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  14359. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14361. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  14362. if !m.op.Is(OpUpdateOne) {
  14363. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  14364. }
  14365. if m.id == nil || m.oldValue == nil {
  14366. return v, errors.New("OldNtype requires an ID field in the mutation")
  14367. }
  14368. oldValue, err := m.oldValue(ctx)
  14369. if err != nil {
  14370. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  14371. }
  14372. return oldValue.Ntype, nil
  14373. }
  14374. // AddNtype adds i to the "ntype" field.
  14375. func (m *CreditUsageMutation) AddNtype(i int) {
  14376. if m.addntype != nil {
  14377. *m.addntype += i
  14378. } else {
  14379. m.addntype = &i
  14380. }
  14381. }
  14382. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  14383. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  14384. v := m.addntype
  14385. if v == nil {
  14386. return
  14387. }
  14388. return *v, true
  14389. }
  14390. // ResetNtype resets all changes to the "ntype" field.
  14391. func (m *CreditUsageMutation) ResetNtype() {
  14392. m.ntype = nil
  14393. m.addntype = nil
  14394. }
  14395. // SetTable sets the "table" field.
  14396. func (m *CreditUsageMutation) SetTable(s string) {
  14397. m.table = &s
  14398. }
  14399. // Table returns the value of the "table" field in the mutation.
  14400. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  14401. v := m.table
  14402. if v == nil {
  14403. return
  14404. }
  14405. return *v, true
  14406. }
  14407. // OldTable returns the old "table" field's value of the CreditUsage entity.
  14408. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14410. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  14411. if !m.op.Is(OpUpdateOne) {
  14412. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  14413. }
  14414. if m.id == nil || m.oldValue == nil {
  14415. return v, errors.New("OldTable requires an ID field in the mutation")
  14416. }
  14417. oldValue, err := m.oldValue(ctx)
  14418. if err != nil {
  14419. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  14420. }
  14421. return oldValue.Table, nil
  14422. }
  14423. // ResetTable resets all changes to the "table" field.
  14424. func (m *CreditUsageMutation) ResetTable() {
  14425. m.table = nil
  14426. }
  14427. // SetOrganizationID sets the "organization_id" field.
  14428. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  14429. m.organization_id = &u
  14430. m.addorganization_id = nil
  14431. }
  14432. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14433. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  14434. v := m.organization_id
  14435. if v == nil {
  14436. return
  14437. }
  14438. return *v, true
  14439. }
  14440. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  14441. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14443. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14444. if !m.op.Is(OpUpdateOne) {
  14445. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14446. }
  14447. if m.id == nil || m.oldValue == nil {
  14448. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14449. }
  14450. oldValue, err := m.oldValue(ctx)
  14451. if err != nil {
  14452. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14453. }
  14454. return oldValue.OrganizationID, nil
  14455. }
  14456. // AddOrganizationID adds u to the "organization_id" field.
  14457. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  14458. if m.addorganization_id != nil {
  14459. *m.addorganization_id += u
  14460. } else {
  14461. m.addorganization_id = &u
  14462. }
  14463. }
  14464. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14465. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  14466. v := m.addorganization_id
  14467. if v == nil {
  14468. return
  14469. }
  14470. return *v, true
  14471. }
  14472. // ClearOrganizationID clears the value of the "organization_id" field.
  14473. func (m *CreditUsageMutation) ClearOrganizationID() {
  14474. m.organization_id = nil
  14475. m.addorganization_id = nil
  14476. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  14477. }
  14478. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14479. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  14480. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  14481. return ok
  14482. }
  14483. // ResetOrganizationID resets all changes to the "organization_id" field.
  14484. func (m *CreditUsageMutation) ResetOrganizationID() {
  14485. m.organization_id = nil
  14486. m.addorganization_id = nil
  14487. delete(m.clearedFields, creditusage.FieldOrganizationID)
  14488. }
  14489. // SetNid sets the "nid" field.
  14490. func (m *CreditUsageMutation) SetNid(u uint64) {
  14491. m.nid = &u
  14492. m.addnid = nil
  14493. }
  14494. // Nid returns the value of the "nid" field in the mutation.
  14495. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  14496. v := m.nid
  14497. if v == nil {
  14498. return
  14499. }
  14500. return *v, true
  14501. }
  14502. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  14503. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14505. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  14506. if !m.op.Is(OpUpdateOne) {
  14507. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  14508. }
  14509. if m.id == nil || m.oldValue == nil {
  14510. return v, errors.New("OldNid requires an ID field in the mutation")
  14511. }
  14512. oldValue, err := m.oldValue(ctx)
  14513. if err != nil {
  14514. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  14515. }
  14516. return oldValue.Nid, nil
  14517. }
  14518. // AddNid adds u to the "nid" field.
  14519. func (m *CreditUsageMutation) AddNid(u int64) {
  14520. if m.addnid != nil {
  14521. *m.addnid += u
  14522. } else {
  14523. m.addnid = &u
  14524. }
  14525. }
  14526. // AddedNid returns the value that was added to the "nid" field in this mutation.
  14527. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  14528. v := m.addnid
  14529. if v == nil {
  14530. return
  14531. }
  14532. return *v, true
  14533. }
  14534. // ResetNid resets all changes to the "nid" field.
  14535. func (m *CreditUsageMutation) ResetNid() {
  14536. m.nid = nil
  14537. m.addnid = nil
  14538. }
  14539. // SetReason sets the "reason" field.
  14540. func (m *CreditUsageMutation) SetReason(s string) {
  14541. m.reason = &s
  14542. }
  14543. // Reason returns the value of the "reason" field in the mutation.
  14544. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  14545. v := m.reason
  14546. if v == nil {
  14547. return
  14548. }
  14549. return *v, true
  14550. }
  14551. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  14552. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14554. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  14555. if !m.op.Is(OpUpdateOne) {
  14556. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  14557. }
  14558. if m.id == nil || m.oldValue == nil {
  14559. return v, errors.New("OldReason requires an ID field in the mutation")
  14560. }
  14561. oldValue, err := m.oldValue(ctx)
  14562. if err != nil {
  14563. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  14564. }
  14565. return oldValue.Reason, nil
  14566. }
  14567. // ResetReason resets all changes to the "reason" field.
  14568. func (m *CreditUsageMutation) ResetReason() {
  14569. m.reason = nil
  14570. }
  14571. // SetOperator sets the "operator" field.
  14572. func (m *CreditUsageMutation) SetOperator(s string) {
  14573. m.operator = &s
  14574. }
  14575. // Operator returns the value of the "operator" field in the mutation.
  14576. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  14577. v := m.operator
  14578. if v == nil {
  14579. return
  14580. }
  14581. return *v, true
  14582. }
  14583. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  14584. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14586. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  14587. if !m.op.Is(OpUpdateOne) {
  14588. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  14589. }
  14590. if m.id == nil || m.oldValue == nil {
  14591. return v, errors.New("OldOperator requires an ID field in the mutation")
  14592. }
  14593. oldValue, err := m.oldValue(ctx)
  14594. if err != nil {
  14595. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  14596. }
  14597. return oldValue.Operator, nil
  14598. }
  14599. // ResetOperator resets all changes to the "operator" field.
  14600. func (m *CreditUsageMutation) ResetOperator() {
  14601. m.operator = nil
  14602. }
  14603. // Where appends a list predicates to the CreditUsageMutation builder.
  14604. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  14605. m.predicates = append(m.predicates, ps...)
  14606. }
  14607. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  14608. // users can use type-assertion to append predicates that do not depend on any generated package.
  14609. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  14610. p := make([]predicate.CreditUsage, len(ps))
  14611. for i := range ps {
  14612. p[i] = ps[i]
  14613. }
  14614. m.Where(p...)
  14615. }
  14616. // Op returns the operation name.
  14617. func (m *CreditUsageMutation) Op() Op {
  14618. return m.op
  14619. }
  14620. // SetOp allows setting the mutation operation.
  14621. func (m *CreditUsageMutation) SetOp(op Op) {
  14622. m.op = op
  14623. }
  14624. // Type returns the node type of this mutation (CreditUsage).
  14625. func (m *CreditUsageMutation) Type() string {
  14626. return m.typ
  14627. }
  14628. // Fields returns all fields that were changed during this mutation. Note that in
  14629. // order to get all numeric fields that were incremented/decremented, call
  14630. // AddedFields().
  14631. func (m *CreditUsageMutation) Fields() []string {
  14632. fields := make([]string, 0, 16)
  14633. if m.created_at != nil {
  14634. fields = append(fields, creditusage.FieldCreatedAt)
  14635. }
  14636. if m.updated_at != nil {
  14637. fields = append(fields, creditusage.FieldUpdatedAt)
  14638. }
  14639. if m.deleted_at != nil {
  14640. fields = append(fields, creditusage.FieldDeletedAt)
  14641. }
  14642. if m.user_id != nil {
  14643. fields = append(fields, creditusage.FieldUserID)
  14644. }
  14645. if m.number != nil {
  14646. fields = append(fields, creditusage.FieldNumber)
  14647. }
  14648. if m.pay_number != nil {
  14649. fields = append(fields, creditusage.FieldPayNumber)
  14650. }
  14651. if m.before_number != nil {
  14652. fields = append(fields, creditusage.FieldBeforeNumber)
  14653. }
  14654. if m.after_number != nil {
  14655. fields = append(fields, creditusage.FieldAfterNumber)
  14656. }
  14657. if m.pay_method != nil {
  14658. fields = append(fields, creditusage.FieldPayMethod)
  14659. }
  14660. if m.status != nil {
  14661. fields = append(fields, creditusage.FieldStatus)
  14662. }
  14663. if m.ntype != nil {
  14664. fields = append(fields, creditusage.FieldNtype)
  14665. }
  14666. if m.table != nil {
  14667. fields = append(fields, creditusage.FieldTable)
  14668. }
  14669. if m.organization_id != nil {
  14670. fields = append(fields, creditusage.FieldOrganizationID)
  14671. }
  14672. if m.nid != nil {
  14673. fields = append(fields, creditusage.FieldNid)
  14674. }
  14675. if m.reason != nil {
  14676. fields = append(fields, creditusage.FieldReason)
  14677. }
  14678. if m.operator != nil {
  14679. fields = append(fields, creditusage.FieldOperator)
  14680. }
  14681. return fields
  14682. }
  14683. // Field returns the value of a field with the given name. The second boolean
  14684. // return value indicates that this field was not set, or was not defined in the
  14685. // schema.
  14686. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  14687. switch name {
  14688. case creditusage.FieldCreatedAt:
  14689. return m.CreatedAt()
  14690. case creditusage.FieldUpdatedAt:
  14691. return m.UpdatedAt()
  14692. case creditusage.FieldDeletedAt:
  14693. return m.DeletedAt()
  14694. case creditusage.FieldUserID:
  14695. return m.UserID()
  14696. case creditusage.FieldNumber:
  14697. return m.Number()
  14698. case creditusage.FieldPayNumber:
  14699. return m.PayNumber()
  14700. case creditusage.FieldBeforeNumber:
  14701. return m.BeforeNumber()
  14702. case creditusage.FieldAfterNumber:
  14703. return m.AfterNumber()
  14704. case creditusage.FieldPayMethod:
  14705. return m.PayMethod()
  14706. case creditusage.FieldStatus:
  14707. return m.Status()
  14708. case creditusage.FieldNtype:
  14709. return m.Ntype()
  14710. case creditusage.FieldTable:
  14711. return m.Table()
  14712. case creditusage.FieldOrganizationID:
  14713. return m.OrganizationID()
  14714. case creditusage.FieldNid:
  14715. return m.Nid()
  14716. case creditusage.FieldReason:
  14717. return m.Reason()
  14718. case creditusage.FieldOperator:
  14719. return m.Operator()
  14720. }
  14721. return nil, false
  14722. }
  14723. // OldField returns the old value of the field from the database. An error is
  14724. // returned if the mutation operation is not UpdateOne, or the query to the
  14725. // database failed.
  14726. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14727. switch name {
  14728. case creditusage.FieldCreatedAt:
  14729. return m.OldCreatedAt(ctx)
  14730. case creditusage.FieldUpdatedAt:
  14731. return m.OldUpdatedAt(ctx)
  14732. case creditusage.FieldDeletedAt:
  14733. return m.OldDeletedAt(ctx)
  14734. case creditusage.FieldUserID:
  14735. return m.OldUserID(ctx)
  14736. case creditusage.FieldNumber:
  14737. return m.OldNumber(ctx)
  14738. case creditusage.FieldPayNumber:
  14739. return m.OldPayNumber(ctx)
  14740. case creditusage.FieldBeforeNumber:
  14741. return m.OldBeforeNumber(ctx)
  14742. case creditusage.FieldAfterNumber:
  14743. return m.OldAfterNumber(ctx)
  14744. case creditusage.FieldPayMethod:
  14745. return m.OldPayMethod(ctx)
  14746. case creditusage.FieldStatus:
  14747. return m.OldStatus(ctx)
  14748. case creditusage.FieldNtype:
  14749. return m.OldNtype(ctx)
  14750. case creditusage.FieldTable:
  14751. return m.OldTable(ctx)
  14752. case creditusage.FieldOrganizationID:
  14753. return m.OldOrganizationID(ctx)
  14754. case creditusage.FieldNid:
  14755. return m.OldNid(ctx)
  14756. case creditusage.FieldReason:
  14757. return m.OldReason(ctx)
  14758. case creditusage.FieldOperator:
  14759. return m.OldOperator(ctx)
  14760. }
  14761. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  14762. }
  14763. // SetField sets the value of a field with the given name. It returns an error if
  14764. // the field is not defined in the schema, or if the type mismatched the field
  14765. // type.
  14766. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  14767. switch name {
  14768. case creditusage.FieldCreatedAt:
  14769. v, ok := value.(time.Time)
  14770. if !ok {
  14771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14772. }
  14773. m.SetCreatedAt(v)
  14774. return nil
  14775. case creditusage.FieldUpdatedAt:
  14776. v, ok := value.(time.Time)
  14777. if !ok {
  14778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14779. }
  14780. m.SetUpdatedAt(v)
  14781. return nil
  14782. case creditusage.FieldDeletedAt:
  14783. v, ok := value.(time.Time)
  14784. if !ok {
  14785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14786. }
  14787. m.SetDeletedAt(v)
  14788. return nil
  14789. case creditusage.FieldUserID:
  14790. v, ok := value.(string)
  14791. if !ok {
  14792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14793. }
  14794. m.SetUserID(v)
  14795. return nil
  14796. case creditusage.FieldNumber:
  14797. v, ok := value.(float64)
  14798. if !ok {
  14799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14800. }
  14801. m.SetNumber(v)
  14802. return nil
  14803. case creditusage.FieldPayNumber:
  14804. v, ok := value.(float64)
  14805. if !ok {
  14806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14807. }
  14808. m.SetPayNumber(v)
  14809. return nil
  14810. case creditusage.FieldBeforeNumber:
  14811. v, ok := value.(float64)
  14812. if !ok {
  14813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14814. }
  14815. m.SetBeforeNumber(v)
  14816. return nil
  14817. case creditusage.FieldAfterNumber:
  14818. v, ok := value.(float64)
  14819. if !ok {
  14820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14821. }
  14822. m.SetAfterNumber(v)
  14823. return nil
  14824. case creditusage.FieldPayMethod:
  14825. v, ok := value.(string)
  14826. if !ok {
  14827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14828. }
  14829. m.SetPayMethod(v)
  14830. return nil
  14831. case creditusage.FieldStatus:
  14832. v, ok := value.(int)
  14833. if !ok {
  14834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14835. }
  14836. m.SetStatus(v)
  14837. return nil
  14838. case creditusage.FieldNtype:
  14839. v, ok := value.(int)
  14840. if !ok {
  14841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14842. }
  14843. m.SetNtype(v)
  14844. return nil
  14845. case creditusage.FieldTable:
  14846. v, ok := value.(string)
  14847. if !ok {
  14848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14849. }
  14850. m.SetTable(v)
  14851. return nil
  14852. case creditusage.FieldOrganizationID:
  14853. v, ok := value.(uint64)
  14854. if !ok {
  14855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14856. }
  14857. m.SetOrganizationID(v)
  14858. return nil
  14859. case creditusage.FieldNid:
  14860. v, ok := value.(uint64)
  14861. if !ok {
  14862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14863. }
  14864. m.SetNid(v)
  14865. return nil
  14866. case creditusage.FieldReason:
  14867. v, ok := value.(string)
  14868. if !ok {
  14869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14870. }
  14871. m.SetReason(v)
  14872. return nil
  14873. case creditusage.FieldOperator:
  14874. v, ok := value.(string)
  14875. if !ok {
  14876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14877. }
  14878. m.SetOperator(v)
  14879. return nil
  14880. }
  14881. return fmt.Errorf("unknown CreditUsage field %s", name)
  14882. }
  14883. // AddedFields returns all numeric fields that were incremented/decremented during
  14884. // this mutation.
  14885. func (m *CreditUsageMutation) AddedFields() []string {
  14886. var fields []string
  14887. if m.addnumber != nil {
  14888. fields = append(fields, creditusage.FieldNumber)
  14889. }
  14890. if m.addpay_number != nil {
  14891. fields = append(fields, creditusage.FieldPayNumber)
  14892. }
  14893. if m.addbefore_number != nil {
  14894. fields = append(fields, creditusage.FieldBeforeNumber)
  14895. }
  14896. if m.addafter_number != nil {
  14897. fields = append(fields, creditusage.FieldAfterNumber)
  14898. }
  14899. if m.addstatus != nil {
  14900. fields = append(fields, creditusage.FieldStatus)
  14901. }
  14902. if m.addntype != nil {
  14903. fields = append(fields, creditusage.FieldNtype)
  14904. }
  14905. if m.addorganization_id != nil {
  14906. fields = append(fields, creditusage.FieldOrganizationID)
  14907. }
  14908. if m.addnid != nil {
  14909. fields = append(fields, creditusage.FieldNid)
  14910. }
  14911. return fields
  14912. }
  14913. // AddedField returns the numeric value that was incremented/decremented on a field
  14914. // with the given name. The second boolean return value indicates that this field
  14915. // was not set, or was not defined in the schema.
  14916. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  14917. switch name {
  14918. case creditusage.FieldNumber:
  14919. return m.AddedNumber()
  14920. case creditusage.FieldPayNumber:
  14921. return m.AddedPayNumber()
  14922. case creditusage.FieldBeforeNumber:
  14923. return m.AddedBeforeNumber()
  14924. case creditusage.FieldAfterNumber:
  14925. return m.AddedAfterNumber()
  14926. case creditusage.FieldStatus:
  14927. return m.AddedStatus()
  14928. case creditusage.FieldNtype:
  14929. return m.AddedNtype()
  14930. case creditusage.FieldOrganizationID:
  14931. return m.AddedOrganizationID()
  14932. case creditusage.FieldNid:
  14933. return m.AddedNid()
  14934. }
  14935. return nil, false
  14936. }
  14937. // AddField adds the value to the field with the given name. It returns an error if
  14938. // the field is not defined in the schema, or if the type mismatched the field
  14939. // type.
  14940. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  14941. switch name {
  14942. case creditusage.FieldNumber:
  14943. v, ok := value.(float64)
  14944. if !ok {
  14945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14946. }
  14947. m.AddNumber(v)
  14948. return nil
  14949. case creditusage.FieldPayNumber:
  14950. v, ok := value.(float64)
  14951. if !ok {
  14952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14953. }
  14954. m.AddPayNumber(v)
  14955. return nil
  14956. case creditusage.FieldBeforeNumber:
  14957. v, ok := value.(float64)
  14958. if !ok {
  14959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14960. }
  14961. m.AddBeforeNumber(v)
  14962. return nil
  14963. case creditusage.FieldAfterNumber:
  14964. v, ok := value.(float64)
  14965. if !ok {
  14966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14967. }
  14968. m.AddAfterNumber(v)
  14969. return nil
  14970. case creditusage.FieldStatus:
  14971. v, ok := value.(int)
  14972. if !ok {
  14973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14974. }
  14975. m.AddStatus(v)
  14976. return nil
  14977. case creditusage.FieldNtype:
  14978. v, ok := value.(int)
  14979. if !ok {
  14980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14981. }
  14982. m.AddNtype(v)
  14983. return nil
  14984. case creditusage.FieldOrganizationID:
  14985. v, ok := value.(int64)
  14986. if !ok {
  14987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14988. }
  14989. m.AddOrganizationID(v)
  14990. return nil
  14991. case creditusage.FieldNid:
  14992. v, ok := value.(int64)
  14993. if !ok {
  14994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14995. }
  14996. m.AddNid(v)
  14997. return nil
  14998. }
  14999. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  15000. }
  15001. // ClearedFields returns all nullable fields that were cleared during this
  15002. // mutation.
  15003. func (m *CreditUsageMutation) ClearedFields() []string {
  15004. var fields []string
  15005. if m.FieldCleared(creditusage.FieldDeletedAt) {
  15006. fields = append(fields, creditusage.FieldDeletedAt)
  15007. }
  15008. if m.FieldCleared(creditusage.FieldUserID) {
  15009. fields = append(fields, creditusage.FieldUserID)
  15010. }
  15011. if m.FieldCleared(creditusage.FieldPayNumber) {
  15012. fields = append(fields, creditusage.FieldPayNumber)
  15013. }
  15014. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  15015. fields = append(fields, creditusage.FieldBeforeNumber)
  15016. }
  15017. if m.FieldCleared(creditusage.FieldAfterNumber) {
  15018. fields = append(fields, creditusage.FieldAfterNumber)
  15019. }
  15020. if m.FieldCleared(creditusage.FieldPayMethod) {
  15021. fields = append(fields, creditusage.FieldPayMethod)
  15022. }
  15023. if m.FieldCleared(creditusage.FieldStatus) {
  15024. fields = append(fields, creditusage.FieldStatus)
  15025. }
  15026. if m.FieldCleared(creditusage.FieldOrganizationID) {
  15027. fields = append(fields, creditusage.FieldOrganizationID)
  15028. }
  15029. return fields
  15030. }
  15031. // FieldCleared returns a boolean indicating if a field with the given name was
  15032. // cleared in this mutation.
  15033. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  15034. _, ok := m.clearedFields[name]
  15035. return ok
  15036. }
  15037. // ClearField clears the value of the field with the given name. It returns an
  15038. // error if the field is not defined in the schema.
  15039. func (m *CreditUsageMutation) ClearField(name string) error {
  15040. switch name {
  15041. case creditusage.FieldDeletedAt:
  15042. m.ClearDeletedAt()
  15043. return nil
  15044. case creditusage.FieldUserID:
  15045. m.ClearUserID()
  15046. return nil
  15047. case creditusage.FieldPayNumber:
  15048. m.ClearPayNumber()
  15049. return nil
  15050. case creditusage.FieldBeforeNumber:
  15051. m.ClearBeforeNumber()
  15052. return nil
  15053. case creditusage.FieldAfterNumber:
  15054. m.ClearAfterNumber()
  15055. return nil
  15056. case creditusage.FieldPayMethod:
  15057. m.ClearPayMethod()
  15058. return nil
  15059. case creditusage.FieldStatus:
  15060. m.ClearStatus()
  15061. return nil
  15062. case creditusage.FieldOrganizationID:
  15063. m.ClearOrganizationID()
  15064. return nil
  15065. }
  15066. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  15067. }
  15068. // ResetField resets all changes in the mutation for the field with the given name.
  15069. // It returns an error if the field is not defined in the schema.
  15070. func (m *CreditUsageMutation) ResetField(name string) error {
  15071. switch name {
  15072. case creditusage.FieldCreatedAt:
  15073. m.ResetCreatedAt()
  15074. return nil
  15075. case creditusage.FieldUpdatedAt:
  15076. m.ResetUpdatedAt()
  15077. return nil
  15078. case creditusage.FieldDeletedAt:
  15079. m.ResetDeletedAt()
  15080. return nil
  15081. case creditusage.FieldUserID:
  15082. m.ResetUserID()
  15083. return nil
  15084. case creditusage.FieldNumber:
  15085. m.ResetNumber()
  15086. return nil
  15087. case creditusage.FieldPayNumber:
  15088. m.ResetPayNumber()
  15089. return nil
  15090. case creditusage.FieldBeforeNumber:
  15091. m.ResetBeforeNumber()
  15092. return nil
  15093. case creditusage.FieldAfterNumber:
  15094. m.ResetAfterNumber()
  15095. return nil
  15096. case creditusage.FieldPayMethod:
  15097. m.ResetPayMethod()
  15098. return nil
  15099. case creditusage.FieldStatus:
  15100. m.ResetStatus()
  15101. return nil
  15102. case creditusage.FieldNtype:
  15103. m.ResetNtype()
  15104. return nil
  15105. case creditusage.FieldTable:
  15106. m.ResetTable()
  15107. return nil
  15108. case creditusage.FieldOrganizationID:
  15109. m.ResetOrganizationID()
  15110. return nil
  15111. case creditusage.FieldNid:
  15112. m.ResetNid()
  15113. return nil
  15114. case creditusage.FieldReason:
  15115. m.ResetReason()
  15116. return nil
  15117. case creditusage.FieldOperator:
  15118. m.ResetOperator()
  15119. return nil
  15120. }
  15121. return fmt.Errorf("unknown CreditUsage field %s", name)
  15122. }
  15123. // AddedEdges returns all edge names that were set/added in this mutation.
  15124. func (m *CreditUsageMutation) AddedEdges() []string {
  15125. edges := make([]string, 0, 0)
  15126. return edges
  15127. }
  15128. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15129. // name in this mutation.
  15130. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  15131. return nil
  15132. }
  15133. // RemovedEdges returns all edge names that were removed in this mutation.
  15134. func (m *CreditUsageMutation) RemovedEdges() []string {
  15135. edges := make([]string, 0, 0)
  15136. return edges
  15137. }
  15138. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15139. // the given name in this mutation.
  15140. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  15141. return nil
  15142. }
  15143. // ClearedEdges returns all edge names that were cleared in this mutation.
  15144. func (m *CreditUsageMutation) ClearedEdges() []string {
  15145. edges := make([]string, 0, 0)
  15146. return edges
  15147. }
  15148. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15149. // was cleared in this mutation.
  15150. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  15151. return false
  15152. }
  15153. // ClearEdge clears the value of the edge with the given name. It returns an error
  15154. // if that edge is not defined in the schema.
  15155. func (m *CreditUsageMutation) ClearEdge(name string) error {
  15156. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  15157. }
  15158. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15159. // It returns an error if the edge is not defined in the schema.
  15160. func (m *CreditUsageMutation) ResetEdge(name string) error {
  15161. return fmt.Errorf("unknown CreditUsage edge %s", name)
  15162. }
  15163. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  15164. type EmployeeMutation struct {
  15165. config
  15166. op Op
  15167. typ string
  15168. id *uint64
  15169. created_at *time.Time
  15170. updated_at *time.Time
  15171. deleted_at *time.Time
  15172. title *string
  15173. avatar *string
  15174. tags *string
  15175. hire_count *int
  15176. addhire_count *int
  15177. service_count *int
  15178. addservice_count *int
  15179. achievement_count *int
  15180. addachievement_count *int
  15181. intro *string
  15182. estimate *string
  15183. skill *string
  15184. ability_type *string
  15185. scene *string
  15186. switch_in *string
  15187. video_url *string
  15188. organization_id *uint64
  15189. addorganization_id *int64
  15190. category_id *uint64
  15191. addcategory_id *int64
  15192. api_base *string
  15193. api_key *string
  15194. ai_info *string
  15195. is_vip *int
  15196. addis_vip *int
  15197. chat_url *string
  15198. clearedFields map[string]struct{}
  15199. em_work_experiences map[uint64]struct{}
  15200. removedem_work_experiences map[uint64]struct{}
  15201. clearedem_work_experiences bool
  15202. em_tutorial map[uint64]struct{}
  15203. removedem_tutorial map[uint64]struct{}
  15204. clearedem_tutorial bool
  15205. done bool
  15206. oldValue func(context.Context) (*Employee, error)
  15207. predicates []predicate.Employee
  15208. }
  15209. var _ ent.Mutation = (*EmployeeMutation)(nil)
  15210. // employeeOption allows management of the mutation configuration using functional options.
  15211. type employeeOption func(*EmployeeMutation)
  15212. // newEmployeeMutation creates new mutation for the Employee entity.
  15213. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  15214. m := &EmployeeMutation{
  15215. config: c,
  15216. op: op,
  15217. typ: TypeEmployee,
  15218. clearedFields: make(map[string]struct{}),
  15219. }
  15220. for _, opt := range opts {
  15221. opt(m)
  15222. }
  15223. return m
  15224. }
  15225. // withEmployeeID sets the ID field of the mutation.
  15226. func withEmployeeID(id uint64) employeeOption {
  15227. return func(m *EmployeeMutation) {
  15228. var (
  15229. err error
  15230. once sync.Once
  15231. value *Employee
  15232. )
  15233. m.oldValue = func(ctx context.Context) (*Employee, error) {
  15234. once.Do(func() {
  15235. if m.done {
  15236. err = errors.New("querying old values post mutation is not allowed")
  15237. } else {
  15238. value, err = m.Client().Employee.Get(ctx, id)
  15239. }
  15240. })
  15241. return value, err
  15242. }
  15243. m.id = &id
  15244. }
  15245. }
  15246. // withEmployee sets the old Employee of the mutation.
  15247. func withEmployee(node *Employee) employeeOption {
  15248. return func(m *EmployeeMutation) {
  15249. m.oldValue = func(context.Context) (*Employee, error) {
  15250. return node, nil
  15251. }
  15252. m.id = &node.ID
  15253. }
  15254. }
  15255. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15256. // executed in a transaction (ent.Tx), a transactional client is returned.
  15257. func (m EmployeeMutation) Client() *Client {
  15258. client := &Client{config: m.config}
  15259. client.init()
  15260. return client
  15261. }
  15262. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15263. // it returns an error otherwise.
  15264. func (m EmployeeMutation) Tx() (*Tx, error) {
  15265. if _, ok := m.driver.(*txDriver); !ok {
  15266. return nil, errors.New("ent: mutation is not running in a transaction")
  15267. }
  15268. tx := &Tx{config: m.config}
  15269. tx.init()
  15270. return tx, nil
  15271. }
  15272. // SetID sets the value of the id field. Note that this
  15273. // operation is only accepted on creation of Employee entities.
  15274. func (m *EmployeeMutation) SetID(id uint64) {
  15275. m.id = &id
  15276. }
  15277. // ID returns the ID value in the mutation. Note that the ID is only available
  15278. // if it was provided to the builder or after it was returned from the database.
  15279. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  15280. if m.id == nil {
  15281. return
  15282. }
  15283. return *m.id, true
  15284. }
  15285. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15286. // That means, if the mutation is applied within a transaction with an isolation level such
  15287. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15288. // or updated by the mutation.
  15289. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  15290. switch {
  15291. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15292. id, exists := m.ID()
  15293. if exists {
  15294. return []uint64{id}, nil
  15295. }
  15296. fallthrough
  15297. case m.op.Is(OpUpdate | OpDelete):
  15298. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  15299. default:
  15300. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15301. }
  15302. }
  15303. // SetCreatedAt sets the "created_at" field.
  15304. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  15305. m.created_at = &t
  15306. }
  15307. // CreatedAt returns the value of the "created_at" field in the mutation.
  15308. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  15309. v := m.created_at
  15310. if v == nil {
  15311. return
  15312. }
  15313. return *v, true
  15314. }
  15315. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  15316. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15318. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15319. if !m.op.Is(OpUpdateOne) {
  15320. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15321. }
  15322. if m.id == nil || m.oldValue == nil {
  15323. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15324. }
  15325. oldValue, err := m.oldValue(ctx)
  15326. if err != nil {
  15327. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15328. }
  15329. return oldValue.CreatedAt, nil
  15330. }
  15331. // ResetCreatedAt resets all changes to the "created_at" field.
  15332. func (m *EmployeeMutation) ResetCreatedAt() {
  15333. m.created_at = nil
  15334. }
  15335. // SetUpdatedAt sets the "updated_at" field.
  15336. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  15337. m.updated_at = &t
  15338. }
  15339. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15340. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  15341. v := m.updated_at
  15342. if v == nil {
  15343. return
  15344. }
  15345. return *v, true
  15346. }
  15347. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15351. if !m.op.Is(OpUpdateOne) {
  15352. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15353. }
  15354. if m.id == nil || m.oldValue == nil {
  15355. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  15360. }
  15361. return oldValue.UpdatedAt, nil
  15362. }
  15363. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15364. func (m *EmployeeMutation) ResetUpdatedAt() {
  15365. m.updated_at = nil
  15366. }
  15367. // SetDeletedAt sets the "deleted_at" field.
  15368. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  15369. m.deleted_at = &t
  15370. }
  15371. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15372. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  15373. v := m.deleted_at
  15374. if v == nil {
  15375. return
  15376. }
  15377. return *v, true
  15378. }
  15379. // OldDeletedAt returns the old "deleted_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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15383. if !m.op.Is(OpUpdateOne) {
  15384. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15385. }
  15386. if m.id == nil || m.oldValue == nil {
  15387. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  15392. }
  15393. return oldValue.DeletedAt, nil
  15394. }
  15395. // ClearDeletedAt clears the value of the "deleted_at" field.
  15396. func (m *EmployeeMutation) ClearDeletedAt() {
  15397. m.deleted_at = nil
  15398. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  15399. }
  15400. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15401. func (m *EmployeeMutation) DeletedAtCleared() bool {
  15402. _, ok := m.clearedFields[employee.FieldDeletedAt]
  15403. return ok
  15404. }
  15405. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15406. func (m *EmployeeMutation) ResetDeletedAt() {
  15407. m.deleted_at = nil
  15408. delete(m.clearedFields, employee.FieldDeletedAt)
  15409. }
  15410. // SetTitle sets the "title" field.
  15411. func (m *EmployeeMutation) SetTitle(s string) {
  15412. m.title = &s
  15413. }
  15414. // Title returns the value of the "title" field in the mutation.
  15415. func (m *EmployeeMutation) Title() (r string, exists bool) {
  15416. v := m.title
  15417. if v == nil {
  15418. return
  15419. }
  15420. return *v, true
  15421. }
  15422. // OldTitle returns the old "title" field's value of the Employee entity.
  15423. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15425. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  15426. if !m.op.Is(OpUpdateOne) {
  15427. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15428. }
  15429. if m.id == nil || m.oldValue == nil {
  15430. return v, errors.New("OldTitle requires an ID field in the mutation")
  15431. }
  15432. oldValue, err := m.oldValue(ctx)
  15433. if err != nil {
  15434. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15435. }
  15436. return oldValue.Title, nil
  15437. }
  15438. // ResetTitle resets all changes to the "title" field.
  15439. func (m *EmployeeMutation) ResetTitle() {
  15440. m.title = nil
  15441. }
  15442. // SetAvatar sets the "avatar" field.
  15443. func (m *EmployeeMutation) SetAvatar(s string) {
  15444. m.avatar = &s
  15445. }
  15446. // Avatar returns the value of the "avatar" field in the mutation.
  15447. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  15448. v := m.avatar
  15449. if v == nil {
  15450. return
  15451. }
  15452. return *v, true
  15453. }
  15454. // OldAvatar returns the old "avatar" 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) OldAvatar(ctx context.Context) (v string, err error) {
  15458. if !m.op.Is(OpUpdateOne) {
  15459. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  15460. }
  15461. if m.id == nil || m.oldValue == nil {
  15462. return v, errors.New("OldAvatar 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 OldAvatar: %w", err)
  15467. }
  15468. return oldValue.Avatar, nil
  15469. }
  15470. // ResetAvatar resets all changes to the "avatar" field.
  15471. func (m *EmployeeMutation) ResetAvatar() {
  15472. m.avatar = nil
  15473. }
  15474. // SetTags sets the "tags" field.
  15475. func (m *EmployeeMutation) SetTags(s string) {
  15476. m.tags = &s
  15477. }
  15478. // Tags returns the value of the "tags" field in the mutation.
  15479. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  15480. v := m.tags
  15481. if v == nil {
  15482. return
  15483. }
  15484. return *v, true
  15485. }
  15486. // OldTags returns the old "tags" 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) OldTags(ctx context.Context) (v string, err error) {
  15490. if !m.op.Is(OpUpdateOne) {
  15491. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  15492. }
  15493. if m.id == nil || m.oldValue == nil {
  15494. return v, errors.New("OldTags 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 OldTags: %w", err)
  15499. }
  15500. return oldValue.Tags, nil
  15501. }
  15502. // ResetTags resets all changes to the "tags" field.
  15503. func (m *EmployeeMutation) ResetTags() {
  15504. m.tags = nil
  15505. }
  15506. // SetHireCount sets the "hire_count" field.
  15507. func (m *EmployeeMutation) SetHireCount(i int) {
  15508. m.hire_count = &i
  15509. m.addhire_count = nil
  15510. }
  15511. // HireCount returns the value of the "hire_count" field in the mutation.
  15512. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  15513. v := m.hire_count
  15514. if v == nil {
  15515. return
  15516. }
  15517. return *v, true
  15518. }
  15519. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  15520. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15522. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  15523. if !m.op.Is(OpUpdateOne) {
  15524. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  15525. }
  15526. if m.id == nil || m.oldValue == nil {
  15527. return v, errors.New("OldHireCount requires an ID field in the mutation")
  15528. }
  15529. oldValue, err := m.oldValue(ctx)
  15530. if err != nil {
  15531. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  15532. }
  15533. return oldValue.HireCount, nil
  15534. }
  15535. // AddHireCount adds i to the "hire_count" field.
  15536. func (m *EmployeeMutation) AddHireCount(i int) {
  15537. if m.addhire_count != nil {
  15538. *m.addhire_count += i
  15539. } else {
  15540. m.addhire_count = &i
  15541. }
  15542. }
  15543. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  15544. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  15545. v := m.addhire_count
  15546. if v == nil {
  15547. return
  15548. }
  15549. return *v, true
  15550. }
  15551. // ResetHireCount resets all changes to the "hire_count" field.
  15552. func (m *EmployeeMutation) ResetHireCount() {
  15553. m.hire_count = nil
  15554. m.addhire_count = nil
  15555. }
  15556. // SetServiceCount sets the "service_count" field.
  15557. func (m *EmployeeMutation) SetServiceCount(i int) {
  15558. m.service_count = &i
  15559. m.addservice_count = nil
  15560. }
  15561. // ServiceCount returns the value of the "service_count" field in the mutation.
  15562. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  15563. v := m.service_count
  15564. if v == nil {
  15565. return
  15566. }
  15567. return *v, true
  15568. }
  15569. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  15570. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15572. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  15573. if !m.op.Is(OpUpdateOne) {
  15574. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  15575. }
  15576. if m.id == nil || m.oldValue == nil {
  15577. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  15578. }
  15579. oldValue, err := m.oldValue(ctx)
  15580. if err != nil {
  15581. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  15582. }
  15583. return oldValue.ServiceCount, nil
  15584. }
  15585. // AddServiceCount adds i to the "service_count" field.
  15586. func (m *EmployeeMutation) AddServiceCount(i int) {
  15587. if m.addservice_count != nil {
  15588. *m.addservice_count += i
  15589. } else {
  15590. m.addservice_count = &i
  15591. }
  15592. }
  15593. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  15594. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  15595. v := m.addservice_count
  15596. if v == nil {
  15597. return
  15598. }
  15599. return *v, true
  15600. }
  15601. // ResetServiceCount resets all changes to the "service_count" field.
  15602. func (m *EmployeeMutation) ResetServiceCount() {
  15603. m.service_count = nil
  15604. m.addservice_count = nil
  15605. }
  15606. // SetAchievementCount sets the "achievement_count" field.
  15607. func (m *EmployeeMutation) SetAchievementCount(i int) {
  15608. m.achievement_count = &i
  15609. m.addachievement_count = nil
  15610. }
  15611. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  15612. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  15613. v := m.achievement_count
  15614. if v == nil {
  15615. return
  15616. }
  15617. return *v, true
  15618. }
  15619. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  15620. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15622. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  15623. if !m.op.Is(OpUpdateOne) {
  15624. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  15625. }
  15626. if m.id == nil || m.oldValue == nil {
  15627. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  15628. }
  15629. oldValue, err := m.oldValue(ctx)
  15630. if err != nil {
  15631. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  15632. }
  15633. return oldValue.AchievementCount, nil
  15634. }
  15635. // AddAchievementCount adds i to the "achievement_count" field.
  15636. func (m *EmployeeMutation) AddAchievementCount(i int) {
  15637. if m.addachievement_count != nil {
  15638. *m.addachievement_count += i
  15639. } else {
  15640. m.addachievement_count = &i
  15641. }
  15642. }
  15643. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  15644. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  15645. v := m.addachievement_count
  15646. if v == nil {
  15647. return
  15648. }
  15649. return *v, true
  15650. }
  15651. // ResetAchievementCount resets all changes to the "achievement_count" field.
  15652. func (m *EmployeeMutation) ResetAchievementCount() {
  15653. m.achievement_count = nil
  15654. m.addachievement_count = nil
  15655. }
  15656. // SetIntro sets the "intro" field.
  15657. func (m *EmployeeMutation) SetIntro(s string) {
  15658. m.intro = &s
  15659. }
  15660. // Intro returns the value of the "intro" field in the mutation.
  15661. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  15662. v := m.intro
  15663. if v == nil {
  15664. return
  15665. }
  15666. return *v, true
  15667. }
  15668. // OldIntro returns the old "intro" field's value of the Employee entity.
  15669. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15671. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  15672. if !m.op.Is(OpUpdateOne) {
  15673. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  15674. }
  15675. if m.id == nil || m.oldValue == nil {
  15676. return v, errors.New("OldIntro requires an ID field in the mutation")
  15677. }
  15678. oldValue, err := m.oldValue(ctx)
  15679. if err != nil {
  15680. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  15681. }
  15682. return oldValue.Intro, nil
  15683. }
  15684. // ResetIntro resets all changes to the "intro" field.
  15685. func (m *EmployeeMutation) ResetIntro() {
  15686. m.intro = nil
  15687. }
  15688. // SetEstimate sets the "estimate" field.
  15689. func (m *EmployeeMutation) SetEstimate(s string) {
  15690. m.estimate = &s
  15691. }
  15692. // Estimate returns the value of the "estimate" field in the mutation.
  15693. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  15694. v := m.estimate
  15695. if v == nil {
  15696. return
  15697. }
  15698. return *v, true
  15699. }
  15700. // OldEstimate returns the old "estimate" 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) OldEstimate(ctx context.Context) (v string, err error) {
  15704. if !m.op.Is(OpUpdateOne) {
  15705. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  15706. }
  15707. if m.id == nil || m.oldValue == nil {
  15708. return v, errors.New("OldEstimate 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 OldEstimate: %w", err)
  15713. }
  15714. return oldValue.Estimate, nil
  15715. }
  15716. // ResetEstimate resets all changes to the "estimate" field.
  15717. func (m *EmployeeMutation) ResetEstimate() {
  15718. m.estimate = nil
  15719. }
  15720. // SetSkill sets the "skill" field.
  15721. func (m *EmployeeMutation) SetSkill(s string) {
  15722. m.skill = &s
  15723. }
  15724. // Skill returns the value of the "skill" field in the mutation.
  15725. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  15726. v := m.skill
  15727. if v == nil {
  15728. return
  15729. }
  15730. return *v, true
  15731. }
  15732. // OldSkill returns the old "skill" 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) OldSkill(ctx context.Context) (v string, err error) {
  15736. if !m.op.Is(OpUpdateOne) {
  15737. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  15738. }
  15739. if m.id == nil || m.oldValue == nil {
  15740. return v, errors.New("OldSkill 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 OldSkill: %w", err)
  15745. }
  15746. return oldValue.Skill, nil
  15747. }
  15748. // ResetSkill resets all changes to the "skill" field.
  15749. func (m *EmployeeMutation) ResetSkill() {
  15750. m.skill = nil
  15751. }
  15752. // SetAbilityType sets the "ability_type" field.
  15753. func (m *EmployeeMutation) SetAbilityType(s string) {
  15754. m.ability_type = &s
  15755. }
  15756. // AbilityType returns the value of the "ability_type" field in the mutation.
  15757. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  15758. v := m.ability_type
  15759. if v == nil {
  15760. return
  15761. }
  15762. return *v, true
  15763. }
  15764. // OldAbilityType returns the old "ability_type" 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) OldAbilityType(ctx context.Context) (v string, err error) {
  15768. if !m.op.Is(OpUpdateOne) {
  15769. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  15770. }
  15771. if m.id == nil || m.oldValue == nil {
  15772. return v, errors.New("OldAbilityType 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 OldAbilityType: %w", err)
  15777. }
  15778. return oldValue.AbilityType, nil
  15779. }
  15780. // ResetAbilityType resets all changes to the "ability_type" field.
  15781. func (m *EmployeeMutation) ResetAbilityType() {
  15782. m.ability_type = nil
  15783. }
  15784. // SetScene sets the "scene" field.
  15785. func (m *EmployeeMutation) SetScene(s string) {
  15786. m.scene = &s
  15787. }
  15788. // Scene returns the value of the "scene" field in the mutation.
  15789. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  15790. v := m.scene
  15791. if v == nil {
  15792. return
  15793. }
  15794. return *v, true
  15795. }
  15796. // OldScene returns the old "scene" 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) OldScene(ctx context.Context) (v string, err error) {
  15800. if !m.op.Is(OpUpdateOne) {
  15801. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  15802. }
  15803. if m.id == nil || m.oldValue == nil {
  15804. return v, errors.New("OldScene 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 OldScene: %w", err)
  15809. }
  15810. return oldValue.Scene, nil
  15811. }
  15812. // ResetScene resets all changes to the "scene" field.
  15813. func (m *EmployeeMutation) ResetScene() {
  15814. m.scene = nil
  15815. }
  15816. // SetSwitchIn sets the "switch_in" field.
  15817. func (m *EmployeeMutation) SetSwitchIn(s string) {
  15818. m.switch_in = &s
  15819. }
  15820. // SwitchIn returns the value of the "switch_in" field in the mutation.
  15821. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  15822. v := m.switch_in
  15823. if v == nil {
  15824. return
  15825. }
  15826. return *v, true
  15827. }
  15828. // OldSwitchIn returns the old "switch_in" 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) OldSwitchIn(ctx context.Context) (v string, err error) {
  15832. if !m.op.Is(OpUpdateOne) {
  15833. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  15834. }
  15835. if m.id == nil || m.oldValue == nil {
  15836. return v, errors.New("OldSwitchIn 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 OldSwitchIn: %w", err)
  15841. }
  15842. return oldValue.SwitchIn, nil
  15843. }
  15844. // ResetSwitchIn resets all changes to the "switch_in" field.
  15845. func (m *EmployeeMutation) ResetSwitchIn() {
  15846. m.switch_in = nil
  15847. }
  15848. // SetVideoURL sets the "video_url" field.
  15849. func (m *EmployeeMutation) SetVideoURL(s string) {
  15850. m.video_url = &s
  15851. }
  15852. // VideoURL returns the value of the "video_url" field in the mutation.
  15853. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  15854. v := m.video_url
  15855. if v == nil {
  15856. return
  15857. }
  15858. return *v, true
  15859. }
  15860. // OldVideoURL returns the old "video_url" 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) OldVideoURL(ctx context.Context) (v string, err error) {
  15864. if !m.op.Is(OpUpdateOne) {
  15865. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  15866. }
  15867. if m.id == nil || m.oldValue == nil {
  15868. return v, errors.New("OldVideoURL 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 OldVideoURL: %w", err)
  15873. }
  15874. return oldValue.VideoURL, nil
  15875. }
  15876. // ResetVideoURL resets all changes to the "video_url" field.
  15877. func (m *EmployeeMutation) ResetVideoURL() {
  15878. m.video_url = nil
  15879. }
  15880. // SetOrganizationID sets the "organization_id" field.
  15881. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  15882. m.organization_id = &u
  15883. m.addorganization_id = nil
  15884. }
  15885. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15886. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  15887. v := m.organization_id
  15888. if v == nil {
  15889. return
  15890. }
  15891. return *v, true
  15892. }
  15893. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  15894. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15896. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15897. if !m.op.Is(OpUpdateOne) {
  15898. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15899. }
  15900. if m.id == nil || m.oldValue == nil {
  15901. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15902. }
  15903. oldValue, err := m.oldValue(ctx)
  15904. if err != nil {
  15905. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15906. }
  15907. return oldValue.OrganizationID, nil
  15908. }
  15909. // AddOrganizationID adds u to the "organization_id" field.
  15910. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  15911. if m.addorganization_id != nil {
  15912. *m.addorganization_id += u
  15913. } else {
  15914. m.addorganization_id = &u
  15915. }
  15916. }
  15917. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15918. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  15919. v := m.addorganization_id
  15920. if v == nil {
  15921. return
  15922. }
  15923. return *v, true
  15924. }
  15925. // ResetOrganizationID resets all changes to the "organization_id" field.
  15926. func (m *EmployeeMutation) ResetOrganizationID() {
  15927. m.organization_id = nil
  15928. m.addorganization_id = nil
  15929. }
  15930. // SetCategoryID sets the "category_id" field.
  15931. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  15932. m.category_id = &u
  15933. m.addcategory_id = nil
  15934. }
  15935. // CategoryID returns the value of the "category_id" field in the mutation.
  15936. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  15937. v := m.category_id
  15938. if v == nil {
  15939. return
  15940. }
  15941. return *v, true
  15942. }
  15943. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  15944. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15946. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  15947. if !m.op.Is(OpUpdateOne) {
  15948. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  15949. }
  15950. if m.id == nil || m.oldValue == nil {
  15951. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  15952. }
  15953. oldValue, err := m.oldValue(ctx)
  15954. if err != nil {
  15955. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  15956. }
  15957. return oldValue.CategoryID, nil
  15958. }
  15959. // AddCategoryID adds u to the "category_id" field.
  15960. func (m *EmployeeMutation) AddCategoryID(u int64) {
  15961. if m.addcategory_id != nil {
  15962. *m.addcategory_id += u
  15963. } else {
  15964. m.addcategory_id = &u
  15965. }
  15966. }
  15967. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  15968. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  15969. v := m.addcategory_id
  15970. if v == nil {
  15971. return
  15972. }
  15973. return *v, true
  15974. }
  15975. // ResetCategoryID resets all changes to the "category_id" field.
  15976. func (m *EmployeeMutation) ResetCategoryID() {
  15977. m.category_id = nil
  15978. m.addcategory_id = nil
  15979. }
  15980. // SetAPIBase sets the "api_base" field.
  15981. func (m *EmployeeMutation) SetAPIBase(s string) {
  15982. m.api_base = &s
  15983. }
  15984. // APIBase returns the value of the "api_base" field in the mutation.
  15985. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  15986. v := m.api_base
  15987. if v == nil {
  15988. return
  15989. }
  15990. return *v, true
  15991. }
  15992. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  15993. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15995. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  15996. if !m.op.Is(OpUpdateOne) {
  15997. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  15998. }
  15999. if m.id == nil || m.oldValue == nil {
  16000. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  16001. }
  16002. oldValue, err := m.oldValue(ctx)
  16003. if err != nil {
  16004. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  16005. }
  16006. return oldValue.APIBase, nil
  16007. }
  16008. // ResetAPIBase resets all changes to the "api_base" field.
  16009. func (m *EmployeeMutation) ResetAPIBase() {
  16010. m.api_base = nil
  16011. }
  16012. // SetAPIKey sets the "api_key" field.
  16013. func (m *EmployeeMutation) SetAPIKey(s string) {
  16014. m.api_key = &s
  16015. }
  16016. // APIKey returns the value of the "api_key" field in the mutation.
  16017. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  16018. v := m.api_key
  16019. if v == nil {
  16020. return
  16021. }
  16022. return *v, true
  16023. }
  16024. // OldAPIKey returns the old "api_key" 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) OldAPIKey(ctx context.Context) (v string, err error) {
  16028. if !m.op.Is(OpUpdateOne) {
  16029. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  16030. }
  16031. if m.id == nil || m.oldValue == nil {
  16032. return v, errors.New("OldAPIKey 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 OldAPIKey: %w", err)
  16037. }
  16038. return oldValue.APIKey, nil
  16039. }
  16040. // ResetAPIKey resets all changes to the "api_key" field.
  16041. func (m *EmployeeMutation) ResetAPIKey() {
  16042. m.api_key = nil
  16043. }
  16044. // SetAiInfo sets the "ai_info" field.
  16045. func (m *EmployeeMutation) SetAiInfo(s string) {
  16046. m.ai_info = &s
  16047. }
  16048. // AiInfo returns the value of the "ai_info" field in the mutation.
  16049. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  16050. v := m.ai_info
  16051. if v == nil {
  16052. return
  16053. }
  16054. return *v, true
  16055. }
  16056. // OldAiInfo returns the old "ai_info" 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) OldAiInfo(ctx context.Context) (v string, err error) {
  16060. if !m.op.Is(OpUpdateOne) {
  16061. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  16062. }
  16063. if m.id == nil || m.oldValue == nil {
  16064. return v, errors.New("OldAiInfo 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 OldAiInfo: %w", err)
  16069. }
  16070. return oldValue.AiInfo, nil
  16071. }
  16072. // ClearAiInfo clears the value of the "ai_info" field.
  16073. func (m *EmployeeMutation) ClearAiInfo() {
  16074. m.ai_info = nil
  16075. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  16076. }
  16077. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  16078. func (m *EmployeeMutation) AiInfoCleared() bool {
  16079. _, ok := m.clearedFields[employee.FieldAiInfo]
  16080. return ok
  16081. }
  16082. // ResetAiInfo resets all changes to the "ai_info" field.
  16083. func (m *EmployeeMutation) ResetAiInfo() {
  16084. m.ai_info = nil
  16085. delete(m.clearedFields, employee.FieldAiInfo)
  16086. }
  16087. // SetIsVip sets the "is_vip" field.
  16088. func (m *EmployeeMutation) SetIsVip(i int) {
  16089. m.is_vip = &i
  16090. m.addis_vip = nil
  16091. }
  16092. // IsVip returns the value of the "is_vip" field in the mutation.
  16093. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  16094. v := m.is_vip
  16095. if v == nil {
  16096. return
  16097. }
  16098. return *v, true
  16099. }
  16100. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  16101. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16103. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  16104. if !m.op.Is(OpUpdateOne) {
  16105. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  16106. }
  16107. if m.id == nil || m.oldValue == nil {
  16108. return v, errors.New("OldIsVip requires an ID field in the mutation")
  16109. }
  16110. oldValue, err := m.oldValue(ctx)
  16111. if err != nil {
  16112. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  16113. }
  16114. return oldValue.IsVip, nil
  16115. }
  16116. // AddIsVip adds i to the "is_vip" field.
  16117. func (m *EmployeeMutation) AddIsVip(i int) {
  16118. if m.addis_vip != nil {
  16119. *m.addis_vip += i
  16120. } else {
  16121. m.addis_vip = &i
  16122. }
  16123. }
  16124. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  16125. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  16126. v := m.addis_vip
  16127. if v == nil {
  16128. return
  16129. }
  16130. return *v, true
  16131. }
  16132. // ResetIsVip resets all changes to the "is_vip" field.
  16133. func (m *EmployeeMutation) ResetIsVip() {
  16134. m.is_vip = nil
  16135. m.addis_vip = nil
  16136. }
  16137. // SetChatURL sets the "chat_url" field.
  16138. func (m *EmployeeMutation) SetChatURL(s string) {
  16139. m.chat_url = &s
  16140. }
  16141. // ChatURL returns the value of the "chat_url" field in the mutation.
  16142. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  16143. v := m.chat_url
  16144. if v == nil {
  16145. return
  16146. }
  16147. return *v, true
  16148. }
  16149. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  16150. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16152. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  16153. if !m.op.Is(OpUpdateOne) {
  16154. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  16155. }
  16156. if m.id == nil || m.oldValue == nil {
  16157. return v, errors.New("OldChatURL requires an ID field in the mutation")
  16158. }
  16159. oldValue, err := m.oldValue(ctx)
  16160. if err != nil {
  16161. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  16162. }
  16163. return oldValue.ChatURL, nil
  16164. }
  16165. // ResetChatURL resets all changes to the "chat_url" field.
  16166. func (m *EmployeeMutation) ResetChatURL() {
  16167. m.chat_url = nil
  16168. }
  16169. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  16170. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  16171. if m.em_work_experiences == nil {
  16172. m.em_work_experiences = make(map[uint64]struct{})
  16173. }
  16174. for i := range ids {
  16175. m.em_work_experiences[ids[i]] = struct{}{}
  16176. }
  16177. }
  16178. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  16179. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  16180. m.clearedem_work_experiences = true
  16181. }
  16182. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  16183. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  16184. return m.clearedem_work_experiences
  16185. }
  16186. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  16187. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  16188. if m.removedem_work_experiences == nil {
  16189. m.removedem_work_experiences = make(map[uint64]struct{})
  16190. }
  16191. for i := range ids {
  16192. delete(m.em_work_experiences, ids[i])
  16193. m.removedem_work_experiences[ids[i]] = struct{}{}
  16194. }
  16195. }
  16196. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  16197. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  16198. for id := range m.removedem_work_experiences {
  16199. ids = append(ids, id)
  16200. }
  16201. return
  16202. }
  16203. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  16204. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  16205. for id := range m.em_work_experiences {
  16206. ids = append(ids, id)
  16207. }
  16208. return
  16209. }
  16210. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  16211. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  16212. m.em_work_experiences = nil
  16213. m.clearedem_work_experiences = false
  16214. m.removedem_work_experiences = nil
  16215. }
  16216. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  16217. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  16218. if m.em_tutorial == nil {
  16219. m.em_tutorial = make(map[uint64]struct{})
  16220. }
  16221. for i := range ids {
  16222. m.em_tutorial[ids[i]] = struct{}{}
  16223. }
  16224. }
  16225. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  16226. func (m *EmployeeMutation) ClearEmTutorial() {
  16227. m.clearedem_tutorial = true
  16228. }
  16229. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  16230. func (m *EmployeeMutation) EmTutorialCleared() bool {
  16231. return m.clearedem_tutorial
  16232. }
  16233. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  16234. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  16235. if m.removedem_tutorial == nil {
  16236. m.removedem_tutorial = make(map[uint64]struct{})
  16237. }
  16238. for i := range ids {
  16239. delete(m.em_tutorial, ids[i])
  16240. m.removedem_tutorial[ids[i]] = struct{}{}
  16241. }
  16242. }
  16243. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  16244. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  16245. for id := range m.removedem_tutorial {
  16246. ids = append(ids, id)
  16247. }
  16248. return
  16249. }
  16250. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  16251. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  16252. for id := range m.em_tutorial {
  16253. ids = append(ids, id)
  16254. }
  16255. return
  16256. }
  16257. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  16258. func (m *EmployeeMutation) ResetEmTutorial() {
  16259. m.em_tutorial = nil
  16260. m.clearedem_tutorial = false
  16261. m.removedem_tutorial = nil
  16262. }
  16263. // Where appends a list predicates to the EmployeeMutation builder.
  16264. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  16265. m.predicates = append(m.predicates, ps...)
  16266. }
  16267. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  16268. // users can use type-assertion to append predicates that do not depend on any generated package.
  16269. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  16270. p := make([]predicate.Employee, len(ps))
  16271. for i := range ps {
  16272. p[i] = ps[i]
  16273. }
  16274. m.Where(p...)
  16275. }
  16276. // Op returns the operation name.
  16277. func (m *EmployeeMutation) Op() Op {
  16278. return m.op
  16279. }
  16280. // SetOp allows setting the mutation operation.
  16281. func (m *EmployeeMutation) SetOp(op Op) {
  16282. m.op = op
  16283. }
  16284. // Type returns the node type of this mutation (Employee).
  16285. func (m *EmployeeMutation) Type() string {
  16286. return m.typ
  16287. }
  16288. // Fields returns all fields that were changed during this mutation. Note that in
  16289. // order to get all numeric fields that were incremented/decremented, call
  16290. // AddedFields().
  16291. func (m *EmployeeMutation) Fields() []string {
  16292. fields := make([]string, 0, 23)
  16293. if m.created_at != nil {
  16294. fields = append(fields, employee.FieldCreatedAt)
  16295. }
  16296. if m.updated_at != nil {
  16297. fields = append(fields, employee.FieldUpdatedAt)
  16298. }
  16299. if m.deleted_at != nil {
  16300. fields = append(fields, employee.FieldDeletedAt)
  16301. }
  16302. if m.title != nil {
  16303. fields = append(fields, employee.FieldTitle)
  16304. }
  16305. if m.avatar != nil {
  16306. fields = append(fields, employee.FieldAvatar)
  16307. }
  16308. if m.tags != nil {
  16309. fields = append(fields, employee.FieldTags)
  16310. }
  16311. if m.hire_count != nil {
  16312. fields = append(fields, employee.FieldHireCount)
  16313. }
  16314. if m.service_count != nil {
  16315. fields = append(fields, employee.FieldServiceCount)
  16316. }
  16317. if m.achievement_count != nil {
  16318. fields = append(fields, employee.FieldAchievementCount)
  16319. }
  16320. if m.intro != nil {
  16321. fields = append(fields, employee.FieldIntro)
  16322. }
  16323. if m.estimate != nil {
  16324. fields = append(fields, employee.FieldEstimate)
  16325. }
  16326. if m.skill != nil {
  16327. fields = append(fields, employee.FieldSkill)
  16328. }
  16329. if m.ability_type != nil {
  16330. fields = append(fields, employee.FieldAbilityType)
  16331. }
  16332. if m.scene != nil {
  16333. fields = append(fields, employee.FieldScene)
  16334. }
  16335. if m.switch_in != nil {
  16336. fields = append(fields, employee.FieldSwitchIn)
  16337. }
  16338. if m.video_url != nil {
  16339. fields = append(fields, employee.FieldVideoURL)
  16340. }
  16341. if m.organization_id != nil {
  16342. fields = append(fields, employee.FieldOrganizationID)
  16343. }
  16344. if m.category_id != nil {
  16345. fields = append(fields, employee.FieldCategoryID)
  16346. }
  16347. if m.api_base != nil {
  16348. fields = append(fields, employee.FieldAPIBase)
  16349. }
  16350. if m.api_key != nil {
  16351. fields = append(fields, employee.FieldAPIKey)
  16352. }
  16353. if m.ai_info != nil {
  16354. fields = append(fields, employee.FieldAiInfo)
  16355. }
  16356. if m.is_vip != nil {
  16357. fields = append(fields, employee.FieldIsVip)
  16358. }
  16359. if m.chat_url != nil {
  16360. fields = append(fields, employee.FieldChatURL)
  16361. }
  16362. return fields
  16363. }
  16364. // Field returns the value of a field with the given name. The second boolean
  16365. // return value indicates that this field was not set, or was not defined in the
  16366. // schema.
  16367. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  16368. switch name {
  16369. case employee.FieldCreatedAt:
  16370. return m.CreatedAt()
  16371. case employee.FieldUpdatedAt:
  16372. return m.UpdatedAt()
  16373. case employee.FieldDeletedAt:
  16374. return m.DeletedAt()
  16375. case employee.FieldTitle:
  16376. return m.Title()
  16377. case employee.FieldAvatar:
  16378. return m.Avatar()
  16379. case employee.FieldTags:
  16380. return m.Tags()
  16381. case employee.FieldHireCount:
  16382. return m.HireCount()
  16383. case employee.FieldServiceCount:
  16384. return m.ServiceCount()
  16385. case employee.FieldAchievementCount:
  16386. return m.AchievementCount()
  16387. case employee.FieldIntro:
  16388. return m.Intro()
  16389. case employee.FieldEstimate:
  16390. return m.Estimate()
  16391. case employee.FieldSkill:
  16392. return m.Skill()
  16393. case employee.FieldAbilityType:
  16394. return m.AbilityType()
  16395. case employee.FieldScene:
  16396. return m.Scene()
  16397. case employee.FieldSwitchIn:
  16398. return m.SwitchIn()
  16399. case employee.FieldVideoURL:
  16400. return m.VideoURL()
  16401. case employee.FieldOrganizationID:
  16402. return m.OrganizationID()
  16403. case employee.FieldCategoryID:
  16404. return m.CategoryID()
  16405. case employee.FieldAPIBase:
  16406. return m.APIBase()
  16407. case employee.FieldAPIKey:
  16408. return m.APIKey()
  16409. case employee.FieldAiInfo:
  16410. return m.AiInfo()
  16411. case employee.FieldIsVip:
  16412. return m.IsVip()
  16413. case employee.FieldChatURL:
  16414. return m.ChatURL()
  16415. }
  16416. return nil, false
  16417. }
  16418. // OldField returns the old value of the field from the database. An error is
  16419. // returned if the mutation operation is not UpdateOne, or the query to the
  16420. // database failed.
  16421. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16422. switch name {
  16423. case employee.FieldCreatedAt:
  16424. return m.OldCreatedAt(ctx)
  16425. case employee.FieldUpdatedAt:
  16426. return m.OldUpdatedAt(ctx)
  16427. case employee.FieldDeletedAt:
  16428. return m.OldDeletedAt(ctx)
  16429. case employee.FieldTitle:
  16430. return m.OldTitle(ctx)
  16431. case employee.FieldAvatar:
  16432. return m.OldAvatar(ctx)
  16433. case employee.FieldTags:
  16434. return m.OldTags(ctx)
  16435. case employee.FieldHireCount:
  16436. return m.OldHireCount(ctx)
  16437. case employee.FieldServiceCount:
  16438. return m.OldServiceCount(ctx)
  16439. case employee.FieldAchievementCount:
  16440. return m.OldAchievementCount(ctx)
  16441. case employee.FieldIntro:
  16442. return m.OldIntro(ctx)
  16443. case employee.FieldEstimate:
  16444. return m.OldEstimate(ctx)
  16445. case employee.FieldSkill:
  16446. return m.OldSkill(ctx)
  16447. case employee.FieldAbilityType:
  16448. return m.OldAbilityType(ctx)
  16449. case employee.FieldScene:
  16450. return m.OldScene(ctx)
  16451. case employee.FieldSwitchIn:
  16452. return m.OldSwitchIn(ctx)
  16453. case employee.FieldVideoURL:
  16454. return m.OldVideoURL(ctx)
  16455. case employee.FieldOrganizationID:
  16456. return m.OldOrganizationID(ctx)
  16457. case employee.FieldCategoryID:
  16458. return m.OldCategoryID(ctx)
  16459. case employee.FieldAPIBase:
  16460. return m.OldAPIBase(ctx)
  16461. case employee.FieldAPIKey:
  16462. return m.OldAPIKey(ctx)
  16463. case employee.FieldAiInfo:
  16464. return m.OldAiInfo(ctx)
  16465. case employee.FieldIsVip:
  16466. return m.OldIsVip(ctx)
  16467. case employee.FieldChatURL:
  16468. return m.OldChatURL(ctx)
  16469. }
  16470. return nil, fmt.Errorf("unknown Employee field %s", name)
  16471. }
  16472. // SetField sets the value of a field with the given name. It returns an error if
  16473. // the field is not defined in the schema, or if the type mismatched the field
  16474. // type.
  16475. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  16476. switch name {
  16477. case employee.FieldCreatedAt:
  16478. v, ok := value.(time.Time)
  16479. if !ok {
  16480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16481. }
  16482. m.SetCreatedAt(v)
  16483. return nil
  16484. case employee.FieldUpdatedAt:
  16485. v, ok := value.(time.Time)
  16486. if !ok {
  16487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16488. }
  16489. m.SetUpdatedAt(v)
  16490. return nil
  16491. case employee.FieldDeletedAt:
  16492. v, ok := value.(time.Time)
  16493. if !ok {
  16494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16495. }
  16496. m.SetDeletedAt(v)
  16497. return nil
  16498. case employee.FieldTitle:
  16499. v, ok := value.(string)
  16500. if !ok {
  16501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16502. }
  16503. m.SetTitle(v)
  16504. return nil
  16505. case employee.FieldAvatar:
  16506. v, ok := value.(string)
  16507. if !ok {
  16508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16509. }
  16510. m.SetAvatar(v)
  16511. return nil
  16512. case employee.FieldTags:
  16513. v, ok := value.(string)
  16514. if !ok {
  16515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16516. }
  16517. m.SetTags(v)
  16518. return nil
  16519. case employee.FieldHireCount:
  16520. v, ok := value.(int)
  16521. if !ok {
  16522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16523. }
  16524. m.SetHireCount(v)
  16525. return nil
  16526. case employee.FieldServiceCount:
  16527. v, ok := value.(int)
  16528. if !ok {
  16529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16530. }
  16531. m.SetServiceCount(v)
  16532. return nil
  16533. case employee.FieldAchievementCount:
  16534. v, ok := value.(int)
  16535. if !ok {
  16536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16537. }
  16538. m.SetAchievementCount(v)
  16539. return nil
  16540. case employee.FieldIntro:
  16541. v, ok := value.(string)
  16542. if !ok {
  16543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16544. }
  16545. m.SetIntro(v)
  16546. return nil
  16547. case employee.FieldEstimate:
  16548. v, ok := value.(string)
  16549. if !ok {
  16550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16551. }
  16552. m.SetEstimate(v)
  16553. return nil
  16554. case employee.FieldSkill:
  16555. v, ok := value.(string)
  16556. if !ok {
  16557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16558. }
  16559. m.SetSkill(v)
  16560. return nil
  16561. case employee.FieldAbilityType:
  16562. v, ok := value.(string)
  16563. if !ok {
  16564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16565. }
  16566. m.SetAbilityType(v)
  16567. return nil
  16568. case employee.FieldScene:
  16569. v, ok := value.(string)
  16570. if !ok {
  16571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16572. }
  16573. m.SetScene(v)
  16574. return nil
  16575. case employee.FieldSwitchIn:
  16576. v, ok := value.(string)
  16577. if !ok {
  16578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16579. }
  16580. m.SetSwitchIn(v)
  16581. return nil
  16582. case employee.FieldVideoURL:
  16583. v, ok := value.(string)
  16584. if !ok {
  16585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16586. }
  16587. m.SetVideoURL(v)
  16588. return nil
  16589. case employee.FieldOrganizationID:
  16590. v, ok := value.(uint64)
  16591. if !ok {
  16592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16593. }
  16594. m.SetOrganizationID(v)
  16595. return nil
  16596. case employee.FieldCategoryID:
  16597. v, ok := value.(uint64)
  16598. if !ok {
  16599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16600. }
  16601. m.SetCategoryID(v)
  16602. return nil
  16603. case employee.FieldAPIBase:
  16604. v, ok := value.(string)
  16605. if !ok {
  16606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16607. }
  16608. m.SetAPIBase(v)
  16609. return nil
  16610. case employee.FieldAPIKey:
  16611. v, ok := value.(string)
  16612. if !ok {
  16613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16614. }
  16615. m.SetAPIKey(v)
  16616. return nil
  16617. case employee.FieldAiInfo:
  16618. v, ok := value.(string)
  16619. if !ok {
  16620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16621. }
  16622. m.SetAiInfo(v)
  16623. return nil
  16624. case employee.FieldIsVip:
  16625. v, ok := value.(int)
  16626. if !ok {
  16627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16628. }
  16629. m.SetIsVip(v)
  16630. return nil
  16631. case employee.FieldChatURL:
  16632. v, ok := value.(string)
  16633. if !ok {
  16634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16635. }
  16636. m.SetChatURL(v)
  16637. return nil
  16638. }
  16639. return fmt.Errorf("unknown Employee field %s", name)
  16640. }
  16641. // AddedFields returns all numeric fields that were incremented/decremented during
  16642. // this mutation.
  16643. func (m *EmployeeMutation) AddedFields() []string {
  16644. var fields []string
  16645. if m.addhire_count != nil {
  16646. fields = append(fields, employee.FieldHireCount)
  16647. }
  16648. if m.addservice_count != nil {
  16649. fields = append(fields, employee.FieldServiceCount)
  16650. }
  16651. if m.addachievement_count != nil {
  16652. fields = append(fields, employee.FieldAchievementCount)
  16653. }
  16654. if m.addorganization_id != nil {
  16655. fields = append(fields, employee.FieldOrganizationID)
  16656. }
  16657. if m.addcategory_id != nil {
  16658. fields = append(fields, employee.FieldCategoryID)
  16659. }
  16660. if m.addis_vip != nil {
  16661. fields = append(fields, employee.FieldIsVip)
  16662. }
  16663. return fields
  16664. }
  16665. // AddedField returns the numeric value that was incremented/decremented on a field
  16666. // with the given name. The second boolean return value indicates that this field
  16667. // was not set, or was not defined in the schema.
  16668. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  16669. switch name {
  16670. case employee.FieldHireCount:
  16671. return m.AddedHireCount()
  16672. case employee.FieldServiceCount:
  16673. return m.AddedServiceCount()
  16674. case employee.FieldAchievementCount:
  16675. return m.AddedAchievementCount()
  16676. case employee.FieldOrganizationID:
  16677. return m.AddedOrganizationID()
  16678. case employee.FieldCategoryID:
  16679. return m.AddedCategoryID()
  16680. case employee.FieldIsVip:
  16681. return m.AddedIsVip()
  16682. }
  16683. return nil, false
  16684. }
  16685. // AddField adds the value to the field with the given name. It returns an error if
  16686. // the field is not defined in the schema, or if the type mismatched the field
  16687. // type.
  16688. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  16689. switch name {
  16690. case employee.FieldHireCount:
  16691. v, ok := value.(int)
  16692. if !ok {
  16693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16694. }
  16695. m.AddHireCount(v)
  16696. return nil
  16697. case employee.FieldServiceCount:
  16698. v, ok := value.(int)
  16699. if !ok {
  16700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16701. }
  16702. m.AddServiceCount(v)
  16703. return nil
  16704. case employee.FieldAchievementCount:
  16705. v, ok := value.(int)
  16706. if !ok {
  16707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16708. }
  16709. m.AddAchievementCount(v)
  16710. return nil
  16711. case employee.FieldOrganizationID:
  16712. v, ok := value.(int64)
  16713. if !ok {
  16714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16715. }
  16716. m.AddOrganizationID(v)
  16717. return nil
  16718. case employee.FieldCategoryID:
  16719. v, ok := value.(int64)
  16720. if !ok {
  16721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16722. }
  16723. m.AddCategoryID(v)
  16724. return nil
  16725. case employee.FieldIsVip:
  16726. v, ok := value.(int)
  16727. if !ok {
  16728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16729. }
  16730. m.AddIsVip(v)
  16731. return nil
  16732. }
  16733. return fmt.Errorf("unknown Employee numeric field %s", name)
  16734. }
  16735. // ClearedFields returns all nullable fields that were cleared during this
  16736. // mutation.
  16737. func (m *EmployeeMutation) ClearedFields() []string {
  16738. var fields []string
  16739. if m.FieldCleared(employee.FieldDeletedAt) {
  16740. fields = append(fields, employee.FieldDeletedAt)
  16741. }
  16742. if m.FieldCleared(employee.FieldAiInfo) {
  16743. fields = append(fields, employee.FieldAiInfo)
  16744. }
  16745. return fields
  16746. }
  16747. // FieldCleared returns a boolean indicating if a field with the given name was
  16748. // cleared in this mutation.
  16749. func (m *EmployeeMutation) FieldCleared(name string) bool {
  16750. _, ok := m.clearedFields[name]
  16751. return ok
  16752. }
  16753. // ClearField clears the value of the field with the given name. It returns an
  16754. // error if the field is not defined in the schema.
  16755. func (m *EmployeeMutation) ClearField(name string) error {
  16756. switch name {
  16757. case employee.FieldDeletedAt:
  16758. m.ClearDeletedAt()
  16759. return nil
  16760. case employee.FieldAiInfo:
  16761. m.ClearAiInfo()
  16762. return nil
  16763. }
  16764. return fmt.Errorf("unknown Employee nullable field %s", name)
  16765. }
  16766. // ResetField resets all changes in the mutation for the field with the given name.
  16767. // It returns an error if the field is not defined in the schema.
  16768. func (m *EmployeeMutation) ResetField(name string) error {
  16769. switch name {
  16770. case employee.FieldCreatedAt:
  16771. m.ResetCreatedAt()
  16772. return nil
  16773. case employee.FieldUpdatedAt:
  16774. m.ResetUpdatedAt()
  16775. return nil
  16776. case employee.FieldDeletedAt:
  16777. m.ResetDeletedAt()
  16778. return nil
  16779. case employee.FieldTitle:
  16780. m.ResetTitle()
  16781. return nil
  16782. case employee.FieldAvatar:
  16783. m.ResetAvatar()
  16784. return nil
  16785. case employee.FieldTags:
  16786. m.ResetTags()
  16787. return nil
  16788. case employee.FieldHireCount:
  16789. m.ResetHireCount()
  16790. return nil
  16791. case employee.FieldServiceCount:
  16792. m.ResetServiceCount()
  16793. return nil
  16794. case employee.FieldAchievementCount:
  16795. m.ResetAchievementCount()
  16796. return nil
  16797. case employee.FieldIntro:
  16798. m.ResetIntro()
  16799. return nil
  16800. case employee.FieldEstimate:
  16801. m.ResetEstimate()
  16802. return nil
  16803. case employee.FieldSkill:
  16804. m.ResetSkill()
  16805. return nil
  16806. case employee.FieldAbilityType:
  16807. m.ResetAbilityType()
  16808. return nil
  16809. case employee.FieldScene:
  16810. m.ResetScene()
  16811. return nil
  16812. case employee.FieldSwitchIn:
  16813. m.ResetSwitchIn()
  16814. return nil
  16815. case employee.FieldVideoURL:
  16816. m.ResetVideoURL()
  16817. return nil
  16818. case employee.FieldOrganizationID:
  16819. m.ResetOrganizationID()
  16820. return nil
  16821. case employee.FieldCategoryID:
  16822. m.ResetCategoryID()
  16823. return nil
  16824. case employee.FieldAPIBase:
  16825. m.ResetAPIBase()
  16826. return nil
  16827. case employee.FieldAPIKey:
  16828. m.ResetAPIKey()
  16829. return nil
  16830. case employee.FieldAiInfo:
  16831. m.ResetAiInfo()
  16832. return nil
  16833. case employee.FieldIsVip:
  16834. m.ResetIsVip()
  16835. return nil
  16836. case employee.FieldChatURL:
  16837. m.ResetChatURL()
  16838. return nil
  16839. }
  16840. return fmt.Errorf("unknown Employee field %s", name)
  16841. }
  16842. // AddedEdges returns all edge names that were set/added in this mutation.
  16843. func (m *EmployeeMutation) AddedEdges() []string {
  16844. edges := make([]string, 0, 2)
  16845. if m.em_work_experiences != nil {
  16846. edges = append(edges, employee.EdgeEmWorkExperiences)
  16847. }
  16848. if m.em_tutorial != nil {
  16849. edges = append(edges, employee.EdgeEmTutorial)
  16850. }
  16851. return edges
  16852. }
  16853. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16854. // name in this mutation.
  16855. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  16856. switch name {
  16857. case employee.EdgeEmWorkExperiences:
  16858. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  16859. for id := range m.em_work_experiences {
  16860. ids = append(ids, id)
  16861. }
  16862. return ids
  16863. case employee.EdgeEmTutorial:
  16864. ids := make([]ent.Value, 0, len(m.em_tutorial))
  16865. for id := range m.em_tutorial {
  16866. ids = append(ids, id)
  16867. }
  16868. return ids
  16869. }
  16870. return nil
  16871. }
  16872. // RemovedEdges returns all edge names that were removed in this mutation.
  16873. func (m *EmployeeMutation) RemovedEdges() []string {
  16874. edges := make([]string, 0, 2)
  16875. if m.removedem_work_experiences != nil {
  16876. edges = append(edges, employee.EdgeEmWorkExperiences)
  16877. }
  16878. if m.removedem_tutorial != nil {
  16879. edges = append(edges, employee.EdgeEmTutorial)
  16880. }
  16881. return edges
  16882. }
  16883. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16884. // the given name in this mutation.
  16885. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  16886. switch name {
  16887. case employee.EdgeEmWorkExperiences:
  16888. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  16889. for id := range m.removedem_work_experiences {
  16890. ids = append(ids, id)
  16891. }
  16892. return ids
  16893. case employee.EdgeEmTutorial:
  16894. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  16895. for id := range m.removedem_tutorial {
  16896. ids = append(ids, id)
  16897. }
  16898. return ids
  16899. }
  16900. return nil
  16901. }
  16902. // ClearedEdges returns all edge names that were cleared in this mutation.
  16903. func (m *EmployeeMutation) ClearedEdges() []string {
  16904. edges := make([]string, 0, 2)
  16905. if m.clearedem_work_experiences {
  16906. edges = append(edges, employee.EdgeEmWorkExperiences)
  16907. }
  16908. if m.clearedem_tutorial {
  16909. edges = append(edges, employee.EdgeEmTutorial)
  16910. }
  16911. return edges
  16912. }
  16913. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16914. // was cleared in this mutation.
  16915. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  16916. switch name {
  16917. case employee.EdgeEmWorkExperiences:
  16918. return m.clearedem_work_experiences
  16919. case employee.EdgeEmTutorial:
  16920. return m.clearedem_tutorial
  16921. }
  16922. return false
  16923. }
  16924. // ClearEdge clears the value of the edge with the given name. It returns an error
  16925. // if that edge is not defined in the schema.
  16926. func (m *EmployeeMutation) ClearEdge(name string) error {
  16927. switch name {
  16928. }
  16929. return fmt.Errorf("unknown Employee unique edge %s", name)
  16930. }
  16931. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16932. // It returns an error if the edge is not defined in the schema.
  16933. func (m *EmployeeMutation) ResetEdge(name string) error {
  16934. switch name {
  16935. case employee.EdgeEmWorkExperiences:
  16936. m.ResetEmWorkExperiences()
  16937. return nil
  16938. case employee.EdgeEmTutorial:
  16939. m.ResetEmTutorial()
  16940. return nil
  16941. }
  16942. return fmt.Errorf("unknown Employee edge %s", name)
  16943. }
  16944. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  16945. type EmployeeConfigMutation struct {
  16946. config
  16947. op Op
  16948. typ string
  16949. id *uint64
  16950. created_at *time.Time
  16951. updated_at *time.Time
  16952. deleted_at *time.Time
  16953. stype *string
  16954. title *string
  16955. photo *string
  16956. organization_id *uint64
  16957. addorganization_id *int64
  16958. clearedFields map[string]struct{}
  16959. done bool
  16960. oldValue func(context.Context) (*EmployeeConfig, error)
  16961. predicates []predicate.EmployeeConfig
  16962. }
  16963. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  16964. // employeeconfigOption allows management of the mutation configuration using functional options.
  16965. type employeeconfigOption func(*EmployeeConfigMutation)
  16966. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  16967. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  16968. m := &EmployeeConfigMutation{
  16969. config: c,
  16970. op: op,
  16971. typ: TypeEmployeeConfig,
  16972. clearedFields: make(map[string]struct{}),
  16973. }
  16974. for _, opt := range opts {
  16975. opt(m)
  16976. }
  16977. return m
  16978. }
  16979. // withEmployeeConfigID sets the ID field of the mutation.
  16980. func withEmployeeConfigID(id uint64) employeeconfigOption {
  16981. return func(m *EmployeeConfigMutation) {
  16982. var (
  16983. err error
  16984. once sync.Once
  16985. value *EmployeeConfig
  16986. )
  16987. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  16988. once.Do(func() {
  16989. if m.done {
  16990. err = errors.New("querying old values post mutation is not allowed")
  16991. } else {
  16992. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  16993. }
  16994. })
  16995. return value, err
  16996. }
  16997. m.id = &id
  16998. }
  16999. }
  17000. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  17001. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  17002. return func(m *EmployeeConfigMutation) {
  17003. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  17004. return node, nil
  17005. }
  17006. m.id = &node.ID
  17007. }
  17008. }
  17009. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17010. // executed in a transaction (ent.Tx), a transactional client is returned.
  17011. func (m EmployeeConfigMutation) Client() *Client {
  17012. client := &Client{config: m.config}
  17013. client.init()
  17014. return client
  17015. }
  17016. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17017. // it returns an error otherwise.
  17018. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  17019. if _, ok := m.driver.(*txDriver); !ok {
  17020. return nil, errors.New("ent: mutation is not running in a transaction")
  17021. }
  17022. tx := &Tx{config: m.config}
  17023. tx.init()
  17024. return tx, nil
  17025. }
  17026. // SetID sets the value of the id field. Note that this
  17027. // operation is only accepted on creation of EmployeeConfig entities.
  17028. func (m *EmployeeConfigMutation) SetID(id uint64) {
  17029. m.id = &id
  17030. }
  17031. // ID returns the ID value in the mutation. Note that the ID is only available
  17032. // if it was provided to the builder or after it was returned from the database.
  17033. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  17034. if m.id == nil {
  17035. return
  17036. }
  17037. return *m.id, true
  17038. }
  17039. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17040. // That means, if the mutation is applied within a transaction with an isolation level such
  17041. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17042. // or updated by the mutation.
  17043. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  17044. switch {
  17045. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17046. id, exists := m.ID()
  17047. if exists {
  17048. return []uint64{id}, nil
  17049. }
  17050. fallthrough
  17051. case m.op.Is(OpUpdate | OpDelete):
  17052. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  17053. default:
  17054. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17055. }
  17056. }
  17057. // SetCreatedAt sets the "created_at" field.
  17058. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  17059. m.created_at = &t
  17060. }
  17061. // CreatedAt returns the value of the "created_at" field in the mutation.
  17062. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  17063. v := m.created_at
  17064. if v == nil {
  17065. return
  17066. }
  17067. return *v, true
  17068. }
  17069. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  17070. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17072. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17073. if !m.op.Is(OpUpdateOne) {
  17074. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17075. }
  17076. if m.id == nil || m.oldValue == nil {
  17077. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17078. }
  17079. oldValue, err := m.oldValue(ctx)
  17080. if err != nil {
  17081. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17082. }
  17083. return oldValue.CreatedAt, nil
  17084. }
  17085. // ResetCreatedAt resets all changes to the "created_at" field.
  17086. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  17087. m.created_at = nil
  17088. }
  17089. // SetUpdatedAt sets the "updated_at" field.
  17090. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  17091. m.updated_at = &t
  17092. }
  17093. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17094. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  17095. v := m.updated_at
  17096. if v == nil {
  17097. return
  17098. }
  17099. return *v, true
  17100. }
  17101. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17105. if !m.op.Is(OpUpdateOne) {
  17106. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17107. }
  17108. if m.id == nil || m.oldValue == nil {
  17109. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  17114. }
  17115. return oldValue.UpdatedAt, nil
  17116. }
  17117. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17118. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  17119. m.updated_at = nil
  17120. }
  17121. // SetDeletedAt sets the "deleted_at" field.
  17122. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  17123. m.deleted_at = &t
  17124. }
  17125. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17126. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  17127. v := m.deleted_at
  17128. if v == nil {
  17129. return
  17130. }
  17131. return *v, true
  17132. }
  17133. // OldDeletedAt returns the old "deleted_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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17137. if !m.op.Is(OpUpdateOne) {
  17138. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17139. }
  17140. if m.id == nil || m.oldValue == nil {
  17141. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  17146. }
  17147. return oldValue.DeletedAt, nil
  17148. }
  17149. // ClearDeletedAt clears the value of the "deleted_at" field.
  17150. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  17151. m.deleted_at = nil
  17152. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  17153. }
  17154. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17155. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  17156. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  17157. return ok
  17158. }
  17159. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17160. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  17161. m.deleted_at = nil
  17162. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  17163. }
  17164. // SetStype sets the "stype" field.
  17165. func (m *EmployeeConfigMutation) SetStype(s string) {
  17166. m.stype = &s
  17167. }
  17168. // Stype returns the value of the "stype" field in the mutation.
  17169. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  17170. v := m.stype
  17171. if v == nil {
  17172. return
  17173. }
  17174. return *v, true
  17175. }
  17176. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  17177. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17179. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  17180. if !m.op.Is(OpUpdateOne) {
  17181. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  17182. }
  17183. if m.id == nil || m.oldValue == nil {
  17184. return v, errors.New("OldStype requires an ID field in the mutation")
  17185. }
  17186. oldValue, err := m.oldValue(ctx)
  17187. if err != nil {
  17188. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  17189. }
  17190. return oldValue.Stype, nil
  17191. }
  17192. // ResetStype resets all changes to the "stype" field.
  17193. func (m *EmployeeConfigMutation) ResetStype() {
  17194. m.stype = nil
  17195. }
  17196. // SetTitle sets the "title" field.
  17197. func (m *EmployeeConfigMutation) SetTitle(s string) {
  17198. m.title = &s
  17199. }
  17200. // Title returns the value of the "title" field in the mutation.
  17201. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  17202. v := m.title
  17203. if v == nil {
  17204. return
  17205. }
  17206. return *v, true
  17207. }
  17208. // OldTitle returns the old "title" 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) OldTitle(ctx context.Context) (v string, err error) {
  17212. if !m.op.Is(OpUpdateOne) {
  17213. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  17214. }
  17215. if m.id == nil || m.oldValue == nil {
  17216. return v, errors.New("OldTitle 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 OldTitle: %w", err)
  17221. }
  17222. return oldValue.Title, nil
  17223. }
  17224. // ResetTitle resets all changes to the "title" field.
  17225. func (m *EmployeeConfigMutation) ResetTitle() {
  17226. m.title = nil
  17227. }
  17228. // SetPhoto sets the "photo" field.
  17229. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  17230. m.photo = &s
  17231. }
  17232. // Photo returns the value of the "photo" field in the mutation.
  17233. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  17234. v := m.photo
  17235. if v == nil {
  17236. return
  17237. }
  17238. return *v, true
  17239. }
  17240. // OldPhoto returns the old "photo" 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) OldPhoto(ctx context.Context) (v string, err error) {
  17244. if !m.op.Is(OpUpdateOne) {
  17245. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  17246. }
  17247. if m.id == nil || m.oldValue == nil {
  17248. return v, errors.New("OldPhoto 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 OldPhoto: %w", err)
  17253. }
  17254. return oldValue.Photo, nil
  17255. }
  17256. // ResetPhoto resets all changes to the "photo" field.
  17257. func (m *EmployeeConfigMutation) ResetPhoto() {
  17258. m.photo = nil
  17259. }
  17260. // SetOrganizationID sets the "organization_id" field.
  17261. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  17262. m.organization_id = &u
  17263. m.addorganization_id = nil
  17264. }
  17265. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17266. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  17267. v := m.organization_id
  17268. if v == nil {
  17269. return
  17270. }
  17271. return *v, true
  17272. }
  17273. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  17274. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17276. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17277. if !m.op.Is(OpUpdateOne) {
  17278. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17279. }
  17280. if m.id == nil || m.oldValue == nil {
  17281. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17282. }
  17283. oldValue, err := m.oldValue(ctx)
  17284. if err != nil {
  17285. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17286. }
  17287. return oldValue.OrganizationID, nil
  17288. }
  17289. // AddOrganizationID adds u to the "organization_id" field.
  17290. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  17291. if m.addorganization_id != nil {
  17292. *m.addorganization_id += u
  17293. } else {
  17294. m.addorganization_id = &u
  17295. }
  17296. }
  17297. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17298. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  17299. v := m.addorganization_id
  17300. if v == nil {
  17301. return
  17302. }
  17303. return *v, true
  17304. }
  17305. // ClearOrganizationID clears the value of the "organization_id" field.
  17306. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  17307. m.organization_id = nil
  17308. m.addorganization_id = nil
  17309. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  17310. }
  17311. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17312. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  17313. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  17314. return ok
  17315. }
  17316. // ResetOrganizationID resets all changes to the "organization_id" field.
  17317. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  17318. m.organization_id = nil
  17319. m.addorganization_id = nil
  17320. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  17321. }
  17322. // Where appends a list predicates to the EmployeeConfigMutation builder.
  17323. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  17324. m.predicates = append(m.predicates, ps...)
  17325. }
  17326. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  17327. // users can use type-assertion to append predicates that do not depend on any generated package.
  17328. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  17329. p := make([]predicate.EmployeeConfig, len(ps))
  17330. for i := range ps {
  17331. p[i] = ps[i]
  17332. }
  17333. m.Where(p...)
  17334. }
  17335. // Op returns the operation name.
  17336. func (m *EmployeeConfigMutation) Op() Op {
  17337. return m.op
  17338. }
  17339. // SetOp allows setting the mutation operation.
  17340. func (m *EmployeeConfigMutation) SetOp(op Op) {
  17341. m.op = op
  17342. }
  17343. // Type returns the node type of this mutation (EmployeeConfig).
  17344. func (m *EmployeeConfigMutation) Type() string {
  17345. return m.typ
  17346. }
  17347. // Fields returns all fields that were changed during this mutation. Note that in
  17348. // order to get all numeric fields that were incremented/decremented, call
  17349. // AddedFields().
  17350. func (m *EmployeeConfigMutation) Fields() []string {
  17351. fields := make([]string, 0, 7)
  17352. if m.created_at != nil {
  17353. fields = append(fields, employeeconfig.FieldCreatedAt)
  17354. }
  17355. if m.updated_at != nil {
  17356. fields = append(fields, employeeconfig.FieldUpdatedAt)
  17357. }
  17358. if m.deleted_at != nil {
  17359. fields = append(fields, employeeconfig.FieldDeletedAt)
  17360. }
  17361. if m.stype != nil {
  17362. fields = append(fields, employeeconfig.FieldStype)
  17363. }
  17364. if m.title != nil {
  17365. fields = append(fields, employeeconfig.FieldTitle)
  17366. }
  17367. if m.photo != nil {
  17368. fields = append(fields, employeeconfig.FieldPhoto)
  17369. }
  17370. if m.organization_id != nil {
  17371. fields = append(fields, employeeconfig.FieldOrganizationID)
  17372. }
  17373. return fields
  17374. }
  17375. // Field returns the value of a field with the given name. The second boolean
  17376. // return value indicates that this field was not set, or was not defined in the
  17377. // schema.
  17378. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  17379. switch name {
  17380. case employeeconfig.FieldCreatedAt:
  17381. return m.CreatedAt()
  17382. case employeeconfig.FieldUpdatedAt:
  17383. return m.UpdatedAt()
  17384. case employeeconfig.FieldDeletedAt:
  17385. return m.DeletedAt()
  17386. case employeeconfig.FieldStype:
  17387. return m.Stype()
  17388. case employeeconfig.FieldTitle:
  17389. return m.Title()
  17390. case employeeconfig.FieldPhoto:
  17391. return m.Photo()
  17392. case employeeconfig.FieldOrganizationID:
  17393. return m.OrganizationID()
  17394. }
  17395. return nil, false
  17396. }
  17397. // OldField returns the old value of the field from the database. An error is
  17398. // returned if the mutation operation is not UpdateOne, or the query to the
  17399. // database failed.
  17400. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17401. switch name {
  17402. case employeeconfig.FieldCreatedAt:
  17403. return m.OldCreatedAt(ctx)
  17404. case employeeconfig.FieldUpdatedAt:
  17405. return m.OldUpdatedAt(ctx)
  17406. case employeeconfig.FieldDeletedAt:
  17407. return m.OldDeletedAt(ctx)
  17408. case employeeconfig.FieldStype:
  17409. return m.OldStype(ctx)
  17410. case employeeconfig.FieldTitle:
  17411. return m.OldTitle(ctx)
  17412. case employeeconfig.FieldPhoto:
  17413. return m.OldPhoto(ctx)
  17414. case employeeconfig.FieldOrganizationID:
  17415. return m.OldOrganizationID(ctx)
  17416. }
  17417. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  17418. }
  17419. // SetField sets the value of a field with the given name. It returns an error if
  17420. // the field is not defined in the schema, or if the type mismatched the field
  17421. // type.
  17422. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  17423. switch name {
  17424. case employeeconfig.FieldCreatedAt:
  17425. v, ok := value.(time.Time)
  17426. if !ok {
  17427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17428. }
  17429. m.SetCreatedAt(v)
  17430. return nil
  17431. case employeeconfig.FieldUpdatedAt:
  17432. v, ok := value.(time.Time)
  17433. if !ok {
  17434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17435. }
  17436. m.SetUpdatedAt(v)
  17437. return nil
  17438. case employeeconfig.FieldDeletedAt:
  17439. v, ok := value.(time.Time)
  17440. if !ok {
  17441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17442. }
  17443. m.SetDeletedAt(v)
  17444. return nil
  17445. case employeeconfig.FieldStype:
  17446. v, ok := value.(string)
  17447. if !ok {
  17448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17449. }
  17450. m.SetStype(v)
  17451. return nil
  17452. case employeeconfig.FieldTitle:
  17453. v, ok := value.(string)
  17454. if !ok {
  17455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17456. }
  17457. m.SetTitle(v)
  17458. return nil
  17459. case employeeconfig.FieldPhoto:
  17460. v, ok := value.(string)
  17461. if !ok {
  17462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17463. }
  17464. m.SetPhoto(v)
  17465. return nil
  17466. case employeeconfig.FieldOrganizationID:
  17467. v, ok := value.(uint64)
  17468. if !ok {
  17469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17470. }
  17471. m.SetOrganizationID(v)
  17472. return nil
  17473. }
  17474. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17475. }
  17476. // AddedFields returns all numeric fields that were incremented/decremented during
  17477. // this mutation.
  17478. func (m *EmployeeConfigMutation) AddedFields() []string {
  17479. var fields []string
  17480. if m.addorganization_id != nil {
  17481. fields = append(fields, employeeconfig.FieldOrganizationID)
  17482. }
  17483. return fields
  17484. }
  17485. // AddedField returns the numeric value that was incremented/decremented on a field
  17486. // with the given name. The second boolean return value indicates that this field
  17487. // was not set, or was not defined in the schema.
  17488. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  17489. switch name {
  17490. case employeeconfig.FieldOrganizationID:
  17491. return m.AddedOrganizationID()
  17492. }
  17493. return nil, false
  17494. }
  17495. // AddField adds the value to the field with the given name. It returns an error if
  17496. // the field is not defined in the schema, or if the type mismatched the field
  17497. // type.
  17498. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  17499. switch name {
  17500. case employeeconfig.FieldOrganizationID:
  17501. v, ok := value.(int64)
  17502. if !ok {
  17503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17504. }
  17505. m.AddOrganizationID(v)
  17506. return nil
  17507. }
  17508. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  17509. }
  17510. // ClearedFields returns all nullable fields that were cleared during this
  17511. // mutation.
  17512. func (m *EmployeeConfigMutation) ClearedFields() []string {
  17513. var fields []string
  17514. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  17515. fields = append(fields, employeeconfig.FieldDeletedAt)
  17516. }
  17517. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  17518. fields = append(fields, employeeconfig.FieldOrganizationID)
  17519. }
  17520. return fields
  17521. }
  17522. // FieldCleared returns a boolean indicating if a field with the given name was
  17523. // cleared in this mutation.
  17524. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  17525. _, ok := m.clearedFields[name]
  17526. return ok
  17527. }
  17528. // ClearField clears the value of the field with the given name. It returns an
  17529. // error if the field is not defined in the schema.
  17530. func (m *EmployeeConfigMutation) ClearField(name string) error {
  17531. switch name {
  17532. case employeeconfig.FieldDeletedAt:
  17533. m.ClearDeletedAt()
  17534. return nil
  17535. case employeeconfig.FieldOrganizationID:
  17536. m.ClearOrganizationID()
  17537. return nil
  17538. }
  17539. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  17540. }
  17541. // ResetField resets all changes in the mutation for the field with the given name.
  17542. // It returns an error if the field is not defined in the schema.
  17543. func (m *EmployeeConfigMutation) ResetField(name string) error {
  17544. switch name {
  17545. case employeeconfig.FieldCreatedAt:
  17546. m.ResetCreatedAt()
  17547. return nil
  17548. case employeeconfig.FieldUpdatedAt:
  17549. m.ResetUpdatedAt()
  17550. return nil
  17551. case employeeconfig.FieldDeletedAt:
  17552. m.ResetDeletedAt()
  17553. return nil
  17554. case employeeconfig.FieldStype:
  17555. m.ResetStype()
  17556. return nil
  17557. case employeeconfig.FieldTitle:
  17558. m.ResetTitle()
  17559. return nil
  17560. case employeeconfig.FieldPhoto:
  17561. m.ResetPhoto()
  17562. return nil
  17563. case employeeconfig.FieldOrganizationID:
  17564. m.ResetOrganizationID()
  17565. return nil
  17566. }
  17567. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17568. }
  17569. // AddedEdges returns all edge names that were set/added in this mutation.
  17570. func (m *EmployeeConfigMutation) AddedEdges() []string {
  17571. edges := make([]string, 0, 0)
  17572. return edges
  17573. }
  17574. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17575. // name in this mutation.
  17576. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  17577. return nil
  17578. }
  17579. // RemovedEdges returns all edge names that were removed in this mutation.
  17580. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  17581. edges := make([]string, 0, 0)
  17582. return edges
  17583. }
  17584. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17585. // the given name in this mutation.
  17586. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  17587. return nil
  17588. }
  17589. // ClearedEdges returns all edge names that were cleared in this mutation.
  17590. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  17591. edges := make([]string, 0, 0)
  17592. return edges
  17593. }
  17594. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17595. // was cleared in this mutation.
  17596. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  17597. return false
  17598. }
  17599. // ClearEdge clears the value of the edge with the given name. It returns an error
  17600. // if that edge is not defined in the schema.
  17601. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  17602. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  17603. }
  17604. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17605. // It returns an error if the edge is not defined in the schema.
  17606. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  17607. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  17608. }
  17609. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  17610. type LabelMutation struct {
  17611. config
  17612. op Op
  17613. typ string
  17614. id *uint64
  17615. created_at *time.Time
  17616. updated_at *time.Time
  17617. status *uint8
  17618. addstatus *int8
  17619. _type *int
  17620. add_type *int
  17621. name *string
  17622. from *int
  17623. addfrom *int
  17624. mode *int
  17625. addmode *int
  17626. conditions *string
  17627. organization_id *uint64
  17628. addorganization_id *int64
  17629. clearedFields map[string]struct{}
  17630. label_relationships map[uint64]struct{}
  17631. removedlabel_relationships map[uint64]struct{}
  17632. clearedlabel_relationships bool
  17633. done bool
  17634. oldValue func(context.Context) (*Label, error)
  17635. predicates []predicate.Label
  17636. }
  17637. var _ ent.Mutation = (*LabelMutation)(nil)
  17638. // labelOption allows management of the mutation configuration using functional options.
  17639. type labelOption func(*LabelMutation)
  17640. // newLabelMutation creates new mutation for the Label entity.
  17641. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  17642. m := &LabelMutation{
  17643. config: c,
  17644. op: op,
  17645. typ: TypeLabel,
  17646. clearedFields: make(map[string]struct{}),
  17647. }
  17648. for _, opt := range opts {
  17649. opt(m)
  17650. }
  17651. return m
  17652. }
  17653. // withLabelID sets the ID field of the mutation.
  17654. func withLabelID(id uint64) labelOption {
  17655. return func(m *LabelMutation) {
  17656. var (
  17657. err error
  17658. once sync.Once
  17659. value *Label
  17660. )
  17661. m.oldValue = func(ctx context.Context) (*Label, error) {
  17662. once.Do(func() {
  17663. if m.done {
  17664. err = errors.New("querying old values post mutation is not allowed")
  17665. } else {
  17666. value, err = m.Client().Label.Get(ctx, id)
  17667. }
  17668. })
  17669. return value, err
  17670. }
  17671. m.id = &id
  17672. }
  17673. }
  17674. // withLabel sets the old Label of the mutation.
  17675. func withLabel(node *Label) labelOption {
  17676. return func(m *LabelMutation) {
  17677. m.oldValue = func(context.Context) (*Label, error) {
  17678. return node, nil
  17679. }
  17680. m.id = &node.ID
  17681. }
  17682. }
  17683. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17684. // executed in a transaction (ent.Tx), a transactional client is returned.
  17685. func (m LabelMutation) Client() *Client {
  17686. client := &Client{config: m.config}
  17687. client.init()
  17688. return client
  17689. }
  17690. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17691. // it returns an error otherwise.
  17692. func (m LabelMutation) Tx() (*Tx, error) {
  17693. if _, ok := m.driver.(*txDriver); !ok {
  17694. return nil, errors.New("ent: mutation is not running in a transaction")
  17695. }
  17696. tx := &Tx{config: m.config}
  17697. tx.init()
  17698. return tx, nil
  17699. }
  17700. // SetID sets the value of the id field. Note that this
  17701. // operation is only accepted on creation of Label entities.
  17702. func (m *LabelMutation) SetID(id uint64) {
  17703. m.id = &id
  17704. }
  17705. // ID returns the ID value in the mutation. Note that the ID is only available
  17706. // if it was provided to the builder or after it was returned from the database.
  17707. func (m *LabelMutation) ID() (id uint64, exists bool) {
  17708. if m.id == nil {
  17709. return
  17710. }
  17711. return *m.id, true
  17712. }
  17713. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17714. // That means, if the mutation is applied within a transaction with an isolation level such
  17715. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17716. // or updated by the mutation.
  17717. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  17718. switch {
  17719. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17720. id, exists := m.ID()
  17721. if exists {
  17722. return []uint64{id}, nil
  17723. }
  17724. fallthrough
  17725. case m.op.Is(OpUpdate | OpDelete):
  17726. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  17727. default:
  17728. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17729. }
  17730. }
  17731. // SetCreatedAt sets the "created_at" field.
  17732. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  17733. m.created_at = &t
  17734. }
  17735. // CreatedAt returns the value of the "created_at" field in the mutation.
  17736. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  17737. v := m.created_at
  17738. if v == nil {
  17739. return
  17740. }
  17741. return *v, true
  17742. }
  17743. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  17744. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17746. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17747. if !m.op.Is(OpUpdateOne) {
  17748. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17749. }
  17750. if m.id == nil || m.oldValue == nil {
  17751. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17752. }
  17753. oldValue, err := m.oldValue(ctx)
  17754. if err != nil {
  17755. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17756. }
  17757. return oldValue.CreatedAt, nil
  17758. }
  17759. // ResetCreatedAt resets all changes to the "created_at" field.
  17760. func (m *LabelMutation) ResetCreatedAt() {
  17761. m.created_at = nil
  17762. }
  17763. // SetUpdatedAt sets the "updated_at" field.
  17764. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  17765. m.updated_at = &t
  17766. }
  17767. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17768. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  17769. v := m.updated_at
  17770. if v == nil {
  17771. return
  17772. }
  17773. return *v, true
  17774. }
  17775. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17779. if !m.op.Is(OpUpdateOne) {
  17780. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17781. }
  17782. if m.id == nil || m.oldValue == nil {
  17783. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  17788. }
  17789. return oldValue.UpdatedAt, nil
  17790. }
  17791. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17792. func (m *LabelMutation) ResetUpdatedAt() {
  17793. m.updated_at = nil
  17794. }
  17795. // SetStatus sets the "status" field.
  17796. func (m *LabelMutation) SetStatus(u uint8) {
  17797. m.status = &u
  17798. m.addstatus = nil
  17799. }
  17800. // Status returns the value of the "status" field in the mutation.
  17801. func (m *LabelMutation) Status() (r uint8, exists bool) {
  17802. v := m.status
  17803. if v == nil {
  17804. return
  17805. }
  17806. return *v, true
  17807. }
  17808. // OldStatus returns the old "status" field's value of the Label entity.
  17809. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17811. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17812. if !m.op.Is(OpUpdateOne) {
  17813. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17814. }
  17815. if m.id == nil || m.oldValue == nil {
  17816. return v, errors.New("OldStatus requires an ID field in the mutation")
  17817. }
  17818. oldValue, err := m.oldValue(ctx)
  17819. if err != nil {
  17820. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17821. }
  17822. return oldValue.Status, nil
  17823. }
  17824. // AddStatus adds u to the "status" field.
  17825. func (m *LabelMutation) AddStatus(u int8) {
  17826. if m.addstatus != nil {
  17827. *m.addstatus += u
  17828. } else {
  17829. m.addstatus = &u
  17830. }
  17831. }
  17832. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17833. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  17834. v := m.addstatus
  17835. if v == nil {
  17836. return
  17837. }
  17838. return *v, true
  17839. }
  17840. // ClearStatus clears the value of the "status" field.
  17841. func (m *LabelMutation) ClearStatus() {
  17842. m.status = nil
  17843. m.addstatus = nil
  17844. m.clearedFields[label.FieldStatus] = struct{}{}
  17845. }
  17846. // StatusCleared returns if the "status" field was cleared in this mutation.
  17847. func (m *LabelMutation) StatusCleared() bool {
  17848. _, ok := m.clearedFields[label.FieldStatus]
  17849. return ok
  17850. }
  17851. // ResetStatus resets all changes to the "status" field.
  17852. func (m *LabelMutation) ResetStatus() {
  17853. m.status = nil
  17854. m.addstatus = nil
  17855. delete(m.clearedFields, label.FieldStatus)
  17856. }
  17857. // SetType sets the "type" field.
  17858. func (m *LabelMutation) SetType(i int) {
  17859. m._type = &i
  17860. m.add_type = nil
  17861. }
  17862. // GetType returns the value of the "type" field in the mutation.
  17863. func (m *LabelMutation) GetType() (r int, exists bool) {
  17864. v := m._type
  17865. if v == nil {
  17866. return
  17867. }
  17868. return *v, true
  17869. }
  17870. // OldType returns the old "type" field's value of the Label entity.
  17871. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17873. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  17874. if !m.op.Is(OpUpdateOne) {
  17875. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17876. }
  17877. if m.id == nil || m.oldValue == nil {
  17878. return v, errors.New("OldType requires an ID field in the mutation")
  17879. }
  17880. oldValue, err := m.oldValue(ctx)
  17881. if err != nil {
  17882. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17883. }
  17884. return oldValue.Type, nil
  17885. }
  17886. // AddType adds i to the "type" field.
  17887. func (m *LabelMutation) AddType(i int) {
  17888. if m.add_type != nil {
  17889. *m.add_type += i
  17890. } else {
  17891. m.add_type = &i
  17892. }
  17893. }
  17894. // AddedType returns the value that was added to the "type" field in this mutation.
  17895. func (m *LabelMutation) AddedType() (r int, exists bool) {
  17896. v := m.add_type
  17897. if v == nil {
  17898. return
  17899. }
  17900. return *v, true
  17901. }
  17902. // ResetType resets all changes to the "type" field.
  17903. func (m *LabelMutation) ResetType() {
  17904. m._type = nil
  17905. m.add_type = nil
  17906. }
  17907. // SetName sets the "name" field.
  17908. func (m *LabelMutation) SetName(s string) {
  17909. m.name = &s
  17910. }
  17911. // Name returns the value of the "name" field in the mutation.
  17912. func (m *LabelMutation) Name() (r string, exists bool) {
  17913. v := m.name
  17914. if v == nil {
  17915. return
  17916. }
  17917. return *v, true
  17918. }
  17919. // OldName returns the old "name" field's value of the Label entity.
  17920. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17922. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  17923. if !m.op.Is(OpUpdateOne) {
  17924. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17925. }
  17926. if m.id == nil || m.oldValue == nil {
  17927. return v, errors.New("OldName requires an ID field in the mutation")
  17928. }
  17929. oldValue, err := m.oldValue(ctx)
  17930. if err != nil {
  17931. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17932. }
  17933. return oldValue.Name, nil
  17934. }
  17935. // ResetName resets all changes to the "name" field.
  17936. func (m *LabelMutation) ResetName() {
  17937. m.name = nil
  17938. }
  17939. // SetFrom sets the "from" field.
  17940. func (m *LabelMutation) SetFrom(i int) {
  17941. m.from = &i
  17942. m.addfrom = nil
  17943. }
  17944. // From returns the value of the "from" field in the mutation.
  17945. func (m *LabelMutation) From() (r int, exists bool) {
  17946. v := m.from
  17947. if v == nil {
  17948. return
  17949. }
  17950. return *v, true
  17951. }
  17952. // OldFrom returns the old "from" field's value of the Label entity.
  17953. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17955. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  17956. if !m.op.Is(OpUpdateOne) {
  17957. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  17958. }
  17959. if m.id == nil || m.oldValue == nil {
  17960. return v, errors.New("OldFrom requires an ID field in the mutation")
  17961. }
  17962. oldValue, err := m.oldValue(ctx)
  17963. if err != nil {
  17964. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  17965. }
  17966. return oldValue.From, nil
  17967. }
  17968. // AddFrom adds i to the "from" field.
  17969. func (m *LabelMutation) AddFrom(i int) {
  17970. if m.addfrom != nil {
  17971. *m.addfrom += i
  17972. } else {
  17973. m.addfrom = &i
  17974. }
  17975. }
  17976. // AddedFrom returns the value that was added to the "from" field in this mutation.
  17977. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  17978. v := m.addfrom
  17979. if v == nil {
  17980. return
  17981. }
  17982. return *v, true
  17983. }
  17984. // ResetFrom resets all changes to the "from" field.
  17985. func (m *LabelMutation) ResetFrom() {
  17986. m.from = nil
  17987. m.addfrom = nil
  17988. }
  17989. // SetMode sets the "mode" field.
  17990. func (m *LabelMutation) SetMode(i int) {
  17991. m.mode = &i
  17992. m.addmode = nil
  17993. }
  17994. // Mode returns the value of the "mode" field in the mutation.
  17995. func (m *LabelMutation) Mode() (r int, exists bool) {
  17996. v := m.mode
  17997. if v == nil {
  17998. return
  17999. }
  18000. return *v, true
  18001. }
  18002. // OldMode returns the old "mode" field's value of the Label entity.
  18003. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18005. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  18006. if !m.op.Is(OpUpdateOne) {
  18007. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  18008. }
  18009. if m.id == nil || m.oldValue == nil {
  18010. return v, errors.New("OldMode requires an ID field in the mutation")
  18011. }
  18012. oldValue, err := m.oldValue(ctx)
  18013. if err != nil {
  18014. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  18015. }
  18016. return oldValue.Mode, nil
  18017. }
  18018. // AddMode adds i to the "mode" field.
  18019. func (m *LabelMutation) AddMode(i int) {
  18020. if m.addmode != nil {
  18021. *m.addmode += i
  18022. } else {
  18023. m.addmode = &i
  18024. }
  18025. }
  18026. // AddedMode returns the value that was added to the "mode" field in this mutation.
  18027. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  18028. v := m.addmode
  18029. if v == nil {
  18030. return
  18031. }
  18032. return *v, true
  18033. }
  18034. // ResetMode resets all changes to the "mode" field.
  18035. func (m *LabelMutation) ResetMode() {
  18036. m.mode = nil
  18037. m.addmode = nil
  18038. }
  18039. // SetConditions sets the "conditions" field.
  18040. func (m *LabelMutation) SetConditions(s string) {
  18041. m.conditions = &s
  18042. }
  18043. // Conditions returns the value of the "conditions" field in the mutation.
  18044. func (m *LabelMutation) Conditions() (r string, exists bool) {
  18045. v := m.conditions
  18046. if v == nil {
  18047. return
  18048. }
  18049. return *v, true
  18050. }
  18051. // OldConditions returns the old "conditions" field's value of the Label entity.
  18052. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18054. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  18055. if !m.op.Is(OpUpdateOne) {
  18056. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  18057. }
  18058. if m.id == nil || m.oldValue == nil {
  18059. return v, errors.New("OldConditions requires an ID field in the mutation")
  18060. }
  18061. oldValue, err := m.oldValue(ctx)
  18062. if err != nil {
  18063. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  18064. }
  18065. return oldValue.Conditions, nil
  18066. }
  18067. // ClearConditions clears the value of the "conditions" field.
  18068. func (m *LabelMutation) ClearConditions() {
  18069. m.conditions = nil
  18070. m.clearedFields[label.FieldConditions] = struct{}{}
  18071. }
  18072. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  18073. func (m *LabelMutation) ConditionsCleared() bool {
  18074. _, ok := m.clearedFields[label.FieldConditions]
  18075. return ok
  18076. }
  18077. // ResetConditions resets all changes to the "conditions" field.
  18078. func (m *LabelMutation) ResetConditions() {
  18079. m.conditions = nil
  18080. delete(m.clearedFields, label.FieldConditions)
  18081. }
  18082. // SetOrganizationID sets the "organization_id" field.
  18083. func (m *LabelMutation) SetOrganizationID(u uint64) {
  18084. m.organization_id = &u
  18085. m.addorganization_id = nil
  18086. }
  18087. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18088. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  18089. v := m.organization_id
  18090. if v == nil {
  18091. return
  18092. }
  18093. return *v, true
  18094. }
  18095. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  18096. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18098. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18099. if !m.op.Is(OpUpdateOne) {
  18100. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18101. }
  18102. if m.id == nil || m.oldValue == nil {
  18103. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18104. }
  18105. oldValue, err := m.oldValue(ctx)
  18106. if err != nil {
  18107. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18108. }
  18109. return oldValue.OrganizationID, nil
  18110. }
  18111. // AddOrganizationID adds u to the "organization_id" field.
  18112. func (m *LabelMutation) AddOrganizationID(u int64) {
  18113. if m.addorganization_id != nil {
  18114. *m.addorganization_id += u
  18115. } else {
  18116. m.addorganization_id = &u
  18117. }
  18118. }
  18119. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18120. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  18121. v := m.addorganization_id
  18122. if v == nil {
  18123. return
  18124. }
  18125. return *v, true
  18126. }
  18127. // ClearOrganizationID clears the value of the "organization_id" field.
  18128. func (m *LabelMutation) ClearOrganizationID() {
  18129. m.organization_id = nil
  18130. m.addorganization_id = nil
  18131. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  18132. }
  18133. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18134. func (m *LabelMutation) OrganizationIDCleared() bool {
  18135. _, ok := m.clearedFields[label.FieldOrganizationID]
  18136. return ok
  18137. }
  18138. // ResetOrganizationID resets all changes to the "organization_id" field.
  18139. func (m *LabelMutation) ResetOrganizationID() {
  18140. m.organization_id = nil
  18141. m.addorganization_id = nil
  18142. delete(m.clearedFields, label.FieldOrganizationID)
  18143. }
  18144. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  18145. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  18146. if m.label_relationships == nil {
  18147. m.label_relationships = make(map[uint64]struct{})
  18148. }
  18149. for i := range ids {
  18150. m.label_relationships[ids[i]] = struct{}{}
  18151. }
  18152. }
  18153. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  18154. func (m *LabelMutation) ClearLabelRelationships() {
  18155. m.clearedlabel_relationships = true
  18156. }
  18157. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  18158. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  18159. return m.clearedlabel_relationships
  18160. }
  18161. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  18162. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  18163. if m.removedlabel_relationships == nil {
  18164. m.removedlabel_relationships = make(map[uint64]struct{})
  18165. }
  18166. for i := range ids {
  18167. delete(m.label_relationships, ids[i])
  18168. m.removedlabel_relationships[ids[i]] = struct{}{}
  18169. }
  18170. }
  18171. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  18172. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  18173. for id := range m.removedlabel_relationships {
  18174. ids = append(ids, id)
  18175. }
  18176. return
  18177. }
  18178. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  18179. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  18180. for id := range m.label_relationships {
  18181. ids = append(ids, id)
  18182. }
  18183. return
  18184. }
  18185. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  18186. func (m *LabelMutation) ResetLabelRelationships() {
  18187. m.label_relationships = nil
  18188. m.clearedlabel_relationships = false
  18189. m.removedlabel_relationships = nil
  18190. }
  18191. // Where appends a list predicates to the LabelMutation builder.
  18192. func (m *LabelMutation) Where(ps ...predicate.Label) {
  18193. m.predicates = append(m.predicates, ps...)
  18194. }
  18195. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  18196. // users can use type-assertion to append predicates that do not depend on any generated package.
  18197. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  18198. p := make([]predicate.Label, len(ps))
  18199. for i := range ps {
  18200. p[i] = ps[i]
  18201. }
  18202. m.Where(p...)
  18203. }
  18204. // Op returns the operation name.
  18205. func (m *LabelMutation) Op() Op {
  18206. return m.op
  18207. }
  18208. // SetOp allows setting the mutation operation.
  18209. func (m *LabelMutation) SetOp(op Op) {
  18210. m.op = op
  18211. }
  18212. // Type returns the node type of this mutation (Label).
  18213. func (m *LabelMutation) Type() string {
  18214. return m.typ
  18215. }
  18216. // Fields returns all fields that were changed during this mutation. Note that in
  18217. // order to get all numeric fields that were incremented/decremented, call
  18218. // AddedFields().
  18219. func (m *LabelMutation) Fields() []string {
  18220. fields := make([]string, 0, 9)
  18221. if m.created_at != nil {
  18222. fields = append(fields, label.FieldCreatedAt)
  18223. }
  18224. if m.updated_at != nil {
  18225. fields = append(fields, label.FieldUpdatedAt)
  18226. }
  18227. if m.status != nil {
  18228. fields = append(fields, label.FieldStatus)
  18229. }
  18230. if m._type != nil {
  18231. fields = append(fields, label.FieldType)
  18232. }
  18233. if m.name != nil {
  18234. fields = append(fields, label.FieldName)
  18235. }
  18236. if m.from != nil {
  18237. fields = append(fields, label.FieldFrom)
  18238. }
  18239. if m.mode != nil {
  18240. fields = append(fields, label.FieldMode)
  18241. }
  18242. if m.conditions != nil {
  18243. fields = append(fields, label.FieldConditions)
  18244. }
  18245. if m.organization_id != nil {
  18246. fields = append(fields, label.FieldOrganizationID)
  18247. }
  18248. return fields
  18249. }
  18250. // Field returns the value of a field with the given name. The second boolean
  18251. // return value indicates that this field was not set, or was not defined in the
  18252. // schema.
  18253. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  18254. switch name {
  18255. case label.FieldCreatedAt:
  18256. return m.CreatedAt()
  18257. case label.FieldUpdatedAt:
  18258. return m.UpdatedAt()
  18259. case label.FieldStatus:
  18260. return m.Status()
  18261. case label.FieldType:
  18262. return m.GetType()
  18263. case label.FieldName:
  18264. return m.Name()
  18265. case label.FieldFrom:
  18266. return m.From()
  18267. case label.FieldMode:
  18268. return m.Mode()
  18269. case label.FieldConditions:
  18270. return m.Conditions()
  18271. case label.FieldOrganizationID:
  18272. return m.OrganizationID()
  18273. }
  18274. return nil, false
  18275. }
  18276. // OldField returns the old value of the field from the database. An error is
  18277. // returned if the mutation operation is not UpdateOne, or the query to the
  18278. // database failed.
  18279. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18280. switch name {
  18281. case label.FieldCreatedAt:
  18282. return m.OldCreatedAt(ctx)
  18283. case label.FieldUpdatedAt:
  18284. return m.OldUpdatedAt(ctx)
  18285. case label.FieldStatus:
  18286. return m.OldStatus(ctx)
  18287. case label.FieldType:
  18288. return m.OldType(ctx)
  18289. case label.FieldName:
  18290. return m.OldName(ctx)
  18291. case label.FieldFrom:
  18292. return m.OldFrom(ctx)
  18293. case label.FieldMode:
  18294. return m.OldMode(ctx)
  18295. case label.FieldConditions:
  18296. return m.OldConditions(ctx)
  18297. case label.FieldOrganizationID:
  18298. return m.OldOrganizationID(ctx)
  18299. }
  18300. return nil, fmt.Errorf("unknown Label field %s", name)
  18301. }
  18302. // SetField sets the value of a field with the given name. It returns an error if
  18303. // the field is not defined in the schema, or if the type mismatched the field
  18304. // type.
  18305. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  18306. switch name {
  18307. case label.FieldCreatedAt:
  18308. v, ok := value.(time.Time)
  18309. if !ok {
  18310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18311. }
  18312. m.SetCreatedAt(v)
  18313. return nil
  18314. case label.FieldUpdatedAt:
  18315. v, ok := value.(time.Time)
  18316. if !ok {
  18317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18318. }
  18319. m.SetUpdatedAt(v)
  18320. return nil
  18321. case label.FieldStatus:
  18322. v, ok := value.(uint8)
  18323. if !ok {
  18324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18325. }
  18326. m.SetStatus(v)
  18327. return nil
  18328. case label.FieldType:
  18329. v, ok := value.(int)
  18330. if !ok {
  18331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18332. }
  18333. m.SetType(v)
  18334. return nil
  18335. case label.FieldName:
  18336. v, ok := value.(string)
  18337. if !ok {
  18338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18339. }
  18340. m.SetName(v)
  18341. return nil
  18342. case label.FieldFrom:
  18343. v, ok := value.(int)
  18344. if !ok {
  18345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18346. }
  18347. m.SetFrom(v)
  18348. return nil
  18349. case label.FieldMode:
  18350. v, ok := value.(int)
  18351. if !ok {
  18352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18353. }
  18354. m.SetMode(v)
  18355. return nil
  18356. case label.FieldConditions:
  18357. v, ok := value.(string)
  18358. if !ok {
  18359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18360. }
  18361. m.SetConditions(v)
  18362. return nil
  18363. case label.FieldOrganizationID:
  18364. v, ok := value.(uint64)
  18365. if !ok {
  18366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18367. }
  18368. m.SetOrganizationID(v)
  18369. return nil
  18370. }
  18371. return fmt.Errorf("unknown Label field %s", name)
  18372. }
  18373. // AddedFields returns all numeric fields that were incremented/decremented during
  18374. // this mutation.
  18375. func (m *LabelMutation) AddedFields() []string {
  18376. var fields []string
  18377. if m.addstatus != nil {
  18378. fields = append(fields, label.FieldStatus)
  18379. }
  18380. if m.add_type != nil {
  18381. fields = append(fields, label.FieldType)
  18382. }
  18383. if m.addfrom != nil {
  18384. fields = append(fields, label.FieldFrom)
  18385. }
  18386. if m.addmode != nil {
  18387. fields = append(fields, label.FieldMode)
  18388. }
  18389. if m.addorganization_id != nil {
  18390. fields = append(fields, label.FieldOrganizationID)
  18391. }
  18392. return fields
  18393. }
  18394. // AddedField returns the numeric value that was incremented/decremented on a field
  18395. // with the given name. The second boolean return value indicates that this field
  18396. // was not set, or was not defined in the schema.
  18397. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  18398. switch name {
  18399. case label.FieldStatus:
  18400. return m.AddedStatus()
  18401. case label.FieldType:
  18402. return m.AddedType()
  18403. case label.FieldFrom:
  18404. return m.AddedFrom()
  18405. case label.FieldMode:
  18406. return m.AddedMode()
  18407. case label.FieldOrganizationID:
  18408. return m.AddedOrganizationID()
  18409. }
  18410. return nil, false
  18411. }
  18412. // AddField adds the value to the field with the given name. It returns an error if
  18413. // the field is not defined in the schema, or if the type mismatched the field
  18414. // type.
  18415. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  18416. switch name {
  18417. case label.FieldStatus:
  18418. v, ok := value.(int8)
  18419. if !ok {
  18420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18421. }
  18422. m.AddStatus(v)
  18423. return nil
  18424. case label.FieldType:
  18425. v, ok := value.(int)
  18426. if !ok {
  18427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18428. }
  18429. m.AddType(v)
  18430. return nil
  18431. case label.FieldFrom:
  18432. v, ok := value.(int)
  18433. if !ok {
  18434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18435. }
  18436. m.AddFrom(v)
  18437. return nil
  18438. case label.FieldMode:
  18439. v, ok := value.(int)
  18440. if !ok {
  18441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18442. }
  18443. m.AddMode(v)
  18444. return nil
  18445. case label.FieldOrganizationID:
  18446. v, ok := value.(int64)
  18447. if !ok {
  18448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18449. }
  18450. m.AddOrganizationID(v)
  18451. return nil
  18452. }
  18453. return fmt.Errorf("unknown Label numeric field %s", name)
  18454. }
  18455. // ClearedFields returns all nullable fields that were cleared during this
  18456. // mutation.
  18457. func (m *LabelMutation) ClearedFields() []string {
  18458. var fields []string
  18459. if m.FieldCleared(label.FieldStatus) {
  18460. fields = append(fields, label.FieldStatus)
  18461. }
  18462. if m.FieldCleared(label.FieldConditions) {
  18463. fields = append(fields, label.FieldConditions)
  18464. }
  18465. if m.FieldCleared(label.FieldOrganizationID) {
  18466. fields = append(fields, label.FieldOrganizationID)
  18467. }
  18468. return fields
  18469. }
  18470. // FieldCleared returns a boolean indicating if a field with the given name was
  18471. // cleared in this mutation.
  18472. func (m *LabelMutation) FieldCleared(name string) bool {
  18473. _, ok := m.clearedFields[name]
  18474. return ok
  18475. }
  18476. // ClearField clears the value of the field with the given name. It returns an
  18477. // error if the field is not defined in the schema.
  18478. func (m *LabelMutation) ClearField(name string) error {
  18479. switch name {
  18480. case label.FieldStatus:
  18481. m.ClearStatus()
  18482. return nil
  18483. case label.FieldConditions:
  18484. m.ClearConditions()
  18485. return nil
  18486. case label.FieldOrganizationID:
  18487. m.ClearOrganizationID()
  18488. return nil
  18489. }
  18490. return fmt.Errorf("unknown Label nullable field %s", name)
  18491. }
  18492. // ResetField resets all changes in the mutation for the field with the given name.
  18493. // It returns an error if the field is not defined in the schema.
  18494. func (m *LabelMutation) ResetField(name string) error {
  18495. switch name {
  18496. case label.FieldCreatedAt:
  18497. m.ResetCreatedAt()
  18498. return nil
  18499. case label.FieldUpdatedAt:
  18500. m.ResetUpdatedAt()
  18501. return nil
  18502. case label.FieldStatus:
  18503. m.ResetStatus()
  18504. return nil
  18505. case label.FieldType:
  18506. m.ResetType()
  18507. return nil
  18508. case label.FieldName:
  18509. m.ResetName()
  18510. return nil
  18511. case label.FieldFrom:
  18512. m.ResetFrom()
  18513. return nil
  18514. case label.FieldMode:
  18515. m.ResetMode()
  18516. return nil
  18517. case label.FieldConditions:
  18518. m.ResetConditions()
  18519. return nil
  18520. case label.FieldOrganizationID:
  18521. m.ResetOrganizationID()
  18522. return nil
  18523. }
  18524. return fmt.Errorf("unknown Label field %s", name)
  18525. }
  18526. // AddedEdges returns all edge names that were set/added in this mutation.
  18527. func (m *LabelMutation) AddedEdges() []string {
  18528. edges := make([]string, 0, 1)
  18529. if m.label_relationships != nil {
  18530. edges = append(edges, label.EdgeLabelRelationships)
  18531. }
  18532. return edges
  18533. }
  18534. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18535. // name in this mutation.
  18536. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  18537. switch name {
  18538. case label.EdgeLabelRelationships:
  18539. ids := make([]ent.Value, 0, len(m.label_relationships))
  18540. for id := range m.label_relationships {
  18541. ids = append(ids, id)
  18542. }
  18543. return ids
  18544. }
  18545. return nil
  18546. }
  18547. // RemovedEdges returns all edge names that were removed in this mutation.
  18548. func (m *LabelMutation) RemovedEdges() []string {
  18549. edges := make([]string, 0, 1)
  18550. if m.removedlabel_relationships != nil {
  18551. edges = append(edges, label.EdgeLabelRelationships)
  18552. }
  18553. return edges
  18554. }
  18555. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18556. // the given name in this mutation.
  18557. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  18558. switch name {
  18559. case label.EdgeLabelRelationships:
  18560. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  18561. for id := range m.removedlabel_relationships {
  18562. ids = append(ids, id)
  18563. }
  18564. return ids
  18565. }
  18566. return nil
  18567. }
  18568. // ClearedEdges returns all edge names that were cleared in this mutation.
  18569. func (m *LabelMutation) ClearedEdges() []string {
  18570. edges := make([]string, 0, 1)
  18571. if m.clearedlabel_relationships {
  18572. edges = append(edges, label.EdgeLabelRelationships)
  18573. }
  18574. return edges
  18575. }
  18576. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18577. // was cleared in this mutation.
  18578. func (m *LabelMutation) EdgeCleared(name string) bool {
  18579. switch name {
  18580. case label.EdgeLabelRelationships:
  18581. return m.clearedlabel_relationships
  18582. }
  18583. return false
  18584. }
  18585. // ClearEdge clears the value of the edge with the given name. It returns an error
  18586. // if that edge is not defined in the schema.
  18587. func (m *LabelMutation) ClearEdge(name string) error {
  18588. switch name {
  18589. }
  18590. return fmt.Errorf("unknown Label unique edge %s", name)
  18591. }
  18592. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18593. // It returns an error if the edge is not defined in the schema.
  18594. func (m *LabelMutation) ResetEdge(name string) error {
  18595. switch name {
  18596. case label.EdgeLabelRelationships:
  18597. m.ResetLabelRelationships()
  18598. return nil
  18599. }
  18600. return fmt.Errorf("unknown Label edge %s", name)
  18601. }
  18602. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  18603. type LabelRelationshipMutation struct {
  18604. config
  18605. op Op
  18606. typ string
  18607. id *uint64
  18608. created_at *time.Time
  18609. updated_at *time.Time
  18610. status *uint8
  18611. addstatus *int8
  18612. organization_id *uint64
  18613. addorganization_id *int64
  18614. clearedFields map[string]struct{}
  18615. contacts *uint64
  18616. clearedcontacts bool
  18617. labels *uint64
  18618. clearedlabels bool
  18619. done bool
  18620. oldValue func(context.Context) (*LabelRelationship, error)
  18621. predicates []predicate.LabelRelationship
  18622. }
  18623. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  18624. // labelrelationshipOption allows management of the mutation configuration using functional options.
  18625. type labelrelationshipOption func(*LabelRelationshipMutation)
  18626. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  18627. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  18628. m := &LabelRelationshipMutation{
  18629. config: c,
  18630. op: op,
  18631. typ: TypeLabelRelationship,
  18632. clearedFields: make(map[string]struct{}),
  18633. }
  18634. for _, opt := range opts {
  18635. opt(m)
  18636. }
  18637. return m
  18638. }
  18639. // withLabelRelationshipID sets the ID field of the mutation.
  18640. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  18641. return func(m *LabelRelationshipMutation) {
  18642. var (
  18643. err error
  18644. once sync.Once
  18645. value *LabelRelationship
  18646. )
  18647. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  18648. once.Do(func() {
  18649. if m.done {
  18650. err = errors.New("querying old values post mutation is not allowed")
  18651. } else {
  18652. value, err = m.Client().LabelRelationship.Get(ctx, id)
  18653. }
  18654. })
  18655. return value, err
  18656. }
  18657. m.id = &id
  18658. }
  18659. }
  18660. // withLabelRelationship sets the old LabelRelationship of the mutation.
  18661. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  18662. return func(m *LabelRelationshipMutation) {
  18663. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  18664. return node, nil
  18665. }
  18666. m.id = &node.ID
  18667. }
  18668. }
  18669. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18670. // executed in a transaction (ent.Tx), a transactional client is returned.
  18671. func (m LabelRelationshipMutation) Client() *Client {
  18672. client := &Client{config: m.config}
  18673. client.init()
  18674. return client
  18675. }
  18676. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18677. // it returns an error otherwise.
  18678. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  18679. if _, ok := m.driver.(*txDriver); !ok {
  18680. return nil, errors.New("ent: mutation is not running in a transaction")
  18681. }
  18682. tx := &Tx{config: m.config}
  18683. tx.init()
  18684. return tx, nil
  18685. }
  18686. // SetID sets the value of the id field. Note that this
  18687. // operation is only accepted on creation of LabelRelationship entities.
  18688. func (m *LabelRelationshipMutation) SetID(id uint64) {
  18689. m.id = &id
  18690. }
  18691. // ID returns the ID value in the mutation. Note that the ID is only available
  18692. // if it was provided to the builder or after it was returned from the database.
  18693. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  18694. if m.id == nil {
  18695. return
  18696. }
  18697. return *m.id, true
  18698. }
  18699. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18700. // That means, if the mutation is applied within a transaction with an isolation level such
  18701. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18702. // or updated by the mutation.
  18703. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  18704. switch {
  18705. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18706. id, exists := m.ID()
  18707. if exists {
  18708. return []uint64{id}, nil
  18709. }
  18710. fallthrough
  18711. case m.op.Is(OpUpdate | OpDelete):
  18712. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  18713. default:
  18714. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18715. }
  18716. }
  18717. // SetCreatedAt sets the "created_at" field.
  18718. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  18719. m.created_at = &t
  18720. }
  18721. // CreatedAt returns the value of the "created_at" field in the mutation.
  18722. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  18723. v := m.created_at
  18724. if v == nil {
  18725. return
  18726. }
  18727. return *v, true
  18728. }
  18729. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  18730. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18732. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18733. if !m.op.Is(OpUpdateOne) {
  18734. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18735. }
  18736. if m.id == nil || m.oldValue == nil {
  18737. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18738. }
  18739. oldValue, err := m.oldValue(ctx)
  18740. if err != nil {
  18741. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18742. }
  18743. return oldValue.CreatedAt, nil
  18744. }
  18745. // ResetCreatedAt resets all changes to the "created_at" field.
  18746. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  18747. m.created_at = nil
  18748. }
  18749. // SetUpdatedAt sets the "updated_at" field.
  18750. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  18751. m.updated_at = &t
  18752. }
  18753. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18754. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  18755. v := m.updated_at
  18756. if v == nil {
  18757. return
  18758. }
  18759. return *v, true
  18760. }
  18761. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18765. if !m.op.Is(OpUpdateOne) {
  18766. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18767. }
  18768. if m.id == nil || m.oldValue == nil {
  18769. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  18774. }
  18775. return oldValue.UpdatedAt, nil
  18776. }
  18777. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18778. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  18779. m.updated_at = nil
  18780. }
  18781. // SetStatus sets the "status" field.
  18782. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  18783. m.status = &u
  18784. m.addstatus = nil
  18785. }
  18786. // Status returns the value of the "status" field in the mutation.
  18787. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  18788. v := m.status
  18789. if v == nil {
  18790. return
  18791. }
  18792. return *v, true
  18793. }
  18794. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  18795. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18797. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18798. if !m.op.Is(OpUpdateOne) {
  18799. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18800. }
  18801. if m.id == nil || m.oldValue == nil {
  18802. return v, errors.New("OldStatus requires an ID field in the mutation")
  18803. }
  18804. oldValue, err := m.oldValue(ctx)
  18805. if err != nil {
  18806. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18807. }
  18808. return oldValue.Status, nil
  18809. }
  18810. // AddStatus adds u to the "status" field.
  18811. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  18812. if m.addstatus != nil {
  18813. *m.addstatus += u
  18814. } else {
  18815. m.addstatus = &u
  18816. }
  18817. }
  18818. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18819. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  18820. v := m.addstatus
  18821. if v == nil {
  18822. return
  18823. }
  18824. return *v, true
  18825. }
  18826. // ClearStatus clears the value of the "status" field.
  18827. func (m *LabelRelationshipMutation) ClearStatus() {
  18828. m.status = nil
  18829. m.addstatus = nil
  18830. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  18831. }
  18832. // StatusCleared returns if the "status" field was cleared in this mutation.
  18833. func (m *LabelRelationshipMutation) StatusCleared() bool {
  18834. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  18835. return ok
  18836. }
  18837. // ResetStatus resets all changes to the "status" field.
  18838. func (m *LabelRelationshipMutation) ResetStatus() {
  18839. m.status = nil
  18840. m.addstatus = nil
  18841. delete(m.clearedFields, labelrelationship.FieldStatus)
  18842. }
  18843. // SetLabelID sets the "label_id" field.
  18844. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  18845. m.labels = &u
  18846. }
  18847. // LabelID returns the value of the "label_id" field in the mutation.
  18848. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  18849. v := m.labels
  18850. if v == nil {
  18851. return
  18852. }
  18853. return *v, true
  18854. }
  18855. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  18856. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18858. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  18859. if !m.op.Is(OpUpdateOne) {
  18860. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  18861. }
  18862. if m.id == nil || m.oldValue == nil {
  18863. return v, errors.New("OldLabelID requires an ID field in the mutation")
  18864. }
  18865. oldValue, err := m.oldValue(ctx)
  18866. if err != nil {
  18867. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  18868. }
  18869. return oldValue.LabelID, nil
  18870. }
  18871. // ResetLabelID resets all changes to the "label_id" field.
  18872. func (m *LabelRelationshipMutation) ResetLabelID() {
  18873. m.labels = nil
  18874. }
  18875. // SetContactID sets the "contact_id" field.
  18876. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  18877. m.contacts = &u
  18878. }
  18879. // ContactID returns the value of the "contact_id" field in the mutation.
  18880. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  18881. v := m.contacts
  18882. if v == nil {
  18883. return
  18884. }
  18885. return *v, true
  18886. }
  18887. // OldContactID returns the old "contact_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) OldContactID(ctx context.Context) (v uint64, err error) {
  18891. if !m.op.Is(OpUpdateOne) {
  18892. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  18893. }
  18894. if m.id == nil || m.oldValue == nil {
  18895. return v, errors.New("OldContactID 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 OldContactID: %w", err)
  18900. }
  18901. return oldValue.ContactID, nil
  18902. }
  18903. // ResetContactID resets all changes to the "contact_id" field.
  18904. func (m *LabelRelationshipMutation) ResetContactID() {
  18905. m.contacts = nil
  18906. }
  18907. // SetOrganizationID sets the "organization_id" field.
  18908. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  18909. m.organization_id = &u
  18910. m.addorganization_id = nil
  18911. }
  18912. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18913. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  18914. v := m.organization_id
  18915. if v == nil {
  18916. return
  18917. }
  18918. return *v, true
  18919. }
  18920. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  18921. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18923. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18924. if !m.op.Is(OpUpdateOne) {
  18925. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18926. }
  18927. if m.id == nil || m.oldValue == nil {
  18928. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18929. }
  18930. oldValue, err := m.oldValue(ctx)
  18931. if err != nil {
  18932. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18933. }
  18934. return oldValue.OrganizationID, nil
  18935. }
  18936. // AddOrganizationID adds u to the "organization_id" field.
  18937. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  18938. if m.addorganization_id != nil {
  18939. *m.addorganization_id += u
  18940. } else {
  18941. m.addorganization_id = &u
  18942. }
  18943. }
  18944. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18945. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  18946. v := m.addorganization_id
  18947. if v == nil {
  18948. return
  18949. }
  18950. return *v, true
  18951. }
  18952. // ClearOrganizationID clears the value of the "organization_id" field.
  18953. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  18954. m.organization_id = nil
  18955. m.addorganization_id = nil
  18956. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  18957. }
  18958. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18959. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  18960. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  18961. return ok
  18962. }
  18963. // ResetOrganizationID resets all changes to the "organization_id" field.
  18964. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  18965. m.organization_id = nil
  18966. m.addorganization_id = nil
  18967. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  18968. }
  18969. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  18970. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  18971. m.contacts = &id
  18972. }
  18973. // ClearContacts clears the "contacts" edge to the Contact entity.
  18974. func (m *LabelRelationshipMutation) ClearContacts() {
  18975. m.clearedcontacts = true
  18976. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  18977. }
  18978. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  18979. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  18980. return m.clearedcontacts
  18981. }
  18982. // ContactsID returns the "contacts" edge ID in the mutation.
  18983. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  18984. if m.contacts != nil {
  18985. return *m.contacts, true
  18986. }
  18987. return
  18988. }
  18989. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  18990. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18991. // ContactsID instead. It exists only for internal usage by the builders.
  18992. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  18993. if id := m.contacts; id != nil {
  18994. ids = append(ids, *id)
  18995. }
  18996. return
  18997. }
  18998. // ResetContacts resets all changes to the "contacts" edge.
  18999. func (m *LabelRelationshipMutation) ResetContacts() {
  19000. m.contacts = nil
  19001. m.clearedcontacts = false
  19002. }
  19003. // SetLabelsID sets the "labels" edge to the Label entity by id.
  19004. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  19005. m.labels = &id
  19006. }
  19007. // ClearLabels clears the "labels" edge to the Label entity.
  19008. func (m *LabelRelationshipMutation) ClearLabels() {
  19009. m.clearedlabels = true
  19010. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  19011. }
  19012. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  19013. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  19014. return m.clearedlabels
  19015. }
  19016. // LabelsID returns the "labels" edge ID in the mutation.
  19017. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  19018. if m.labels != nil {
  19019. return *m.labels, true
  19020. }
  19021. return
  19022. }
  19023. // LabelsIDs returns the "labels" edge IDs in the mutation.
  19024. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19025. // LabelsID instead. It exists only for internal usage by the builders.
  19026. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  19027. if id := m.labels; id != nil {
  19028. ids = append(ids, *id)
  19029. }
  19030. return
  19031. }
  19032. // ResetLabels resets all changes to the "labels" edge.
  19033. func (m *LabelRelationshipMutation) ResetLabels() {
  19034. m.labels = nil
  19035. m.clearedlabels = false
  19036. }
  19037. // Where appends a list predicates to the LabelRelationshipMutation builder.
  19038. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  19039. m.predicates = append(m.predicates, ps...)
  19040. }
  19041. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  19042. // users can use type-assertion to append predicates that do not depend on any generated package.
  19043. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  19044. p := make([]predicate.LabelRelationship, len(ps))
  19045. for i := range ps {
  19046. p[i] = ps[i]
  19047. }
  19048. m.Where(p...)
  19049. }
  19050. // Op returns the operation name.
  19051. func (m *LabelRelationshipMutation) Op() Op {
  19052. return m.op
  19053. }
  19054. // SetOp allows setting the mutation operation.
  19055. func (m *LabelRelationshipMutation) SetOp(op Op) {
  19056. m.op = op
  19057. }
  19058. // Type returns the node type of this mutation (LabelRelationship).
  19059. func (m *LabelRelationshipMutation) Type() string {
  19060. return m.typ
  19061. }
  19062. // Fields returns all fields that were changed during this mutation. Note that in
  19063. // order to get all numeric fields that were incremented/decremented, call
  19064. // AddedFields().
  19065. func (m *LabelRelationshipMutation) Fields() []string {
  19066. fields := make([]string, 0, 6)
  19067. if m.created_at != nil {
  19068. fields = append(fields, labelrelationship.FieldCreatedAt)
  19069. }
  19070. if m.updated_at != nil {
  19071. fields = append(fields, labelrelationship.FieldUpdatedAt)
  19072. }
  19073. if m.status != nil {
  19074. fields = append(fields, labelrelationship.FieldStatus)
  19075. }
  19076. if m.labels != nil {
  19077. fields = append(fields, labelrelationship.FieldLabelID)
  19078. }
  19079. if m.contacts != nil {
  19080. fields = append(fields, labelrelationship.FieldContactID)
  19081. }
  19082. if m.organization_id != nil {
  19083. fields = append(fields, labelrelationship.FieldOrganizationID)
  19084. }
  19085. return fields
  19086. }
  19087. // Field returns the value of a field with the given name. The second boolean
  19088. // return value indicates that this field was not set, or was not defined in the
  19089. // schema.
  19090. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  19091. switch name {
  19092. case labelrelationship.FieldCreatedAt:
  19093. return m.CreatedAt()
  19094. case labelrelationship.FieldUpdatedAt:
  19095. return m.UpdatedAt()
  19096. case labelrelationship.FieldStatus:
  19097. return m.Status()
  19098. case labelrelationship.FieldLabelID:
  19099. return m.LabelID()
  19100. case labelrelationship.FieldContactID:
  19101. return m.ContactID()
  19102. case labelrelationship.FieldOrganizationID:
  19103. return m.OrganizationID()
  19104. }
  19105. return nil, false
  19106. }
  19107. // OldField returns the old value of the field from the database. An error is
  19108. // returned if the mutation operation is not UpdateOne, or the query to the
  19109. // database failed.
  19110. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19111. switch name {
  19112. case labelrelationship.FieldCreatedAt:
  19113. return m.OldCreatedAt(ctx)
  19114. case labelrelationship.FieldUpdatedAt:
  19115. return m.OldUpdatedAt(ctx)
  19116. case labelrelationship.FieldStatus:
  19117. return m.OldStatus(ctx)
  19118. case labelrelationship.FieldLabelID:
  19119. return m.OldLabelID(ctx)
  19120. case labelrelationship.FieldContactID:
  19121. return m.OldContactID(ctx)
  19122. case labelrelationship.FieldOrganizationID:
  19123. return m.OldOrganizationID(ctx)
  19124. }
  19125. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  19126. }
  19127. // SetField sets the value of a field with the given name. It returns an error if
  19128. // the field is not defined in the schema, or if the type mismatched the field
  19129. // type.
  19130. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  19131. switch name {
  19132. case labelrelationship.FieldCreatedAt:
  19133. v, ok := value.(time.Time)
  19134. if !ok {
  19135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19136. }
  19137. m.SetCreatedAt(v)
  19138. return nil
  19139. case labelrelationship.FieldUpdatedAt:
  19140. v, ok := value.(time.Time)
  19141. if !ok {
  19142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19143. }
  19144. m.SetUpdatedAt(v)
  19145. return nil
  19146. case labelrelationship.FieldStatus:
  19147. v, ok := value.(uint8)
  19148. if !ok {
  19149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19150. }
  19151. m.SetStatus(v)
  19152. return nil
  19153. case labelrelationship.FieldLabelID:
  19154. v, ok := value.(uint64)
  19155. if !ok {
  19156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19157. }
  19158. m.SetLabelID(v)
  19159. return nil
  19160. case labelrelationship.FieldContactID:
  19161. v, ok := value.(uint64)
  19162. if !ok {
  19163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19164. }
  19165. m.SetContactID(v)
  19166. return nil
  19167. case labelrelationship.FieldOrganizationID:
  19168. v, ok := value.(uint64)
  19169. if !ok {
  19170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19171. }
  19172. m.SetOrganizationID(v)
  19173. return nil
  19174. }
  19175. return fmt.Errorf("unknown LabelRelationship field %s", name)
  19176. }
  19177. // AddedFields returns all numeric fields that were incremented/decremented during
  19178. // this mutation.
  19179. func (m *LabelRelationshipMutation) AddedFields() []string {
  19180. var fields []string
  19181. if m.addstatus != nil {
  19182. fields = append(fields, labelrelationship.FieldStatus)
  19183. }
  19184. if m.addorganization_id != nil {
  19185. fields = append(fields, labelrelationship.FieldOrganizationID)
  19186. }
  19187. return fields
  19188. }
  19189. // AddedField returns the numeric value that was incremented/decremented on a field
  19190. // with the given name. The second boolean return value indicates that this field
  19191. // was not set, or was not defined in the schema.
  19192. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  19193. switch name {
  19194. case labelrelationship.FieldStatus:
  19195. return m.AddedStatus()
  19196. case labelrelationship.FieldOrganizationID:
  19197. return m.AddedOrganizationID()
  19198. }
  19199. return nil, false
  19200. }
  19201. // AddField adds the value to the field with the given name. It returns an error if
  19202. // the field is not defined in the schema, or if the type mismatched the field
  19203. // type.
  19204. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  19205. switch name {
  19206. case labelrelationship.FieldStatus:
  19207. v, ok := value.(int8)
  19208. if !ok {
  19209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19210. }
  19211. m.AddStatus(v)
  19212. return nil
  19213. case labelrelationship.FieldOrganizationID:
  19214. v, ok := value.(int64)
  19215. if !ok {
  19216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19217. }
  19218. m.AddOrganizationID(v)
  19219. return nil
  19220. }
  19221. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  19222. }
  19223. // ClearedFields returns all nullable fields that were cleared during this
  19224. // mutation.
  19225. func (m *LabelRelationshipMutation) ClearedFields() []string {
  19226. var fields []string
  19227. if m.FieldCleared(labelrelationship.FieldStatus) {
  19228. fields = append(fields, labelrelationship.FieldStatus)
  19229. }
  19230. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  19231. fields = append(fields, labelrelationship.FieldOrganizationID)
  19232. }
  19233. return fields
  19234. }
  19235. // FieldCleared returns a boolean indicating if a field with the given name was
  19236. // cleared in this mutation.
  19237. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  19238. _, ok := m.clearedFields[name]
  19239. return ok
  19240. }
  19241. // ClearField clears the value of the field with the given name. It returns an
  19242. // error if the field is not defined in the schema.
  19243. func (m *LabelRelationshipMutation) ClearField(name string) error {
  19244. switch name {
  19245. case labelrelationship.FieldStatus:
  19246. m.ClearStatus()
  19247. return nil
  19248. case labelrelationship.FieldOrganizationID:
  19249. m.ClearOrganizationID()
  19250. return nil
  19251. }
  19252. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  19253. }
  19254. // ResetField resets all changes in the mutation for the field with the given name.
  19255. // It returns an error if the field is not defined in the schema.
  19256. func (m *LabelRelationshipMutation) ResetField(name string) error {
  19257. switch name {
  19258. case labelrelationship.FieldCreatedAt:
  19259. m.ResetCreatedAt()
  19260. return nil
  19261. case labelrelationship.FieldUpdatedAt:
  19262. m.ResetUpdatedAt()
  19263. return nil
  19264. case labelrelationship.FieldStatus:
  19265. m.ResetStatus()
  19266. return nil
  19267. case labelrelationship.FieldLabelID:
  19268. m.ResetLabelID()
  19269. return nil
  19270. case labelrelationship.FieldContactID:
  19271. m.ResetContactID()
  19272. return nil
  19273. case labelrelationship.FieldOrganizationID:
  19274. m.ResetOrganizationID()
  19275. return nil
  19276. }
  19277. return fmt.Errorf("unknown LabelRelationship field %s", name)
  19278. }
  19279. // AddedEdges returns all edge names that were set/added in this mutation.
  19280. func (m *LabelRelationshipMutation) AddedEdges() []string {
  19281. edges := make([]string, 0, 2)
  19282. if m.contacts != nil {
  19283. edges = append(edges, labelrelationship.EdgeContacts)
  19284. }
  19285. if m.labels != nil {
  19286. edges = append(edges, labelrelationship.EdgeLabels)
  19287. }
  19288. return edges
  19289. }
  19290. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19291. // name in this mutation.
  19292. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  19293. switch name {
  19294. case labelrelationship.EdgeContacts:
  19295. if id := m.contacts; id != nil {
  19296. return []ent.Value{*id}
  19297. }
  19298. case labelrelationship.EdgeLabels:
  19299. if id := m.labels; id != nil {
  19300. return []ent.Value{*id}
  19301. }
  19302. }
  19303. return nil
  19304. }
  19305. // RemovedEdges returns all edge names that were removed in this mutation.
  19306. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  19307. edges := make([]string, 0, 2)
  19308. return edges
  19309. }
  19310. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19311. // the given name in this mutation.
  19312. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  19313. return nil
  19314. }
  19315. // ClearedEdges returns all edge names that were cleared in this mutation.
  19316. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  19317. edges := make([]string, 0, 2)
  19318. if m.clearedcontacts {
  19319. edges = append(edges, labelrelationship.EdgeContacts)
  19320. }
  19321. if m.clearedlabels {
  19322. edges = append(edges, labelrelationship.EdgeLabels)
  19323. }
  19324. return edges
  19325. }
  19326. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19327. // was cleared in this mutation.
  19328. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  19329. switch name {
  19330. case labelrelationship.EdgeContacts:
  19331. return m.clearedcontacts
  19332. case labelrelationship.EdgeLabels:
  19333. return m.clearedlabels
  19334. }
  19335. return false
  19336. }
  19337. // ClearEdge clears the value of the edge with the given name. It returns an error
  19338. // if that edge is not defined in the schema.
  19339. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  19340. switch name {
  19341. case labelrelationship.EdgeContacts:
  19342. m.ClearContacts()
  19343. return nil
  19344. case labelrelationship.EdgeLabels:
  19345. m.ClearLabels()
  19346. return nil
  19347. }
  19348. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  19349. }
  19350. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19351. // It returns an error if the edge is not defined in the schema.
  19352. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  19353. switch name {
  19354. case labelrelationship.EdgeContacts:
  19355. m.ResetContacts()
  19356. return nil
  19357. case labelrelationship.EdgeLabels:
  19358. m.ResetLabels()
  19359. return nil
  19360. }
  19361. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  19362. }
  19363. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  19364. type LabelTaggingMutation struct {
  19365. config
  19366. op Op
  19367. typ string
  19368. id *uint64
  19369. created_at *time.Time
  19370. updated_at *time.Time
  19371. status *uint8
  19372. addstatus *int8
  19373. deleted_at *time.Time
  19374. organization_id *uint64
  19375. addorganization_id *int64
  19376. _type *int
  19377. add_type *int
  19378. conditions *string
  19379. action_label_add *[]uint64
  19380. appendaction_label_add []uint64
  19381. action_label_del *[]uint64
  19382. appendaction_label_del []uint64
  19383. clearedFields map[string]struct{}
  19384. done bool
  19385. oldValue func(context.Context) (*LabelTagging, error)
  19386. predicates []predicate.LabelTagging
  19387. }
  19388. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  19389. // labeltaggingOption allows management of the mutation configuration using functional options.
  19390. type labeltaggingOption func(*LabelTaggingMutation)
  19391. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  19392. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  19393. m := &LabelTaggingMutation{
  19394. config: c,
  19395. op: op,
  19396. typ: TypeLabelTagging,
  19397. clearedFields: make(map[string]struct{}),
  19398. }
  19399. for _, opt := range opts {
  19400. opt(m)
  19401. }
  19402. return m
  19403. }
  19404. // withLabelTaggingID sets the ID field of the mutation.
  19405. func withLabelTaggingID(id uint64) labeltaggingOption {
  19406. return func(m *LabelTaggingMutation) {
  19407. var (
  19408. err error
  19409. once sync.Once
  19410. value *LabelTagging
  19411. )
  19412. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  19413. once.Do(func() {
  19414. if m.done {
  19415. err = errors.New("querying old values post mutation is not allowed")
  19416. } else {
  19417. value, err = m.Client().LabelTagging.Get(ctx, id)
  19418. }
  19419. })
  19420. return value, err
  19421. }
  19422. m.id = &id
  19423. }
  19424. }
  19425. // withLabelTagging sets the old LabelTagging of the mutation.
  19426. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  19427. return func(m *LabelTaggingMutation) {
  19428. m.oldValue = func(context.Context) (*LabelTagging, error) {
  19429. return node, nil
  19430. }
  19431. m.id = &node.ID
  19432. }
  19433. }
  19434. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19435. // executed in a transaction (ent.Tx), a transactional client is returned.
  19436. func (m LabelTaggingMutation) Client() *Client {
  19437. client := &Client{config: m.config}
  19438. client.init()
  19439. return client
  19440. }
  19441. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19442. // it returns an error otherwise.
  19443. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  19444. if _, ok := m.driver.(*txDriver); !ok {
  19445. return nil, errors.New("ent: mutation is not running in a transaction")
  19446. }
  19447. tx := &Tx{config: m.config}
  19448. tx.init()
  19449. return tx, nil
  19450. }
  19451. // SetID sets the value of the id field. Note that this
  19452. // operation is only accepted on creation of LabelTagging entities.
  19453. func (m *LabelTaggingMutation) SetID(id uint64) {
  19454. m.id = &id
  19455. }
  19456. // ID returns the ID value in the mutation. Note that the ID is only available
  19457. // if it was provided to the builder or after it was returned from the database.
  19458. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  19459. if m.id == nil {
  19460. return
  19461. }
  19462. return *m.id, true
  19463. }
  19464. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19465. // That means, if the mutation is applied within a transaction with an isolation level such
  19466. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19467. // or updated by the mutation.
  19468. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  19469. switch {
  19470. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19471. id, exists := m.ID()
  19472. if exists {
  19473. return []uint64{id}, nil
  19474. }
  19475. fallthrough
  19476. case m.op.Is(OpUpdate | OpDelete):
  19477. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  19478. default:
  19479. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19480. }
  19481. }
  19482. // SetCreatedAt sets the "created_at" field.
  19483. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  19484. m.created_at = &t
  19485. }
  19486. // CreatedAt returns the value of the "created_at" field in the mutation.
  19487. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  19488. v := m.created_at
  19489. if v == nil {
  19490. return
  19491. }
  19492. return *v, true
  19493. }
  19494. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  19495. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19497. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19498. if !m.op.Is(OpUpdateOne) {
  19499. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19500. }
  19501. if m.id == nil || m.oldValue == nil {
  19502. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19503. }
  19504. oldValue, err := m.oldValue(ctx)
  19505. if err != nil {
  19506. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19507. }
  19508. return oldValue.CreatedAt, nil
  19509. }
  19510. // ResetCreatedAt resets all changes to the "created_at" field.
  19511. func (m *LabelTaggingMutation) ResetCreatedAt() {
  19512. m.created_at = nil
  19513. }
  19514. // SetUpdatedAt sets the "updated_at" field.
  19515. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  19516. m.updated_at = &t
  19517. }
  19518. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19519. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  19520. v := m.updated_at
  19521. if v == nil {
  19522. return
  19523. }
  19524. return *v, true
  19525. }
  19526. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19530. if !m.op.Is(OpUpdateOne) {
  19531. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19532. }
  19533. if m.id == nil || m.oldValue == nil {
  19534. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  19539. }
  19540. return oldValue.UpdatedAt, nil
  19541. }
  19542. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19543. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  19544. m.updated_at = nil
  19545. }
  19546. // SetStatus sets the "status" field.
  19547. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  19548. m.status = &u
  19549. m.addstatus = nil
  19550. }
  19551. // Status returns the value of the "status" field in the mutation.
  19552. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  19553. v := m.status
  19554. if v == nil {
  19555. return
  19556. }
  19557. return *v, true
  19558. }
  19559. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  19560. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19562. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19563. if !m.op.Is(OpUpdateOne) {
  19564. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19565. }
  19566. if m.id == nil || m.oldValue == nil {
  19567. return v, errors.New("OldStatus requires an ID field in the mutation")
  19568. }
  19569. oldValue, err := m.oldValue(ctx)
  19570. if err != nil {
  19571. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19572. }
  19573. return oldValue.Status, nil
  19574. }
  19575. // AddStatus adds u to the "status" field.
  19576. func (m *LabelTaggingMutation) AddStatus(u int8) {
  19577. if m.addstatus != nil {
  19578. *m.addstatus += u
  19579. } else {
  19580. m.addstatus = &u
  19581. }
  19582. }
  19583. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19584. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  19585. v := m.addstatus
  19586. if v == nil {
  19587. return
  19588. }
  19589. return *v, true
  19590. }
  19591. // ClearStatus clears the value of the "status" field.
  19592. func (m *LabelTaggingMutation) ClearStatus() {
  19593. m.status = nil
  19594. m.addstatus = nil
  19595. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  19596. }
  19597. // StatusCleared returns if the "status" field was cleared in this mutation.
  19598. func (m *LabelTaggingMutation) StatusCleared() bool {
  19599. _, ok := m.clearedFields[labeltagging.FieldStatus]
  19600. return ok
  19601. }
  19602. // ResetStatus resets all changes to the "status" field.
  19603. func (m *LabelTaggingMutation) ResetStatus() {
  19604. m.status = nil
  19605. m.addstatus = nil
  19606. delete(m.clearedFields, labeltagging.FieldStatus)
  19607. }
  19608. // SetDeletedAt sets the "deleted_at" field.
  19609. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  19610. m.deleted_at = &t
  19611. }
  19612. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19613. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  19614. v := m.deleted_at
  19615. if v == nil {
  19616. return
  19617. }
  19618. return *v, true
  19619. }
  19620. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  19621. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19623. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19624. if !m.op.Is(OpUpdateOne) {
  19625. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19626. }
  19627. if m.id == nil || m.oldValue == nil {
  19628. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19629. }
  19630. oldValue, err := m.oldValue(ctx)
  19631. if err != nil {
  19632. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19633. }
  19634. return oldValue.DeletedAt, nil
  19635. }
  19636. // ClearDeletedAt clears the value of the "deleted_at" field.
  19637. func (m *LabelTaggingMutation) ClearDeletedAt() {
  19638. m.deleted_at = nil
  19639. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  19640. }
  19641. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19642. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  19643. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  19644. return ok
  19645. }
  19646. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19647. func (m *LabelTaggingMutation) ResetDeletedAt() {
  19648. m.deleted_at = nil
  19649. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  19650. }
  19651. // SetOrganizationID sets the "organization_id" field.
  19652. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  19653. m.organization_id = &u
  19654. m.addorganization_id = nil
  19655. }
  19656. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19657. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  19658. v := m.organization_id
  19659. if v == nil {
  19660. return
  19661. }
  19662. return *v, true
  19663. }
  19664. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  19665. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19667. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19668. if !m.op.Is(OpUpdateOne) {
  19669. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19670. }
  19671. if m.id == nil || m.oldValue == nil {
  19672. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19673. }
  19674. oldValue, err := m.oldValue(ctx)
  19675. if err != nil {
  19676. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19677. }
  19678. return oldValue.OrganizationID, nil
  19679. }
  19680. // AddOrganizationID adds u to the "organization_id" field.
  19681. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  19682. if m.addorganization_id != nil {
  19683. *m.addorganization_id += u
  19684. } else {
  19685. m.addorganization_id = &u
  19686. }
  19687. }
  19688. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19689. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  19690. v := m.addorganization_id
  19691. if v == nil {
  19692. return
  19693. }
  19694. return *v, true
  19695. }
  19696. // ResetOrganizationID resets all changes to the "organization_id" field.
  19697. func (m *LabelTaggingMutation) ResetOrganizationID() {
  19698. m.organization_id = nil
  19699. m.addorganization_id = nil
  19700. }
  19701. // SetType sets the "type" field.
  19702. func (m *LabelTaggingMutation) SetType(i int) {
  19703. m._type = &i
  19704. m.add_type = nil
  19705. }
  19706. // GetType returns the value of the "type" field in the mutation.
  19707. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  19708. v := m._type
  19709. if v == nil {
  19710. return
  19711. }
  19712. return *v, true
  19713. }
  19714. // OldType returns the old "type" field's value of the LabelTagging entity.
  19715. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19717. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  19718. if !m.op.Is(OpUpdateOne) {
  19719. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19720. }
  19721. if m.id == nil || m.oldValue == nil {
  19722. return v, errors.New("OldType requires an ID field in the mutation")
  19723. }
  19724. oldValue, err := m.oldValue(ctx)
  19725. if err != nil {
  19726. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19727. }
  19728. return oldValue.Type, nil
  19729. }
  19730. // AddType adds i to the "type" field.
  19731. func (m *LabelTaggingMutation) AddType(i int) {
  19732. if m.add_type != nil {
  19733. *m.add_type += i
  19734. } else {
  19735. m.add_type = &i
  19736. }
  19737. }
  19738. // AddedType returns the value that was added to the "type" field in this mutation.
  19739. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  19740. v := m.add_type
  19741. if v == nil {
  19742. return
  19743. }
  19744. return *v, true
  19745. }
  19746. // ResetType resets all changes to the "type" field.
  19747. func (m *LabelTaggingMutation) ResetType() {
  19748. m._type = nil
  19749. m.add_type = nil
  19750. }
  19751. // SetConditions sets the "conditions" field.
  19752. func (m *LabelTaggingMutation) SetConditions(s string) {
  19753. m.conditions = &s
  19754. }
  19755. // Conditions returns the value of the "conditions" field in the mutation.
  19756. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  19757. v := m.conditions
  19758. if v == nil {
  19759. return
  19760. }
  19761. return *v, true
  19762. }
  19763. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  19764. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19766. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  19767. if !m.op.Is(OpUpdateOne) {
  19768. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  19769. }
  19770. if m.id == nil || m.oldValue == nil {
  19771. return v, errors.New("OldConditions requires an ID field in the mutation")
  19772. }
  19773. oldValue, err := m.oldValue(ctx)
  19774. if err != nil {
  19775. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19776. }
  19777. return oldValue.Conditions, nil
  19778. }
  19779. // ResetConditions resets all changes to the "conditions" field.
  19780. func (m *LabelTaggingMutation) ResetConditions() {
  19781. m.conditions = nil
  19782. }
  19783. // SetActionLabelAdd sets the "action_label_add" field.
  19784. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  19785. m.action_label_add = &u
  19786. m.appendaction_label_add = nil
  19787. }
  19788. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19789. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19790. v := m.action_label_add
  19791. if v == nil {
  19792. return
  19793. }
  19794. return *v, true
  19795. }
  19796. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  19797. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19799. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19800. if !m.op.Is(OpUpdateOne) {
  19801. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19802. }
  19803. if m.id == nil || m.oldValue == nil {
  19804. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19805. }
  19806. oldValue, err := m.oldValue(ctx)
  19807. if err != nil {
  19808. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19809. }
  19810. return oldValue.ActionLabelAdd, nil
  19811. }
  19812. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19813. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  19814. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19815. }
  19816. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19817. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19818. if len(m.appendaction_label_add) == 0 {
  19819. return nil, false
  19820. }
  19821. return m.appendaction_label_add, true
  19822. }
  19823. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19824. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  19825. m.action_label_add = nil
  19826. m.appendaction_label_add = nil
  19827. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  19828. }
  19829. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19830. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  19831. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  19832. return ok
  19833. }
  19834. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19835. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  19836. m.action_label_add = nil
  19837. m.appendaction_label_add = nil
  19838. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  19839. }
  19840. // SetActionLabelDel sets the "action_label_del" field.
  19841. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  19842. m.action_label_del = &u
  19843. m.appendaction_label_del = nil
  19844. }
  19845. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19846. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  19847. v := m.action_label_del
  19848. if v == nil {
  19849. return
  19850. }
  19851. return *v, true
  19852. }
  19853. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  19854. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19856. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19857. if !m.op.Is(OpUpdateOne) {
  19858. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19859. }
  19860. if m.id == nil || m.oldValue == nil {
  19861. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19862. }
  19863. oldValue, err := m.oldValue(ctx)
  19864. if err != nil {
  19865. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19866. }
  19867. return oldValue.ActionLabelDel, nil
  19868. }
  19869. // AppendActionLabelDel adds u to the "action_label_del" field.
  19870. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  19871. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19872. }
  19873. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19874. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19875. if len(m.appendaction_label_del) == 0 {
  19876. return nil, false
  19877. }
  19878. return m.appendaction_label_del, true
  19879. }
  19880. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19881. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  19882. m.action_label_del = nil
  19883. m.appendaction_label_del = nil
  19884. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  19885. }
  19886. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19887. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  19888. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  19889. return ok
  19890. }
  19891. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19892. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  19893. m.action_label_del = nil
  19894. m.appendaction_label_del = nil
  19895. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  19896. }
  19897. // Where appends a list predicates to the LabelTaggingMutation builder.
  19898. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  19899. m.predicates = append(m.predicates, ps...)
  19900. }
  19901. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  19902. // users can use type-assertion to append predicates that do not depend on any generated package.
  19903. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  19904. p := make([]predicate.LabelTagging, len(ps))
  19905. for i := range ps {
  19906. p[i] = ps[i]
  19907. }
  19908. m.Where(p...)
  19909. }
  19910. // Op returns the operation name.
  19911. func (m *LabelTaggingMutation) Op() Op {
  19912. return m.op
  19913. }
  19914. // SetOp allows setting the mutation operation.
  19915. func (m *LabelTaggingMutation) SetOp(op Op) {
  19916. m.op = op
  19917. }
  19918. // Type returns the node type of this mutation (LabelTagging).
  19919. func (m *LabelTaggingMutation) Type() string {
  19920. return m.typ
  19921. }
  19922. // Fields returns all fields that were changed during this mutation. Note that in
  19923. // order to get all numeric fields that were incremented/decremented, call
  19924. // AddedFields().
  19925. func (m *LabelTaggingMutation) Fields() []string {
  19926. fields := make([]string, 0, 9)
  19927. if m.created_at != nil {
  19928. fields = append(fields, labeltagging.FieldCreatedAt)
  19929. }
  19930. if m.updated_at != nil {
  19931. fields = append(fields, labeltagging.FieldUpdatedAt)
  19932. }
  19933. if m.status != nil {
  19934. fields = append(fields, labeltagging.FieldStatus)
  19935. }
  19936. if m.deleted_at != nil {
  19937. fields = append(fields, labeltagging.FieldDeletedAt)
  19938. }
  19939. if m.organization_id != nil {
  19940. fields = append(fields, labeltagging.FieldOrganizationID)
  19941. }
  19942. if m._type != nil {
  19943. fields = append(fields, labeltagging.FieldType)
  19944. }
  19945. if m.conditions != nil {
  19946. fields = append(fields, labeltagging.FieldConditions)
  19947. }
  19948. if m.action_label_add != nil {
  19949. fields = append(fields, labeltagging.FieldActionLabelAdd)
  19950. }
  19951. if m.action_label_del != nil {
  19952. fields = append(fields, labeltagging.FieldActionLabelDel)
  19953. }
  19954. return fields
  19955. }
  19956. // Field returns the value of a field with the given name. The second boolean
  19957. // return value indicates that this field was not set, or was not defined in the
  19958. // schema.
  19959. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  19960. switch name {
  19961. case labeltagging.FieldCreatedAt:
  19962. return m.CreatedAt()
  19963. case labeltagging.FieldUpdatedAt:
  19964. return m.UpdatedAt()
  19965. case labeltagging.FieldStatus:
  19966. return m.Status()
  19967. case labeltagging.FieldDeletedAt:
  19968. return m.DeletedAt()
  19969. case labeltagging.FieldOrganizationID:
  19970. return m.OrganizationID()
  19971. case labeltagging.FieldType:
  19972. return m.GetType()
  19973. case labeltagging.FieldConditions:
  19974. return m.Conditions()
  19975. case labeltagging.FieldActionLabelAdd:
  19976. return m.ActionLabelAdd()
  19977. case labeltagging.FieldActionLabelDel:
  19978. return m.ActionLabelDel()
  19979. }
  19980. return nil, false
  19981. }
  19982. // OldField returns the old value of the field from the database. An error is
  19983. // returned if the mutation operation is not UpdateOne, or the query to the
  19984. // database failed.
  19985. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19986. switch name {
  19987. case labeltagging.FieldCreatedAt:
  19988. return m.OldCreatedAt(ctx)
  19989. case labeltagging.FieldUpdatedAt:
  19990. return m.OldUpdatedAt(ctx)
  19991. case labeltagging.FieldStatus:
  19992. return m.OldStatus(ctx)
  19993. case labeltagging.FieldDeletedAt:
  19994. return m.OldDeletedAt(ctx)
  19995. case labeltagging.FieldOrganizationID:
  19996. return m.OldOrganizationID(ctx)
  19997. case labeltagging.FieldType:
  19998. return m.OldType(ctx)
  19999. case labeltagging.FieldConditions:
  20000. return m.OldConditions(ctx)
  20001. case labeltagging.FieldActionLabelAdd:
  20002. return m.OldActionLabelAdd(ctx)
  20003. case labeltagging.FieldActionLabelDel:
  20004. return m.OldActionLabelDel(ctx)
  20005. }
  20006. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  20007. }
  20008. // SetField sets the value of a field with the given name. It returns an error if
  20009. // the field is not defined in the schema, or if the type mismatched the field
  20010. // type.
  20011. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  20012. switch name {
  20013. case labeltagging.FieldCreatedAt:
  20014. v, ok := value.(time.Time)
  20015. if !ok {
  20016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20017. }
  20018. m.SetCreatedAt(v)
  20019. return nil
  20020. case labeltagging.FieldUpdatedAt:
  20021. v, ok := value.(time.Time)
  20022. if !ok {
  20023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20024. }
  20025. m.SetUpdatedAt(v)
  20026. return nil
  20027. case labeltagging.FieldStatus:
  20028. v, ok := value.(uint8)
  20029. if !ok {
  20030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20031. }
  20032. m.SetStatus(v)
  20033. return nil
  20034. case labeltagging.FieldDeletedAt:
  20035. v, ok := value.(time.Time)
  20036. if !ok {
  20037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20038. }
  20039. m.SetDeletedAt(v)
  20040. return nil
  20041. case labeltagging.FieldOrganizationID:
  20042. v, ok := value.(uint64)
  20043. if !ok {
  20044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20045. }
  20046. m.SetOrganizationID(v)
  20047. return nil
  20048. case labeltagging.FieldType:
  20049. v, ok := value.(int)
  20050. if !ok {
  20051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20052. }
  20053. m.SetType(v)
  20054. return nil
  20055. case labeltagging.FieldConditions:
  20056. v, ok := value.(string)
  20057. if !ok {
  20058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20059. }
  20060. m.SetConditions(v)
  20061. return nil
  20062. case labeltagging.FieldActionLabelAdd:
  20063. v, ok := value.([]uint64)
  20064. if !ok {
  20065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20066. }
  20067. m.SetActionLabelAdd(v)
  20068. return nil
  20069. case labeltagging.FieldActionLabelDel:
  20070. v, ok := value.([]uint64)
  20071. if !ok {
  20072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20073. }
  20074. m.SetActionLabelDel(v)
  20075. return nil
  20076. }
  20077. return fmt.Errorf("unknown LabelTagging field %s", name)
  20078. }
  20079. // AddedFields returns all numeric fields that were incremented/decremented during
  20080. // this mutation.
  20081. func (m *LabelTaggingMutation) AddedFields() []string {
  20082. var fields []string
  20083. if m.addstatus != nil {
  20084. fields = append(fields, labeltagging.FieldStatus)
  20085. }
  20086. if m.addorganization_id != nil {
  20087. fields = append(fields, labeltagging.FieldOrganizationID)
  20088. }
  20089. if m.add_type != nil {
  20090. fields = append(fields, labeltagging.FieldType)
  20091. }
  20092. return fields
  20093. }
  20094. // AddedField returns the numeric value that was incremented/decremented on a field
  20095. // with the given name. The second boolean return value indicates that this field
  20096. // was not set, or was not defined in the schema.
  20097. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  20098. switch name {
  20099. case labeltagging.FieldStatus:
  20100. return m.AddedStatus()
  20101. case labeltagging.FieldOrganizationID:
  20102. return m.AddedOrganizationID()
  20103. case labeltagging.FieldType:
  20104. return m.AddedType()
  20105. }
  20106. return nil, false
  20107. }
  20108. // AddField adds the value to the field with the given name. It returns an error if
  20109. // the field is not defined in the schema, or if the type mismatched the field
  20110. // type.
  20111. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  20112. switch name {
  20113. case labeltagging.FieldStatus:
  20114. v, ok := value.(int8)
  20115. if !ok {
  20116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20117. }
  20118. m.AddStatus(v)
  20119. return nil
  20120. case labeltagging.FieldOrganizationID:
  20121. v, ok := value.(int64)
  20122. if !ok {
  20123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20124. }
  20125. m.AddOrganizationID(v)
  20126. return nil
  20127. case labeltagging.FieldType:
  20128. v, ok := value.(int)
  20129. if !ok {
  20130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20131. }
  20132. m.AddType(v)
  20133. return nil
  20134. }
  20135. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  20136. }
  20137. // ClearedFields returns all nullable fields that were cleared during this
  20138. // mutation.
  20139. func (m *LabelTaggingMutation) ClearedFields() []string {
  20140. var fields []string
  20141. if m.FieldCleared(labeltagging.FieldStatus) {
  20142. fields = append(fields, labeltagging.FieldStatus)
  20143. }
  20144. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  20145. fields = append(fields, labeltagging.FieldDeletedAt)
  20146. }
  20147. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  20148. fields = append(fields, labeltagging.FieldActionLabelAdd)
  20149. }
  20150. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  20151. fields = append(fields, labeltagging.FieldActionLabelDel)
  20152. }
  20153. return fields
  20154. }
  20155. // FieldCleared returns a boolean indicating if a field with the given name was
  20156. // cleared in this mutation.
  20157. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  20158. _, ok := m.clearedFields[name]
  20159. return ok
  20160. }
  20161. // ClearField clears the value of the field with the given name. It returns an
  20162. // error if the field is not defined in the schema.
  20163. func (m *LabelTaggingMutation) ClearField(name string) error {
  20164. switch name {
  20165. case labeltagging.FieldStatus:
  20166. m.ClearStatus()
  20167. return nil
  20168. case labeltagging.FieldDeletedAt:
  20169. m.ClearDeletedAt()
  20170. return nil
  20171. case labeltagging.FieldActionLabelAdd:
  20172. m.ClearActionLabelAdd()
  20173. return nil
  20174. case labeltagging.FieldActionLabelDel:
  20175. m.ClearActionLabelDel()
  20176. return nil
  20177. }
  20178. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  20179. }
  20180. // ResetField resets all changes in the mutation for the field with the given name.
  20181. // It returns an error if the field is not defined in the schema.
  20182. func (m *LabelTaggingMutation) ResetField(name string) error {
  20183. switch name {
  20184. case labeltagging.FieldCreatedAt:
  20185. m.ResetCreatedAt()
  20186. return nil
  20187. case labeltagging.FieldUpdatedAt:
  20188. m.ResetUpdatedAt()
  20189. return nil
  20190. case labeltagging.FieldStatus:
  20191. m.ResetStatus()
  20192. return nil
  20193. case labeltagging.FieldDeletedAt:
  20194. m.ResetDeletedAt()
  20195. return nil
  20196. case labeltagging.FieldOrganizationID:
  20197. m.ResetOrganizationID()
  20198. return nil
  20199. case labeltagging.FieldType:
  20200. m.ResetType()
  20201. return nil
  20202. case labeltagging.FieldConditions:
  20203. m.ResetConditions()
  20204. return nil
  20205. case labeltagging.FieldActionLabelAdd:
  20206. m.ResetActionLabelAdd()
  20207. return nil
  20208. case labeltagging.FieldActionLabelDel:
  20209. m.ResetActionLabelDel()
  20210. return nil
  20211. }
  20212. return fmt.Errorf("unknown LabelTagging field %s", name)
  20213. }
  20214. // AddedEdges returns all edge names that were set/added in this mutation.
  20215. func (m *LabelTaggingMutation) AddedEdges() []string {
  20216. edges := make([]string, 0, 0)
  20217. return edges
  20218. }
  20219. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20220. // name in this mutation.
  20221. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  20222. return nil
  20223. }
  20224. // RemovedEdges returns all edge names that were removed in this mutation.
  20225. func (m *LabelTaggingMutation) RemovedEdges() []string {
  20226. edges := make([]string, 0, 0)
  20227. return edges
  20228. }
  20229. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20230. // the given name in this mutation.
  20231. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  20232. return nil
  20233. }
  20234. // ClearedEdges returns all edge names that were cleared in this mutation.
  20235. func (m *LabelTaggingMutation) ClearedEdges() []string {
  20236. edges := make([]string, 0, 0)
  20237. return edges
  20238. }
  20239. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20240. // was cleared in this mutation.
  20241. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  20242. return false
  20243. }
  20244. // ClearEdge clears the value of the edge with the given name. It returns an error
  20245. // if that edge is not defined in the schema.
  20246. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  20247. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  20248. }
  20249. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20250. // It returns an error if the edge is not defined in the schema.
  20251. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  20252. return fmt.Errorf("unknown LabelTagging edge %s", name)
  20253. }
  20254. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  20255. type MessageMutation struct {
  20256. config
  20257. op Op
  20258. typ string
  20259. id *int
  20260. wx_wxid *string
  20261. wxid *string
  20262. content *string
  20263. clearedFields map[string]struct{}
  20264. done bool
  20265. oldValue func(context.Context) (*Message, error)
  20266. predicates []predicate.Message
  20267. }
  20268. var _ ent.Mutation = (*MessageMutation)(nil)
  20269. // messageOption allows management of the mutation configuration using functional options.
  20270. type messageOption func(*MessageMutation)
  20271. // newMessageMutation creates new mutation for the Message entity.
  20272. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  20273. m := &MessageMutation{
  20274. config: c,
  20275. op: op,
  20276. typ: TypeMessage,
  20277. clearedFields: make(map[string]struct{}),
  20278. }
  20279. for _, opt := range opts {
  20280. opt(m)
  20281. }
  20282. return m
  20283. }
  20284. // withMessageID sets the ID field of the mutation.
  20285. func withMessageID(id int) messageOption {
  20286. return func(m *MessageMutation) {
  20287. var (
  20288. err error
  20289. once sync.Once
  20290. value *Message
  20291. )
  20292. m.oldValue = func(ctx context.Context) (*Message, error) {
  20293. once.Do(func() {
  20294. if m.done {
  20295. err = errors.New("querying old values post mutation is not allowed")
  20296. } else {
  20297. value, err = m.Client().Message.Get(ctx, id)
  20298. }
  20299. })
  20300. return value, err
  20301. }
  20302. m.id = &id
  20303. }
  20304. }
  20305. // withMessage sets the old Message of the mutation.
  20306. func withMessage(node *Message) messageOption {
  20307. return func(m *MessageMutation) {
  20308. m.oldValue = func(context.Context) (*Message, error) {
  20309. return node, nil
  20310. }
  20311. m.id = &node.ID
  20312. }
  20313. }
  20314. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20315. // executed in a transaction (ent.Tx), a transactional client is returned.
  20316. func (m MessageMutation) Client() *Client {
  20317. client := &Client{config: m.config}
  20318. client.init()
  20319. return client
  20320. }
  20321. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20322. // it returns an error otherwise.
  20323. func (m MessageMutation) Tx() (*Tx, error) {
  20324. if _, ok := m.driver.(*txDriver); !ok {
  20325. return nil, errors.New("ent: mutation is not running in a transaction")
  20326. }
  20327. tx := &Tx{config: m.config}
  20328. tx.init()
  20329. return tx, nil
  20330. }
  20331. // ID returns the ID value in the mutation. Note that the ID is only available
  20332. // if it was provided to the builder or after it was returned from the database.
  20333. func (m *MessageMutation) ID() (id int, exists bool) {
  20334. if m.id == nil {
  20335. return
  20336. }
  20337. return *m.id, true
  20338. }
  20339. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20340. // That means, if the mutation is applied within a transaction with an isolation level such
  20341. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20342. // or updated by the mutation.
  20343. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  20344. switch {
  20345. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20346. id, exists := m.ID()
  20347. if exists {
  20348. return []int{id}, nil
  20349. }
  20350. fallthrough
  20351. case m.op.Is(OpUpdate | OpDelete):
  20352. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  20353. default:
  20354. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20355. }
  20356. }
  20357. // SetWxWxid sets the "wx_wxid" field.
  20358. func (m *MessageMutation) SetWxWxid(s string) {
  20359. m.wx_wxid = &s
  20360. }
  20361. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  20362. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  20363. v := m.wx_wxid
  20364. if v == nil {
  20365. return
  20366. }
  20367. return *v, true
  20368. }
  20369. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  20370. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20372. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  20373. if !m.op.Is(OpUpdateOne) {
  20374. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  20375. }
  20376. if m.id == nil || m.oldValue == nil {
  20377. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  20378. }
  20379. oldValue, err := m.oldValue(ctx)
  20380. if err != nil {
  20381. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  20382. }
  20383. return oldValue.WxWxid, nil
  20384. }
  20385. // ClearWxWxid clears the value of the "wx_wxid" field.
  20386. func (m *MessageMutation) ClearWxWxid() {
  20387. m.wx_wxid = nil
  20388. m.clearedFields[message.FieldWxWxid] = struct{}{}
  20389. }
  20390. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  20391. func (m *MessageMutation) WxWxidCleared() bool {
  20392. _, ok := m.clearedFields[message.FieldWxWxid]
  20393. return ok
  20394. }
  20395. // ResetWxWxid resets all changes to the "wx_wxid" field.
  20396. func (m *MessageMutation) ResetWxWxid() {
  20397. m.wx_wxid = nil
  20398. delete(m.clearedFields, message.FieldWxWxid)
  20399. }
  20400. // SetWxid sets the "wxid" field.
  20401. func (m *MessageMutation) SetWxid(s string) {
  20402. m.wxid = &s
  20403. }
  20404. // Wxid returns the value of the "wxid" field in the mutation.
  20405. func (m *MessageMutation) Wxid() (r string, exists bool) {
  20406. v := m.wxid
  20407. if v == nil {
  20408. return
  20409. }
  20410. return *v, true
  20411. }
  20412. // OldWxid returns the old "wxid" field's value of the Message entity.
  20413. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20415. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  20416. if !m.op.Is(OpUpdateOne) {
  20417. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  20418. }
  20419. if m.id == nil || m.oldValue == nil {
  20420. return v, errors.New("OldWxid requires an ID field in the mutation")
  20421. }
  20422. oldValue, err := m.oldValue(ctx)
  20423. if err != nil {
  20424. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  20425. }
  20426. return oldValue.Wxid, nil
  20427. }
  20428. // ResetWxid resets all changes to the "wxid" field.
  20429. func (m *MessageMutation) ResetWxid() {
  20430. m.wxid = nil
  20431. }
  20432. // SetContent sets the "content" field.
  20433. func (m *MessageMutation) SetContent(s string) {
  20434. m.content = &s
  20435. }
  20436. // Content returns the value of the "content" field in the mutation.
  20437. func (m *MessageMutation) Content() (r string, exists bool) {
  20438. v := m.content
  20439. if v == nil {
  20440. return
  20441. }
  20442. return *v, true
  20443. }
  20444. // OldContent returns the old "content" 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) OldContent(ctx context.Context) (v string, err error) {
  20448. if !m.op.Is(OpUpdateOne) {
  20449. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20450. }
  20451. if m.id == nil || m.oldValue == nil {
  20452. return v, errors.New("OldContent 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 OldContent: %w", err)
  20457. }
  20458. return oldValue.Content, nil
  20459. }
  20460. // ResetContent resets all changes to the "content" field.
  20461. func (m *MessageMutation) ResetContent() {
  20462. m.content = nil
  20463. }
  20464. // Where appends a list predicates to the MessageMutation builder.
  20465. func (m *MessageMutation) Where(ps ...predicate.Message) {
  20466. m.predicates = append(m.predicates, ps...)
  20467. }
  20468. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  20469. // users can use type-assertion to append predicates that do not depend on any generated package.
  20470. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  20471. p := make([]predicate.Message, len(ps))
  20472. for i := range ps {
  20473. p[i] = ps[i]
  20474. }
  20475. m.Where(p...)
  20476. }
  20477. // Op returns the operation name.
  20478. func (m *MessageMutation) Op() Op {
  20479. return m.op
  20480. }
  20481. // SetOp allows setting the mutation operation.
  20482. func (m *MessageMutation) SetOp(op Op) {
  20483. m.op = op
  20484. }
  20485. // Type returns the node type of this mutation (Message).
  20486. func (m *MessageMutation) Type() string {
  20487. return m.typ
  20488. }
  20489. // Fields returns all fields that were changed during this mutation. Note that in
  20490. // order to get all numeric fields that were incremented/decremented, call
  20491. // AddedFields().
  20492. func (m *MessageMutation) Fields() []string {
  20493. fields := make([]string, 0, 3)
  20494. if m.wx_wxid != nil {
  20495. fields = append(fields, message.FieldWxWxid)
  20496. }
  20497. if m.wxid != nil {
  20498. fields = append(fields, message.FieldWxid)
  20499. }
  20500. if m.content != nil {
  20501. fields = append(fields, message.FieldContent)
  20502. }
  20503. return fields
  20504. }
  20505. // Field returns the value of a field with the given name. The second boolean
  20506. // return value indicates that this field was not set, or was not defined in the
  20507. // schema.
  20508. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  20509. switch name {
  20510. case message.FieldWxWxid:
  20511. return m.WxWxid()
  20512. case message.FieldWxid:
  20513. return m.Wxid()
  20514. case message.FieldContent:
  20515. return m.Content()
  20516. }
  20517. return nil, false
  20518. }
  20519. // OldField returns the old value of the field from the database. An error is
  20520. // returned if the mutation operation is not UpdateOne, or the query to the
  20521. // database failed.
  20522. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20523. switch name {
  20524. case message.FieldWxWxid:
  20525. return m.OldWxWxid(ctx)
  20526. case message.FieldWxid:
  20527. return m.OldWxid(ctx)
  20528. case message.FieldContent:
  20529. return m.OldContent(ctx)
  20530. }
  20531. return nil, fmt.Errorf("unknown Message field %s", name)
  20532. }
  20533. // SetField sets the value of a field with the given name. It returns an error if
  20534. // the field is not defined in the schema, or if the type mismatched the field
  20535. // type.
  20536. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  20537. switch name {
  20538. case message.FieldWxWxid:
  20539. v, ok := value.(string)
  20540. if !ok {
  20541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20542. }
  20543. m.SetWxWxid(v)
  20544. return nil
  20545. case message.FieldWxid:
  20546. v, ok := value.(string)
  20547. if !ok {
  20548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20549. }
  20550. m.SetWxid(v)
  20551. return nil
  20552. case message.FieldContent:
  20553. v, ok := value.(string)
  20554. if !ok {
  20555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20556. }
  20557. m.SetContent(v)
  20558. return nil
  20559. }
  20560. return fmt.Errorf("unknown Message field %s", name)
  20561. }
  20562. // AddedFields returns all numeric fields that were incremented/decremented during
  20563. // this mutation.
  20564. func (m *MessageMutation) AddedFields() []string {
  20565. return nil
  20566. }
  20567. // AddedField returns the numeric value that was incremented/decremented on a field
  20568. // with the given name. The second boolean return value indicates that this field
  20569. // was not set, or was not defined in the schema.
  20570. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  20571. return nil, false
  20572. }
  20573. // AddField adds the value to the field with the given name. It returns an error if
  20574. // the field is not defined in the schema, or if the type mismatched the field
  20575. // type.
  20576. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  20577. switch name {
  20578. }
  20579. return fmt.Errorf("unknown Message numeric field %s", name)
  20580. }
  20581. // ClearedFields returns all nullable fields that were cleared during this
  20582. // mutation.
  20583. func (m *MessageMutation) ClearedFields() []string {
  20584. var fields []string
  20585. if m.FieldCleared(message.FieldWxWxid) {
  20586. fields = append(fields, message.FieldWxWxid)
  20587. }
  20588. return fields
  20589. }
  20590. // FieldCleared returns a boolean indicating if a field with the given name was
  20591. // cleared in this mutation.
  20592. func (m *MessageMutation) FieldCleared(name string) bool {
  20593. _, ok := m.clearedFields[name]
  20594. return ok
  20595. }
  20596. // ClearField clears the value of the field with the given name. It returns an
  20597. // error if the field is not defined in the schema.
  20598. func (m *MessageMutation) ClearField(name string) error {
  20599. switch name {
  20600. case message.FieldWxWxid:
  20601. m.ClearWxWxid()
  20602. return nil
  20603. }
  20604. return fmt.Errorf("unknown Message nullable field %s", name)
  20605. }
  20606. // ResetField resets all changes in the mutation for the field with the given name.
  20607. // It returns an error if the field is not defined in the schema.
  20608. func (m *MessageMutation) ResetField(name string) error {
  20609. switch name {
  20610. case message.FieldWxWxid:
  20611. m.ResetWxWxid()
  20612. return nil
  20613. case message.FieldWxid:
  20614. m.ResetWxid()
  20615. return nil
  20616. case message.FieldContent:
  20617. m.ResetContent()
  20618. return nil
  20619. }
  20620. return fmt.Errorf("unknown Message field %s", name)
  20621. }
  20622. // AddedEdges returns all edge names that were set/added in this mutation.
  20623. func (m *MessageMutation) AddedEdges() []string {
  20624. edges := make([]string, 0, 0)
  20625. return edges
  20626. }
  20627. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20628. // name in this mutation.
  20629. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  20630. return nil
  20631. }
  20632. // RemovedEdges returns all edge names that were removed in this mutation.
  20633. func (m *MessageMutation) RemovedEdges() []string {
  20634. edges := make([]string, 0, 0)
  20635. return edges
  20636. }
  20637. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20638. // the given name in this mutation.
  20639. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  20640. return nil
  20641. }
  20642. // ClearedEdges returns all edge names that were cleared in this mutation.
  20643. func (m *MessageMutation) ClearedEdges() []string {
  20644. edges := make([]string, 0, 0)
  20645. return edges
  20646. }
  20647. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20648. // was cleared in this mutation.
  20649. func (m *MessageMutation) EdgeCleared(name string) bool {
  20650. return false
  20651. }
  20652. // ClearEdge clears the value of the edge with the given name. It returns an error
  20653. // if that edge is not defined in the schema.
  20654. func (m *MessageMutation) ClearEdge(name string) error {
  20655. return fmt.Errorf("unknown Message unique edge %s", name)
  20656. }
  20657. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20658. // It returns an error if the edge is not defined in the schema.
  20659. func (m *MessageMutation) ResetEdge(name string) error {
  20660. return fmt.Errorf("unknown Message edge %s", name)
  20661. }
  20662. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  20663. type MessageRecordsMutation struct {
  20664. config
  20665. op Op
  20666. typ string
  20667. id *uint64
  20668. created_at *time.Time
  20669. updated_at *time.Time
  20670. status *uint8
  20671. addstatus *int8
  20672. bot_wxid *string
  20673. contact_type *int
  20674. addcontact_type *int
  20675. contact_wxid *string
  20676. content_type *int
  20677. addcontent_type *int
  20678. content *string
  20679. meta *custom_types.Meta
  20680. error_detail *string
  20681. send_time *time.Time
  20682. source_type *int
  20683. addsource_type *int
  20684. organization_id *uint64
  20685. addorganization_id *int64
  20686. clearedFields map[string]struct{}
  20687. sop_stage *uint64
  20688. clearedsop_stage bool
  20689. sop_node *uint64
  20690. clearedsop_node bool
  20691. message_contact *uint64
  20692. clearedmessage_contact bool
  20693. done bool
  20694. oldValue func(context.Context) (*MessageRecords, error)
  20695. predicates []predicate.MessageRecords
  20696. }
  20697. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  20698. // messagerecordsOption allows management of the mutation configuration using functional options.
  20699. type messagerecordsOption func(*MessageRecordsMutation)
  20700. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  20701. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  20702. m := &MessageRecordsMutation{
  20703. config: c,
  20704. op: op,
  20705. typ: TypeMessageRecords,
  20706. clearedFields: make(map[string]struct{}),
  20707. }
  20708. for _, opt := range opts {
  20709. opt(m)
  20710. }
  20711. return m
  20712. }
  20713. // withMessageRecordsID sets the ID field of the mutation.
  20714. func withMessageRecordsID(id uint64) messagerecordsOption {
  20715. return func(m *MessageRecordsMutation) {
  20716. var (
  20717. err error
  20718. once sync.Once
  20719. value *MessageRecords
  20720. )
  20721. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  20722. once.Do(func() {
  20723. if m.done {
  20724. err = errors.New("querying old values post mutation is not allowed")
  20725. } else {
  20726. value, err = m.Client().MessageRecords.Get(ctx, id)
  20727. }
  20728. })
  20729. return value, err
  20730. }
  20731. m.id = &id
  20732. }
  20733. }
  20734. // withMessageRecords sets the old MessageRecords of the mutation.
  20735. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  20736. return func(m *MessageRecordsMutation) {
  20737. m.oldValue = func(context.Context) (*MessageRecords, error) {
  20738. return node, nil
  20739. }
  20740. m.id = &node.ID
  20741. }
  20742. }
  20743. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20744. // executed in a transaction (ent.Tx), a transactional client is returned.
  20745. func (m MessageRecordsMutation) Client() *Client {
  20746. client := &Client{config: m.config}
  20747. client.init()
  20748. return client
  20749. }
  20750. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20751. // it returns an error otherwise.
  20752. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  20753. if _, ok := m.driver.(*txDriver); !ok {
  20754. return nil, errors.New("ent: mutation is not running in a transaction")
  20755. }
  20756. tx := &Tx{config: m.config}
  20757. tx.init()
  20758. return tx, nil
  20759. }
  20760. // SetID sets the value of the id field. Note that this
  20761. // operation is only accepted on creation of MessageRecords entities.
  20762. func (m *MessageRecordsMutation) SetID(id uint64) {
  20763. m.id = &id
  20764. }
  20765. // ID returns the ID value in the mutation. Note that the ID is only available
  20766. // if it was provided to the builder or after it was returned from the database.
  20767. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  20768. if m.id == nil {
  20769. return
  20770. }
  20771. return *m.id, true
  20772. }
  20773. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20774. // That means, if the mutation is applied within a transaction with an isolation level such
  20775. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20776. // or updated by the mutation.
  20777. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  20778. switch {
  20779. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20780. id, exists := m.ID()
  20781. if exists {
  20782. return []uint64{id}, nil
  20783. }
  20784. fallthrough
  20785. case m.op.Is(OpUpdate | OpDelete):
  20786. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  20787. default:
  20788. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20789. }
  20790. }
  20791. // SetCreatedAt sets the "created_at" field.
  20792. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  20793. m.created_at = &t
  20794. }
  20795. // CreatedAt returns the value of the "created_at" field in the mutation.
  20796. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  20797. v := m.created_at
  20798. if v == nil {
  20799. return
  20800. }
  20801. return *v, true
  20802. }
  20803. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  20804. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20806. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20807. if !m.op.Is(OpUpdateOne) {
  20808. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20809. }
  20810. if m.id == nil || m.oldValue == nil {
  20811. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20812. }
  20813. oldValue, err := m.oldValue(ctx)
  20814. if err != nil {
  20815. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20816. }
  20817. return oldValue.CreatedAt, nil
  20818. }
  20819. // ResetCreatedAt resets all changes to the "created_at" field.
  20820. func (m *MessageRecordsMutation) ResetCreatedAt() {
  20821. m.created_at = nil
  20822. }
  20823. // SetUpdatedAt sets the "updated_at" field.
  20824. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  20825. m.updated_at = &t
  20826. }
  20827. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20828. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  20829. v := m.updated_at
  20830. if v == nil {
  20831. return
  20832. }
  20833. return *v, true
  20834. }
  20835. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20839. if !m.op.Is(OpUpdateOne) {
  20840. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20841. }
  20842. if m.id == nil || m.oldValue == nil {
  20843. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  20848. }
  20849. return oldValue.UpdatedAt, nil
  20850. }
  20851. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20852. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  20853. m.updated_at = nil
  20854. }
  20855. // SetStatus sets the "status" field.
  20856. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  20857. m.status = &u
  20858. m.addstatus = nil
  20859. }
  20860. // Status returns the value of the "status" field in the mutation.
  20861. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  20862. v := m.status
  20863. if v == nil {
  20864. return
  20865. }
  20866. return *v, true
  20867. }
  20868. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  20869. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20871. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20872. if !m.op.Is(OpUpdateOne) {
  20873. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20874. }
  20875. if m.id == nil || m.oldValue == nil {
  20876. return v, errors.New("OldStatus requires an ID field in the mutation")
  20877. }
  20878. oldValue, err := m.oldValue(ctx)
  20879. if err != nil {
  20880. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20881. }
  20882. return oldValue.Status, nil
  20883. }
  20884. // AddStatus adds u to the "status" field.
  20885. func (m *MessageRecordsMutation) AddStatus(u int8) {
  20886. if m.addstatus != nil {
  20887. *m.addstatus += u
  20888. } else {
  20889. m.addstatus = &u
  20890. }
  20891. }
  20892. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20893. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  20894. v := m.addstatus
  20895. if v == nil {
  20896. return
  20897. }
  20898. return *v, true
  20899. }
  20900. // ClearStatus clears the value of the "status" field.
  20901. func (m *MessageRecordsMutation) ClearStatus() {
  20902. m.status = nil
  20903. m.addstatus = nil
  20904. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  20905. }
  20906. // StatusCleared returns if the "status" field was cleared in this mutation.
  20907. func (m *MessageRecordsMutation) StatusCleared() bool {
  20908. _, ok := m.clearedFields[messagerecords.FieldStatus]
  20909. return ok
  20910. }
  20911. // ResetStatus resets all changes to the "status" field.
  20912. func (m *MessageRecordsMutation) ResetStatus() {
  20913. m.status = nil
  20914. m.addstatus = nil
  20915. delete(m.clearedFields, messagerecords.FieldStatus)
  20916. }
  20917. // SetBotWxid sets the "bot_wxid" field.
  20918. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  20919. m.bot_wxid = &s
  20920. }
  20921. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  20922. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  20923. v := m.bot_wxid
  20924. if v == nil {
  20925. return
  20926. }
  20927. return *v, true
  20928. }
  20929. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  20930. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20932. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  20933. if !m.op.Is(OpUpdateOne) {
  20934. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  20935. }
  20936. if m.id == nil || m.oldValue == nil {
  20937. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  20938. }
  20939. oldValue, err := m.oldValue(ctx)
  20940. if err != nil {
  20941. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  20942. }
  20943. return oldValue.BotWxid, nil
  20944. }
  20945. // ResetBotWxid resets all changes to the "bot_wxid" field.
  20946. func (m *MessageRecordsMutation) ResetBotWxid() {
  20947. m.bot_wxid = nil
  20948. }
  20949. // SetContactID sets the "contact_id" field.
  20950. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  20951. m.message_contact = &u
  20952. }
  20953. // ContactID returns the value of the "contact_id" field in the mutation.
  20954. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  20955. v := m.message_contact
  20956. if v == nil {
  20957. return
  20958. }
  20959. return *v, true
  20960. }
  20961. // OldContactID returns the old "contact_id" 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) OldContactID(ctx context.Context) (v uint64, err error) {
  20965. if !m.op.Is(OpUpdateOne) {
  20966. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  20967. }
  20968. if m.id == nil || m.oldValue == nil {
  20969. return v, errors.New("OldContactID 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 OldContactID: %w", err)
  20974. }
  20975. return oldValue.ContactID, nil
  20976. }
  20977. // ClearContactID clears the value of the "contact_id" field.
  20978. func (m *MessageRecordsMutation) ClearContactID() {
  20979. m.message_contact = nil
  20980. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  20981. }
  20982. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  20983. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  20984. _, ok := m.clearedFields[messagerecords.FieldContactID]
  20985. return ok
  20986. }
  20987. // ResetContactID resets all changes to the "contact_id" field.
  20988. func (m *MessageRecordsMutation) ResetContactID() {
  20989. m.message_contact = nil
  20990. delete(m.clearedFields, messagerecords.FieldContactID)
  20991. }
  20992. // SetContactType sets the "contact_type" field.
  20993. func (m *MessageRecordsMutation) SetContactType(i int) {
  20994. m.contact_type = &i
  20995. m.addcontact_type = nil
  20996. }
  20997. // ContactType returns the value of the "contact_type" field in the mutation.
  20998. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  20999. v := m.contact_type
  21000. if v == nil {
  21001. return
  21002. }
  21003. return *v, true
  21004. }
  21005. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  21006. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21008. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  21009. if !m.op.Is(OpUpdateOne) {
  21010. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  21011. }
  21012. if m.id == nil || m.oldValue == nil {
  21013. return v, errors.New("OldContactType requires an ID field in the mutation")
  21014. }
  21015. oldValue, err := m.oldValue(ctx)
  21016. if err != nil {
  21017. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  21018. }
  21019. return oldValue.ContactType, nil
  21020. }
  21021. // AddContactType adds i to the "contact_type" field.
  21022. func (m *MessageRecordsMutation) AddContactType(i int) {
  21023. if m.addcontact_type != nil {
  21024. *m.addcontact_type += i
  21025. } else {
  21026. m.addcontact_type = &i
  21027. }
  21028. }
  21029. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  21030. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  21031. v := m.addcontact_type
  21032. if v == nil {
  21033. return
  21034. }
  21035. return *v, true
  21036. }
  21037. // ResetContactType resets all changes to the "contact_type" field.
  21038. func (m *MessageRecordsMutation) ResetContactType() {
  21039. m.contact_type = nil
  21040. m.addcontact_type = nil
  21041. }
  21042. // SetContactWxid sets the "contact_wxid" field.
  21043. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  21044. m.contact_wxid = &s
  21045. }
  21046. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  21047. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  21048. v := m.contact_wxid
  21049. if v == nil {
  21050. return
  21051. }
  21052. return *v, true
  21053. }
  21054. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  21055. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21057. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  21058. if !m.op.Is(OpUpdateOne) {
  21059. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  21060. }
  21061. if m.id == nil || m.oldValue == nil {
  21062. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  21063. }
  21064. oldValue, err := m.oldValue(ctx)
  21065. if err != nil {
  21066. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  21067. }
  21068. return oldValue.ContactWxid, nil
  21069. }
  21070. // ResetContactWxid resets all changes to the "contact_wxid" field.
  21071. func (m *MessageRecordsMutation) ResetContactWxid() {
  21072. m.contact_wxid = nil
  21073. }
  21074. // SetContentType sets the "content_type" field.
  21075. func (m *MessageRecordsMutation) SetContentType(i int) {
  21076. m.content_type = &i
  21077. m.addcontent_type = nil
  21078. }
  21079. // ContentType returns the value of the "content_type" field in the mutation.
  21080. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  21081. v := m.content_type
  21082. if v == nil {
  21083. return
  21084. }
  21085. return *v, true
  21086. }
  21087. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  21088. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21090. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  21091. if !m.op.Is(OpUpdateOne) {
  21092. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  21093. }
  21094. if m.id == nil || m.oldValue == nil {
  21095. return v, errors.New("OldContentType requires an ID field in the mutation")
  21096. }
  21097. oldValue, err := m.oldValue(ctx)
  21098. if err != nil {
  21099. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  21100. }
  21101. return oldValue.ContentType, nil
  21102. }
  21103. // AddContentType adds i to the "content_type" field.
  21104. func (m *MessageRecordsMutation) AddContentType(i int) {
  21105. if m.addcontent_type != nil {
  21106. *m.addcontent_type += i
  21107. } else {
  21108. m.addcontent_type = &i
  21109. }
  21110. }
  21111. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  21112. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  21113. v := m.addcontent_type
  21114. if v == nil {
  21115. return
  21116. }
  21117. return *v, true
  21118. }
  21119. // ResetContentType resets all changes to the "content_type" field.
  21120. func (m *MessageRecordsMutation) ResetContentType() {
  21121. m.content_type = nil
  21122. m.addcontent_type = nil
  21123. }
  21124. // SetContent sets the "content" field.
  21125. func (m *MessageRecordsMutation) SetContent(s string) {
  21126. m.content = &s
  21127. }
  21128. // Content returns the value of the "content" field in the mutation.
  21129. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  21130. v := m.content
  21131. if v == nil {
  21132. return
  21133. }
  21134. return *v, true
  21135. }
  21136. // OldContent returns the old "content" field's value of the MessageRecords entity.
  21137. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21139. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  21140. if !m.op.Is(OpUpdateOne) {
  21141. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21142. }
  21143. if m.id == nil || m.oldValue == nil {
  21144. return v, errors.New("OldContent requires an ID field in the mutation")
  21145. }
  21146. oldValue, err := m.oldValue(ctx)
  21147. if err != nil {
  21148. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21149. }
  21150. return oldValue.Content, nil
  21151. }
  21152. // ResetContent resets all changes to the "content" field.
  21153. func (m *MessageRecordsMutation) ResetContent() {
  21154. m.content = nil
  21155. }
  21156. // SetMeta sets the "meta" field.
  21157. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  21158. m.meta = &ct
  21159. }
  21160. // Meta returns the value of the "meta" field in the mutation.
  21161. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  21162. v := m.meta
  21163. if v == nil {
  21164. return
  21165. }
  21166. return *v, true
  21167. }
  21168. // OldMeta returns the old "meta" 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) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  21172. if !m.op.Is(OpUpdateOne) {
  21173. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  21174. }
  21175. if m.id == nil || m.oldValue == nil {
  21176. return v, errors.New("OldMeta 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 OldMeta: %w", err)
  21181. }
  21182. return oldValue.Meta, nil
  21183. }
  21184. // ClearMeta clears the value of the "meta" field.
  21185. func (m *MessageRecordsMutation) ClearMeta() {
  21186. m.meta = nil
  21187. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  21188. }
  21189. // MetaCleared returns if the "meta" field was cleared in this mutation.
  21190. func (m *MessageRecordsMutation) MetaCleared() bool {
  21191. _, ok := m.clearedFields[messagerecords.FieldMeta]
  21192. return ok
  21193. }
  21194. // ResetMeta resets all changes to the "meta" field.
  21195. func (m *MessageRecordsMutation) ResetMeta() {
  21196. m.meta = nil
  21197. delete(m.clearedFields, messagerecords.FieldMeta)
  21198. }
  21199. // SetErrorDetail sets the "error_detail" field.
  21200. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  21201. m.error_detail = &s
  21202. }
  21203. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  21204. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  21205. v := m.error_detail
  21206. if v == nil {
  21207. return
  21208. }
  21209. return *v, true
  21210. }
  21211. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  21212. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21214. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  21215. if !m.op.Is(OpUpdateOne) {
  21216. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  21217. }
  21218. if m.id == nil || m.oldValue == nil {
  21219. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  21220. }
  21221. oldValue, err := m.oldValue(ctx)
  21222. if err != nil {
  21223. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  21224. }
  21225. return oldValue.ErrorDetail, nil
  21226. }
  21227. // ResetErrorDetail resets all changes to the "error_detail" field.
  21228. func (m *MessageRecordsMutation) ResetErrorDetail() {
  21229. m.error_detail = nil
  21230. }
  21231. // SetSendTime sets the "send_time" field.
  21232. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  21233. m.send_time = &t
  21234. }
  21235. // SendTime returns the value of the "send_time" field in the mutation.
  21236. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  21237. v := m.send_time
  21238. if v == nil {
  21239. return
  21240. }
  21241. return *v, true
  21242. }
  21243. // OldSendTime returns the old "send_time" 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) OldSendTime(ctx context.Context) (v time.Time, err error) {
  21247. if !m.op.Is(OpUpdateOne) {
  21248. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  21249. }
  21250. if m.id == nil || m.oldValue == nil {
  21251. return v, errors.New("OldSendTime 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 OldSendTime: %w", err)
  21256. }
  21257. return oldValue.SendTime, nil
  21258. }
  21259. // ClearSendTime clears the value of the "send_time" field.
  21260. func (m *MessageRecordsMutation) ClearSendTime() {
  21261. m.send_time = nil
  21262. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  21263. }
  21264. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  21265. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  21266. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  21267. return ok
  21268. }
  21269. // ResetSendTime resets all changes to the "send_time" field.
  21270. func (m *MessageRecordsMutation) ResetSendTime() {
  21271. m.send_time = nil
  21272. delete(m.clearedFields, messagerecords.FieldSendTime)
  21273. }
  21274. // SetSourceType sets the "source_type" field.
  21275. func (m *MessageRecordsMutation) SetSourceType(i int) {
  21276. m.source_type = &i
  21277. m.addsource_type = nil
  21278. }
  21279. // SourceType returns the value of the "source_type" field in the mutation.
  21280. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  21281. v := m.source_type
  21282. if v == nil {
  21283. return
  21284. }
  21285. return *v, true
  21286. }
  21287. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  21288. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21290. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  21291. if !m.op.Is(OpUpdateOne) {
  21292. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  21293. }
  21294. if m.id == nil || m.oldValue == nil {
  21295. return v, errors.New("OldSourceType requires an ID field in the mutation")
  21296. }
  21297. oldValue, err := m.oldValue(ctx)
  21298. if err != nil {
  21299. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  21300. }
  21301. return oldValue.SourceType, nil
  21302. }
  21303. // AddSourceType adds i to the "source_type" field.
  21304. func (m *MessageRecordsMutation) AddSourceType(i int) {
  21305. if m.addsource_type != nil {
  21306. *m.addsource_type += i
  21307. } else {
  21308. m.addsource_type = &i
  21309. }
  21310. }
  21311. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  21312. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  21313. v := m.addsource_type
  21314. if v == nil {
  21315. return
  21316. }
  21317. return *v, true
  21318. }
  21319. // ResetSourceType resets all changes to the "source_type" field.
  21320. func (m *MessageRecordsMutation) ResetSourceType() {
  21321. m.source_type = nil
  21322. m.addsource_type = nil
  21323. }
  21324. // SetSourceID sets the "source_id" field.
  21325. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  21326. m.sop_stage = &u
  21327. }
  21328. // SourceID returns the value of the "source_id" field in the mutation.
  21329. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  21330. v := m.sop_stage
  21331. if v == nil {
  21332. return
  21333. }
  21334. return *v, true
  21335. }
  21336. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  21337. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21339. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  21340. if !m.op.Is(OpUpdateOne) {
  21341. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  21342. }
  21343. if m.id == nil || m.oldValue == nil {
  21344. return v, errors.New("OldSourceID requires an ID field in the mutation")
  21345. }
  21346. oldValue, err := m.oldValue(ctx)
  21347. if err != nil {
  21348. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  21349. }
  21350. return oldValue.SourceID, nil
  21351. }
  21352. // ClearSourceID clears the value of the "source_id" field.
  21353. func (m *MessageRecordsMutation) ClearSourceID() {
  21354. m.sop_stage = nil
  21355. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21356. }
  21357. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  21358. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  21359. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  21360. return ok
  21361. }
  21362. // ResetSourceID resets all changes to the "source_id" field.
  21363. func (m *MessageRecordsMutation) ResetSourceID() {
  21364. m.sop_stage = nil
  21365. delete(m.clearedFields, messagerecords.FieldSourceID)
  21366. }
  21367. // SetSubSourceID sets the "sub_source_id" field.
  21368. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  21369. m.sop_node = &u
  21370. }
  21371. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  21372. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  21373. v := m.sop_node
  21374. if v == nil {
  21375. return
  21376. }
  21377. return *v, true
  21378. }
  21379. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  21380. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21382. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  21383. if !m.op.Is(OpUpdateOne) {
  21384. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  21385. }
  21386. if m.id == nil || m.oldValue == nil {
  21387. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  21388. }
  21389. oldValue, err := m.oldValue(ctx)
  21390. if err != nil {
  21391. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  21392. }
  21393. return oldValue.SubSourceID, nil
  21394. }
  21395. // ClearSubSourceID clears the value of the "sub_source_id" field.
  21396. func (m *MessageRecordsMutation) ClearSubSourceID() {
  21397. m.sop_node = nil
  21398. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21399. }
  21400. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  21401. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  21402. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  21403. return ok
  21404. }
  21405. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  21406. func (m *MessageRecordsMutation) ResetSubSourceID() {
  21407. m.sop_node = nil
  21408. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  21409. }
  21410. // SetOrganizationID sets the "organization_id" field.
  21411. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  21412. m.organization_id = &u
  21413. m.addorganization_id = nil
  21414. }
  21415. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21416. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  21417. v := m.organization_id
  21418. if v == nil {
  21419. return
  21420. }
  21421. return *v, true
  21422. }
  21423. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  21424. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21426. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21427. if !m.op.Is(OpUpdateOne) {
  21428. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21429. }
  21430. if m.id == nil || m.oldValue == nil {
  21431. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21432. }
  21433. oldValue, err := m.oldValue(ctx)
  21434. if err != nil {
  21435. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21436. }
  21437. return oldValue.OrganizationID, nil
  21438. }
  21439. // AddOrganizationID adds u to the "organization_id" field.
  21440. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  21441. if m.addorganization_id != nil {
  21442. *m.addorganization_id += u
  21443. } else {
  21444. m.addorganization_id = &u
  21445. }
  21446. }
  21447. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21448. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  21449. v := m.addorganization_id
  21450. if v == nil {
  21451. return
  21452. }
  21453. return *v, true
  21454. }
  21455. // ClearOrganizationID clears the value of the "organization_id" field.
  21456. func (m *MessageRecordsMutation) ClearOrganizationID() {
  21457. m.organization_id = nil
  21458. m.addorganization_id = nil
  21459. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  21460. }
  21461. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21462. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  21463. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  21464. return ok
  21465. }
  21466. // ResetOrganizationID resets all changes to the "organization_id" field.
  21467. func (m *MessageRecordsMutation) ResetOrganizationID() {
  21468. m.organization_id = nil
  21469. m.addorganization_id = nil
  21470. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  21471. }
  21472. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21473. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  21474. m.sop_stage = &id
  21475. }
  21476. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21477. func (m *MessageRecordsMutation) ClearSopStage() {
  21478. m.clearedsop_stage = true
  21479. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21480. }
  21481. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21482. func (m *MessageRecordsMutation) SopStageCleared() bool {
  21483. return m.SourceIDCleared() || m.clearedsop_stage
  21484. }
  21485. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21486. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  21487. if m.sop_stage != nil {
  21488. return *m.sop_stage, true
  21489. }
  21490. return
  21491. }
  21492. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21493. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21494. // SopStageID instead. It exists only for internal usage by the builders.
  21495. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  21496. if id := m.sop_stage; id != nil {
  21497. ids = append(ids, *id)
  21498. }
  21499. return
  21500. }
  21501. // ResetSopStage resets all changes to the "sop_stage" edge.
  21502. func (m *MessageRecordsMutation) ResetSopStage() {
  21503. m.sop_stage = nil
  21504. m.clearedsop_stage = false
  21505. }
  21506. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  21507. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  21508. m.sop_node = &id
  21509. }
  21510. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  21511. func (m *MessageRecordsMutation) ClearSopNode() {
  21512. m.clearedsop_node = true
  21513. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21514. }
  21515. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  21516. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  21517. return m.SubSourceIDCleared() || m.clearedsop_node
  21518. }
  21519. // SopNodeID returns the "sop_node" edge ID in the mutation.
  21520. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  21521. if m.sop_node != nil {
  21522. return *m.sop_node, true
  21523. }
  21524. return
  21525. }
  21526. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  21527. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21528. // SopNodeID instead. It exists only for internal usage by the builders.
  21529. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  21530. if id := m.sop_node; id != nil {
  21531. ids = append(ids, *id)
  21532. }
  21533. return
  21534. }
  21535. // ResetSopNode resets all changes to the "sop_node" edge.
  21536. func (m *MessageRecordsMutation) ResetSopNode() {
  21537. m.sop_node = nil
  21538. m.clearedsop_node = false
  21539. }
  21540. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  21541. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  21542. m.message_contact = &id
  21543. }
  21544. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  21545. func (m *MessageRecordsMutation) ClearMessageContact() {
  21546. m.clearedmessage_contact = true
  21547. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  21548. }
  21549. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  21550. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  21551. return m.ContactIDCleared() || m.clearedmessage_contact
  21552. }
  21553. // MessageContactID returns the "message_contact" edge ID in the mutation.
  21554. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  21555. if m.message_contact != nil {
  21556. return *m.message_contact, true
  21557. }
  21558. return
  21559. }
  21560. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  21561. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21562. // MessageContactID instead. It exists only for internal usage by the builders.
  21563. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  21564. if id := m.message_contact; id != nil {
  21565. ids = append(ids, *id)
  21566. }
  21567. return
  21568. }
  21569. // ResetMessageContact resets all changes to the "message_contact" edge.
  21570. func (m *MessageRecordsMutation) ResetMessageContact() {
  21571. m.message_contact = nil
  21572. m.clearedmessage_contact = false
  21573. }
  21574. // Where appends a list predicates to the MessageRecordsMutation builder.
  21575. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  21576. m.predicates = append(m.predicates, ps...)
  21577. }
  21578. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  21579. // users can use type-assertion to append predicates that do not depend on any generated package.
  21580. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  21581. p := make([]predicate.MessageRecords, len(ps))
  21582. for i := range ps {
  21583. p[i] = ps[i]
  21584. }
  21585. m.Where(p...)
  21586. }
  21587. // Op returns the operation name.
  21588. func (m *MessageRecordsMutation) Op() Op {
  21589. return m.op
  21590. }
  21591. // SetOp allows setting the mutation operation.
  21592. func (m *MessageRecordsMutation) SetOp(op Op) {
  21593. m.op = op
  21594. }
  21595. // Type returns the node type of this mutation (MessageRecords).
  21596. func (m *MessageRecordsMutation) Type() string {
  21597. return m.typ
  21598. }
  21599. // Fields returns all fields that were changed during this mutation. Note that in
  21600. // order to get all numeric fields that were incremented/decremented, call
  21601. // AddedFields().
  21602. func (m *MessageRecordsMutation) Fields() []string {
  21603. fields := make([]string, 0, 16)
  21604. if m.created_at != nil {
  21605. fields = append(fields, messagerecords.FieldCreatedAt)
  21606. }
  21607. if m.updated_at != nil {
  21608. fields = append(fields, messagerecords.FieldUpdatedAt)
  21609. }
  21610. if m.status != nil {
  21611. fields = append(fields, messagerecords.FieldStatus)
  21612. }
  21613. if m.bot_wxid != nil {
  21614. fields = append(fields, messagerecords.FieldBotWxid)
  21615. }
  21616. if m.message_contact != nil {
  21617. fields = append(fields, messagerecords.FieldContactID)
  21618. }
  21619. if m.contact_type != nil {
  21620. fields = append(fields, messagerecords.FieldContactType)
  21621. }
  21622. if m.contact_wxid != nil {
  21623. fields = append(fields, messagerecords.FieldContactWxid)
  21624. }
  21625. if m.content_type != nil {
  21626. fields = append(fields, messagerecords.FieldContentType)
  21627. }
  21628. if m.content != nil {
  21629. fields = append(fields, messagerecords.FieldContent)
  21630. }
  21631. if m.meta != nil {
  21632. fields = append(fields, messagerecords.FieldMeta)
  21633. }
  21634. if m.error_detail != nil {
  21635. fields = append(fields, messagerecords.FieldErrorDetail)
  21636. }
  21637. if m.send_time != nil {
  21638. fields = append(fields, messagerecords.FieldSendTime)
  21639. }
  21640. if m.source_type != nil {
  21641. fields = append(fields, messagerecords.FieldSourceType)
  21642. }
  21643. if m.sop_stage != nil {
  21644. fields = append(fields, messagerecords.FieldSourceID)
  21645. }
  21646. if m.sop_node != nil {
  21647. fields = append(fields, messagerecords.FieldSubSourceID)
  21648. }
  21649. if m.organization_id != nil {
  21650. fields = append(fields, messagerecords.FieldOrganizationID)
  21651. }
  21652. return fields
  21653. }
  21654. // Field returns the value of a field with the given name. The second boolean
  21655. // return value indicates that this field was not set, or was not defined in the
  21656. // schema.
  21657. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  21658. switch name {
  21659. case messagerecords.FieldCreatedAt:
  21660. return m.CreatedAt()
  21661. case messagerecords.FieldUpdatedAt:
  21662. return m.UpdatedAt()
  21663. case messagerecords.FieldStatus:
  21664. return m.Status()
  21665. case messagerecords.FieldBotWxid:
  21666. return m.BotWxid()
  21667. case messagerecords.FieldContactID:
  21668. return m.ContactID()
  21669. case messagerecords.FieldContactType:
  21670. return m.ContactType()
  21671. case messagerecords.FieldContactWxid:
  21672. return m.ContactWxid()
  21673. case messagerecords.FieldContentType:
  21674. return m.ContentType()
  21675. case messagerecords.FieldContent:
  21676. return m.Content()
  21677. case messagerecords.FieldMeta:
  21678. return m.Meta()
  21679. case messagerecords.FieldErrorDetail:
  21680. return m.ErrorDetail()
  21681. case messagerecords.FieldSendTime:
  21682. return m.SendTime()
  21683. case messagerecords.FieldSourceType:
  21684. return m.SourceType()
  21685. case messagerecords.FieldSourceID:
  21686. return m.SourceID()
  21687. case messagerecords.FieldSubSourceID:
  21688. return m.SubSourceID()
  21689. case messagerecords.FieldOrganizationID:
  21690. return m.OrganizationID()
  21691. }
  21692. return nil, false
  21693. }
  21694. // OldField returns the old value of the field from the database. An error is
  21695. // returned if the mutation operation is not UpdateOne, or the query to the
  21696. // database failed.
  21697. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21698. switch name {
  21699. case messagerecords.FieldCreatedAt:
  21700. return m.OldCreatedAt(ctx)
  21701. case messagerecords.FieldUpdatedAt:
  21702. return m.OldUpdatedAt(ctx)
  21703. case messagerecords.FieldStatus:
  21704. return m.OldStatus(ctx)
  21705. case messagerecords.FieldBotWxid:
  21706. return m.OldBotWxid(ctx)
  21707. case messagerecords.FieldContactID:
  21708. return m.OldContactID(ctx)
  21709. case messagerecords.FieldContactType:
  21710. return m.OldContactType(ctx)
  21711. case messagerecords.FieldContactWxid:
  21712. return m.OldContactWxid(ctx)
  21713. case messagerecords.FieldContentType:
  21714. return m.OldContentType(ctx)
  21715. case messagerecords.FieldContent:
  21716. return m.OldContent(ctx)
  21717. case messagerecords.FieldMeta:
  21718. return m.OldMeta(ctx)
  21719. case messagerecords.FieldErrorDetail:
  21720. return m.OldErrorDetail(ctx)
  21721. case messagerecords.FieldSendTime:
  21722. return m.OldSendTime(ctx)
  21723. case messagerecords.FieldSourceType:
  21724. return m.OldSourceType(ctx)
  21725. case messagerecords.FieldSourceID:
  21726. return m.OldSourceID(ctx)
  21727. case messagerecords.FieldSubSourceID:
  21728. return m.OldSubSourceID(ctx)
  21729. case messagerecords.FieldOrganizationID:
  21730. return m.OldOrganizationID(ctx)
  21731. }
  21732. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  21733. }
  21734. // SetField sets the value of a field with the given name. It returns an error if
  21735. // the field is not defined in the schema, or if the type mismatched the field
  21736. // type.
  21737. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  21738. switch name {
  21739. case messagerecords.FieldCreatedAt:
  21740. v, ok := value.(time.Time)
  21741. if !ok {
  21742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21743. }
  21744. m.SetCreatedAt(v)
  21745. return nil
  21746. case messagerecords.FieldUpdatedAt:
  21747. v, ok := value.(time.Time)
  21748. if !ok {
  21749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21750. }
  21751. m.SetUpdatedAt(v)
  21752. return nil
  21753. case messagerecords.FieldStatus:
  21754. v, ok := value.(uint8)
  21755. if !ok {
  21756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21757. }
  21758. m.SetStatus(v)
  21759. return nil
  21760. case messagerecords.FieldBotWxid:
  21761. v, ok := value.(string)
  21762. if !ok {
  21763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21764. }
  21765. m.SetBotWxid(v)
  21766. return nil
  21767. case messagerecords.FieldContactID:
  21768. v, ok := value.(uint64)
  21769. if !ok {
  21770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21771. }
  21772. m.SetContactID(v)
  21773. return nil
  21774. case messagerecords.FieldContactType:
  21775. v, ok := value.(int)
  21776. if !ok {
  21777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21778. }
  21779. m.SetContactType(v)
  21780. return nil
  21781. case messagerecords.FieldContactWxid:
  21782. v, ok := value.(string)
  21783. if !ok {
  21784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21785. }
  21786. m.SetContactWxid(v)
  21787. return nil
  21788. case messagerecords.FieldContentType:
  21789. v, ok := value.(int)
  21790. if !ok {
  21791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21792. }
  21793. m.SetContentType(v)
  21794. return nil
  21795. case messagerecords.FieldContent:
  21796. v, ok := value.(string)
  21797. if !ok {
  21798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21799. }
  21800. m.SetContent(v)
  21801. return nil
  21802. case messagerecords.FieldMeta:
  21803. v, ok := value.(custom_types.Meta)
  21804. if !ok {
  21805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21806. }
  21807. m.SetMeta(v)
  21808. return nil
  21809. case messagerecords.FieldErrorDetail:
  21810. v, ok := value.(string)
  21811. if !ok {
  21812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21813. }
  21814. m.SetErrorDetail(v)
  21815. return nil
  21816. case messagerecords.FieldSendTime:
  21817. v, ok := value.(time.Time)
  21818. if !ok {
  21819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21820. }
  21821. m.SetSendTime(v)
  21822. return nil
  21823. case messagerecords.FieldSourceType:
  21824. v, ok := value.(int)
  21825. if !ok {
  21826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21827. }
  21828. m.SetSourceType(v)
  21829. return nil
  21830. case messagerecords.FieldSourceID:
  21831. v, ok := value.(uint64)
  21832. if !ok {
  21833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21834. }
  21835. m.SetSourceID(v)
  21836. return nil
  21837. case messagerecords.FieldSubSourceID:
  21838. v, ok := value.(uint64)
  21839. if !ok {
  21840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21841. }
  21842. m.SetSubSourceID(v)
  21843. return nil
  21844. case messagerecords.FieldOrganizationID:
  21845. v, ok := value.(uint64)
  21846. if !ok {
  21847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21848. }
  21849. m.SetOrganizationID(v)
  21850. return nil
  21851. }
  21852. return fmt.Errorf("unknown MessageRecords field %s", name)
  21853. }
  21854. // AddedFields returns all numeric fields that were incremented/decremented during
  21855. // this mutation.
  21856. func (m *MessageRecordsMutation) AddedFields() []string {
  21857. var fields []string
  21858. if m.addstatus != nil {
  21859. fields = append(fields, messagerecords.FieldStatus)
  21860. }
  21861. if m.addcontact_type != nil {
  21862. fields = append(fields, messagerecords.FieldContactType)
  21863. }
  21864. if m.addcontent_type != nil {
  21865. fields = append(fields, messagerecords.FieldContentType)
  21866. }
  21867. if m.addsource_type != nil {
  21868. fields = append(fields, messagerecords.FieldSourceType)
  21869. }
  21870. if m.addorganization_id != nil {
  21871. fields = append(fields, messagerecords.FieldOrganizationID)
  21872. }
  21873. return fields
  21874. }
  21875. // AddedField returns the numeric value that was incremented/decremented on a field
  21876. // with the given name. The second boolean return value indicates that this field
  21877. // was not set, or was not defined in the schema.
  21878. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  21879. switch name {
  21880. case messagerecords.FieldStatus:
  21881. return m.AddedStatus()
  21882. case messagerecords.FieldContactType:
  21883. return m.AddedContactType()
  21884. case messagerecords.FieldContentType:
  21885. return m.AddedContentType()
  21886. case messagerecords.FieldSourceType:
  21887. return m.AddedSourceType()
  21888. case messagerecords.FieldOrganizationID:
  21889. return m.AddedOrganizationID()
  21890. }
  21891. return nil, false
  21892. }
  21893. // AddField adds the value to the field with the given name. It returns an error if
  21894. // the field is not defined in the schema, or if the type mismatched the field
  21895. // type.
  21896. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  21897. switch name {
  21898. case messagerecords.FieldStatus:
  21899. v, ok := value.(int8)
  21900. if !ok {
  21901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21902. }
  21903. m.AddStatus(v)
  21904. return nil
  21905. case messagerecords.FieldContactType:
  21906. v, ok := value.(int)
  21907. if !ok {
  21908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21909. }
  21910. m.AddContactType(v)
  21911. return nil
  21912. case messagerecords.FieldContentType:
  21913. v, ok := value.(int)
  21914. if !ok {
  21915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21916. }
  21917. m.AddContentType(v)
  21918. return nil
  21919. case messagerecords.FieldSourceType:
  21920. v, ok := value.(int)
  21921. if !ok {
  21922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21923. }
  21924. m.AddSourceType(v)
  21925. return nil
  21926. case messagerecords.FieldOrganizationID:
  21927. v, ok := value.(int64)
  21928. if !ok {
  21929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21930. }
  21931. m.AddOrganizationID(v)
  21932. return nil
  21933. }
  21934. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  21935. }
  21936. // ClearedFields returns all nullable fields that were cleared during this
  21937. // mutation.
  21938. func (m *MessageRecordsMutation) ClearedFields() []string {
  21939. var fields []string
  21940. if m.FieldCleared(messagerecords.FieldStatus) {
  21941. fields = append(fields, messagerecords.FieldStatus)
  21942. }
  21943. if m.FieldCleared(messagerecords.FieldContactID) {
  21944. fields = append(fields, messagerecords.FieldContactID)
  21945. }
  21946. if m.FieldCleared(messagerecords.FieldMeta) {
  21947. fields = append(fields, messagerecords.FieldMeta)
  21948. }
  21949. if m.FieldCleared(messagerecords.FieldSendTime) {
  21950. fields = append(fields, messagerecords.FieldSendTime)
  21951. }
  21952. if m.FieldCleared(messagerecords.FieldSourceID) {
  21953. fields = append(fields, messagerecords.FieldSourceID)
  21954. }
  21955. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  21956. fields = append(fields, messagerecords.FieldSubSourceID)
  21957. }
  21958. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  21959. fields = append(fields, messagerecords.FieldOrganizationID)
  21960. }
  21961. return fields
  21962. }
  21963. // FieldCleared returns a boolean indicating if a field with the given name was
  21964. // cleared in this mutation.
  21965. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  21966. _, ok := m.clearedFields[name]
  21967. return ok
  21968. }
  21969. // ClearField clears the value of the field with the given name. It returns an
  21970. // error if the field is not defined in the schema.
  21971. func (m *MessageRecordsMutation) ClearField(name string) error {
  21972. switch name {
  21973. case messagerecords.FieldStatus:
  21974. m.ClearStatus()
  21975. return nil
  21976. case messagerecords.FieldContactID:
  21977. m.ClearContactID()
  21978. return nil
  21979. case messagerecords.FieldMeta:
  21980. m.ClearMeta()
  21981. return nil
  21982. case messagerecords.FieldSendTime:
  21983. m.ClearSendTime()
  21984. return nil
  21985. case messagerecords.FieldSourceID:
  21986. m.ClearSourceID()
  21987. return nil
  21988. case messagerecords.FieldSubSourceID:
  21989. m.ClearSubSourceID()
  21990. return nil
  21991. case messagerecords.FieldOrganizationID:
  21992. m.ClearOrganizationID()
  21993. return nil
  21994. }
  21995. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  21996. }
  21997. // ResetField resets all changes in the mutation for the field with the given name.
  21998. // It returns an error if the field is not defined in the schema.
  21999. func (m *MessageRecordsMutation) ResetField(name string) error {
  22000. switch name {
  22001. case messagerecords.FieldCreatedAt:
  22002. m.ResetCreatedAt()
  22003. return nil
  22004. case messagerecords.FieldUpdatedAt:
  22005. m.ResetUpdatedAt()
  22006. return nil
  22007. case messagerecords.FieldStatus:
  22008. m.ResetStatus()
  22009. return nil
  22010. case messagerecords.FieldBotWxid:
  22011. m.ResetBotWxid()
  22012. return nil
  22013. case messagerecords.FieldContactID:
  22014. m.ResetContactID()
  22015. return nil
  22016. case messagerecords.FieldContactType:
  22017. m.ResetContactType()
  22018. return nil
  22019. case messagerecords.FieldContactWxid:
  22020. m.ResetContactWxid()
  22021. return nil
  22022. case messagerecords.FieldContentType:
  22023. m.ResetContentType()
  22024. return nil
  22025. case messagerecords.FieldContent:
  22026. m.ResetContent()
  22027. return nil
  22028. case messagerecords.FieldMeta:
  22029. m.ResetMeta()
  22030. return nil
  22031. case messagerecords.FieldErrorDetail:
  22032. m.ResetErrorDetail()
  22033. return nil
  22034. case messagerecords.FieldSendTime:
  22035. m.ResetSendTime()
  22036. return nil
  22037. case messagerecords.FieldSourceType:
  22038. m.ResetSourceType()
  22039. return nil
  22040. case messagerecords.FieldSourceID:
  22041. m.ResetSourceID()
  22042. return nil
  22043. case messagerecords.FieldSubSourceID:
  22044. m.ResetSubSourceID()
  22045. return nil
  22046. case messagerecords.FieldOrganizationID:
  22047. m.ResetOrganizationID()
  22048. return nil
  22049. }
  22050. return fmt.Errorf("unknown MessageRecords field %s", name)
  22051. }
  22052. // AddedEdges returns all edge names that were set/added in this mutation.
  22053. func (m *MessageRecordsMutation) AddedEdges() []string {
  22054. edges := make([]string, 0, 3)
  22055. if m.sop_stage != nil {
  22056. edges = append(edges, messagerecords.EdgeSopStage)
  22057. }
  22058. if m.sop_node != nil {
  22059. edges = append(edges, messagerecords.EdgeSopNode)
  22060. }
  22061. if m.message_contact != nil {
  22062. edges = append(edges, messagerecords.EdgeMessageContact)
  22063. }
  22064. return edges
  22065. }
  22066. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22067. // name in this mutation.
  22068. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  22069. switch name {
  22070. case messagerecords.EdgeSopStage:
  22071. if id := m.sop_stage; id != nil {
  22072. return []ent.Value{*id}
  22073. }
  22074. case messagerecords.EdgeSopNode:
  22075. if id := m.sop_node; id != nil {
  22076. return []ent.Value{*id}
  22077. }
  22078. case messagerecords.EdgeMessageContact:
  22079. if id := m.message_contact; id != nil {
  22080. return []ent.Value{*id}
  22081. }
  22082. }
  22083. return nil
  22084. }
  22085. // RemovedEdges returns all edge names that were removed in this mutation.
  22086. func (m *MessageRecordsMutation) RemovedEdges() []string {
  22087. edges := make([]string, 0, 3)
  22088. return edges
  22089. }
  22090. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22091. // the given name in this mutation.
  22092. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  22093. return nil
  22094. }
  22095. // ClearedEdges returns all edge names that were cleared in this mutation.
  22096. func (m *MessageRecordsMutation) ClearedEdges() []string {
  22097. edges := make([]string, 0, 3)
  22098. if m.clearedsop_stage {
  22099. edges = append(edges, messagerecords.EdgeSopStage)
  22100. }
  22101. if m.clearedsop_node {
  22102. edges = append(edges, messagerecords.EdgeSopNode)
  22103. }
  22104. if m.clearedmessage_contact {
  22105. edges = append(edges, messagerecords.EdgeMessageContact)
  22106. }
  22107. return edges
  22108. }
  22109. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22110. // was cleared in this mutation.
  22111. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  22112. switch name {
  22113. case messagerecords.EdgeSopStage:
  22114. return m.clearedsop_stage
  22115. case messagerecords.EdgeSopNode:
  22116. return m.clearedsop_node
  22117. case messagerecords.EdgeMessageContact:
  22118. return m.clearedmessage_contact
  22119. }
  22120. return false
  22121. }
  22122. // ClearEdge clears the value of the edge with the given name. It returns an error
  22123. // if that edge is not defined in the schema.
  22124. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  22125. switch name {
  22126. case messagerecords.EdgeSopStage:
  22127. m.ClearSopStage()
  22128. return nil
  22129. case messagerecords.EdgeSopNode:
  22130. m.ClearSopNode()
  22131. return nil
  22132. case messagerecords.EdgeMessageContact:
  22133. m.ClearMessageContact()
  22134. return nil
  22135. }
  22136. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  22137. }
  22138. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22139. // It returns an error if the edge is not defined in the schema.
  22140. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  22141. switch name {
  22142. case messagerecords.EdgeSopStage:
  22143. m.ResetSopStage()
  22144. return nil
  22145. case messagerecords.EdgeSopNode:
  22146. m.ResetSopNode()
  22147. return nil
  22148. case messagerecords.EdgeMessageContact:
  22149. m.ResetMessageContact()
  22150. return nil
  22151. }
  22152. return fmt.Errorf("unknown MessageRecords edge %s", name)
  22153. }
  22154. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  22155. type MsgMutation struct {
  22156. config
  22157. op Op
  22158. typ string
  22159. id *uint64
  22160. created_at *time.Time
  22161. updated_at *time.Time
  22162. deleted_at *time.Time
  22163. status *uint8
  22164. addstatus *int8
  22165. fromwxid *string
  22166. toid *string
  22167. msgtype *int32
  22168. addmsgtype *int32
  22169. msg *string
  22170. batch_no *string
  22171. cc *string
  22172. phone *string
  22173. clearedFields map[string]struct{}
  22174. done bool
  22175. oldValue func(context.Context) (*Msg, error)
  22176. predicates []predicate.Msg
  22177. }
  22178. var _ ent.Mutation = (*MsgMutation)(nil)
  22179. // msgOption allows management of the mutation configuration using functional options.
  22180. type msgOption func(*MsgMutation)
  22181. // newMsgMutation creates new mutation for the Msg entity.
  22182. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  22183. m := &MsgMutation{
  22184. config: c,
  22185. op: op,
  22186. typ: TypeMsg,
  22187. clearedFields: make(map[string]struct{}),
  22188. }
  22189. for _, opt := range opts {
  22190. opt(m)
  22191. }
  22192. return m
  22193. }
  22194. // withMsgID sets the ID field of the mutation.
  22195. func withMsgID(id uint64) msgOption {
  22196. return func(m *MsgMutation) {
  22197. var (
  22198. err error
  22199. once sync.Once
  22200. value *Msg
  22201. )
  22202. m.oldValue = func(ctx context.Context) (*Msg, error) {
  22203. once.Do(func() {
  22204. if m.done {
  22205. err = errors.New("querying old values post mutation is not allowed")
  22206. } else {
  22207. value, err = m.Client().Msg.Get(ctx, id)
  22208. }
  22209. })
  22210. return value, err
  22211. }
  22212. m.id = &id
  22213. }
  22214. }
  22215. // withMsg sets the old Msg of the mutation.
  22216. func withMsg(node *Msg) msgOption {
  22217. return func(m *MsgMutation) {
  22218. m.oldValue = func(context.Context) (*Msg, error) {
  22219. return node, nil
  22220. }
  22221. m.id = &node.ID
  22222. }
  22223. }
  22224. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22225. // executed in a transaction (ent.Tx), a transactional client is returned.
  22226. func (m MsgMutation) Client() *Client {
  22227. client := &Client{config: m.config}
  22228. client.init()
  22229. return client
  22230. }
  22231. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22232. // it returns an error otherwise.
  22233. func (m MsgMutation) Tx() (*Tx, error) {
  22234. if _, ok := m.driver.(*txDriver); !ok {
  22235. return nil, errors.New("ent: mutation is not running in a transaction")
  22236. }
  22237. tx := &Tx{config: m.config}
  22238. tx.init()
  22239. return tx, nil
  22240. }
  22241. // SetID sets the value of the id field. Note that this
  22242. // operation is only accepted on creation of Msg entities.
  22243. func (m *MsgMutation) SetID(id uint64) {
  22244. m.id = &id
  22245. }
  22246. // ID returns the ID value in the mutation. Note that the ID is only available
  22247. // if it was provided to the builder or after it was returned from the database.
  22248. func (m *MsgMutation) ID() (id uint64, exists bool) {
  22249. if m.id == nil {
  22250. return
  22251. }
  22252. return *m.id, true
  22253. }
  22254. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22255. // That means, if the mutation is applied within a transaction with an isolation level such
  22256. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22257. // or updated by the mutation.
  22258. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  22259. switch {
  22260. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22261. id, exists := m.ID()
  22262. if exists {
  22263. return []uint64{id}, nil
  22264. }
  22265. fallthrough
  22266. case m.op.Is(OpUpdate | OpDelete):
  22267. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  22268. default:
  22269. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22270. }
  22271. }
  22272. // SetCreatedAt sets the "created_at" field.
  22273. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  22274. m.created_at = &t
  22275. }
  22276. // CreatedAt returns the value of the "created_at" field in the mutation.
  22277. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  22278. v := m.created_at
  22279. if v == nil {
  22280. return
  22281. }
  22282. return *v, true
  22283. }
  22284. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  22285. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22287. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22288. if !m.op.Is(OpUpdateOne) {
  22289. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22290. }
  22291. if m.id == nil || m.oldValue == nil {
  22292. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22293. }
  22294. oldValue, err := m.oldValue(ctx)
  22295. if err != nil {
  22296. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22297. }
  22298. return oldValue.CreatedAt, nil
  22299. }
  22300. // ResetCreatedAt resets all changes to the "created_at" field.
  22301. func (m *MsgMutation) ResetCreatedAt() {
  22302. m.created_at = nil
  22303. }
  22304. // SetUpdatedAt sets the "updated_at" field.
  22305. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  22306. m.updated_at = &t
  22307. }
  22308. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22309. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  22310. v := m.updated_at
  22311. if v == nil {
  22312. return
  22313. }
  22314. return *v, true
  22315. }
  22316. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22320. if !m.op.Is(OpUpdateOne) {
  22321. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22322. }
  22323. if m.id == nil || m.oldValue == nil {
  22324. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  22329. }
  22330. return oldValue.UpdatedAt, nil
  22331. }
  22332. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22333. func (m *MsgMutation) ResetUpdatedAt() {
  22334. m.updated_at = nil
  22335. }
  22336. // SetDeletedAt sets the "deleted_at" field.
  22337. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  22338. m.deleted_at = &t
  22339. }
  22340. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22341. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  22342. v := m.deleted_at
  22343. if v == nil {
  22344. return
  22345. }
  22346. return *v, true
  22347. }
  22348. // OldDeletedAt returns the old "deleted_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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22352. if !m.op.Is(OpUpdateOne) {
  22353. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22354. }
  22355. if m.id == nil || m.oldValue == nil {
  22356. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  22361. }
  22362. return oldValue.DeletedAt, nil
  22363. }
  22364. // ClearDeletedAt clears the value of the "deleted_at" field.
  22365. func (m *MsgMutation) ClearDeletedAt() {
  22366. m.deleted_at = nil
  22367. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  22368. }
  22369. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22370. func (m *MsgMutation) DeletedAtCleared() bool {
  22371. _, ok := m.clearedFields[msg.FieldDeletedAt]
  22372. return ok
  22373. }
  22374. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22375. func (m *MsgMutation) ResetDeletedAt() {
  22376. m.deleted_at = nil
  22377. delete(m.clearedFields, msg.FieldDeletedAt)
  22378. }
  22379. // SetStatus sets the "status" field.
  22380. func (m *MsgMutation) SetStatus(u uint8) {
  22381. m.status = &u
  22382. m.addstatus = nil
  22383. }
  22384. // Status returns the value of the "status" field in the mutation.
  22385. func (m *MsgMutation) Status() (r uint8, exists bool) {
  22386. v := m.status
  22387. if v == nil {
  22388. return
  22389. }
  22390. return *v, true
  22391. }
  22392. // OldStatus returns the old "status" field's value of the Msg entity.
  22393. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22395. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22396. if !m.op.Is(OpUpdateOne) {
  22397. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22398. }
  22399. if m.id == nil || m.oldValue == nil {
  22400. return v, errors.New("OldStatus requires an ID field in the mutation")
  22401. }
  22402. oldValue, err := m.oldValue(ctx)
  22403. if err != nil {
  22404. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22405. }
  22406. return oldValue.Status, nil
  22407. }
  22408. // AddStatus adds u to the "status" field.
  22409. func (m *MsgMutation) AddStatus(u int8) {
  22410. if m.addstatus != nil {
  22411. *m.addstatus += u
  22412. } else {
  22413. m.addstatus = &u
  22414. }
  22415. }
  22416. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22417. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  22418. v := m.addstatus
  22419. if v == nil {
  22420. return
  22421. }
  22422. return *v, true
  22423. }
  22424. // ClearStatus clears the value of the "status" field.
  22425. func (m *MsgMutation) ClearStatus() {
  22426. m.status = nil
  22427. m.addstatus = nil
  22428. m.clearedFields[msg.FieldStatus] = struct{}{}
  22429. }
  22430. // StatusCleared returns if the "status" field was cleared in this mutation.
  22431. func (m *MsgMutation) StatusCleared() bool {
  22432. _, ok := m.clearedFields[msg.FieldStatus]
  22433. return ok
  22434. }
  22435. // ResetStatus resets all changes to the "status" field.
  22436. func (m *MsgMutation) ResetStatus() {
  22437. m.status = nil
  22438. m.addstatus = nil
  22439. delete(m.clearedFields, msg.FieldStatus)
  22440. }
  22441. // SetFromwxid sets the "fromwxid" field.
  22442. func (m *MsgMutation) SetFromwxid(s string) {
  22443. m.fromwxid = &s
  22444. }
  22445. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  22446. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  22447. v := m.fromwxid
  22448. if v == nil {
  22449. return
  22450. }
  22451. return *v, true
  22452. }
  22453. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  22454. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22456. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  22457. if !m.op.Is(OpUpdateOne) {
  22458. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  22459. }
  22460. if m.id == nil || m.oldValue == nil {
  22461. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  22462. }
  22463. oldValue, err := m.oldValue(ctx)
  22464. if err != nil {
  22465. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  22466. }
  22467. return oldValue.Fromwxid, nil
  22468. }
  22469. // ClearFromwxid clears the value of the "fromwxid" field.
  22470. func (m *MsgMutation) ClearFromwxid() {
  22471. m.fromwxid = nil
  22472. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  22473. }
  22474. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  22475. func (m *MsgMutation) FromwxidCleared() bool {
  22476. _, ok := m.clearedFields[msg.FieldFromwxid]
  22477. return ok
  22478. }
  22479. // ResetFromwxid resets all changes to the "fromwxid" field.
  22480. func (m *MsgMutation) ResetFromwxid() {
  22481. m.fromwxid = nil
  22482. delete(m.clearedFields, msg.FieldFromwxid)
  22483. }
  22484. // SetToid sets the "toid" field.
  22485. func (m *MsgMutation) SetToid(s string) {
  22486. m.toid = &s
  22487. }
  22488. // Toid returns the value of the "toid" field in the mutation.
  22489. func (m *MsgMutation) Toid() (r string, exists bool) {
  22490. v := m.toid
  22491. if v == nil {
  22492. return
  22493. }
  22494. return *v, true
  22495. }
  22496. // OldToid returns the old "toid" field's value of the Msg entity.
  22497. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22499. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  22500. if !m.op.Is(OpUpdateOne) {
  22501. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  22502. }
  22503. if m.id == nil || m.oldValue == nil {
  22504. return v, errors.New("OldToid requires an ID field in the mutation")
  22505. }
  22506. oldValue, err := m.oldValue(ctx)
  22507. if err != nil {
  22508. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  22509. }
  22510. return oldValue.Toid, nil
  22511. }
  22512. // ClearToid clears the value of the "toid" field.
  22513. func (m *MsgMutation) ClearToid() {
  22514. m.toid = nil
  22515. m.clearedFields[msg.FieldToid] = struct{}{}
  22516. }
  22517. // ToidCleared returns if the "toid" field was cleared in this mutation.
  22518. func (m *MsgMutation) ToidCleared() bool {
  22519. _, ok := m.clearedFields[msg.FieldToid]
  22520. return ok
  22521. }
  22522. // ResetToid resets all changes to the "toid" field.
  22523. func (m *MsgMutation) ResetToid() {
  22524. m.toid = nil
  22525. delete(m.clearedFields, msg.FieldToid)
  22526. }
  22527. // SetMsgtype sets the "msgtype" field.
  22528. func (m *MsgMutation) SetMsgtype(i int32) {
  22529. m.msgtype = &i
  22530. m.addmsgtype = nil
  22531. }
  22532. // Msgtype returns the value of the "msgtype" field in the mutation.
  22533. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  22534. v := m.msgtype
  22535. if v == nil {
  22536. return
  22537. }
  22538. return *v, true
  22539. }
  22540. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  22541. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22543. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  22544. if !m.op.Is(OpUpdateOne) {
  22545. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  22546. }
  22547. if m.id == nil || m.oldValue == nil {
  22548. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  22549. }
  22550. oldValue, err := m.oldValue(ctx)
  22551. if err != nil {
  22552. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  22553. }
  22554. return oldValue.Msgtype, nil
  22555. }
  22556. // AddMsgtype adds i to the "msgtype" field.
  22557. func (m *MsgMutation) AddMsgtype(i int32) {
  22558. if m.addmsgtype != nil {
  22559. *m.addmsgtype += i
  22560. } else {
  22561. m.addmsgtype = &i
  22562. }
  22563. }
  22564. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  22565. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  22566. v := m.addmsgtype
  22567. if v == nil {
  22568. return
  22569. }
  22570. return *v, true
  22571. }
  22572. // ClearMsgtype clears the value of the "msgtype" field.
  22573. func (m *MsgMutation) ClearMsgtype() {
  22574. m.msgtype = nil
  22575. m.addmsgtype = nil
  22576. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  22577. }
  22578. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  22579. func (m *MsgMutation) MsgtypeCleared() bool {
  22580. _, ok := m.clearedFields[msg.FieldMsgtype]
  22581. return ok
  22582. }
  22583. // ResetMsgtype resets all changes to the "msgtype" field.
  22584. func (m *MsgMutation) ResetMsgtype() {
  22585. m.msgtype = nil
  22586. m.addmsgtype = nil
  22587. delete(m.clearedFields, msg.FieldMsgtype)
  22588. }
  22589. // SetMsg sets the "msg" field.
  22590. func (m *MsgMutation) SetMsg(s string) {
  22591. m.msg = &s
  22592. }
  22593. // Msg returns the value of the "msg" field in the mutation.
  22594. func (m *MsgMutation) Msg() (r string, exists bool) {
  22595. v := m.msg
  22596. if v == nil {
  22597. return
  22598. }
  22599. return *v, true
  22600. }
  22601. // OldMsg returns the old "msg" field's value of the Msg entity.
  22602. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22604. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  22605. if !m.op.Is(OpUpdateOne) {
  22606. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  22607. }
  22608. if m.id == nil || m.oldValue == nil {
  22609. return v, errors.New("OldMsg requires an ID field in the mutation")
  22610. }
  22611. oldValue, err := m.oldValue(ctx)
  22612. if err != nil {
  22613. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  22614. }
  22615. return oldValue.Msg, nil
  22616. }
  22617. // ClearMsg clears the value of the "msg" field.
  22618. func (m *MsgMutation) ClearMsg() {
  22619. m.msg = nil
  22620. m.clearedFields[msg.FieldMsg] = struct{}{}
  22621. }
  22622. // MsgCleared returns if the "msg" field was cleared in this mutation.
  22623. func (m *MsgMutation) MsgCleared() bool {
  22624. _, ok := m.clearedFields[msg.FieldMsg]
  22625. return ok
  22626. }
  22627. // ResetMsg resets all changes to the "msg" field.
  22628. func (m *MsgMutation) ResetMsg() {
  22629. m.msg = nil
  22630. delete(m.clearedFields, msg.FieldMsg)
  22631. }
  22632. // SetBatchNo sets the "batch_no" field.
  22633. func (m *MsgMutation) SetBatchNo(s string) {
  22634. m.batch_no = &s
  22635. }
  22636. // BatchNo returns the value of the "batch_no" field in the mutation.
  22637. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  22638. v := m.batch_no
  22639. if v == nil {
  22640. return
  22641. }
  22642. return *v, true
  22643. }
  22644. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  22645. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22647. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  22648. if !m.op.Is(OpUpdateOne) {
  22649. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  22650. }
  22651. if m.id == nil || m.oldValue == nil {
  22652. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  22653. }
  22654. oldValue, err := m.oldValue(ctx)
  22655. if err != nil {
  22656. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  22657. }
  22658. return oldValue.BatchNo, nil
  22659. }
  22660. // ClearBatchNo clears the value of the "batch_no" field.
  22661. func (m *MsgMutation) ClearBatchNo() {
  22662. m.batch_no = nil
  22663. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  22664. }
  22665. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  22666. func (m *MsgMutation) BatchNoCleared() bool {
  22667. _, ok := m.clearedFields[msg.FieldBatchNo]
  22668. return ok
  22669. }
  22670. // ResetBatchNo resets all changes to the "batch_no" field.
  22671. func (m *MsgMutation) ResetBatchNo() {
  22672. m.batch_no = nil
  22673. delete(m.clearedFields, msg.FieldBatchNo)
  22674. }
  22675. // SetCc sets the "cc" field.
  22676. func (m *MsgMutation) SetCc(s string) {
  22677. m.cc = &s
  22678. }
  22679. // Cc returns the value of the "cc" field in the mutation.
  22680. func (m *MsgMutation) Cc() (r string, exists bool) {
  22681. v := m.cc
  22682. if v == nil {
  22683. return
  22684. }
  22685. return *v, true
  22686. }
  22687. // OldCc returns the old "cc" field's value of the Msg entity.
  22688. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22690. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  22691. if !m.op.Is(OpUpdateOne) {
  22692. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  22693. }
  22694. if m.id == nil || m.oldValue == nil {
  22695. return v, errors.New("OldCc requires an ID field in the mutation")
  22696. }
  22697. oldValue, err := m.oldValue(ctx)
  22698. if err != nil {
  22699. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  22700. }
  22701. return oldValue.Cc, nil
  22702. }
  22703. // ResetCc resets all changes to the "cc" field.
  22704. func (m *MsgMutation) ResetCc() {
  22705. m.cc = nil
  22706. }
  22707. // SetPhone sets the "phone" field.
  22708. func (m *MsgMutation) SetPhone(s string) {
  22709. m.phone = &s
  22710. }
  22711. // Phone returns the value of the "phone" field in the mutation.
  22712. func (m *MsgMutation) Phone() (r string, exists bool) {
  22713. v := m.phone
  22714. if v == nil {
  22715. return
  22716. }
  22717. return *v, true
  22718. }
  22719. // OldPhone returns the old "phone" 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) OldPhone(ctx context.Context) (v string, err error) {
  22723. if !m.op.Is(OpUpdateOne) {
  22724. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  22725. }
  22726. if m.id == nil || m.oldValue == nil {
  22727. return v, errors.New("OldPhone 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 OldPhone: %w", err)
  22732. }
  22733. return oldValue.Phone, nil
  22734. }
  22735. // ResetPhone resets all changes to the "phone" field.
  22736. func (m *MsgMutation) ResetPhone() {
  22737. m.phone = nil
  22738. }
  22739. // Where appends a list predicates to the MsgMutation builder.
  22740. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  22741. m.predicates = append(m.predicates, ps...)
  22742. }
  22743. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  22744. // users can use type-assertion to append predicates that do not depend on any generated package.
  22745. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  22746. p := make([]predicate.Msg, len(ps))
  22747. for i := range ps {
  22748. p[i] = ps[i]
  22749. }
  22750. m.Where(p...)
  22751. }
  22752. // Op returns the operation name.
  22753. func (m *MsgMutation) Op() Op {
  22754. return m.op
  22755. }
  22756. // SetOp allows setting the mutation operation.
  22757. func (m *MsgMutation) SetOp(op Op) {
  22758. m.op = op
  22759. }
  22760. // Type returns the node type of this mutation (Msg).
  22761. func (m *MsgMutation) Type() string {
  22762. return m.typ
  22763. }
  22764. // Fields returns all fields that were changed during this mutation. Note that in
  22765. // order to get all numeric fields that were incremented/decremented, call
  22766. // AddedFields().
  22767. func (m *MsgMutation) Fields() []string {
  22768. fields := make([]string, 0, 11)
  22769. if m.created_at != nil {
  22770. fields = append(fields, msg.FieldCreatedAt)
  22771. }
  22772. if m.updated_at != nil {
  22773. fields = append(fields, msg.FieldUpdatedAt)
  22774. }
  22775. if m.deleted_at != nil {
  22776. fields = append(fields, msg.FieldDeletedAt)
  22777. }
  22778. if m.status != nil {
  22779. fields = append(fields, msg.FieldStatus)
  22780. }
  22781. if m.fromwxid != nil {
  22782. fields = append(fields, msg.FieldFromwxid)
  22783. }
  22784. if m.toid != nil {
  22785. fields = append(fields, msg.FieldToid)
  22786. }
  22787. if m.msgtype != nil {
  22788. fields = append(fields, msg.FieldMsgtype)
  22789. }
  22790. if m.msg != nil {
  22791. fields = append(fields, msg.FieldMsg)
  22792. }
  22793. if m.batch_no != nil {
  22794. fields = append(fields, msg.FieldBatchNo)
  22795. }
  22796. if m.cc != nil {
  22797. fields = append(fields, msg.FieldCc)
  22798. }
  22799. if m.phone != nil {
  22800. fields = append(fields, msg.FieldPhone)
  22801. }
  22802. return fields
  22803. }
  22804. // Field returns the value of a field with the given name. The second boolean
  22805. // return value indicates that this field was not set, or was not defined in the
  22806. // schema.
  22807. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  22808. switch name {
  22809. case msg.FieldCreatedAt:
  22810. return m.CreatedAt()
  22811. case msg.FieldUpdatedAt:
  22812. return m.UpdatedAt()
  22813. case msg.FieldDeletedAt:
  22814. return m.DeletedAt()
  22815. case msg.FieldStatus:
  22816. return m.Status()
  22817. case msg.FieldFromwxid:
  22818. return m.Fromwxid()
  22819. case msg.FieldToid:
  22820. return m.Toid()
  22821. case msg.FieldMsgtype:
  22822. return m.Msgtype()
  22823. case msg.FieldMsg:
  22824. return m.Msg()
  22825. case msg.FieldBatchNo:
  22826. return m.BatchNo()
  22827. case msg.FieldCc:
  22828. return m.Cc()
  22829. case msg.FieldPhone:
  22830. return m.Phone()
  22831. }
  22832. return nil, false
  22833. }
  22834. // OldField returns the old value of the field from the database. An error is
  22835. // returned if the mutation operation is not UpdateOne, or the query to the
  22836. // database failed.
  22837. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22838. switch name {
  22839. case msg.FieldCreatedAt:
  22840. return m.OldCreatedAt(ctx)
  22841. case msg.FieldUpdatedAt:
  22842. return m.OldUpdatedAt(ctx)
  22843. case msg.FieldDeletedAt:
  22844. return m.OldDeletedAt(ctx)
  22845. case msg.FieldStatus:
  22846. return m.OldStatus(ctx)
  22847. case msg.FieldFromwxid:
  22848. return m.OldFromwxid(ctx)
  22849. case msg.FieldToid:
  22850. return m.OldToid(ctx)
  22851. case msg.FieldMsgtype:
  22852. return m.OldMsgtype(ctx)
  22853. case msg.FieldMsg:
  22854. return m.OldMsg(ctx)
  22855. case msg.FieldBatchNo:
  22856. return m.OldBatchNo(ctx)
  22857. case msg.FieldCc:
  22858. return m.OldCc(ctx)
  22859. case msg.FieldPhone:
  22860. return m.OldPhone(ctx)
  22861. }
  22862. return nil, fmt.Errorf("unknown Msg field %s", name)
  22863. }
  22864. // SetField sets the value of a field with the given name. It returns an error if
  22865. // the field is not defined in the schema, or if the type mismatched the field
  22866. // type.
  22867. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  22868. switch name {
  22869. case msg.FieldCreatedAt:
  22870. v, ok := value.(time.Time)
  22871. if !ok {
  22872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22873. }
  22874. m.SetCreatedAt(v)
  22875. return nil
  22876. case msg.FieldUpdatedAt:
  22877. v, ok := value.(time.Time)
  22878. if !ok {
  22879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22880. }
  22881. m.SetUpdatedAt(v)
  22882. return nil
  22883. case msg.FieldDeletedAt:
  22884. v, ok := value.(time.Time)
  22885. if !ok {
  22886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22887. }
  22888. m.SetDeletedAt(v)
  22889. return nil
  22890. case msg.FieldStatus:
  22891. v, ok := value.(uint8)
  22892. if !ok {
  22893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22894. }
  22895. m.SetStatus(v)
  22896. return nil
  22897. case msg.FieldFromwxid:
  22898. v, ok := value.(string)
  22899. if !ok {
  22900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22901. }
  22902. m.SetFromwxid(v)
  22903. return nil
  22904. case msg.FieldToid:
  22905. v, ok := value.(string)
  22906. if !ok {
  22907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22908. }
  22909. m.SetToid(v)
  22910. return nil
  22911. case msg.FieldMsgtype:
  22912. v, ok := value.(int32)
  22913. if !ok {
  22914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22915. }
  22916. m.SetMsgtype(v)
  22917. return nil
  22918. case msg.FieldMsg:
  22919. v, ok := value.(string)
  22920. if !ok {
  22921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22922. }
  22923. m.SetMsg(v)
  22924. return nil
  22925. case msg.FieldBatchNo:
  22926. v, ok := value.(string)
  22927. if !ok {
  22928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22929. }
  22930. m.SetBatchNo(v)
  22931. return nil
  22932. case msg.FieldCc:
  22933. v, ok := value.(string)
  22934. if !ok {
  22935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22936. }
  22937. m.SetCc(v)
  22938. return nil
  22939. case msg.FieldPhone:
  22940. v, ok := value.(string)
  22941. if !ok {
  22942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22943. }
  22944. m.SetPhone(v)
  22945. return nil
  22946. }
  22947. return fmt.Errorf("unknown Msg field %s", name)
  22948. }
  22949. // AddedFields returns all numeric fields that were incremented/decremented during
  22950. // this mutation.
  22951. func (m *MsgMutation) AddedFields() []string {
  22952. var fields []string
  22953. if m.addstatus != nil {
  22954. fields = append(fields, msg.FieldStatus)
  22955. }
  22956. if m.addmsgtype != nil {
  22957. fields = append(fields, msg.FieldMsgtype)
  22958. }
  22959. return fields
  22960. }
  22961. // AddedField returns the numeric value that was incremented/decremented on a field
  22962. // with the given name. The second boolean return value indicates that this field
  22963. // was not set, or was not defined in the schema.
  22964. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  22965. switch name {
  22966. case msg.FieldStatus:
  22967. return m.AddedStatus()
  22968. case msg.FieldMsgtype:
  22969. return m.AddedMsgtype()
  22970. }
  22971. return nil, false
  22972. }
  22973. // AddField adds the value to the field with the given name. It returns an error if
  22974. // the field is not defined in the schema, or if the type mismatched the field
  22975. // type.
  22976. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  22977. switch name {
  22978. case msg.FieldStatus:
  22979. v, ok := value.(int8)
  22980. if !ok {
  22981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22982. }
  22983. m.AddStatus(v)
  22984. return nil
  22985. case msg.FieldMsgtype:
  22986. v, ok := value.(int32)
  22987. if !ok {
  22988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22989. }
  22990. m.AddMsgtype(v)
  22991. return nil
  22992. }
  22993. return fmt.Errorf("unknown Msg numeric field %s", name)
  22994. }
  22995. // ClearedFields returns all nullable fields that were cleared during this
  22996. // mutation.
  22997. func (m *MsgMutation) ClearedFields() []string {
  22998. var fields []string
  22999. if m.FieldCleared(msg.FieldDeletedAt) {
  23000. fields = append(fields, msg.FieldDeletedAt)
  23001. }
  23002. if m.FieldCleared(msg.FieldStatus) {
  23003. fields = append(fields, msg.FieldStatus)
  23004. }
  23005. if m.FieldCleared(msg.FieldFromwxid) {
  23006. fields = append(fields, msg.FieldFromwxid)
  23007. }
  23008. if m.FieldCleared(msg.FieldToid) {
  23009. fields = append(fields, msg.FieldToid)
  23010. }
  23011. if m.FieldCleared(msg.FieldMsgtype) {
  23012. fields = append(fields, msg.FieldMsgtype)
  23013. }
  23014. if m.FieldCleared(msg.FieldMsg) {
  23015. fields = append(fields, msg.FieldMsg)
  23016. }
  23017. if m.FieldCleared(msg.FieldBatchNo) {
  23018. fields = append(fields, msg.FieldBatchNo)
  23019. }
  23020. return fields
  23021. }
  23022. // FieldCleared returns a boolean indicating if a field with the given name was
  23023. // cleared in this mutation.
  23024. func (m *MsgMutation) FieldCleared(name string) bool {
  23025. _, ok := m.clearedFields[name]
  23026. return ok
  23027. }
  23028. // ClearField clears the value of the field with the given name. It returns an
  23029. // error if the field is not defined in the schema.
  23030. func (m *MsgMutation) ClearField(name string) error {
  23031. switch name {
  23032. case msg.FieldDeletedAt:
  23033. m.ClearDeletedAt()
  23034. return nil
  23035. case msg.FieldStatus:
  23036. m.ClearStatus()
  23037. return nil
  23038. case msg.FieldFromwxid:
  23039. m.ClearFromwxid()
  23040. return nil
  23041. case msg.FieldToid:
  23042. m.ClearToid()
  23043. return nil
  23044. case msg.FieldMsgtype:
  23045. m.ClearMsgtype()
  23046. return nil
  23047. case msg.FieldMsg:
  23048. m.ClearMsg()
  23049. return nil
  23050. case msg.FieldBatchNo:
  23051. m.ClearBatchNo()
  23052. return nil
  23053. }
  23054. return fmt.Errorf("unknown Msg nullable field %s", name)
  23055. }
  23056. // ResetField resets all changes in the mutation for the field with the given name.
  23057. // It returns an error if the field is not defined in the schema.
  23058. func (m *MsgMutation) ResetField(name string) error {
  23059. switch name {
  23060. case msg.FieldCreatedAt:
  23061. m.ResetCreatedAt()
  23062. return nil
  23063. case msg.FieldUpdatedAt:
  23064. m.ResetUpdatedAt()
  23065. return nil
  23066. case msg.FieldDeletedAt:
  23067. m.ResetDeletedAt()
  23068. return nil
  23069. case msg.FieldStatus:
  23070. m.ResetStatus()
  23071. return nil
  23072. case msg.FieldFromwxid:
  23073. m.ResetFromwxid()
  23074. return nil
  23075. case msg.FieldToid:
  23076. m.ResetToid()
  23077. return nil
  23078. case msg.FieldMsgtype:
  23079. m.ResetMsgtype()
  23080. return nil
  23081. case msg.FieldMsg:
  23082. m.ResetMsg()
  23083. return nil
  23084. case msg.FieldBatchNo:
  23085. m.ResetBatchNo()
  23086. return nil
  23087. case msg.FieldCc:
  23088. m.ResetCc()
  23089. return nil
  23090. case msg.FieldPhone:
  23091. m.ResetPhone()
  23092. return nil
  23093. }
  23094. return fmt.Errorf("unknown Msg field %s", name)
  23095. }
  23096. // AddedEdges returns all edge names that were set/added in this mutation.
  23097. func (m *MsgMutation) AddedEdges() []string {
  23098. edges := make([]string, 0, 0)
  23099. return edges
  23100. }
  23101. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23102. // name in this mutation.
  23103. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  23104. return nil
  23105. }
  23106. // RemovedEdges returns all edge names that were removed in this mutation.
  23107. func (m *MsgMutation) RemovedEdges() []string {
  23108. edges := make([]string, 0, 0)
  23109. return edges
  23110. }
  23111. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23112. // the given name in this mutation.
  23113. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  23114. return nil
  23115. }
  23116. // ClearedEdges returns all edge names that were cleared in this mutation.
  23117. func (m *MsgMutation) ClearedEdges() []string {
  23118. edges := make([]string, 0, 0)
  23119. return edges
  23120. }
  23121. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23122. // was cleared in this mutation.
  23123. func (m *MsgMutation) EdgeCleared(name string) bool {
  23124. return false
  23125. }
  23126. // ClearEdge clears the value of the edge with the given name. It returns an error
  23127. // if that edge is not defined in the schema.
  23128. func (m *MsgMutation) ClearEdge(name string) error {
  23129. return fmt.Errorf("unknown Msg unique edge %s", name)
  23130. }
  23131. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23132. // It returns an error if the edge is not defined in the schema.
  23133. func (m *MsgMutation) ResetEdge(name string) error {
  23134. return fmt.Errorf("unknown Msg edge %s", name)
  23135. }
  23136. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  23137. type PayRechargeMutation struct {
  23138. config
  23139. op Op
  23140. typ string
  23141. id *uint64
  23142. created_at *time.Time
  23143. updated_at *time.Time
  23144. deleted_at *time.Time
  23145. user_id *string
  23146. number *float32
  23147. addnumber *float32
  23148. status *int
  23149. addstatus *int
  23150. money *float32
  23151. addmoney *float32
  23152. out_trade_no *string
  23153. organization_id *uint64
  23154. addorganization_id *int64
  23155. clearedFields map[string]struct{}
  23156. done bool
  23157. oldValue func(context.Context) (*PayRecharge, error)
  23158. predicates []predicate.PayRecharge
  23159. }
  23160. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  23161. // payrechargeOption allows management of the mutation configuration using functional options.
  23162. type payrechargeOption func(*PayRechargeMutation)
  23163. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  23164. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  23165. m := &PayRechargeMutation{
  23166. config: c,
  23167. op: op,
  23168. typ: TypePayRecharge,
  23169. clearedFields: make(map[string]struct{}),
  23170. }
  23171. for _, opt := range opts {
  23172. opt(m)
  23173. }
  23174. return m
  23175. }
  23176. // withPayRechargeID sets the ID field of the mutation.
  23177. func withPayRechargeID(id uint64) payrechargeOption {
  23178. return func(m *PayRechargeMutation) {
  23179. var (
  23180. err error
  23181. once sync.Once
  23182. value *PayRecharge
  23183. )
  23184. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  23185. once.Do(func() {
  23186. if m.done {
  23187. err = errors.New("querying old values post mutation is not allowed")
  23188. } else {
  23189. value, err = m.Client().PayRecharge.Get(ctx, id)
  23190. }
  23191. })
  23192. return value, err
  23193. }
  23194. m.id = &id
  23195. }
  23196. }
  23197. // withPayRecharge sets the old PayRecharge of the mutation.
  23198. func withPayRecharge(node *PayRecharge) payrechargeOption {
  23199. return func(m *PayRechargeMutation) {
  23200. m.oldValue = func(context.Context) (*PayRecharge, error) {
  23201. return node, nil
  23202. }
  23203. m.id = &node.ID
  23204. }
  23205. }
  23206. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23207. // executed in a transaction (ent.Tx), a transactional client is returned.
  23208. func (m PayRechargeMutation) Client() *Client {
  23209. client := &Client{config: m.config}
  23210. client.init()
  23211. return client
  23212. }
  23213. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23214. // it returns an error otherwise.
  23215. func (m PayRechargeMutation) Tx() (*Tx, error) {
  23216. if _, ok := m.driver.(*txDriver); !ok {
  23217. return nil, errors.New("ent: mutation is not running in a transaction")
  23218. }
  23219. tx := &Tx{config: m.config}
  23220. tx.init()
  23221. return tx, nil
  23222. }
  23223. // SetID sets the value of the id field. Note that this
  23224. // operation is only accepted on creation of PayRecharge entities.
  23225. func (m *PayRechargeMutation) SetID(id uint64) {
  23226. m.id = &id
  23227. }
  23228. // ID returns the ID value in the mutation. Note that the ID is only available
  23229. // if it was provided to the builder or after it was returned from the database.
  23230. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  23231. if m.id == nil {
  23232. return
  23233. }
  23234. return *m.id, true
  23235. }
  23236. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23237. // That means, if the mutation is applied within a transaction with an isolation level such
  23238. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23239. // or updated by the mutation.
  23240. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23241. switch {
  23242. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23243. id, exists := m.ID()
  23244. if exists {
  23245. return []uint64{id}, nil
  23246. }
  23247. fallthrough
  23248. case m.op.Is(OpUpdate | OpDelete):
  23249. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  23250. default:
  23251. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23252. }
  23253. }
  23254. // SetCreatedAt sets the "created_at" field.
  23255. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  23256. m.created_at = &t
  23257. }
  23258. // CreatedAt returns the value of the "created_at" field in the mutation.
  23259. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  23260. v := m.created_at
  23261. if v == nil {
  23262. return
  23263. }
  23264. return *v, true
  23265. }
  23266. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  23267. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23269. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23270. if !m.op.Is(OpUpdateOne) {
  23271. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23272. }
  23273. if m.id == nil || m.oldValue == nil {
  23274. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23275. }
  23276. oldValue, err := m.oldValue(ctx)
  23277. if err != nil {
  23278. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23279. }
  23280. return oldValue.CreatedAt, nil
  23281. }
  23282. // ResetCreatedAt resets all changes to the "created_at" field.
  23283. func (m *PayRechargeMutation) ResetCreatedAt() {
  23284. m.created_at = nil
  23285. }
  23286. // SetUpdatedAt sets the "updated_at" field.
  23287. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  23288. m.updated_at = &t
  23289. }
  23290. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23291. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  23292. v := m.updated_at
  23293. if v == nil {
  23294. return
  23295. }
  23296. return *v, true
  23297. }
  23298. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23302. if !m.op.Is(OpUpdateOne) {
  23303. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23304. }
  23305. if m.id == nil || m.oldValue == nil {
  23306. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  23311. }
  23312. return oldValue.UpdatedAt, nil
  23313. }
  23314. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23315. func (m *PayRechargeMutation) ResetUpdatedAt() {
  23316. m.updated_at = nil
  23317. }
  23318. // SetDeletedAt sets the "deleted_at" field.
  23319. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  23320. m.deleted_at = &t
  23321. }
  23322. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23323. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  23324. v := m.deleted_at
  23325. if v == nil {
  23326. return
  23327. }
  23328. return *v, true
  23329. }
  23330. // OldDeletedAt returns the old "deleted_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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23334. if !m.op.Is(OpUpdateOne) {
  23335. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23336. }
  23337. if m.id == nil || m.oldValue == nil {
  23338. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  23343. }
  23344. return oldValue.DeletedAt, nil
  23345. }
  23346. // ClearDeletedAt clears the value of the "deleted_at" field.
  23347. func (m *PayRechargeMutation) ClearDeletedAt() {
  23348. m.deleted_at = nil
  23349. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  23350. }
  23351. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23352. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  23353. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  23354. return ok
  23355. }
  23356. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23357. func (m *PayRechargeMutation) ResetDeletedAt() {
  23358. m.deleted_at = nil
  23359. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  23360. }
  23361. // SetUserID sets the "user_id" field.
  23362. func (m *PayRechargeMutation) SetUserID(s string) {
  23363. m.user_id = &s
  23364. }
  23365. // UserID returns the value of the "user_id" field in the mutation.
  23366. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  23367. v := m.user_id
  23368. if v == nil {
  23369. return
  23370. }
  23371. return *v, true
  23372. }
  23373. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  23374. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23376. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  23377. if !m.op.Is(OpUpdateOne) {
  23378. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  23379. }
  23380. if m.id == nil || m.oldValue == nil {
  23381. return v, errors.New("OldUserID requires an ID field in the mutation")
  23382. }
  23383. oldValue, err := m.oldValue(ctx)
  23384. if err != nil {
  23385. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  23386. }
  23387. return oldValue.UserID, nil
  23388. }
  23389. // ResetUserID resets all changes to the "user_id" field.
  23390. func (m *PayRechargeMutation) ResetUserID() {
  23391. m.user_id = nil
  23392. }
  23393. // SetNumber sets the "number" field.
  23394. func (m *PayRechargeMutation) SetNumber(f float32) {
  23395. m.number = &f
  23396. m.addnumber = nil
  23397. }
  23398. // Number returns the value of the "number" field in the mutation.
  23399. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  23400. v := m.number
  23401. if v == nil {
  23402. return
  23403. }
  23404. return *v, true
  23405. }
  23406. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  23407. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23409. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  23410. if !m.op.Is(OpUpdateOne) {
  23411. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  23412. }
  23413. if m.id == nil || m.oldValue == nil {
  23414. return v, errors.New("OldNumber requires an ID field in the mutation")
  23415. }
  23416. oldValue, err := m.oldValue(ctx)
  23417. if err != nil {
  23418. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  23419. }
  23420. return oldValue.Number, nil
  23421. }
  23422. // AddNumber adds f to the "number" field.
  23423. func (m *PayRechargeMutation) AddNumber(f float32) {
  23424. if m.addnumber != nil {
  23425. *m.addnumber += f
  23426. } else {
  23427. m.addnumber = &f
  23428. }
  23429. }
  23430. // AddedNumber returns the value that was added to the "number" field in this mutation.
  23431. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  23432. v := m.addnumber
  23433. if v == nil {
  23434. return
  23435. }
  23436. return *v, true
  23437. }
  23438. // ResetNumber resets all changes to the "number" field.
  23439. func (m *PayRechargeMutation) ResetNumber() {
  23440. m.number = nil
  23441. m.addnumber = nil
  23442. }
  23443. // SetStatus sets the "status" field.
  23444. func (m *PayRechargeMutation) SetStatus(i int) {
  23445. m.status = &i
  23446. m.addstatus = nil
  23447. }
  23448. // Status returns the value of the "status" field in the mutation.
  23449. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  23450. v := m.status
  23451. if v == nil {
  23452. return
  23453. }
  23454. return *v, true
  23455. }
  23456. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  23457. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23459. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  23460. if !m.op.Is(OpUpdateOne) {
  23461. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23462. }
  23463. if m.id == nil || m.oldValue == nil {
  23464. return v, errors.New("OldStatus requires an ID field in the mutation")
  23465. }
  23466. oldValue, err := m.oldValue(ctx)
  23467. if err != nil {
  23468. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23469. }
  23470. return oldValue.Status, nil
  23471. }
  23472. // AddStatus adds i to the "status" field.
  23473. func (m *PayRechargeMutation) AddStatus(i int) {
  23474. if m.addstatus != nil {
  23475. *m.addstatus += i
  23476. } else {
  23477. m.addstatus = &i
  23478. }
  23479. }
  23480. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23481. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  23482. v := m.addstatus
  23483. if v == nil {
  23484. return
  23485. }
  23486. return *v, true
  23487. }
  23488. // ClearStatus clears the value of the "status" field.
  23489. func (m *PayRechargeMutation) ClearStatus() {
  23490. m.status = nil
  23491. m.addstatus = nil
  23492. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  23493. }
  23494. // StatusCleared returns if the "status" field was cleared in this mutation.
  23495. func (m *PayRechargeMutation) StatusCleared() bool {
  23496. _, ok := m.clearedFields[payrecharge.FieldStatus]
  23497. return ok
  23498. }
  23499. // ResetStatus resets all changes to the "status" field.
  23500. func (m *PayRechargeMutation) ResetStatus() {
  23501. m.status = nil
  23502. m.addstatus = nil
  23503. delete(m.clearedFields, payrecharge.FieldStatus)
  23504. }
  23505. // SetMoney sets the "money" field.
  23506. func (m *PayRechargeMutation) SetMoney(f float32) {
  23507. m.money = &f
  23508. m.addmoney = nil
  23509. }
  23510. // Money returns the value of the "money" field in the mutation.
  23511. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  23512. v := m.money
  23513. if v == nil {
  23514. return
  23515. }
  23516. return *v, true
  23517. }
  23518. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  23519. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23521. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  23522. if !m.op.Is(OpUpdateOne) {
  23523. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  23524. }
  23525. if m.id == nil || m.oldValue == nil {
  23526. return v, errors.New("OldMoney requires an ID field in the mutation")
  23527. }
  23528. oldValue, err := m.oldValue(ctx)
  23529. if err != nil {
  23530. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  23531. }
  23532. return oldValue.Money, nil
  23533. }
  23534. // AddMoney adds f to the "money" field.
  23535. func (m *PayRechargeMutation) AddMoney(f float32) {
  23536. if m.addmoney != nil {
  23537. *m.addmoney += f
  23538. } else {
  23539. m.addmoney = &f
  23540. }
  23541. }
  23542. // AddedMoney returns the value that was added to the "money" field in this mutation.
  23543. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  23544. v := m.addmoney
  23545. if v == nil {
  23546. return
  23547. }
  23548. return *v, true
  23549. }
  23550. // ClearMoney clears the value of the "money" field.
  23551. func (m *PayRechargeMutation) ClearMoney() {
  23552. m.money = nil
  23553. m.addmoney = nil
  23554. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  23555. }
  23556. // MoneyCleared returns if the "money" field was cleared in this mutation.
  23557. func (m *PayRechargeMutation) MoneyCleared() bool {
  23558. _, ok := m.clearedFields[payrecharge.FieldMoney]
  23559. return ok
  23560. }
  23561. // ResetMoney resets all changes to the "money" field.
  23562. func (m *PayRechargeMutation) ResetMoney() {
  23563. m.money = nil
  23564. m.addmoney = nil
  23565. delete(m.clearedFields, payrecharge.FieldMoney)
  23566. }
  23567. // SetOutTradeNo sets the "out_trade_no" field.
  23568. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  23569. m.out_trade_no = &s
  23570. }
  23571. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  23572. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  23573. v := m.out_trade_no
  23574. if v == nil {
  23575. return
  23576. }
  23577. return *v, true
  23578. }
  23579. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  23580. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23582. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  23583. if !m.op.Is(OpUpdateOne) {
  23584. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  23585. }
  23586. if m.id == nil || m.oldValue == nil {
  23587. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  23588. }
  23589. oldValue, err := m.oldValue(ctx)
  23590. if err != nil {
  23591. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  23592. }
  23593. return oldValue.OutTradeNo, nil
  23594. }
  23595. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  23596. func (m *PayRechargeMutation) ClearOutTradeNo() {
  23597. m.out_trade_no = nil
  23598. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  23599. }
  23600. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  23601. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  23602. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  23603. return ok
  23604. }
  23605. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  23606. func (m *PayRechargeMutation) ResetOutTradeNo() {
  23607. m.out_trade_no = nil
  23608. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  23609. }
  23610. // SetOrganizationID sets the "organization_id" field.
  23611. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  23612. m.organization_id = &u
  23613. m.addorganization_id = nil
  23614. }
  23615. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23616. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  23617. v := m.organization_id
  23618. if v == nil {
  23619. return
  23620. }
  23621. return *v, true
  23622. }
  23623. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  23624. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23626. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23627. if !m.op.Is(OpUpdateOne) {
  23628. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23629. }
  23630. if m.id == nil || m.oldValue == nil {
  23631. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23632. }
  23633. oldValue, err := m.oldValue(ctx)
  23634. if err != nil {
  23635. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23636. }
  23637. return oldValue.OrganizationID, nil
  23638. }
  23639. // AddOrganizationID adds u to the "organization_id" field.
  23640. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  23641. if m.addorganization_id != nil {
  23642. *m.addorganization_id += u
  23643. } else {
  23644. m.addorganization_id = &u
  23645. }
  23646. }
  23647. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23648. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  23649. v := m.addorganization_id
  23650. if v == nil {
  23651. return
  23652. }
  23653. return *v, true
  23654. }
  23655. // ResetOrganizationID resets all changes to the "organization_id" field.
  23656. func (m *PayRechargeMutation) ResetOrganizationID() {
  23657. m.organization_id = nil
  23658. m.addorganization_id = nil
  23659. }
  23660. // Where appends a list predicates to the PayRechargeMutation builder.
  23661. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  23662. m.predicates = append(m.predicates, ps...)
  23663. }
  23664. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  23665. // users can use type-assertion to append predicates that do not depend on any generated package.
  23666. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  23667. p := make([]predicate.PayRecharge, len(ps))
  23668. for i := range ps {
  23669. p[i] = ps[i]
  23670. }
  23671. m.Where(p...)
  23672. }
  23673. // Op returns the operation name.
  23674. func (m *PayRechargeMutation) Op() Op {
  23675. return m.op
  23676. }
  23677. // SetOp allows setting the mutation operation.
  23678. func (m *PayRechargeMutation) SetOp(op Op) {
  23679. m.op = op
  23680. }
  23681. // Type returns the node type of this mutation (PayRecharge).
  23682. func (m *PayRechargeMutation) Type() string {
  23683. return m.typ
  23684. }
  23685. // Fields returns all fields that were changed during this mutation. Note that in
  23686. // order to get all numeric fields that were incremented/decremented, call
  23687. // AddedFields().
  23688. func (m *PayRechargeMutation) Fields() []string {
  23689. fields := make([]string, 0, 9)
  23690. if m.created_at != nil {
  23691. fields = append(fields, payrecharge.FieldCreatedAt)
  23692. }
  23693. if m.updated_at != nil {
  23694. fields = append(fields, payrecharge.FieldUpdatedAt)
  23695. }
  23696. if m.deleted_at != nil {
  23697. fields = append(fields, payrecharge.FieldDeletedAt)
  23698. }
  23699. if m.user_id != nil {
  23700. fields = append(fields, payrecharge.FieldUserID)
  23701. }
  23702. if m.number != nil {
  23703. fields = append(fields, payrecharge.FieldNumber)
  23704. }
  23705. if m.status != nil {
  23706. fields = append(fields, payrecharge.FieldStatus)
  23707. }
  23708. if m.money != nil {
  23709. fields = append(fields, payrecharge.FieldMoney)
  23710. }
  23711. if m.out_trade_no != nil {
  23712. fields = append(fields, payrecharge.FieldOutTradeNo)
  23713. }
  23714. if m.organization_id != nil {
  23715. fields = append(fields, payrecharge.FieldOrganizationID)
  23716. }
  23717. return fields
  23718. }
  23719. // Field returns the value of a field with the given name. The second boolean
  23720. // return value indicates that this field was not set, or was not defined in the
  23721. // schema.
  23722. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  23723. switch name {
  23724. case payrecharge.FieldCreatedAt:
  23725. return m.CreatedAt()
  23726. case payrecharge.FieldUpdatedAt:
  23727. return m.UpdatedAt()
  23728. case payrecharge.FieldDeletedAt:
  23729. return m.DeletedAt()
  23730. case payrecharge.FieldUserID:
  23731. return m.UserID()
  23732. case payrecharge.FieldNumber:
  23733. return m.Number()
  23734. case payrecharge.FieldStatus:
  23735. return m.Status()
  23736. case payrecharge.FieldMoney:
  23737. return m.Money()
  23738. case payrecharge.FieldOutTradeNo:
  23739. return m.OutTradeNo()
  23740. case payrecharge.FieldOrganizationID:
  23741. return m.OrganizationID()
  23742. }
  23743. return nil, false
  23744. }
  23745. // OldField returns the old value of the field from the database. An error is
  23746. // returned if the mutation operation is not UpdateOne, or the query to the
  23747. // database failed.
  23748. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23749. switch name {
  23750. case payrecharge.FieldCreatedAt:
  23751. return m.OldCreatedAt(ctx)
  23752. case payrecharge.FieldUpdatedAt:
  23753. return m.OldUpdatedAt(ctx)
  23754. case payrecharge.FieldDeletedAt:
  23755. return m.OldDeletedAt(ctx)
  23756. case payrecharge.FieldUserID:
  23757. return m.OldUserID(ctx)
  23758. case payrecharge.FieldNumber:
  23759. return m.OldNumber(ctx)
  23760. case payrecharge.FieldStatus:
  23761. return m.OldStatus(ctx)
  23762. case payrecharge.FieldMoney:
  23763. return m.OldMoney(ctx)
  23764. case payrecharge.FieldOutTradeNo:
  23765. return m.OldOutTradeNo(ctx)
  23766. case payrecharge.FieldOrganizationID:
  23767. return m.OldOrganizationID(ctx)
  23768. }
  23769. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  23770. }
  23771. // SetField sets the value of a field with the given name. It returns an error if
  23772. // the field is not defined in the schema, or if the type mismatched the field
  23773. // type.
  23774. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  23775. switch name {
  23776. case payrecharge.FieldCreatedAt:
  23777. v, ok := value.(time.Time)
  23778. if !ok {
  23779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23780. }
  23781. m.SetCreatedAt(v)
  23782. return nil
  23783. case payrecharge.FieldUpdatedAt:
  23784. v, ok := value.(time.Time)
  23785. if !ok {
  23786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23787. }
  23788. m.SetUpdatedAt(v)
  23789. return nil
  23790. case payrecharge.FieldDeletedAt:
  23791. v, ok := value.(time.Time)
  23792. if !ok {
  23793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23794. }
  23795. m.SetDeletedAt(v)
  23796. return nil
  23797. case payrecharge.FieldUserID:
  23798. v, ok := value.(string)
  23799. if !ok {
  23800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23801. }
  23802. m.SetUserID(v)
  23803. return nil
  23804. case payrecharge.FieldNumber:
  23805. v, ok := value.(float32)
  23806. if !ok {
  23807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23808. }
  23809. m.SetNumber(v)
  23810. return nil
  23811. case payrecharge.FieldStatus:
  23812. v, ok := value.(int)
  23813. if !ok {
  23814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23815. }
  23816. m.SetStatus(v)
  23817. return nil
  23818. case payrecharge.FieldMoney:
  23819. v, ok := value.(float32)
  23820. if !ok {
  23821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23822. }
  23823. m.SetMoney(v)
  23824. return nil
  23825. case payrecharge.FieldOutTradeNo:
  23826. v, ok := value.(string)
  23827. if !ok {
  23828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23829. }
  23830. m.SetOutTradeNo(v)
  23831. return nil
  23832. case payrecharge.FieldOrganizationID:
  23833. v, ok := value.(uint64)
  23834. if !ok {
  23835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23836. }
  23837. m.SetOrganizationID(v)
  23838. return nil
  23839. }
  23840. return fmt.Errorf("unknown PayRecharge field %s", name)
  23841. }
  23842. // AddedFields returns all numeric fields that were incremented/decremented during
  23843. // this mutation.
  23844. func (m *PayRechargeMutation) AddedFields() []string {
  23845. var fields []string
  23846. if m.addnumber != nil {
  23847. fields = append(fields, payrecharge.FieldNumber)
  23848. }
  23849. if m.addstatus != nil {
  23850. fields = append(fields, payrecharge.FieldStatus)
  23851. }
  23852. if m.addmoney != nil {
  23853. fields = append(fields, payrecharge.FieldMoney)
  23854. }
  23855. if m.addorganization_id != nil {
  23856. fields = append(fields, payrecharge.FieldOrganizationID)
  23857. }
  23858. return fields
  23859. }
  23860. // AddedField returns the numeric value that was incremented/decremented on a field
  23861. // with the given name. The second boolean return value indicates that this field
  23862. // was not set, or was not defined in the schema.
  23863. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  23864. switch name {
  23865. case payrecharge.FieldNumber:
  23866. return m.AddedNumber()
  23867. case payrecharge.FieldStatus:
  23868. return m.AddedStatus()
  23869. case payrecharge.FieldMoney:
  23870. return m.AddedMoney()
  23871. case payrecharge.FieldOrganizationID:
  23872. return m.AddedOrganizationID()
  23873. }
  23874. return nil, false
  23875. }
  23876. // AddField adds the value to the field with the given name. It returns an error if
  23877. // the field is not defined in the schema, or if the type mismatched the field
  23878. // type.
  23879. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  23880. switch name {
  23881. case payrecharge.FieldNumber:
  23882. v, ok := value.(float32)
  23883. if !ok {
  23884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23885. }
  23886. m.AddNumber(v)
  23887. return nil
  23888. case payrecharge.FieldStatus:
  23889. v, ok := value.(int)
  23890. if !ok {
  23891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23892. }
  23893. m.AddStatus(v)
  23894. return nil
  23895. case payrecharge.FieldMoney:
  23896. v, ok := value.(float32)
  23897. if !ok {
  23898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23899. }
  23900. m.AddMoney(v)
  23901. return nil
  23902. case payrecharge.FieldOrganizationID:
  23903. v, ok := value.(int64)
  23904. if !ok {
  23905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23906. }
  23907. m.AddOrganizationID(v)
  23908. return nil
  23909. }
  23910. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  23911. }
  23912. // ClearedFields returns all nullable fields that were cleared during this
  23913. // mutation.
  23914. func (m *PayRechargeMutation) ClearedFields() []string {
  23915. var fields []string
  23916. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  23917. fields = append(fields, payrecharge.FieldDeletedAt)
  23918. }
  23919. if m.FieldCleared(payrecharge.FieldStatus) {
  23920. fields = append(fields, payrecharge.FieldStatus)
  23921. }
  23922. if m.FieldCleared(payrecharge.FieldMoney) {
  23923. fields = append(fields, payrecharge.FieldMoney)
  23924. }
  23925. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  23926. fields = append(fields, payrecharge.FieldOutTradeNo)
  23927. }
  23928. return fields
  23929. }
  23930. // FieldCleared returns a boolean indicating if a field with the given name was
  23931. // cleared in this mutation.
  23932. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  23933. _, ok := m.clearedFields[name]
  23934. return ok
  23935. }
  23936. // ClearField clears the value of the field with the given name. It returns an
  23937. // error if the field is not defined in the schema.
  23938. func (m *PayRechargeMutation) ClearField(name string) error {
  23939. switch name {
  23940. case payrecharge.FieldDeletedAt:
  23941. m.ClearDeletedAt()
  23942. return nil
  23943. case payrecharge.FieldStatus:
  23944. m.ClearStatus()
  23945. return nil
  23946. case payrecharge.FieldMoney:
  23947. m.ClearMoney()
  23948. return nil
  23949. case payrecharge.FieldOutTradeNo:
  23950. m.ClearOutTradeNo()
  23951. return nil
  23952. }
  23953. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  23954. }
  23955. // ResetField resets all changes in the mutation for the field with the given name.
  23956. // It returns an error if the field is not defined in the schema.
  23957. func (m *PayRechargeMutation) ResetField(name string) error {
  23958. switch name {
  23959. case payrecharge.FieldCreatedAt:
  23960. m.ResetCreatedAt()
  23961. return nil
  23962. case payrecharge.FieldUpdatedAt:
  23963. m.ResetUpdatedAt()
  23964. return nil
  23965. case payrecharge.FieldDeletedAt:
  23966. m.ResetDeletedAt()
  23967. return nil
  23968. case payrecharge.FieldUserID:
  23969. m.ResetUserID()
  23970. return nil
  23971. case payrecharge.FieldNumber:
  23972. m.ResetNumber()
  23973. return nil
  23974. case payrecharge.FieldStatus:
  23975. m.ResetStatus()
  23976. return nil
  23977. case payrecharge.FieldMoney:
  23978. m.ResetMoney()
  23979. return nil
  23980. case payrecharge.FieldOutTradeNo:
  23981. m.ResetOutTradeNo()
  23982. return nil
  23983. case payrecharge.FieldOrganizationID:
  23984. m.ResetOrganizationID()
  23985. return nil
  23986. }
  23987. return fmt.Errorf("unknown PayRecharge field %s", name)
  23988. }
  23989. // AddedEdges returns all edge names that were set/added in this mutation.
  23990. func (m *PayRechargeMutation) AddedEdges() []string {
  23991. edges := make([]string, 0, 0)
  23992. return edges
  23993. }
  23994. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23995. // name in this mutation.
  23996. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  23997. return nil
  23998. }
  23999. // RemovedEdges returns all edge names that were removed in this mutation.
  24000. func (m *PayRechargeMutation) RemovedEdges() []string {
  24001. edges := make([]string, 0, 0)
  24002. return edges
  24003. }
  24004. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24005. // the given name in this mutation.
  24006. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  24007. return nil
  24008. }
  24009. // ClearedEdges returns all edge names that were cleared in this mutation.
  24010. func (m *PayRechargeMutation) ClearedEdges() []string {
  24011. edges := make([]string, 0, 0)
  24012. return edges
  24013. }
  24014. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24015. // was cleared in this mutation.
  24016. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  24017. return false
  24018. }
  24019. // ClearEdge clears the value of the edge with the given name. It returns an error
  24020. // if that edge is not defined in the schema.
  24021. func (m *PayRechargeMutation) ClearEdge(name string) error {
  24022. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  24023. }
  24024. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24025. // It returns an error if the edge is not defined in the schema.
  24026. func (m *PayRechargeMutation) ResetEdge(name string) error {
  24027. return fmt.Errorf("unknown PayRecharge edge %s", name)
  24028. }
  24029. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  24030. type ServerMutation struct {
  24031. config
  24032. op Op
  24033. typ string
  24034. id *uint64
  24035. created_at *time.Time
  24036. updated_at *time.Time
  24037. status *uint8
  24038. addstatus *int8
  24039. deleted_at *time.Time
  24040. name *string
  24041. public_ip *string
  24042. private_ip *string
  24043. admin_port *string
  24044. clearedFields map[string]struct{}
  24045. wxs map[uint64]struct{}
  24046. removedwxs map[uint64]struct{}
  24047. clearedwxs bool
  24048. done bool
  24049. oldValue func(context.Context) (*Server, error)
  24050. predicates []predicate.Server
  24051. }
  24052. var _ ent.Mutation = (*ServerMutation)(nil)
  24053. // serverOption allows management of the mutation configuration using functional options.
  24054. type serverOption func(*ServerMutation)
  24055. // newServerMutation creates new mutation for the Server entity.
  24056. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  24057. m := &ServerMutation{
  24058. config: c,
  24059. op: op,
  24060. typ: TypeServer,
  24061. clearedFields: make(map[string]struct{}),
  24062. }
  24063. for _, opt := range opts {
  24064. opt(m)
  24065. }
  24066. return m
  24067. }
  24068. // withServerID sets the ID field of the mutation.
  24069. func withServerID(id uint64) serverOption {
  24070. return func(m *ServerMutation) {
  24071. var (
  24072. err error
  24073. once sync.Once
  24074. value *Server
  24075. )
  24076. m.oldValue = func(ctx context.Context) (*Server, error) {
  24077. once.Do(func() {
  24078. if m.done {
  24079. err = errors.New("querying old values post mutation is not allowed")
  24080. } else {
  24081. value, err = m.Client().Server.Get(ctx, id)
  24082. }
  24083. })
  24084. return value, err
  24085. }
  24086. m.id = &id
  24087. }
  24088. }
  24089. // withServer sets the old Server of the mutation.
  24090. func withServer(node *Server) serverOption {
  24091. return func(m *ServerMutation) {
  24092. m.oldValue = func(context.Context) (*Server, error) {
  24093. return node, nil
  24094. }
  24095. m.id = &node.ID
  24096. }
  24097. }
  24098. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24099. // executed in a transaction (ent.Tx), a transactional client is returned.
  24100. func (m ServerMutation) Client() *Client {
  24101. client := &Client{config: m.config}
  24102. client.init()
  24103. return client
  24104. }
  24105. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24106. // it returns an error otherwise.
  24107. func (m ServerMutation) Tx() (*Tx, error) {
  24108. if _, ok := m.driver.(*txDriver); !ok {
  24109. return nil, errors.New("ent: mutation is not running in a transaction")
  24110. }
  24111. tx := &Tx{config: m.config}
  24112. tx.init()
  24113. return tx, nil
  24114. }
  24115. // SetID sets the value of the id field. Note that this
  24116. // operation is only accepted on creation of Server entities.
  24117. func (m *ServerMutation) SetID(id uint64) {
  24118. m.id = &id
  24119. }
  24120. // ID returns the ID value in the mutation. Note that the ID is only available
  24121. // if it was provided to the builder or after it was returned from the database.
  24122. func (m *ServerMutation) ID() (id uint64, exists bool) {
  24123. if m.id == nil {
  24124. return
  24125. }
  24126. return *m.id, true
  24127. }
  24128. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24129. // That means, if the mutation is applied within a transaction with an isolation level such
  24130. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24131. // or updated by the mutation.
  24132. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  24133. switch {
  24134. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24135. id, exists := m.ID()
  24136. if exists {
  24137. return []uint64{id}, nil
  24138. }
  24139. fallthrough
  24140. case m.op.Is(OpUpdate | OpDelete):
  24141. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  24142. default:
  24143. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24144. }
  24145. }
  24146. // SetCreatedAt sets the "created_at" field.
  24147. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  24148. m.created_at = &t
  24149. }
  24150. // CreatedAt returns the value of the "created_at" field in the mutation.
  24151. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  24152. v := m.created_at
  24153. if v == nil {
  24154. return
  24155. }
  24156. return *v, true
  24157. }
  24158. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  24159. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24161. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24162. if !m.op.Is(OpUpdateOne) {
  24163. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24164. }
  24165. if m.id == nil || m.oldValue == nil {
  24166. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24167. }
  24168. oldValue, err := m.oldValue(ctx)
  24169. if err != nil {
  24170. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24171. }
  24172. return oldValue.CreatedAt, nil
  24173. }
  24174. // ResetCreatedAt resets all changes to the "created_at" field.
  24175. func (m *ServerMutation) ResetCreatedAt() {
  24176. m.created_at = nil
  24177. }
  24178. // SetUpdatedAt sets the "updated_at" field.
  24179. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  24180. m.updated_at = &t
  24181. }
  24182. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24183. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  24184. v := m.updated_at
  24185. if v == nil {
  24186. return
  24187. }
  24188. return *v, true
  24189. }
  24190. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24194. if !m.op.Is(OpUpdateOne) {
  24195. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24196. }
  24197. if m.id == nil || m.oldValue == nil {
  24198. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  24203. }
  24204. return oldValue.UpdatedAt, nil
  24205. }
  24206. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24207. func (m *ServerMutation) ResetUpdatedAt() {
  24208. m.updated_at = nil
  24209. }
  24210. // SetStatus sets the "status" field.
  24211. func (m *ServerMutation) SetStatus(u uint8) {
  24212. m.status = &u
  24213. m.addstatus = nil
  24214. }
  24215. // Status returns the value of the "status" field in the mutation.
  24216. func (m *ServerMutation) Status() (r uint8, exists bool) {
  24217. v := m.status
  24218. if v == nil {
  24219. return
  24220. }
  24221. return *v, true
  24222. }
  24223. // OldStatus returns the old "status" field's value of the Server entity.
  24224. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24226. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24227. if !m.op.Is(OpUpdateOne) {
  24228. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24229. }
  24230. if m.id == nil || m.oldValue == nil {
  24231. return v, errors.New("OldStatus requires an ID field in the mutation")
  24232. }
  24233. oldValue, err := m.oldValue(ctx)
  24234. if err != nil {
  24235. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24236. }
  24237. return oldValue.Status, nil
  24238. }
  24239. // AddStatus adds u to the "status" field.
  24240. func (m *ServerMutation) AddStatus(u int8) {
  24241. if m.addstatus != nil {
  24242. *m.addstatus += u
  24243. } else {
  24244. m.addstatus = &u
  24245. }
  24246. }
  24247. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24248. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  24249. v := m.addstatus
  24250. if v == nil {
  24251. return
  24252. }
  24253. return *v, true
  24254. }
  24255. // ClearStatus clears the value of the "status" field.
  24256. func (m *ServerMutation) ClearStatus() {
  24257. m.status = nil
  24258. m.addstatus = nil
  24259. m.clearedFields[server.FieldStatus] = struct{}{}
  24260. }
  24261. // StatusCleared returns if the "status" field was cleared in this mutation.
  24262. func (m *ServerMutation) StatusCleared() bool {
  24263. _, ok := m.clearedFields[server.FieldStatus]
  24264. return ok
  24265. }
  24266. // ResetStatus resets all changes to the "status" field.
  24267. func (m *ServerMutation) ResetStatus() {
  24268. m.status = nil
  24269. m.addstatus = nil
  24270. delete(m.clearedFields, server.FieldStatus)
  24271. }
  24272. // SetDeletedAt sets the "deleted_at" field.
  24273. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  24274. m.deleted_at = &t
  24275. }
  24276. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24277. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  24278. v := m.deleted_at
  24279. if v == nil {
  24280. return
  24281. }
  24282. return *v, true
  24283. }
  24284. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  24285. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24287. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24288. if !m.op.Is(OpUpdateOne) {
  24289. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24290. }
  24291. if m.id == nil || m.oldValue == nil {
  24292. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24293. }
  24294. oldValue, err := m.oldValue(ctx)
  24295. if err != nil {
  24296. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24297. }
  24298. return oldValue.DeletedAt, nil
  24299. }
  24300. // ClearDeletedAt clears the value of the "deleted_at" field.
  24301. func (m *ServerMutation) ClearDeletedAt() {
  24302. m.deleted_at = nil
  24303. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  24304. }
  24305. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24306. func (m *ServerMutation) DeletedAtCleared() bool {
  24307. _, ok := m.clearedFields[server.FieldDeletedAt]
  24308. return ok
  24309. }
  24310. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24311. func (m *ServerMutation) ResetDeletedAt() {
  24312. m.deleted_at = nil
  24313. delete(m.clearedFields, server.FieldDeletedAt)
  24314. }
  24315. // SetName sets the "name" field.
  24316. func (m *ServerMutation) SetName(s string) {
  24317. m.name = &s
  24318. }
  24319. // Name returns the value of the "name" field in the mutation.
  24320. func (m *ServerMutation) Name() (r string, exists bool) {
  24321. v := m.name
  24322. if v == nil {
  24323. return
  24324. }
  24325. return *v, true
  24326. }
  24327. // OldName returns the old "name" field's value of the Server entity.
  24328. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24330. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  24331. if !m.op.Is(OpUpdateOne) {
  24332. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24333. }
  24334. if m.id == nil || m.oldValue == nil {
  24335. return v, errors.New("OldName requires an ID field in the mutation")
  24336. }
  24337. oldValue, err := m.oldValue(ctx)
  24338. if err != nil {
  24339. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24340. }
  24341. return oldValue.Name, nil
  24342. }
  24343. // ResetName resets all changes to the "name" field.
  24344. func (m *ServerMutation) ResetName() {
  24345. m.name = nil
  24346. }
  24347. // SetPublicIP sets the "public_ip" field.
  24348. func (m *ServerMutation) SetPublicIP(s string) {
  24349. m.public_ip = &s
  24350. }
  24351. // PublicIP returns the value of the "public_ip" field in the mutation.
  24352. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  24353. v := m.public_ip
  24354. if v == nil {
  24355. return
  24356. }
  24357. return *v, true
  24358. }
  24359. // OldPublicIP returns the old "public_ip" 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) OldPublicIP(ctx context.Context) (v string, err error) {
  24363. if !m.op.Is(OpUpdateOne) {
  24364. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  24365. }
  24366. if m.id == nil || m.oldValue == nil {
  24367. return v, errors.New("OldPublicIP 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 OldPublicIP: %w", err)
  24372. }
  24373. return oldValue.PublicIP, nil
  24374. }
  24375. // ResetPublicIP resets all changes to the "public_ip" field.
  24376. func (m *ServerMutation) ResetPublicIP() {
  24377. m.public_ip = nil
  24378. }
  24379. // SetPrivateIP sets the "private_ip" field.
  24380. func (m *ServerMutation) SetPrivateIP(s string) {
  24381. m.private_ip = &s
  24382. }
  24383. // PrivateIP returns the value of the "private_ip" field in the mutation.
  24384. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  24385. v := m.private_ip
  24386. if v == nil {
  24387. return
  24388. }
  24389. return *v, true
  24390. }
  24391. // OldPrivateIP returns the old "private_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) OldPrivateIP(ctx context.Context) (v string, err error) {
  24395. if !m.op.Is(OpUpdateOne) {
  24396. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  24397. }
  24398. if m.id == nil || m.oldValue == nil {
  24399. return v, errors.New("OldPrivateIP 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 OldPrivateIP: %w", err)
  24404. }
  24405. return oldValue.PrivateIP, nil
  24406. }
  24407. // ResetPrivateIP resets all changes to the "private_ip" field.
  24408. func (m *ServerMutation) ResetPrivateIP() {
  24409. m.private_ip = nil
  24410. }
  24411. // SetAdminPort sets the "admin_port" field.
  24412. func (m *ServerMutation) SetAdminPort(s string) {
  24413. m.admin_port = &s
  24414. }
  24415. // AdminPort returns the value of the "admin_port" field in the mutation.
  24416. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  24417. v := m.admin_port
  24418. if v == nil {
  24419. return
  24420. }
  24421. return *v, true
  24422. }
  24423. // OldAdminPort returns the old "admin_port" 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) OldAdminPort(ctx context.Context) (v string, err error) {
  24427. if !m.op.Is(OpUpdateOne) {
  24428. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  24429. }
  24430. if m.id == nil || m.oldValue == nil {
  24431. return v, errors.New("OldAdminPort 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 OldAdminPort: %w", err)
  24436. }
  24437. return oldValue.AdminPort, nil
  24438. }
  24439. // ResetAdminPort resets all changes to the "admin_port" field.
  24440. func (m *ServerMutation) ResetAdminPort() {
  24441. m.admin_port = nil
  24442. }
  24443. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  24444. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  24445. if m.wxs == nil {
  24446. m.wxs = make(map[uint64]struct{})
  24447. }
  24448. for i := range ids {
  24449. m.wxs[ids[i]] = struct{}{}
  24450. }
  24451. }
  24452. // ClearWxs clears the "wxs" edge to the Wx entity.
  24453. func (m *ServerMutation) ClearWxs() {
  24454. m.clearedwxs = true
  24455. }
  24456. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  24457. func (m *ServerMutation) WxsCleared() bool {
  24458. return m.clearedwxs
  24459. }
  24460. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  24461. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  24462. if m.removedwxs == nil {
  24463. m.removedwxs = make(map[uint64]struct{})
  24464. }
  24465. for i := range ids {
  24466. delete(m.wxs, ids[i])
  24467. m.removedwxs[ids[i]] = struct{}{}
  24468. }
  24469. }
  24470. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  24471. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  24472. for id := range m.removedwxs {
  24473. ids = append(ids, id)
  24474. }
  24475. return
  24476. }
  24477. // WxsIDs returns the "wxs" edge IDs in the mutation.
  24478. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  24479. for id := range m.wxs {
  24480. ids = append(ids, id)
  24481. }
  24482. return
  24483. }
  24484. // ResetWxs resets all changes to the "wxs" edge.
  24485. func (m *ServerMutation) ResetWxs() {
  24486. m.wxs = nil
  24487. m.clearedwxs = false
  24488. m.removedwxs = nil
  24489. }
  24490. // Where appends a list predicates to the ServerMutation builder.
  24491. func (m *ServerMutation) Where(ps ...predicate.Server) {
  24492. m.predicates = append(m.predicates, ps...)
  24493. }
  24494. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  24495. // users can use type-assertion to append predicates that do not depend on any generated package.
  24496. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  24497. p := make([]predicate.Server, len(ps))
  24498. for i := range ps {
  24499. p[i] = ps[i]
  24500. }
  24501. m.Where(p...)
  24502. }
  24503. // Op returns the operation name.
  24504. func (m *ServerMutation) Op() Op {
  24505. return m.op
  24506. }
  24507. // SetOp allows setting the mutation operation.
  24508. func (m *ServerMutation) SetOp(op Op) {
  24509. m.op = op
  24510. }
  24511. // Type returns the node type of this mutation (Server).
  24512. func (m *ServerMutation) Type() string {
  24513. return m.typ
  24514. }
  24515. // Fields returns all fields that were changed during this mutation. Note that in
  24516. // order to get all numeric fields that were incremented/decremented, call
  24517. // AddedFields().
  24518. func (m *ServerMutation) Fields() []string {
  24519. fields := make([]string, 0, 8)
  24520. if m.created_at != nil {
  24521. fields = append(fields, server.FieldCreatedAt)
  24522. }
  24523. if m.updated_at != nil {
  24524. fields = append(fields, server.FieldUpdatedAt)
  24525. }
  24526. if m.status != nil {
  24527. fields = append(fields, server.FieldStatus)
  24528. }
  24529. if m.deleted_at != nil {
  24530. fields = append(fields, server.FieldDeletedAt)
  24531. }
  24532. if m.name != nil {
  24533. fields = append(fields, server.FieldName)
  24534. }
  24535. if m.public_ip != nil {
  24536. fields = append(fields, server.FieldPublicIP)
  24537. }
  24538. if m.private_ip != nil {
  24539. fields = append(fields, server.FieldPrivateIP)
  24540. }
  24541. if m.admin_port != nil {
  24542. fields = append(fields, server.FieldAdminPort)
  24543. }
  24544. return fields
  24545. }
  24546. // Field returns the value of a field with the given name. The second boolean
  24547. // return value indicates that this field was not set, or was not defined in the
  24548. // schema.
  24549. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  24550. switch name {
  24551. case server.FieldCreatedAt:
  24552. return m.CreatedAt()
  24553. case server.FieldUpdatedAt:
  24554. return m.UpdatedAt()
  24555. case server.FieldStatus:
  24556. return m.Status()
  24557. case server.FieldDeletedAt:
  24558. return m.DeletedAt()
  24559. case server.FieldName:
  24560. return m.Name()
  24561. case server.FieldPublicIP:
  24562. return m.PublicIP()
  24563. case server.FieldPrivateIP:
  24564. return m.PrivateIP()
  24565. case server.FieldAdminPort:
  24566. return m.AdminPort()
  24567. }
  24568. return nil, false
  24569. }
  24570. // OldField returns the old value of the field from the database. An error is
  24571. // returned if the mutation operation is not UpdateOne, or the query to the
  24572. // database failed.
  24573. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24574. switch name {
  24575. case server.FieldCreatedAt:
  24576. return m.OldCreatedAt(ctx)
  24577. case server.FieldUpdatedAt:
  24578. return m.OldUpdatedAt(ctx)
  24579. case server.FieldStatus:
  24580. return m.OldStatus(ctx)
  24581. case server.FieldDeletedAt:
  24582. return m.OldDeletedAt(ctx)
  24583. case server.FieldName:
  24584. return m.OldName(ctx)
  24585. case server.FieldPublicIP:
  24586. return m.OldPublicIP(ctx)
  24587. case server.FieldPrivateIP:
  24588. return m.OldPrivateIP(ctx)
  24589. case server.FieldAdminPort:
  24590. return m.OldAdminPort(ctx)
  24591. }
  24592. return nil, fmt.Errorf("unknown Server field %s", name)
  24593. }
  24594. // SetField sets the value of a field with the given name. It returns an error if
  24595. // the field is not defined in the schema, or if the type mismatched the field
  24596. // type.
  24597. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  24598. switch name {
  24599. case server.FieldCreatedAt:
  24600. v, ok := value.(time.Time)
  24601. if !ok {
  24602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24603. }
  24604. m.SetCreatedAt(v)
  24605. return nil
  24606. case server.FieldUpdatedAt:
  24607. v, ok := value.(time.Time)
  24608. if !ok {
  24609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24610. }
  24611. m.SetUpdatedAt(v)
  24612. return nil
  24613. case server.FieldStatus:
  24614. v, ok := value.(uint8)
  24615. if !ok {
  24616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24617. }
  24618. m.SetStatus(v)
  24619. return nil
  24620. case server.FieldDeletedAt:
  24621. v, ok := value.(time.Time)
  24622. if !ok {
  24623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24624. }
  24625. m.SetDeletedAt(v)
  24626. return nil
  24627. case server.FieldName:
  24628. v, ok := value.(string)
  24629. if !ok {
  24630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24631. }
  24632. m.SetName(v)
  24633. return nil
  24634. case server.FieldPublicIP:
  24635. v, ok := value.(string)
  24636. if !ok {
  24637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24638. }
  24639. m.SetPublicIP(v)
  24640. return nil
  24641. case server.FieldPrivateIP:
  24642. v, ok := value.(string)
  24643. if !ok {
  24644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24645. }
  24646. m.SetPrivateIP(v)
  24647. return nil
  24648. case server.FieldAdminPort:
  24649. v, ok := value.(string)
  24650. if !ok {
  24651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24652. }
  24653. m.SetAdminPort(v)
  24654. return nil
  24655. }
  24656. return fmt.Errorf("unknown Server field %s", name)
  24657. }
  24658. // AddedFields returns all numeric fields that were incremented/decremented during
  24659. // this mutation.
  24660. func (m *ServerMutation) AddedFields() []string {
  24661. var fields []string
  24662. if m.addstatus != nil {
  24663. fields = append(fields, server.FieldStatus)
  24664. }
  24665. return fields
  24666. }
  24667. // AddedField returns the numeric value that was incremented/decremented on a field
  24668. // with the given name. The second boolean return value indicates that this field
  24669. // was not set, or was not defined in the schema.
  24670. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  24671. switch name {
  24672. case server.FieldStatus:
  24673. return m.AddedStatus()
  24674. }
  24675. return nil, false
  24676. }
  24677. // AddField adds the value to the field with the given name. It returns an error if
  24678. // the field is not defined in the schema, or if the type mismatched the field
  24679. // type.
  24680. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  24681. switch name {
  24682. case server.FieldStatus:
  24683. v, ok := value.(int8)
  24684. if !ok {
  24685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24686. }
  24687. m.AddStatus(v)
  24688. return nil
  24689. }
  24690. return fmt.Errorf("unknown Server numeric field %s", name)
  24691. }
  24692. // ClearedFields returns all nullable fields that were cleared during this
  24693. // mutation.
  24694. func (m *ServerMutation) ClearedFields() []string {
  24695. var fields []string
  24696. if m.FieldCleared(server.FieldStatus) {
  24697. fields = append(fields, server.FieldStatus)
  24698. }
  24699. if m.FieldCleared(server.FieldDeletedAt) {
  24700. fields = append(fields, server.FieldDeletedAt)
  24701. }
  24702. return fields
  24703. }
  24704. // FieldCleared returns a boolean indicating if a field with the given name was
  24705. // cleared in this mutation.
  24706. func (m *ServerMutation) FieldCleared(name string) bool {
  24707. _, ok := m.clearedFields[name]
  24708. return ok
  24709. }
  24710. // ClearField clears the value of the field with the given name. It returns an
  24711. // error if the field is not defined in the schema.
  24712. func (m *ServerMutation) ClearField(name string) error {
  24713. switch name {
  24714. case server.FieldStatus:
  24715. m.ClearStatus()
  24716. return nil
  24717. case server.FieldDeletedAt:
  24718. m.ClearDeletedAt()
  24719. return nil
  24720. }
  24721. return fmt.Errorf("unknown Server nullable field %s", name)
  24722. }
  24723. // ResetField resets all changes in the mutation for the field with the given name.
  24724. // It returns an error if the field is not defined in the schema.
  24725. func (m *ServerMutation) ResetField(name string) error {
  24726. switch name {
  24727. case server.FieldCreatedAt:
  24728. m.ResetCreatedAt()
  24729. return nil
  24730. case server.FieldUpdatedAt:
  24731. m.ResetUpdatedAt()
  24732. return nil
  24733. case server.FieldStatus:
  24734. m.ResetStatus()
  24735. return nil
  24736. case server.FieldDeletedAt:
  24737. m.ResetDeletedAt()
  24738. return nil
  24739. case server.FieldName:
  24740. m.ResetName()
  24741. return nil
  24742. case server.FieldPublicIP:
  24743. m.ResetPublicIP()
  24744. return nil
  24745. case server.FieldPrivateIP:
  24746. m.ResetPrivateIP()
  24747. return nil
  24748. case server.FieldAdminPort:
  24749. m.ResetAdminPort()
  24750. return nil
  24751. }
  24752. return fmt.Errorf("unknown Server field %s", name)
  24753. }
  24754. // AddedEdges returns all edge names that were set/added in this mutation.
  24755. func (m *ServerMutation) AddedEdges() []string {
  24756. edges := make([]string, 0, 1)
  24757. if m.wxs != nil {
  24758. edges = append(edges, server.EdgeWxs)
  24759. }
  24760. return edges
  24761. }
  24762. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24763. // name in this mutation.
  24764. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  24765. switch name {
  24766. case server.EdgeWxs:
  24767. ids := make([]ent.Value, 0, len(m.wxs))
  24768. for id := range m.wxs {
  24769. ids = append(ids, id)
  24770. }
  24771. return ids
  24772. }
  24773. return nil
  24774. }
  24775. // RemovedEdges returns all edge names that were removed in this mutation.
  24776. func (m *ServerMutation) RemovedEdges() []string {
  24777. edges := make([]string, 0, 1)
  24778. if m.removedwxs != nil {
  24779. edges = append(edges, server.EdgeWxs)
  24780. }
  24781. return edges
  24782. }
  24783. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24784. // the given name in this mutation.
  24785. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  24786. switch name {
  24787. case server.EdgeWxs:
  24788. ids := make([]ent.Value, 0, len(m.removedwxs))
  24789. for id := range m.removedwxs {
  24790. ids = append(ids, id)
  24791. }
  24792. return ids
  24793. }
  24794. return nil
  24795. }
  24796. // ClearedEdges returns all edge names that were cleared in this mutation.
  24797. func (m *ServerMutation) ClearedEdges() []string {
  24798. edges := make([]string, 0, 1)
  24799. if m.clearedwxs {
  24800. edges = append(edges, server.EdgeWxs)
  24801. }
  24802. return edges
  24803. }
  24804. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24805. // was cleared in this mutation.
  24806. func (m *ServerMutation) EdgeCleared(name string) bool {
  24807. switch name {
  24808. case server.EdgeWxs:
  24809. return m.clearedwxs
  24810. }
  24811. return false
  24812. }
  24813. // ClearEdge clears the value of the edge with the given name. It returns an error
  24814. // if that edge is not defined in the schema.
  24815. func (m *ServerMutation) ClearEdge(name string) error {
  24816. switch name {
  24817. }
  24818. return fmt.Errorf("unknown Server unique edge %s", name)
  24819. }
  24820. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24821. // It returns an error if the edge is not defined in the schema.
  24822. func (m *ServerMutation) ResetEdge(name string) error {
  24823. switch name {
  24824. case server.EdgeWxs:
  24825. m.ResetWxs()
  24826. return nil
  24827. }
  24828. return fmt.Errorf("unknown Server edge %s", name)
  24829. }
  24830. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  24831. type SopNodeMutation struct {
  24832. config
  24833. op Op
  24834. typ string
  24835. id *uint64
  24836. created_at *time.Time
  24837. updated_at *time.Time
  24838. status *uint8
  24839. addstatus *int8
  24840. deleted_at *time.Time
  24841. parent_id *uint64
  24842. addparent_id *int64
  24843. name *string
  24844. condition_type *int
  24845. addcondition_type *int
  24846. condition_list *[]string
  24847. appendcondition_list []string
  24848. no_reply_condition *uint64
  24849. addno_reply_condition *int64
  24850. no_reply_unit *string
  24851. action_message *[]custom_types.Action
  24852. appendaction_message []custom_types.Action
  24853. action_label_add *[]uint64
  24854. appendaction_label_add []uint64
  24855. action_label_del *[]uint64
  24856. appendaction_label_del []uint64
  24857. action_forward **custom_types.ActionForward
  24858. clearedFields map[string]struct{}
  24859. sop_stage *uint64
  24860. clearedsop_stage bool
  24861. node_messages map[uint64]struct{}
  24862. removednode_messages map[uint64]struct{}
  24863. clearednode_messages bool
  24864. done bool
  24865. oldValue func(context.Context) (*SopNode, error)
  24866. predicates []predicate.SopNode
  24867. }
  24868. var _ ent.Mutation = (*SopNodeMutation)(nil)
  24869. // sopnodeOption allows management of the mutation configuration using functional options.
  24870. type sopnodeOption func(*SopNodeMutation)
  24871. // newSopNodeMutation creates new mutation for the SopNode entity.
  24872. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  24873. m := &SopNodeMutation{
  24874. config: c,
  24875. op: op,
  24876. typ: TypeSopNode,
  24877. clearedFields: make(map[string]struct{}),
  24878. }
  24879. for _, opt := range opts {
  24880. opt(m)
  24881. }
  24882. return m
  24883. }
  24884. // withSopNodeID sets the ID field of the mutation.
  24885. func withSopNodeID(id uint64) sopnodeOption {
  24886. return func(m *SopNodeMutation) {
  24887. var (
  24888. err error
  24889. once sync.Once
  24890. value *SopNode
  24891. )
  24892. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  24893. once.Do(func() {
  24894. if m.done {
  24895. err = errors.New("querying old values post mutation is not allowed")
  24896. } else {
  24897. value, err = m.Client().SopNode.Get(ctx, id)
  24898. }
  24899. })
  24900. return value, err
  24901. }
  24902. m.id = &id
  24903. }
  24904. }
  24905. // withSopNode sets the old SopNode of the mutation.
  24906. func withSopNode(node *SopNode) sopnodeOption {
  24907. return func(m *SopNodeMutation) {
  24908. m.oldValue = func(context.Context) (*SopNode, error) {
  24909. return node, nil
  24910. }
  24911. m.id = &node.ID
  24912. }
  24913. }
  24914. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24915. // executed in a transaction (ent.Tx), a transactional client is returned.
  24916. func (m SopNodeMutation) Client() *Client {
  24917. client := &Client{config: m.config}
  24918. client.init()
  24919. return client
  24920. }
  24921. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24922. // it returns an error otherwise.
  24923. func (m SopNodeMutation) Tx() (*Tx, error) {
  24924. if _, ok := m.driver.(*txDriver); !ok {
  24925. return nil, errors.New("ent: mutation is not running in a transaction")
  24926. }
  24927. tx := &Tx{config: m.config}
  24928. tx.init()
  24929. return tx, nil
  24930. }
  24931. // SetID sets the value of the id field. Note that this
  24932. // operation is only accepted on creation of SopNode entities.
  24933. func (m *SopNodeMutation) SetID(id uint64) {
  24934. m.id = &id
  24935. }
  24936. // ID returns the ID value in the mutation. Note that the ID is only available
  24937. // if it was provided to the builder or after it was returned from the database.
  24938. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  24939. if m.id == nil {
  24940. return
  24941. }
  24942. return *m.id, true
  24943. }
  24944. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24945. // That means, if the mutation is applied within a transaction with an isolation level such
  24946. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24947. // or updated by the mutation.
  24948. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  24949. switch {
  24950. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24951. id, exists := m.ID()
  24952. if exists {
  24953. return []uint64{id}, nil
  24954. }
  24955. fallthrough
  24956. case m.op.Is(OpUpdate | OpDelete):
  24957. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  24958. default:
  24959. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24960. }
  24961. }
  24962. // SetCreatedAt sets the "created_at" field.
  24963. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  24964. m.created_at = &t
  24965. }
  24966. // CreatedAt returns the value of the "created_at" field in the mutation.
  24967. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  24968. v := m.created_at
  24969. if v == nil {
  24970. return
  24971. }
  24972. return *v, true
  24973. }
  24974. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  24975. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24977. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24978. if !m.op.Is(OpUpdateOne) {
  24979. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24980. }
  24981. if m.id == nil || m.oldValue == nil {
  24982. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24983. }
  24984. oldValue, err := m.oldValue(ctx)
  24985. if err != nil {
  24986. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24987. }
  24988. return oldValue.CreatedAt, nil
  24989. }
  24990. // ResetCreatedAt resets all changes to the "created_at" field.
  24991. func (m *SopNodeMutation) ResetCreatedAt() {
  24992. m.created_at = nil
  24993. }
  24994. // SetUpdatedAt sets the "updated_at" field.
  24995. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  24996. m.updated_at = &t
  24997. }
  24998. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24999. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  25000. v := m.updated_at
  25001. if v == nil {
  25002. return
  25003. }
  25004. return *v, true
  25005. }
  25006. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25010. if !m.op.Is(OpUpdateOne) {
  25011. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25012. }
  25013. if m.id == nil || m.oldValue == nil {
  25014. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  25019. }
  25020. return oldValue.UpdatedAt, nil
  25021. }
  25022. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25023. func (m *SopNodeMutation) ResetUpdatedAt() {
  25024. m.updated_at = nil
  25025. }
  25026. // SetStatus sets the "status" field.
  25027. func (m *SopNodeMutation) SetStatus(u uint8) {
  25028. m.status = &u
  25029. m.addstatus = nil
  25030. }
  25031. // Status returns the value of the "status" field in the mutation.
  25032. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  25033. v := m.status
  25034. if v == nil {
  25035. return
  25036. }
  25037. return *v, true
  25038. }
  25039. // OldStatus returns the old "status" field's value of the SopNode entity.
  25040. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25042. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25043. if !m.op.Is(OpUpdateOne) {
  25044. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25045. }
  25046. if m.id == nil || m.oldValue == nil {
  25047. return v, errors.New("OldStatus requires an ID field in the mutation")
  25048. }
  25049. oldValue, err := m.oldValue(ctx)
  25050. if err != nil {
  25051. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25052. }
  25053. return oldValue.Status, nil
  25054. }
  25055. // AddStatus adds u to the "status" field.
  25056. func (m *SopNodeMutation) AddStatus(u int8) {
  25057. if m.addstatus != nil {
  25058. *m.addstatus += u
  25059. } else {
  25060. m.addstatus = &u
  25061. }
  25062. }
  25063. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25064. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  25065. v := m.addstatus
  25066. if v == nil {
  25067. return
  25068. }
  25069. return *v, true
  25070. }
  25071. // ClearStatus clears the value of the "status" field.
  25072. func (m *SopNodeMutation) ClearStatus() {
  25073. m.status = nil
  25074. m.addstatus = nil
  25075. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  25076. }
  25077. // StatusCleared returns if the "status" field was cleared in this mutation.
  25078. func (m *SopNodeMutation) StatusCleared() bool {
  25079. _, ok := m.clearedFields[sopnode.FieldStatus]
  25080. return ok
  25081. }
  25082. // ResetStatus resets all changes to the "status" field.
  25083. func (m *SopNodeMutation) ResetStatus() {
  25084. m.status = nil
  25085. m.addstatus = nil
  25086. delete(m.clearedFields, sopnode.FieldStatus)
  25087. }
  25088. // SetDeletedAt sets the "deleted_at" field.
  25089. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  25090. m.deleted_at = &t
  25091. }
  25092. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25093. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  25094. v := m.deleted_at
  25095. if v == nil {
  25096. return
  25097. }
  25098. return *v, true
  25099. }
  25100. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  25101. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25103. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25104. if !m.op.Is(OpUpdateOne) {
  25105. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25106. }
  25107. if m.id == nil || m.oldValue == nil {
  25108. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25109. }
  25110. oldValue, err := m.oldValue(ctx)
  25111. if err != nil {
  25112. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25113. }
  25114. return oldValue.DeletedAt, nil
  25115. }
  25116. // ClearDeletedAt clears the value of the "deleted_at" field.
  25117. func (m *SopNodeMutation) ClearDeletedAt() {
  25118. m.deleted_at = nil
  25119. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  25120. }
  25121. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25122. func (m *SopNodeMutation) DeletedAtCleared() bool {
  25123. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  25124. return ok
  25125. }
  25126. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25127. func (m *SopNodeMutation) ResetDeletedAt() {
  25128. m.deleted_at = nil
  25129. delete(m.clearedFields, sopnode.FieldDeletedAt)
  25130. }
  25131. // SetStageID sets the "stage_id" field.
  25132. func (m *SopNodeMutation) SetStageID(u uint64) {
  25133. m.sop_stage = &u
  25134. }
  25135. // StageID returns the value of the "stage_id" field in the mutation.
  25136. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  25137. v := m.sop_stage
  25138. if v == nil {
  25139. return
  25140. }
  25141. return *v, true
  25142. }
  25143. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  25144. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25146. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  25147. if !m.op.Is(OpUpdateOne) {
  25148. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  25149. }
  25150. if m.id == nil || m.oldValue == nil {
  25151. return v, errors.New("OldStageID requires an ID field in the mutation")
  25152. }
  25153. oldValue, err := m.oldValue(ctx)
  25154. if err != nil {
  25155. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  25156. }
  25157. return oldValue.StageID, nil
  25158. }
  25159. // ResetStageID resets all changes to the "stage_id" field.
  25160. func (m *SopNodeMutation) ResetStageID() {
  25161. m.sop_stage = nil
  25162. }
  25163. // SetParentID sets the "parent_id" field.
  25164. func (m *SopNodeMutation) SetParentID(u uint64) {
  25165. m.parent_id = &u
  25166. m.addparent_id = nil
  25167. }
  25168. // ParentID returns the value of the "parent_id" field in the mutation.
  25169. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  25170. v := m.parent_id
  25171. if v == nil {
  25172. return
  25173. }
  25174. return *v, true
  25175. }
  25176. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  25177. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25179. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  25180. if !m.op.Is(OpUpdateOne) {
  25181. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  25182. }
  25183. if m.id == nil || m.oldValue == nil {
  25184. return v, errors.New("OldParentID requires an ID field in the mutation")
  25185. }
  25186. oldValue, err := m.oldValue(ctx)
  25187. if err != nil {
  25188. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  25189. }
  25190. return oldValue.ParentID, nil
  25191. }
  25192. // AddParentID adds u to the "parent_id" field.
  25193. func (m *SopNodeMutation) AddParentID(u int64) {
  25194. if m.addparent_id != nil {
  25195. *m.addparent_id += u
  25196. } else {
  25197. m.addparent_id = &u
  25198. }
  25199. }
  25200. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  25201. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  25202. v := m.addparent_id
  25203. if v == nil {
  25204. return
  25205. }
  25206. return *v, true
  25207. }
  25208. // ResetParentID resets all changes to the "parent_id" field.
  25209. func (m *SopNodeMutation) ResetParentID() {
  25210. m.parent_id = nil
  25211. m.addparent_id = nil
  25212. }
  25213. // SetName sets the "name" field.
  25214. func (m *SopNodeMutation) SetName(s string) {
  25215. m.name = &s
  25216. }
  25217. // Name returns the value of the "name" field in the mutation.
  25218. func (m *SopNodeMutation) Name() (r string, exists bool) {
  25219. v := m.name
  25220. if v == nil {
  25221. return
  25222. }
  25223. return *v, true
  25224. }
  25225. // OldName returns the old "name" field's value of the SopNode entity.
  25226. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25228. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  25229. if !m.op.Is(OpUpdateOne) {
  25230. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25231. }
  25232. if m.id == nil || m.oldValue == nil {
  25233. return v, errors.New("OldName requires an ID field in the mutation")
  25234. }
  25235. oldValue, err := m.oldValue(ctx)
  25236. if err != nil {
  25237. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25238. }
  25239. return oldValue.Name, nil
  25240. }
  25241. // ResetName resets all changes to the "name" field.
  25242. func (m *SopNodeMutation) ResetName() {
  25243. m.name = nil
  25244. }
  25245. // SetConditionType sets the "condition_type" field.
  25246. func (m *SopNodeMutation) SetConditionType(i int) {
  25247. m.condition_type = &i
  25248. m.addcondition_type = nil
  25249. }
  25250. // ConditionType returns the value of the "condition_type" field in the mutation.
  25251. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  25252. v := m.condition_type
  25253. if v == nil {
  25254. return
  25255. }
  25256. return *v, true
  25257. }
  25258. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  25259. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25261. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  25262. if !m.op.Is(OpUpdateOne) {
  25263. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  25264. }
  25265. if m.id == nil || m.oldValue == nil {
  25266. return v, errors.New("OldConditionType requires an ID field in the mutation")
  25267. }
  25268. oldValue, err := m.oldValue(ctx)
  25269. if err != nil {
  25270. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  25271. }
  25272. return oldValue.ConditionType, nil
  25273. }
  25274. // AddConditionType adds i to the "condition_type" field.
  25275. func (m *SopNodeMutation) AddConditionType(i int) {
  25276. if m.addcondition_type != nil {
  25277. *m.addcondition_type += i
  25278. } else {
  25279. m.addcondition_type = &i
  25280. }
  25281. }
  25282. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  25283. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  25284. v := m.addcondition_type
  25285. if v == nil {
  25286. return
  25287. }
  25288. return *v, true
  25289. }
  25290. // ResetConditionType resets all changes to the "condition_type" field.
  25291. func (m *SopNodeMutation) ResetConditionType() {
  25292. m.condition_type = nil
  25293. m.addcondition_type = nil
  25294. }
  25295. // SetConditionList sets the "condition_list" field.
  25296. func (m *SopNodeMutation) SetConditionList(s []string) {
  25297. m.condition_list = &s
  25298. m.appendcondition_list = nil
  25299. }
  25300. // ConditionList returns the value of the "condition_list" field in the mutation.
  25301. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  25302. v := m.condition_list
  25303. if v == nil {
  25304. return
  25305. }
  25306. return *v, true
  25307. }
  25308. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  25309. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25311. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  25312. if !m.op.Is(OpUpdateOne) {
  25313. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  25314. }
  25315. if m.id == nil || m.oldValue == nil {
  25316. return v, errors.New("OldConditionList requires an ID field in the mutation")
  25317. }
  25318. oldValue, err := m.oldValue(ctx)
  25319. if err != nil {
  25320. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  25321. }
  25322. return oldValue.ConditionList, nil
  25323. }
  25324. // AppendConditionList adds s to the "condition_list" field.
  25325. func (m *SopNodeMutation) AppendConditionList(s []string) {
  25326. m.appendcondition_list = append(m.appendcondition_list, s...)
  25327. }
  25328. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25329. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  25330. if len(m.appendcondition_list) == 0 {
  25331. return nil, false
  25332. }
  25333. return m.appendcondition_list, true
  25334. }
  25335. // ClearConditionList clears the value of the "condition_list" field.
  25336. func (m *SopNodeMutation) ClearConditionList() {
  25337. m.condition_list = nil
  25338. m.appendcondition_list = nil
  25339. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  25340. }
  25341. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  25342. func (m *SopNodeMutation) ConditionListCleared() bool {
  25343. _, ok := m.clearedFields[sopnode.FieldConditionList]
  25344. return ok
  25345. }
  25346. // ResetConditionList resets all changes to the "condition_list" field.
  25347. func (m *SopNodeMutation) ResetConditionList() {
  25348. m.condition_list = nil
  25349. m.appendcondition_list = nil
  25350. delete(m.clearedFields, sopnode.FieldConditionList)
  25351. }
  25352. // SetNoReplyCondition sets the "no_reply_condition" field.
  25353. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  25354. m.no_reply_condition = &u
  25355. m.addno_reply_condition = nil
  25356. }
  25357. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  25358. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  25359. v := m.no_reply_condition
  25360. if v == nil {
  25361. return
  25362. }
  25363. return *v, true
  25364. }
  25365. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  25366. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25368. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  25369. if !m.op.Is(OpUpdateOne) {
  25370. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  25371. }
  25372. if m.id == nil || m.oldValue == nil {
  25373. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  25374. }
  25375. oldValue, err := m.oldValue(ctx)
  25376. if err != nil {
  25377. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  25378. }
  25379. return oldValue.NoReplyCondition, nil
  25380. }
  25381. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  25382. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  25383. if m.addno_reply_condition != nil {
  25384. *m.addno_reply_condition += u
  25385. } else {
  25386. m.addno_reply_condition = &u
  25387. }
  25388. }
  25389. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  25390. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  25391. v := m.addno_reply_condition
  25392. if v == nil {
  25393. return
  25394. }
  25395. return *v, true
  25396. }
  25397. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  25398. func (m *SopNodeMutation) ResetNoReplyCondition() {
  25399. m.no_reply_condition = nil
  25400. m.addno_reply_condition = nil
  25401. }
  25402. // SetNoReplyUnit sets the "no_reply_unit" field.
  25403. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  25404. m.no_reply_unit = &s
  25405. }
  25406. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  25407. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  25408. v := m.no_reply_unit
  25409. if v == nil {
  25410. return
  25411. }
  25412. return *v, true
  25413. }
  25414. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  25415. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25417. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  25418. if !m.op.Is(OpUpdateOne) {
  25419. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  25420. }
  25421. if m.id == nil || m.oldValue == nil {
  25422. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  25423. }
  25424. oldValue, err := m.oldValue(ctx)
  25425. if err != nil {
  25426. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  25427. }
  25428. return oldValue.NoReplyUnit, nil
  25429. }
  25430. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  25431. func (m *SopNodeMutation) ResetNoReplyUnit() {
  25432. m.no_reply_unit = nil
  25433. }
  25434. // SetActionMessage sets the "action_message" field.
  25435. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  25436. m.action_message = &ct
  25437. m.appendaction_message = nil
  25438. }
  25439. // ActionMessage returns the value of the "action_message" field in the mutation.
  25440. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  25441. v := m.action_message
  25442. if v == nil {
  25443. return
  25444. }
  25445. return *v, true
  25446. }
  25447. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  25448. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25450. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25451. if !m.op.Is(OpUpdateOne) {
  25452. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25453. }
  25454. if m.id == nil || m.oldValue == nil {
  25455. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25456. }
  25457. oldValue, err := m.oldValue(ctx)
  25458. if err != nil {
  25459. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25460. }
  25461. return oldValue.ActionMessage, nil
  25462. }
  25463. // AppendActionMessage adds ct to the "action_message" field.
  25464. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  25465. m.appendaction_message = append(m.appendaction_message, ct...)
  25466. }
  25467. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25468. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25469. if len(m.appendaction_message) == 0 {
  25470. return nil, false
  25471. }
  25472. return m.appendaction_message, true
  25473. }
  25474. // ClearActionMessage clears the value of the "action_message" field.
  25475. func (m *SopNodeMutation) ClearActionMessage() {
  25476. m.action_message = nil
  25477. m.appendaction_message = nil
  25478. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  25479. }
  25480. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25481. func (m *SopNodeMutation) ActionMessageCleared() bool {
  25482. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  25483. return ok
  25484. }
  25485. // ResetActionMessage resets all changes to the "action_message" field.
  25486. func (m *SopNodeMutation) ResetActionMessage() {
  25487. m.action_message = nil
  25488. m.appendaction_message = nil
  25489. delete(m.clearedFields, sopnode.FieldActionMessage)
  25490. }
  25491. // SetActionLabelAdd sets the "action_label_add" field.
  25492. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  25493. m.action_label_add = &u
  25494. m.appendaction_label_add = nil
  25495. }
  25496. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25497. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25498. v := m.action_label_add
  25499. if v == nil {
  25500. return
  25501. }
  25502. return *v, true
  25503. }
  25504. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  25505. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25507. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25508. if !m.op.Is(OpUpdateOne) {
  25509. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25510. }
  25511. if m.id == nil || m.oldValue == nil {
  25512. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25513. }
  25514. oldValue, err := m.oldValue(ctx)
  25515. if err != nil {
  25516. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25517. }
  25518. return oldValue.ActionLabelAdd, nil
  25519. }
  25520. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25521. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  25522. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25523. }
  25524. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25525. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25526. if len(m.appendaction_label_add) == 0 {
  25527. return nil, false
  25528. }
  25529. return m.appendaction_label_add, true
  25530. }
  25531. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25532. func (m *SopNodeMutation) ClearActionLabelAdd() {
  25533. m.action_label_add = nil
  25534. m.appendaction_label_add = nil
  25535. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  25536. }
  25537. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25538. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  25539. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  25540. return ok
  25541. }
  25542. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25543. func (m *SopNodeMutation) ResetActionLabelAdd() {
  25544. m.action_label_add = nil
  25545. m.appendaction_label_add = nil
  25546. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  25547. }
  25548. // SetActionLabelDel sets the "action_label_del" field.
  25549. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  25550. m.action_label_del = &u
  25551. m.appendaction_label_del = nil
  25552. }
  25553. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25554. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  25555. v := m.action_label_del
  25556. if v == nil {
  25557. return
  25558. }
  25559. return *v, true
  25560. }
  25561. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  25562. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25564. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25565. if !m.op.Is(OpUpdateOne) {
  25566. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25567. }
  25568. if m.id == nil || m.oldValue == nil {
  25569. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25570. }
  25571. oldValue, err := m.oldValue(ctx)
  25572. if err != nil {
  25573. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25574. }
  25575. return oldValue.ActionLabelDel, nil
  25576. }
  25577. // AppendActionLabelDel adds u to the "action_label_del" field.
  25578. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  25579. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25580. }
  25581. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25582. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25583. if len(m.appendaction_label_del) == 0 {
  25584. return nil, false
  25585. }
  25586. return m.appendaction_label_del, true
  25587. }
  25588. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25589. func (m *SopNodeMutation) ClearActionLabelDel() {
  25590. m.action_label_del = nil
  25591. m.appendaction_label_del = nil
  25592. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  25593. }
  25594. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25595. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  25596. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  25597. return ok
  25598. }
  25599. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25600. func (m *SopNodeMutation) ResetActionLabelDel() {
  25601. m.action_label_del = nil
  25602. m.appendaction_label_del = nil
  25603. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  25604. }
  25605. // SetActionForward sets the "action_forward" field.
  25606. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25607. m.action_forward = &ctf
  25608. }
  25609. // ActionForward returns the value of the "action_forward" field in the mutation.
  25610. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25611. v := m.action_forward
  25612. if v == nil {
  25613. return
  25614. }
  25615. return *v, true
  25616. }
  25617. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  25618. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25620. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25621. if !m.op.Is(OpUpdateOne) {
  25622. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25623. }
  25624. if m.id == nil || m.oldValue == nil {
  25625. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25626. }
  25627. oldValue, err := m.oldValue(ctx)
  25628. if err != nil {
  25629. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25630. }
  25631. return oldValue.ActionForward, nil
  25632. }
  25633. // ClearActionForward clears the value of the "action_forward" field.
  25634. func (m *SopNodeMutation) ClearActionForward() {
  25635. m.action_forward = nil
  25636. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  25637. }
  25638. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25639. func (m *SopNodeMutation) ActionForwardCleared() bool {
  25640. _, ok := m.clearedFields[sopnode.FieldActionForward]
  25641. return ok
  25642. }
  25643. // ResetActionForward resets all changes to the "action_forward" field.
  25644. func (m *SopNodeMutation) ResetActionForward() {
  25645. m.action_forward = nil
  25646. delete(m.clearedFields, sopnode.FieldActionForward)
  25647. }
  25648. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  25649. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  25650. m.sop_stage = &id
  25651. }
  25652. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  25653. func (m *SopNodeMutation) ClearSopStage() {
  25654. m.clearedsop_stage = true
  25655. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  25656. }
  25657. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  25658. func (m *SopNodeMutation) SopStageCleared() bool {
  25659. return m.clearedsop_stage
  25660. }
  25661. // SopStageID returns the "sop_stage" edge ID in the mutation.
  25662. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  25663. if m.sop_stage != nil {
  25664. return *m.sop_stage, true
  25665. }
  25666. return
  25667. }
  25668. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  25669. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25670. // SopStageID instead. It exists only for internal usage by the builders.
  25671. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  25672. if id := m.sop_stage; id != nil {
  25673. ids = append(ids, *id)
  25674. }
  25675. return
  25676. }
  25677. // ResetSopStage resets all changes to the "sop_stage" edge.
  25678. func (m *SopNodeMutation) ResetSopStage() {
  25679. m.sop_stage = nil
  25680. m.clearedsop_stage = false
  25681. }
  25682. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  25683. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  25684. if m.node_messages == nil {
  25685. m.node_messages = make(map[uint64]struct{})
  25686. }
  25687. for i := range ids {
  25688. m.node_messages[ids[i]] = struct{}{}
  25689. }
  25690. }
  25691. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  25692. func (m *SopNodeMutation) ClearNodeMessages() {
  25693. m.clearednode_messages = true
  25694. }
  25695. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  25696. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  25697. return m.clearednode_messages
  25698. }
  25699. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  25700. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  25701. if m.removednode_messages == nil {
  25702. m.removednode_messages = make(map[uint64]struct{})
  25703. }
  25704. for i := range ids {
  25705. delete(m.node_messages, ids[i])
  25706. m.removednode_messages[ids[i]] = struct{}{}
  25707. }
  25708. }
  25709. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  25710. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  25711. for id := range m.removednode_messages {
  25712. ids = append(ids, id)
  25713. }
  25714. return
  25715. }
  25716. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  25717. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  25718. for id := range m.node_messages {
  25719. ids = append(ids, id)
  25720. }
  25721. return
  25722. }
  25723. // ResetNodeMessages resets all changes to the "node_messages" edge.
  25724. func (m *SopNodeMutation) ResetNodeMessages() {
  25725. m.node_messages = nil
  25726. m.clearednode_messages = false
  25727. m.removednode_messages = nil
  25728. }
  25729. // Where appends a list predicates to the SopNodeMutation builder.
  25730. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  25731. m.predicates = append(m.predicates, ps...)
  25732. }
  25733. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  25734. // users can use type-assertion to append predicates that do not depend on any generated package.
  25735. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  25736. p := make([]predicate.SopNode, len(ps))
  25737. for i := range ps {
  25738. p[i] = ps[i]
  25739. }
  25740. m.Where(p...)
  25741. }
  25742. // Op returns the operation name.
  25743. func (m *SopNodeMutation) Op() Op {
  25744. return m.op
  25745. }
  25746. // SetOp allows setting the mutation operation.
  25747. func (m *SopNodeMutation) SetOp(op Op) {
  25748. m.op = op
  25749. }
  25750. // Type returns the node type of this mutation (SopNode).
  25751. func (m *SopNodeMutation) Type() string {
  25752. return m.typ
  25753. }
  25754. // Fields returns all fields that were changed during this mutation. Note that in
  25755. // order to get all numeric fields that were incremented/decremented, call
  25756. // AddedFields().
  25757. func (m *SopNodeMutation) Fields() []string {
  25758. fields := make([]string, 0, 15)
  25759. if m.created_at != nil {
  25760. fields = append(fields, sopnode.FieldCreatedAt)
  25761. }
  25762. if m.updated_at != nil {
  25763. fields = append(fields, sopnode.FieldUpdatedAt)
  25764. }
  25765. if m.status != nil {
  25766. fields = append(fields, sopnode.FieldStatus)
  25767. }
  25768. if m.deleted_at != nil {
  25769. fields = append(fields, sopnode.FieldDeletedAt)
  25770. }
  25771. if m.sop_stage != nil {
  25772. fields = append(fields, sopnode.FieldStageID)
  25773. }
  25774. if m.parent_id != nil {
  25775. fields = append(fields, sopnode.FieldParentID)
  25776. }
  25777. if m.name != nil {
  25778. fields = append(fields, sopnode.FieldName)
  25779. }
  25780. if m.condition_type != nil {
  25781. fields = append(fields, sopnode.FieldConditionType)
  25782. }
  25783. if m.condition_list != nil {
  25784. fields = append(fields, sopnode.FieldConditionList)
  25785. }
  25786. if m.no_reply_condition != nil {
  25787. fields = append(fields, sopnode.FieldNoReplyCondition)
  25788. }
  25789. if m.no_reply_unit != nil {
  25790. fields = append(fields, sopnode.FieldNoReplyUnit)
  25791. }
  25792. if m.action_message != nil {
  25793. fields = append(fields, sopnode.FieldActionMessage)
  25794. }
  25795. if m.action_label_add != nil {
  25796. fields = append(fields, sopnode.FieldActionLabelAdd)
  25797. }
  25798. if m.action_label_del != nil {
  25799. fields = append(fields, sopnode.FieldActionLabelDel)
  25800. }
  25801. if m.action_forward != nil {
  25802. fields = append(fields, sopnode.FieldActionForward)
  25803. }
  25804. return fields
  25805. }
  25806. // Field returns the value of a field with the given name. The second boolean
  25807. // return value indicates that this field was not set, or was not defined in the
  25808. // schema.
  25809. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  25810. switch name {
  25811. case sopnode.FieldCreatedAt:
  25812. return m.CreatedAt()
  25813. case sopnode.FieldUpdatedAt:
  25814. return m.UpdatedAt()
  25815. case sopnode.FieldStatus:
  25816. return m.Status()
  25817. case sopnode.FieldDeletedAt:
  25818. return m.DeletedAt()
  25819. case sopnode.FieldStageID:
  25820. return m.StageID()
  25821. case sopnode.FieldParentID:
  25822. return m.ParentID()
  25823. case sopnode.FieldName:
  25824. return m.Name()
  25825. case sopnode.FieldConditionType:
  25826. return m.ConditionType()
  25827. case sopnode.FieldConditionList:
  25828. return m.ConditionList()
  25829. case sopnode.FieldNoReplyCondition:
  25830. return m.NoReplyCondition()
  25831. case sopnode.FieldNoReplyUnit:
  25832. return m.NoReplyUnit()
  25833. case sopnode.FieldActionMessage:
  25834. return m.ActionMessage()
  25835. case sopnode.FieldActionLabelAdd:
  25836. return m.ActionLabelAdd()
  25837. case sopnode.FieldActionLabelDel:
  25838. return m.ActionLabelDel()
  25839. case sopnode.FieldActionForward:
  25840. return m.ActionForward()
  25841. }
  25842. return nil, false
  25843. }
  25844. // OldField returns the old value of the field from the database. An error is
  25845. // returned if the mutation operation is not UpdateOne, or the query to the
  25846. // database failed.
  25847. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25848. switch name {
  25849. case sopnode.FieldCreatedAt:
  25850. return m.OldCreatedAt(ctx)
  25851. case sopnode.FieldUpdatedAt:
  25852. return m.OldUpdatedAt(ctx)
  25853. case sopnode.FieldStatus:
  25854. return m.OldStatus(ctx)
  25855. case sopnode.FieldDeletedAt:
  25856. return m.OldDeletedAt(ctx)
  25857. case sopnode.FieldStageID:
  25858. return m.OldStageID(ctx)
  25859. case sopnode.FieldParentID:
  25860. return m.OldParentID(ctx)
  25861. case sopnode.FieldName:
  25862. return m.OldName(ctx)
  25863. case sopnode.FieldConditionType:
  25864. return m.OldConditionType(ctx)
  25865. case sopnode.FieldConditionList:
  25866. return m.OldConditionList(ctx)
  25867. case sopnode.FieldNoReplyCondition:
  25868. return m.OldNoReplyCondition(ctx)
  25869. case sopnode.FieldNoReplyUnit:
  25870. return m.OldNoReplyUnit(ctx)
  25871. case sopnode.FieldActionMessage:
  25872. return m.OldActionMessage(ctx)
  25873. case sopnode.FieldActionLabelAdd:
  25874. return m.OldActionLabelAdd(ctx)
  25875. case sopnode.FieldActionLabelDel:
  25876. return m.OldActionLabelDel(ctx)
  25877. case sopnode.FieldActionForward:
  25878. return m.OldActionForward(ctx)
  25879. }
  25880. return nil, fmt.Errorf("unknown SopNode field %s", name)
  25881. }
  25882. // SetField sets the value of a field with the given name. It returns an error if
  25883. // the field is not defined in the schema, or if the type mismatched the field
  25884. // type.
  25885. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  25886. switch name {
  25887. case sopnode.FieldCreatedAt:
  25888. v, ok := value.(time.Time)
  25889. if !ok {
  25890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25891. }
  25892. m.SetCreatedAt(v)
  25893. return nil
  25894. case sopnode.FieldUpdatedAt:
  25895. v, ok := value.(time.Time)
  25896. if !ok {
  25897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25898. }
  25899. m.SetUpdatedAt(v)
  25900. return nil
  25901. case sopnode.FieldStatus:
  25902. v, ok := value.(uint8)
  25903. if !ok {
  25904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25905. }
  25906. m.SetStatus(v)
  25907. return nil
  25908. case sopnode.FieldDeletedAt:
  25909. v, ok := value.(time.Time)
  25910. if !ok {
  25911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25912. }
  25913. m.SetDeletedAt(v)
  25914. return nil
  25915. case sopnode.FieldStageID:
  25916. v, ok := value.(uint64)
  25917. if !ok {
  25918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25919. }
  25920. m.SetStageID(v)
  25921. return nil
  25922. case sopnode.FieldParentID:
  25923. v, ok := value.(uint64)
  25924. if !ok {
  25925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25926. }
  25927. m.SetParentID(v)
  25928. return nil
  25929. case sopnode.FieldName:
  25930. v, ok := value.(string)
  25931. if !ok {
  25932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25933. }
  25934. m.SetName(v)
  25935. return nil
  25936. case sopnode.FieldConditionType:
  25937. v, ok := value.(int)
  25938. if !ok {
  25939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25940. }
  25941. m.SetConditionType(v)
  25942. return nil
  25943. case sopnode.FieldConditionList:
  25944. v, ok := value.([]string)
  25945. if !ok {
  25946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25947. }
  25948. m.SetConditionList(v)
  25949. return nil
  25950. case sopnode.FieldNoReplyCondition:
  25951. v, ok := value.(uint64)
  25952. if !ok {
  25953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25954. }
  25955. m.SetNoReplyCondition(v)
  25956. return nil
  25957. case sopnode.FieldNoReplyUnit:
  25958. v, ok := value.(string)
  25959. if !ok {
  25960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25961. }
  25962. m.SetNoReplyUnit(v)
  25963. return nil
  25964. case sopnode.FieldActionMessage:
  25965. v, ok := value.([]custom_types.Action)
  25966. if !ok {
  25967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25968. }
  25969. m.SetActionMessage(v)
  25970. return nil
  25971. case sopnode.FieldActionLabelAdd:
  25972. v, ok := value.([]uint64)
  25973. if !ok {
  25974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25975. }
  25976. m.SetActionLabelAdd(v)
  25977. return nil
  25978. case sopnode.FieldActionLabelDel:
  25979. v, ok := value.([]uint64)
  25980. if !ok {
  25981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25982. }
  25983. m.SetActionLabelDel(v)
  25984. return nil
  25985. case sopnode.FieldActionForward:
  25986. v, ok := value.(*custom_types.ActionForward)
  25987. if !ok {
  25988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25989. }
  25990. m.SetActionForward(v)
  25991. return nil
  25992. }
  25993. return fmt.Errorf("unknown SopNode field %s", name)
  25994. }
  25995. // AddedFields returns all numeric fields that were incremented/decremented during
  25996. // this mutation.
  25997. func (m *SopNodeMutation) AddedFields() []string {
  25998. var fields []string
  25999. if m.addstatus != nil {
  26000. fields = append(fields, sopnode.FieldStatus)
  26001. }
  26002. if m.addparent_id != nil {
  26003. fields = append(fields, sopnode.FieldParentID)
  26004. }
  26005. if m.addcondition_type != nil {
  26006. fields = append(fields, sopnode.FieldConditionType)
  26007. }
  26008. if m.addno_reply_condition != nil {
  26009. fields = append(fields, sopnode.FieldNoReplyCondition)
  26010. }
  26011. return fields
  26012. }
  26013. // AddedField returns the numeric value that was incremented/decremented on a field
  26014. // with the given name. The second boolean return value indicates that this field
  26015. // was not set, or was not defined in the schema.
  26016. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  26017. switch name {
  26018. case sopnode.FieldStatus:
  26019. return m.AddedStatus()
  26020. case sopnode.FieldParentID:
  26021. return m.AddedParentID()
  26022. case sopnode.FieldConditionType:
  26023. return m.AddedConditionType()
  26024. case sopnode.FieldNoReplyCondition:
  26025. return m.AddedNoReplyCondition()
  26026. }
  26027. return nil, false
  26028. }
  26029. // AddField adds the value to the field with the given name. It returns an error if
  26030. // the field is not defined in the schema, or if the type mismatched the field
  26031. // type.
  26032. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  26033. switch name {
  26034. case sopnode.FieldStatus:
  26035. v, ok := value.(int8)
  26036. if !ok {
  26037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26038. }
  26039. m.AddStatus(v)
  26040. return nil
  26041. case sopnode.FieldParentID:
  26042. v, ok := value.(int64)
  26043. if !ok {
  26044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26045. }
  26046. m.AddParentID(v)
  26047. return nil
  26048. case sopnode.FieldConditionType:
  26049. v, ok := value.(int)
  26050. if !ok {
  26051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26052. }
  26053. m.AddConditionType(v)
  26054. return nil
  26055. case sopnode.FieldNoReplyCondition:
  26056. v, ok := value.(int64)
  26057. if !ok {
  26058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26059. }
  26060. m.AddNoReplyCondition(v)
  26061. return nil
  26062. }
  26063. return fmt.Errorf("unknown SopNode numeric field %s", name)
  26064. }
  26065. // ClearedFields returns all nullable fields that were cleared during this
  26066. // mutation.
  26067. func (m *SopNodeMutation) ClearedFields() []string {
  26068. var fields []string
  26069. if m.FieldCleared(sopnode.FieldStatus) {
  26070. fields = append(fields, sopnode.FieldStatus)
  26071. }
  26072. if m.FieldCleared(sopnode.FieldDeletedAt) {
  26073. fields = append(fields, sopnode.FieldDeletedAt)
  26074. }
  26075. if m.FieldCleared(sopnode.FieldConditionList) {
  26076. fields = append(fields, sopnode.FieldConditionList)
  26077. }
  26078. if m.FieldCleared(sopnode.FieldActionMessage) {
  26079. fields = append(fields, sopnode.FieldActionMessage)
  26080. }
  26081. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  26082. fields = append(fields, sopnode.FieldActionLabelAdd)
  26083. }
  26084. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  26085. fields = append(fields, sopnode.FieldActionLabelDel)
  26086. }
  26087. if m.FieldCleared(sopnode.FieldActionForward) {
  26088. fields = append(fields, sopnode.FieldActionForward)
  26089. }
  26090. return fields
  26091. }
  26092. // FieldCleared returns a boolean indicating if a field with the given name was
  26093. // cleared in this mutation.
  26094. func (m *SopNodeMutation) FieldCleared(name string) bool {
  26095. _, ok := m.clearedFields[name]
  26096. return ok
  26097. }
  26098. // ClearField clears the value of the field with the given name. It returns an
  26099. // error if the field is not defined in the schema.
  26100. func (m *SopNodeMutation) ClearField(name string) error {
  26101. switch name {
  26102. case sopnode.FieldStatus:
  26103. m.ClearStatus()
  26104. return nil
  26105. case sopnode.FieldDeletedAt:
  26106. m.ClearDeletedAt()
  26107. return nil
  26108. case sopnode.FieldConditionList:
  26109. m.ClearConditionList()
  26110. return nil
  26111. case sopnode.FieldActionMessage:
  26112. m.ClearActionMessage()
  26113. return nil
  26114. case sopnode.FieldActionLabelAdd:
  26115. m.ClearActionLabelAdd()
  26116. return nil
  26117. case sopnode.FieldActionLabelDel:
  26118. m.ClearActionLabelDel()
  26119. return nil
  26120. case sopnode.FieldActionForward:
  26121. m.ClearActionForward()
  26122. return nil
  26123. }
  26124. return fmt.Errorf("unknown SopNode nullable field %s", name)
  26125. }
  26126. // ResetField resets all changes in the mutation for the field with the given name.
  26127. // It returns an error if the field is not defined in the schema.
  26128. func (m *SopNodeMutation) ResetField(name string) error {
  26129. switch name {
  26130. case sopnode.FieldCreatedAt:
  26131. m.ResetCreatedAt()
  26132. return nil
  26133. case sopnode.FieldUpdatedAt:
  26134. m.ResetUpdatedAt()
  26135. return nil
  26136. case sopnode.FieldStatus:
  26137. m.ResetStatus()
  26138. return nil
  26139. case sopnode.FieldDeletedAt:
  26140. m.ResetDeletedAt()
  26141. return nil
  26142. case sopnode.FieldStageID:
  26143. m.ResetStageID()
  26144. return nil
  26145. case sopnode.FieldParentID:
  26146. m.ResetParentID()
  26147. return nil
  26148. case sopnode.FieldName:
  26149. m.ResetName()
  26150. return nil
  26151. case sopnode.FieldConditionType:
  26152. m.ResetConditionType()
  26153. return nil
  26154. case sopnode.FieldConditionList:
  26155. m.ResetConditionList()
  26156. return nil
  26157. case sopnode.FieldNoReplyCondition:
  26158. m.ResetNoReplyCondition()
  26159. return nil
  26160. case sopnode.FieldNoReplyUnit:
  26161. m.ResetNoReplyUnit()
  26162. return nil
  26163. case sopnode.FieldActionMessage:
  26164. m.ResetActionMessage()
  26165. return nil
  26166. case sopnode.FieldActionLabelAdd:
  26167. m.ResetActionLabelAdd()
  26168. return nil
  26169. case sopnode.FieldActionLabelDel:
  26170. m.ResetActionLabelDel()
  26171. return nil
  26172. case sopnode.FieldActionForward:
  26173. m.ResetActionForward()
  26174. return nil
  26175. }
  26176. return fmt.Errorf("unknown SopNode field %s", name)
  26177. }
  26178. // AddedEdges returns all edge names that were set/added in this mutation.
  26179. func (m *SopNodeMutation) AddedEdges() []string {
  26180. edges := make([]string, 0, 2)
  26181. if m.sop_stage != nil {
  26182. edges = append(edges, sopnode.EdgeSopStage)
  26183. }
  26184. if m.node_messages != nil {
  26185. edges = append(edges, sopnode.EdgeNodeMessages)
  26186. }
  26187. return edges
  26188. }
  26189. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26190. // name in this mutation.
  26191. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  26192. switch name {
  26193. case sopnode.EdgeSopStage:
  26194. if id := m.sop_stage; id != nil {
  26195. return []ent.Value{*id}
  26196. }
  26197. case sopnode.EdgeNodeMessages:
  26198. ids := make([]ent.Value, 0, len(m.node_messages))
  26199. for id := range m.node_messages {
  26200. ids = append(ids, id)
  26201. }
  26202. return ids
  26203. }
  26204. return nil
  26205. }
  26206. // RemovedEdges returns all edge names that were removed in this mutation.
  26207. func (m *SopNodeMutation) RemovedEdges() []string {
  26208. edges := make([]string, 0, 2)
  26209. if m.removednode_messages != nil {
  26210. edges = append(edges, sopnode.EdgeNodeMessages)
  26211. }
  26212. return edges
  26213. }
  26214. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26215. // the given name in this mutation.
  26216. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  26217. switch name {
  26218. case sopnode.EdgeNodeMessages:
  26219. ids := make([]ent.Value, 0, len(m.removednode_messages))
  26220. for id := range m.removednode_messages {
  26221. ids = append(ids, id)
  26222. }
  26223. return ids
  26224. }
  26225. return nil
  26226. }
  26227. // ClearedEdges returns all edge names that were cleared in this mutation.
  26228. func (m *SopNodeMutation) ClearedEdges() []string {
  26229. edges := make([]string, 0, 2)
  26230. if m.clearedsop_stage {
  26231. edges = append(edges, sopnode.EdgeSopStage)
  26232. }
  26233. if m.clearednode_messages {
  26234. edges = append(edges, sopnode.EdgeNodeMessages)
  26235. }
  26236. return edges
  26237. }
  26238. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26239. // was cleared in this mutation.
  26240. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  26241. switch name {
  26242. case sopnode.EdgeSopStage:
  26243. return m.clearedsop_stage
  26244. case sopnode.EdgeNodeMessages:
  26245. return m.clearednode_messages
  26246. }
  26247. return false
  26248. }
  26249. // ClearEdge clears the value of the edge with the given name. It returns an error
  26250. // if that edge is not defined in the schema.
  26251. func (m *SopNodeMutation) ClearEdge(name string) error {
  26252. switch name {
  26253. case sopnode.EdgeSopStage:
  26254. m.ClearSopStage()
  26255. return nil
  26256. }
  26257. return fmt.Errorf("unknown SopNode unique edge %s", name)
  26258. }
  26259. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26260. // It returns an error if the edge is not defined in the schema.
  26261. func (m *SopNodeMutation) ResetEdge(name string) error {
  26262. switch name {
  26263. case sopnode.EdgeSopStage:
  26264. m.ResetSopStage()
  26265. return nil
  26266. case sopnode.EdgeNodeMessages:
  26267. m.ResetNodeMessages()
  26268. return nil
  26269. }
  26270. return fmt.Errorf("unknown SopNode edge %s", name)
  26271. }
  26272. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  26273. type SopStageMutation struct {
  26274. config
  26275. op Op
  26276. typ string
  26277. id *uint64
  26278. created_at *time.Time
  26279. updated_at *time.Time
  26280. status *uint8
  26281. addstatus *int8
  26282. deleted_at *time.Time
  26283. name *string
  26284. condition_type *int
  26285. addcondition_type *int
  26286. condition_operator *int
  26287. addcondition_operator *int
  26288. condition_list *[]custom_types.Condition
  26289. appendcondition_list []custom_types.Condition
  26290. action_message *[]custom_types.Action
  26291. appendaction_message []custom_types.Action
  26292. action_label_add *[]uint64
  26293. appendaction_label_add []uint64
  26294. action_label_del *[]uint64
  26295. appendaction_label_del []uint64
  26296. action_forward **custom_types.ActionForward
  26297. index_sort *int
  26298. addindex_sort *int
  26299. clearedFields map[string]struct{}
  26300. sop_task *uint64
  26301. clearedsop_task bool
  26302. stage_nodes map[uint64]struct{}
  26303. removedstage_nodes map[uint64]struct{}
  26304. clearedstage_nodes bool
  26305. stage_messages map[uint64]struct{}
  26306. removedstage_messages map[uint64]struct{}
  26307. clearedstage_messages bool
  26308. done bool
  26309. oldValue func(context.Context) (*SopStage, error)
  26310. predicates []predicate.SopStage
  26311. }
  26312. var _ ent.Mutation = (*SopStageMutation)(nil)
  26313. // sopstageOption allows management of the mutation configuration using functional options.
  26314. type sopstageOption func(*SopStageMutation)
  26315. // newSopStageMutation creates new mutation for the SopStage entity.
  26316. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  26317. m := &SopStageMutation{
  26318. config: c,
  26319. op: op,
  26320. typ: TypeSopStage,
  26321. clearedFields: make(map[string]struct{}),
  26322. }
  26323. for _, opt := range opts {
  26324. opt(m)
  26325. }
  26326. return m
  26327. }
  26328. // withSopStageID sets the ID field of the mutation.
  26329. func withSopStageID(id uint64) sopstageOption {
  26330. return func(m *SopStageMutation) {
  26331. var (
  26332. err error
  26333. once sync.Once
  26334. value *SopStage
  26335. )
  26336. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  26337. once.Do(func() {
  26338. if m.done {
  26339. err = errors.New("querying old values post mutation is not allowed")
  26340. } else {
  26341. value, err = m.Client().SopStage.Get(ctx, id)
  26342. }
  26343. })
  26344. return value, err
  26345. }
  26346. m.id = &id
  26347. }
  26348. }
  26349. // withSopStage sets the old SopStage of the mutation.
  26350. func withSopStage(node *SopStage) sopstageOption {
  26351. return func(m *SopStageMutation) {
  26352. m.oldValue = func(context.Context) (*SopStage, error) {
  26353. return node, nil
  26354. }
  26355. m.id = &node.ID
  26356. }
  26357. }
  26358. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26359. // executed in a transaction (ent.Tx), a transactional client is returned.
  26360. func (m SopStageMutation) Client() *Client {
  26361. client := &Client{config: m.config}
  26362. client.init()
  26363. return client
  26364. }
  26365. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26366. // it returns an error otherwise.
  26367. func (m SopStageMutation) Tx() (*Tx, error) {
  26368. if _, ok := m.driver.(*txDriver); !ok {
  26369. return nil, errors.New("ent: mutation is not running in a transaction")
  26370. }
  26371. tx := &Tx{config: m.config}
  26372. tx.init()
  26373. return tx, nil
  26374. }
  26375. // SetID sets the value of the id field. Note that this
  26376. // operation is only accepted on creation of SopStage entities.
  26377. func (m *SopStageMutation) SetID(id uint64) {
  26378. m.id = &id
  26379. }
  26380. // ID returns the ID value in the mutation. Note that the ID is only available
  26381. // if it was provided to the builder or after it was returned from the database.
  26382. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  26383. if m.id == nil {
  26384. return
  26385. }
  26386. return *m.id, true
  26387. }
  26388. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26389. // That means, if the mutation is applied within a transaction with an isolation level such
  26390. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26391. // or updated by the mutation.
  26392. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  26393. switch {
  26394. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26395. id, exists := m.ID()
  26396. if exists {
  26397. return []uint64{id}, nil
  26398. }
  26399. fallthrough
  26400. case m.op.Is(OpUpdate | OpDelete):
  26401. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  26402. default:
  26403. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26404. }
  26405. }
  26406. // SetCreatedAt sets the "created_at" field.
  26407. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  26408. m.created_at = &t
  26409. }
  26410. // CreatedAt returns the value of the "created_at" field in the mutation.
  26411. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  26412. v := m.created_at
  26413. if v == nil {
  26414. return
  26415. }
  26416. return *v, true
  26417. }
  26418. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  26419. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26421. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26422. if !m.op.Is(OpUpdateOne) {
  26423. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26424. }
  26425. if m.id == nil || m.oldValue == nil {
  26426. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26427. }
  26428. oldValue, err := m.oldValue(ctx)
  26429. if err != nil {
  26430. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26431. }
  26432. return oldValue.CreatedAt, nil
  26433. }
  26434. // ResetCreatedAt resets all changes to the "created_at" field.
  26435. func (m *SopStageMutation) ResetCreatedAt() {
  26436. m.created_at = nil
  26437. }
  26438. // SetUpdatedAt sets the "updated_at" field.
  26439. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  26440. m.updated_at = &t
  26441. }
  26442. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26443. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  26444. v := m.updated_at
  26445. if v == nil {
  26446. return
  26447. }
  26448. return *v, true
  26449. }
  26450. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26454. if !m.op.Is(OpUpdateOne) {
  26455. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26456. }
  26457. if m.id == nil || m.oldValue == nil {
  26458. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  26463. }
  26464. return oldValue.UpdatedAt, nil
  26465. }
  26466. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26467. func (m *SopStageMutation) ResetUpdatedAt() {
  26468. m.updated_at = nil
  26469. }
  26470. // SetStatus sets the "status" field.
  26471. func (m *SopStageMutation) SetStatus(u uint8) {
  26472. m.status = &u
  26473. m.addstatus = nil
  26474. }
  26475. // Status returns the value of the "status" field in the mutation.
  26476. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  26477. v := m.status
  26478. if v == nil {
  26479. return
  26480. }
  26481. return *v, true
  26482. }
  26483. // OldStatus returns the old "status" field's value of the SopStage entity.
  26484. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26486. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26487. if !m.op.Is(OpUpdateOne) {
  26488. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26489. }
  26490. if m.id == nil || m.oldValue == nil {
  26491. return v, errors.New("OldStatus requires an ID field in the mutation")
  26492. }
  26493. oldValue, err := m.oldValue(ctx)
  26494. if err != nil {
  26495. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26496. }
  26497. return oldValue.Status, nil
  26498. }
  26499. // AddStatus adds u to the "status" field.
  26500. func (m *SopStageMutation) AddStatus(u int8) {
  26501. if m.addstatus != nil {
  26502. *m.addstatus += u
  26503. } else {
  26504. m.addstatus = &u
  26505. }
  26506. }
  26507. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26508. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  26509. v := m.addstatus
  26510. if v == nil {
  26511. return
  26512. }
  26513. return *v, true
  26514. }
  26515. // ClearStatus clears the value of the "status" field.
  26516. func (m *SopStageMutation) ClearStatus() {
  26517. m.status = nil
  26518. m.addstatus = nil
  26519. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  26520. }
  26521. // StatusCleared returns if the "status" field was cleared in this mutation.
  26522. func (m *SopStageMutation) StatusCleared() bool {
  26523. _, ok := m.clearedFields[sopstage.FieldStatus]
  26524. return ok
  26525. }
  26526. // ResetStatus resets all changes to the "status" field.
  26527. func (m *SopStageMutation) ResetStatus() {
  26528. m.status = nil
  26529. m.addstatus = nil
  26530. delete(m.clearedFields, sopstage.FieldStatus)
  26531. }
  26532. // SetDeletedAt sets the "deleted_at" field.
  26533. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  26534. m.deleted_at = &t
  26535. }
  26536. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26537. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  26538. v := m.deleted_at
  26539. if v == nil {
  26540. return
  26541. }
  26542. return *v, true
  26543. }
  26544. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  26545. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26547. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26548. if !m.op.Is(OpUpdateOne) {
  26549. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26550. }
  26551. if m.id == nil || m.oldValue == nil {
  26552. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26553. }
  26554. oldValue, err := m.oldValue(ctx)
  26555. if err != nil {
  26556. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26557. }
  26558. return oldValue.DeletedAt, nil
  26559. }
  26560. // ClearDeletedAt clears the value of the "deleted_at" field.
  26561. func (m *SopStageMutation) ClearDeletedAt() {
  26562. m.deleted_at = nil
  26563. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  26564. }
  26565. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26566. func (m *SopStageMutation) DeletedAtCleared() bool {
  26567. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  26568. return ok
  26569. }
  26570. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26571. func (m *SopStageMutation) ResetDeletedAt() {
  26572. m.deleted_at = nil
  26573. delete(m.clearedFields, sopstage.FieldDeletedAt)
  26574. }
  26575. // SetTaskID sets the "task_id" field.
  26576. func (m *SopStageMutation) SetTaskID(u uint64) {
  26577. m.sop_task = &u
  26578. }
  26579. // TaskID returns the value of the "task_id" field in the mutation.
  26580. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  26581. v := m.sop_task
  26582. if v == nil {
  26583. return
  26584. }
  26585. return *v, true
  26586. }
  26587. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  26588. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26590. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  26591. if !m.op.Is(OpUpdateOne) {
  26592. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  26593. }
  26594. if m.id == nil || m.oldValue == nil {
  26595. return v, errors.New("OldTaskID requires an ID field in the mutation")
  26596. }
  26597. oldValue, err := m.oldValue(ctx)
  26598. if err != nil {
  26599. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  26600. }
  26601. return oldValue.TaskID, nil
  26602. }
  26603. // ResetTaskID resets all changes to the "task_id" field.
  26604. func (m *SopStageMutation) ResetTaskID() {
  26605. m.sop_task = nil
  26606. }
  26607. // SetName sets the "name" field.
  26608. func (m *SopStageMutation) SetName(s string) {
  26609. m.name = &s
  26610. }
  26611. // Name returns the value of the "name" field in the mutation.
  26612. func (m *SopStageMutation) Name() (r string, exists bool) {
  26613. v := m.name
  26614. if v == nil {
  26615. return
  26616. }
  26617. return *v, true
  26618. }
  26619. // OldName returns the old "name" 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) OldName(ctx context.Context) (v string, err error) {
  26623. if !m.op.Is(OpUpdateOne) {
  26624. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26625. }
  26626. if m.id == nil || m.oldValue == nil {
  26627. return v, errors.New("OldName 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 OldName: %w", err)
  26632. }
  26633. return oldValue.Name, nil
  26634. }
  26635. // ResetName resets all changes to the "name" field.
  26636. func (m *SopStageMutation) ResetName() {
  26637. m.name = nil
  26638. }
  26639. // SetConditionType sets the "condition_type" field.
  26640. func (m *SopStageMutation) SetConditionType(i int) {
  26641. m.condition_type = &i
  26642. m.addcondition_type = nil
  26643. }
  26644. // ConditionType returns the value of the "condition_type" field in the mutation.
  26645. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  26646. v := m.condition_type
  26647. if v == nil {
  26648. return
  26649. }
  26650. return *v, true
  26651. }
  26652. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  26653. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26655. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  26656. if !m.op.Is(OpUpdateOne) {
  26657. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  26658. }
  26659. if m.id == nil || m.oldValue == nil {
  26660. return v, errors.New("OldConditionType requires an ID field in the mutation")
  26661. }
  26662. oldValue, err := m.oldValue(ctx)
  26663. if err != nil {
  26664. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  26665. }
  26666. return oldValue.ConditionType, nil
  26667. }
  26668. // AddConditionType adds i to the "condition_type" field.
  26669. func (m *SopStageMutation) AddConditionType(i int) {
  26670. if m.addcondition_type != nil {
  26671. *m.addcondition_type += i
  26672. } else {
  26673. m.addcondition_type = &i
  26674. }
  26675. }
  26676. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  26677. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  26678. v := m.addcondition_type
  26679. if v == nil {
  26680. return
  26681. }
  26682. return *v, true
  26683. }
  26684. // ResetConditionType resets all changes to the "condition_type" field.
  26685. func (m *SopStageMutation) ResetConditionType() {
  26686. m.condition_type = nil
  26687. m.addcondition_type = nil
  26688. }
  26689. // SetConditionOperator sets the "condition_operator" field.
  26690. func (m *SopStageMutation) SetConditionOperator(i int) {
  26691. m.condition_operator = &i
  26692. m.addcondition_operator = nil
  26693. }
  26694. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  26695. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  26696. v := m.condition_operator
  26697. if v == nil {
  26698. return
  26699. }
  26700. return *v, true
  26701. }
  26702. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  26703. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26705. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  26706. if !m.op.Is(OpUpdateOne) {
  26707. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  26708. }
  26709. if m.id == nil || m.oldValue == nil {
  26710. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  26711. }
  26712. oldValue, err := m.oldValue(ctx)
  26713. if err != nil {
  26714. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  26715. }
  26716. return oldValue.ConditionOperator, nil
  26717. }
  26718. // AddConditionOperator adds i to the "condition_operator" field.
  26719. func (m *SopStageMutation) AddConditionOperator(i int) {
  26720. if m.addcondition_operator != nil {
  26721. *m.addcondition_operator += i
  26722. } else {
  26723. m.addcondition_operator = &i
  26724. }
  26725. }
  26726. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  26727. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  26728. v := m.addcondition_operator
  26729. if v == nil {
  26730. return
  26731. }
  26732. return *v, true
  26733. }
  26734. // ResetConditionOperator resets all changes to the "condition_operator" field.
  26735. func (m *SopStageMutation) ResetConditionOperator() {
  26736. m.condition_operator = nil
  26737. m.addcondition_operator = nil
  26738. }
  26739. // SetConditionList sets the "condition_list" field.
  26740. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  26741. m.condition_list = &ct
  26742. m.appendcondition_list = nil
  26743. }
  26744. // ConditionList returns the value of the "condition_list" field in the mutation.
  26745. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  26746. v := m.condition_list
  26747. if v == nil {
  26748. return
  26749. }
  26750. return *v, true
  26751. }
  26752. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  26753. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26755. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  26756. if !m.op.Is(OpUpdateOne) {
  26757. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  26758. }
  26759. if m.id == nil || m.oldValue == nil {
  26760. return v, errors.New("OldConditionList requires an ID field in the mutation")
  26761. }
  26762. oldValue, err := m.oldValue(ctx)
  26763. if err != nil {
  26764. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  26765. }
  26766. return oldValue.ConditionList, nil
  26767. }
  26768. // AppendConditionList adds ct to the "condition_list" field.
  26769. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  26770. m.appendcondition_list = append(m.appendcondition_list, ct...)
  26771. }
  26772. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  26773. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  26774. if len(m.appendcondition_list) == 0 {
  26775. return nil, false
  26776. }
  26777. return m.appendcondition_list, true
  26778. }
  26779. // ResetConditionList resets all changes to the "condition_list" field.
  26780. func (m *SopStageMutation) ResetConditionList() {
  26781. m.condition_list = nil
  26782. m.appendcondition_list = nil
  26783. }
  26784. // SetActionMessage sets the "action_message" field.
  26785. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  26786. m.action_message = &ct
  26787. m.appendaction_message = nil
  26788. }
  26789. // ActionMessage returns the value of the "action_message" field in the mutation.
  26790. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  26791. v := m.action_message
  26792. if v == nil {
  26793. return
  26794. }
  26795. return *v, true
  26796. }
  26797. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  26798. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26800. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  26801. if !m.op.Is(OpUpdateOne) {
  26802. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  26803. }
  26804. if m.id == nil || m.oldValue == nil {
  26805. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  26806. }
  26807. oldValue, err := m.oldValue(ctx)
  26808. if err != nil {
  26809. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  26810. }
  26811. return oldValue.ActionMessage, nil
  26812. }
  26813. // AppendActionMessage adds ct to the "action_message" field.
  26814. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  26815. m.appendaction_message = append(m.appendaction_message, ct...)
  26816. }
  26817. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  26818. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  26819. if len(m.appendaction_message) == 0 {
  26820. return nil, false
  26821. }
  26822. return m.appendaction_message, true
  26823. }
  26824. // ClearActionMessage clears the value of the "action_message" field.
  26825. func (m *SopStageMutation) ClearActionMessage() {
  26826. m.action_message = nil
  26827. m.appendaction_message = nil
  26828. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  26829. }
  26830. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  26831. func (m *SopStageMutation) ActionMessageCleared() bool {
  26832. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  26833. return ok
  26834. }
  26835. // ResetActionMessage resets all changes to the "action_message" field.
  26836. func (m *SopStageMutation) ResetActionMessage() {
  26837. m.action_message = nil
  26838. m.appendaction_message = nil
  26839. delete(m.clearedFields, sopstage.FieldActionMessage)
  26840. }
  26841. // SetActionLabelAdd sets the "action_label_add" field.
  26842. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  26843. m.action_label_add = &u
  26844. m.appendaction_label_add = nil
  26845. }
  26846. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  26847. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  26848. v := m.action_label_add
  26849. if v == nil {
  26850. return
  26851. }
  26852. return *v, true
  26853. }
  26854. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  26855. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26857. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  26858. if !m.op.Is(OpUpdateOne) {
  26859. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  26860. }
  26861. if m.id == nil || m.oldValue == nil {
  26862. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  26863. }
  26864. oldValue, err := m.oldValue(ctx)
  26865. if err != nil {
  26866. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  26867. }
  26868. return oldValue.ActionLabelAdd, nil
  26869. }
  26870. // AppendActionLabelAdd adds u to the "action_label_add" field.
  26871. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  26872. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  26873. }
  26874. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  26875. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  26876. if len(m.appendaction_label_add) == 0 {
  26877. return nil, false
  26878. }
  26879. return m.appendaction_label_add, true
  26880. }
  26881. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  26882. func (m *SopStageMutation) ClearActionLabelAdd() {
  26883. m.action_label_add = nil
  26884. m.appendaction_label_add = nil
  26885. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  26886. }
  26887. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  26888. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  26889. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  26890. return ok
  26891. }
  26892. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  26893. func (m *SopStageMutation) ResetActionLabelAdd() {
  26894. m.action_label_add = nil
  26895. m.appendaction_label_add = nil
  26896. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  26897. }
  26898. // SetActionLabelDel sets the "action_label_del" field.
  26899. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  26900. m.action_label_del = &u
  26901. m.appendaction_label_del = nil
  26902. }
  26903. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  26904. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  26905. v := m.action_label_del
  26906. if v == nil {
  26907. return
  26908. }
  26909. return *v, true
  26910. }
  26911. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  26912. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26914. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  26915. if !m.op.Is(OpUpdateOne) {
  26916. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  26917. }
  26918. if m.id == nil || m.oldValue == nil {
  26919. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  26920. }
  26921. oldValue, err := m.oldValue(ctx)
  26922. if err != nil {
  26923. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  26924. }
  26925. return oldValue.ActionLabelDel, nil
  26926. }
  26927. // AppendActionLabelDel adds u to the "action_label_del" field.
  26928. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  26929. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  26930. }
  26931. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  26932. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  26933. if len(m.appendaction_label_del) == 0 {
  26934. return nil, false
  26935. }
  26936. return m.appendaction_label_del, true
  26937. }
  26938. // ClearActionLabelDel clears the value of the "action_label_del" field.
  26939. func (m *SopStageMutation) ClearActionLabelDel() {
  26940. m.action_label_del = nil
  26941. m.appendaction_label_del = nil
  26942. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  26943. }
  26944. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  26945. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  26946. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  26947. return ok
  26948. }
  26949. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  26950. func (m *SopStageMutation) ResetActionLabelDel() {
  26951. m.action_label_del = nil
  26952. m.appendaction_label_del = nil
  26953. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  26954. }
  26955. // SetActionForward sets the "action_forward" field.
  26956. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  26957. m.action_forward = &ctf
  26958. }
  26959. // ActionForward returns the value of the "action_forward" field in the mutation.
  26960. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  26961. v := m.action_forward
  26962. if v == nil {
  26963. return
  26964. }
  26965. return *v, true
  26966. }
  26967. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  26968. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26970. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  26971. if !m.op.Is(OpUpdateOne) {
  26972. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  26973. }
  26974. if m.id == nil || m.oldValue == nil {
  26975. return v, errors.New("OldActionForward requires an ID field in the mutation")
  26976. }
  26977. oldValue, err := m.oldValue(ctx)
  26978. if err != nil {
  26979. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  26980. }
  26981. return oldValue.ActionForward, nil
  26982. }
  26983. // ClearActionForward clears the value of the "action_forward" field.
  26984. func (m *SopStageMutation) ClearActionForward() {
  26985. m.action_forward = nil
  26986. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  26987. }
  26988. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  26989. func (m *SopStageMutation) ActionForwardCleared() bool {
  26990. _, ok := m.clearedFields[sopstage.FieldActionForward]
  26991. return ok
  26992. }
  26993. // ResetActionForward resets all changes to the "action_forward" field.
  26994. func (m *SopStageMutation) ResetActionForward() {
  26995. m.action_forward = nil
  26996. delete(m.clearedFields, sopstage.FieldActionForward)
  26997. }
  26998. // SetIndexSort sets the "index_sort" field.
  26999. func (m *SopStageMutation) SetIndexSort(i int) {
  27000. m.index_sort = &i
  27001. m.addindex_sort = nil
  27002. }
  27003. // IndexSort returns the value of the "index_sort" field in the mutation.
  27004. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  27005. v := m.index_sort
  27006. if v == nil {
  27007. return
  27008. }
  27009. return *v, true
  27010. }
  27011. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  27012. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27014. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  27015. if !m.op.Is(OpUpdateOne) {
  27016. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  27017. }
  27018. if m.id == nil || m.oldValue == nil {
  27019. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  27020. }
  27021. oldValue, err := m.oldValue(ctx)
  27022. if err != nil {
  27023. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  27024. }
  27025. return oldValue.IndexSort, nil
  27026. }
  27027. // AddIndexSort adds i to the "index_sort" field.
  27028. func (m *SopStageMutation) AddIndexSort(i int) {
  27029. if m.addindex_sort != nil {
  27030. *m.addindex_sort += i
  27031. } else {
  27032. m.addindex_sort = &i
  27033. }
  27034. }
  27035. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  27036. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  27037. v := m.addindex_sort
  27038. if v == nil {
  27039. return
  27040. }
  27041. return *v, true
  27042. }
  27043. // ClearIndexSort clears the value of the "index_sort" field.
  27044. func (m *SopStageMutation) ClearIndexSort() {
  27045. m.index_sort = nil
  27046. m.addindex_sort = nil
  27047. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  27048. }
  27049. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  27050. func (m *SopStageMutation) IndexSortCleared() bool {
  27051. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  27052. return ok
  27053. }
  27054. // ResetIndexSort resets all changes to the "index_sort" field.
  27055. func (m *SopStageMutation) ResetIndexSort() {
  27056. m.index_sort = nil
  27057. m.addindex_sort = nil
  27058. delete(m.clearedFields, sopstage.FieldIndexSort)
  27059. }
  27060. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  27061. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  27062. m.sop_task = &id
  27063. }
  27064. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  27065. func (m *SopStageMutation) ClearSopTask() {
  27066. m.clearedsop_task = true
  27067. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  27068. }
  27069. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  27070. func (m *SopStageMutation) SopTaskCleared() bool {
  27071. return m.clearedsop_task
  27072. }
  27073. // SopTaskID returns the "sop_task" edge ID in the mutation.
  27074. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  27075. if m.sop_task != nil {
  27076. return *m.sop_task, true
  27077. }
  27078. return
  27079. }
  27080. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  27081. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27082. // SopTaskID instead. It exists only for internal usage by the builders.
  27083. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  27084. if id := m.sop_task; id != nil {
  27085. ids = append(ids, *id)
  27086. }
  27087. return
  27088. }
  27089. // ResetSopTask resets all changes to the "sop_task" edge.
  27090. func (m *SopStageMutation) ResetSopTask() {
  27091. m.sop_task = nil
  27092. m.clearedsop_task = false
  27093. }
  27094. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  27095. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  27096. if m.stage_nodes == nil {
  27097. m.stage_nodes = make(map[uint64]struct{})
  27098. }
  27099. for i := range ids {
  27100. m.stage_nodes[ids[i]] = struct{}{}
  27101. }
  27102. }
  27103. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  27104. func (m *SopStageMutation) ClearStageNodes() {
  27105. m.clearedstage_nodes = true
  27106. }
  27107. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  27108. func (m *SopStageMutation) StageNodesCleared() bool {
  27109. return m.clearedstage_nodes
  27110. }
  27111. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  27112. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  27113. if m.removedstage_nodes == nil {
  27114. m.removedstage_nodes = make(map[uint64]struct{})
  27115. }
  27116. for i := range ids {
  27117. delete(m.stage_nodes, ids[i])
  27118. m.removedstage_nodes[ids[i]] = struct{}{}
  27119. }
  27120. }
  27121. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  27122. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  27123. for id := range m.removedstage_nodes {
  27124. ids = append(ids, id)
  27125. }
  27126. return
  27127. }
  27128. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  27129. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  27130. for id := range m.stage_nodes {
  27131. ids = append(ids, id)
  27132. }
  27133. return
  27134. }
  27135. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  27136. func (m *SopStageMutation) ResetStageNodes() {
  27137. m.stage_nodes = nil
  27138. m.clearedstage_nodes = false
  27139. m.removedstage_nodes = nil
  27140. }
  27141. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  27142. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  27143. if m.stage_messages == nil {
  27144. m.stage_messages = make(map[uint64]struct{})
  27145. }
  27146. for i := range ids {
  27147. m.stage_messages[ids[i]] = struct{}{}
  27148. }
  27149. }
  27150. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  27151. func (m *SopStageMutation) ClearStageMessages() {
  27152. m.clearedstage_messages = true
  27153. }
  27154. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  27155. func (m *SopStageMutation) StageMessagesCleared() bool {
  27156. return m.clearedstage_messages
  27157. }
  27158. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  27159. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  27160. if m.removedstage_messages == nil {
  27161. m.removedstage_messages = make(map[uint64]struct{})
  27162. }
  27163. for i := range ids {
  27164. delete(m.stage_messages, ids[i])
  27165. m.removedstage_messages[ids[i]] = struct{}{}
  27166. }
  27167. }
  27168. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  27169. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  27170. for id := range m.removedstage_messages {
  27171. ids = append(ids, id)
  27172. }
  27173. return
  27174. }
  27175. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  27176. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  27177. for id := range m.stage_messages {
  27178. ids = append(ids, id)
  27179. }
  27180. return
  27181. }
  27182. // ResetStageMessages resets all changes to the "stage_messages" edge.
  27183. func (m *SopStageMutation) ResetStageMessages() {
  27184. m.stage_messages = nil
  27185. m.clearedstage_messages = false
  27186. m.removedstage_messages = nil
  27187. }
  27188. // Where appends a list predicates to the SopStageMutation builder.
  27189. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  27190. m.predicates = append(m.predicates, ps...)
  27191. }
  27192. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  27193. // users can use type-assertion to append predicates that do not depend on any generated package.
  27194. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  27195. p := make([]predicate.SopStage, len(ps))
  27196. for i := range ps {
  27197. p[i] = ps[i]
  27198. }
  27199. m.Where(p...)
  27200. }
  27201. // Op returns the operation name.
  27202. func (m *SopStageMutation) Op() Op {
  27203. return m.op
  27204. }
  27205. // SetOp allows setting the mutation operation.
  27206. func (m *SopStageMutation) SetOp(op Op) {
  27207. m.op = op
  27208. }
  27209. // Type returns the node type of this mutation (SopStage).
  27210. func (m *SopStageMutation) Type() string {
  27211. return m.typ
  27212. }
  27213. // Fields returns all fields that were changed during this mutation. Note that in
  27214. // order to get all numeric fields that were incremented/decremented, call
  27215. // AddedFields().
  27216. func (m *SopStageMutation) Fields() []string {
  27217. fields := make([]string, 0, 14)
  27218. if m.created_at != nil {
  27219. fields = append(fields, sopstage.FieldCreatedAt)
  27220. }
  27221. if m.updated_at != nil {
  27222. fields = append(fields, sopstage.FieldUpdatedAt)
  27223. }
  27224. if m.status != nil {
  27225. fields = append(fields, sopstage.FieldStatus)
  27226. }
  27227. if m.deleted_at != nil {
  27228. fields = append(fields, sopstage.FieldDeletedAt)
  27229. }
  27230. if m.sop_task != nil {
  27231. fields = append(fields, sopstage.FieldTaskID)
  27232. }
  27233. if m.name != nil {
  27234. fields = append(fields, sopstage.FieldName)
  27235. }
  27236. if m.condition_type != nil {
  27237. fields = append(fields, sopstage.FieldConditionType)
  27238. }
  27239. if m.condition_operator != nil {
  27240. fields = append(fields, sopstage.FieldConditionOperator)
  27241. }
  27242. if m.condition_list != nil {
  27243. fields = append(fields, sopstage.FieldConditionList)
  27244. }
  27245. if m.action_message != nil {
  27246. fields = append(fields, sopstage.FieldActionMessage)
  27247. }
  27248. if m.action_label_add != nil {
  27249. fields = append(fields, sopstage.FieldActionLabelAdd)
  27250. }
  27251. if m.action_label_del != nil {
  27252. fields = append(fields, sopstage.FieldActionLabelDel)
  27253. }
  27254. if m.action_forward != nil {
  27255. fields = append(fields, sopstage.FieldActionForward)
  27256. }
  27257. if m.index_sort != nil {
  27258. fields = append(fields, sopstage.FieldIndexSort)
  27259. }
  27260. return fields
  27261. }
  27262. // Field returns the value of a field with the given name. The second boolean
  27263. // return value indicates that this field was not set, or was not defined in the
  27264. // schema.
  27265. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  27266. switch name {
  27267. case sopstage.FieldCreatedAt:
  27268. return m.CreatedAt()
  27269. case sopstage.FieldUpdatedAt:
  27270. return m.UpdatedAt()
  27271. case sopstage.FieldStatus:
  27272. return m.Status()
  27273. case sopstage.FieldDeletedAt:
  27274. return m.DeletedAt()
  27275. case sopstage.FieldTaskID:
  27276. return m.TaskID()
  27277. case sopstage.FieldName:
  27278. return m.Name()
  27279. case sopstage.FieldConditionType:
  27280. return m.ConditionType()
  27281. case sopstage.FieldConditionOperator:
  27282. return m.ConditionOperator()
  27283. case sopstage.FieldConditionList:
  27284. return m.ConditionList()
  27285. case sopstage.FieldActionMessage:
  27286. return m.ActionMessage()
  27287. case sopstage.FieldActionLabelAdd:
  27288. return m.ActionLabelAdd()
  27289. case sopstage.FieldActionLabelDel:
  27290. return m.ActionLabelDel()
  27291. case sopstage.FieldActionForward:
  27292. return m.ActionForward()
  27293. case sopstage.FieldIndexSort:
  27294. return m.IndexSort()
  27295. }
  27296. return nil, false
  27297. }
  27298. // OldField returns the old value of the field from the database. An error is
  27299. // returned if the mutation operation is not UpdateOne, or the query to the
  27300. // database failed.
  27301. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27302. switch name {
  27303. case sopstage.FieldCreatedAt:
  27304. return m.OldCreatedAt(ctx)
  27305. case sopstage.FieldUpdatedAt:
  27306. return m.OldUpdatedAt(ctx)
  27307. case sopstage.FieldStatus:
  27308. return m.OldStatus(ctx)
  27309. case sopstage.FieldDeletedAt:
  27310. return m.OldDeletedAt(ctx)
  27311. case sopstage.FieldTaskID:
  27312. return m.OldTaskID(ctx)
  27313. case sopstage.FieldName:
  27314. return m.OldName(ctx)
  27315. case sopstage.FieldConditionType:
  27316. return m.OldConditionType(ctx)
  27317. case sopstage.FieldConditionOperator:
  27318. return m.OldConditionOperator(ctx)
  27319. case sopstage.FieldConditionList:
  27320. return m.OldConditionList(ctx)
  27321. case sopstage.FieldActionMessage:
  27322. return m.OldActionMessage(ctx)
  27323. case sopstage.FieldActionLabelAdd:
  27324. return m.OldActionLabelAdd(ctx)
  27325. case sopstage.FieldActionLabelDel:
  27326. return m.OldActionLabelDel(ctx)
  27327. case sopstage.FieldActionForward:
  27328. return m.OldActionForward(ctx)
  27329. case sopstage.FieldIndexSort:
  27330. return m.OldIndexSort(ctx)
  27331. }
  27332. return nil, fmt.Errorf("unknown SopStage field %s", name)
  27333. }
  27334. // SetField sets the value of a field with the given name. It returns an error if
  27335. // the field is not defined in the schema, or if the type mismatched the field
  27336. // type.
  27337. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  27338. switch name {
  27339. case sopstage.FieldCreatedAt:
  27340. v, ok := value.(time.Time)
  27341. if !ok {
  27342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27343. }
  27344. m.SetCreatedAt(v)
  27345. return nil
  27346. case sopstage.FieldUpdatedAt:
  27347. v, ok := value.(time.Time)
  27348. if !ok {
  27349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27350. }
  27351. m.SetUpdatedAt(v)
  27352. return nil
  27353. case sopstage.FieldStatus:
  27354. v, ok := value.(uint8)
  27355. if !ok {
  27356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27357. }
  27358. m.SetStatus(v)
  27359. return nil
  27360. case sopstage.FieldDeletedAt:
  27361. v, ok := value.(time.Time)
  27362. if !ok {
  27363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27364. }
  27365. m.SetDeletedAt(v)
  27366. return nil
  27367. case sopstage.FieldTaskID:
  27368. v, ok := value.(uint64)
  27369. if !ok {
  27370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27371. }
  27372. m.SetTaskID(v)
  27373. return nil
  27374. case sopstage.FieldName:
  27375. v, ok := value.(string)
  27376. if !ok {
  27377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27378. }
  27379. m.SetName(v)
  27380. return nil
  27381. case sopstage.FieldConditionType:
  27382. v, ok := value.(int)
  27383. if !ok {
  27384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27385. }
  27386. m.SetConditionType(v)
  27387. return nil
  27388. case sopstage.FieldConditionOperator:
  27389. v, ok := value.(int)
  27390. if !ok {
  27391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27392. }
  27393. m.SetConditionOperator(v)
  27394. return nil
  27395. case sopstage.FieldConditionList:
  27396. v, ok := value.([]custom_types.Condition)
  27397. if !ok {
  27398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27399. }
  27400. m.SetConditionList(v)
  27401. return nil
  27402. case sopstage.FieldActionMessage:
  27403. v, ok := value.([]custom_types.Action)
  27404. if !ok {
  27405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27406. }
  27407. m.SetActionMessage(v)
  27408. return nil
  27409. case sopstage.FieldActionLabelAdd:
  27410. v, ok := value.([]uint64)
  27411. if !ok {
  27412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27413. }
  27414. m.SetActionLabelAdd(v)
  27415. return nil
  27416. case sopstage.FieldActionLabelDel:
  27417. v, ok := value.([]uint64)
  27418. if !ok {
  27419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27420. }
  27421. m.SetActionLabelDel(v)
  27422. return nil
  27423. case sopstage.FieldActionForward:
  27424. v, ok := value.(*custom_types.ActionForward)
  27425. if !ok {
  27426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27427. }
  27428. m.SetActionForward(v)
  27429. return nil
  27430. case sopstage.FieldIndexSort:
  27431. v, ok := value.(int)
  27432. if !ok {
  27433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27434. }
  27435. m.SetIndexSort(v)
  27436. return nil
  27437. }
  27438. return fmt.Errorf("unknown SopStage field %s", name)
  27439. }
  27440. // AddedFields returns all numeric fields that were incremented/decremented during
  27441. // this mutation.
  27442. func (m *SopStageMutation) AddedFields() []string {
  27443. var fields []string
  27444. if m.addstatus != nil {
  27445. fields = append(fields, sopstage.FieldStatus)
  27446. }
  27447. if m.addcondition_type != nil {
  27448. fields = append(fields, sopstage.FieldConditionType)
  27449. }
  27450. if m.addcondition_operator != nil {
  27451. fields = append(fields, sopstage.FieldConditionOperator)
  27452. }
  27453. if m.addindex_sort != nil {
  27454. fields = append(fields, sopstage.FieldIndexSort)
  27455. }
  27456. return fields
  27457. }
  27458. // AddedField returns the numeric value that was incremented/decremented on a field
  27459. // with the given name. The second boolean return value indicates that this field
  27460. // was not set, or was not defined in the schema.
  27461. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  27462. switch name {
  27463. case sopstage.FieldStatus:
  27464. return m.AddedStatus()
  27465. case sopstage.FieldConditionType:
  27466. return m.AddedConditionType()
  27467. case sopstage.FieldConditionOperator:
  27468. return m.AddedConditionOperator()
  27469. case sopstage.FieldIndexSort:
  27470. return m.AddedIndexSort()
  27471. }
  27472. return nil, false
  27473. }
  27474. // AddField adds the value to the field with the given name. It returns an error if
  27475. // the field is not defined in the schema, or if the type mismatched the field
  27476. // type.
  27477. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  27478. switch name {
  27479. case sopstage.FieldStatus:
  27480. v, ok := value.(int8)
  27481. if !ok {
  27482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27483. }
  27484. m.AddStatus(v)
  27485. return nil
  27486. case sopstage.FieldConditionType:
  27487. v, ok := value.(int)
  27488. if !ok {
  27489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27490. }
  27491. m.AddConditionType(v)
  27492. return nil
  27493. case sopstage.FieldConditionOperator:
  27494. v, ok := value.(int)
  27495. if !ok {
  27496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27497. }
  27498. m.AddConditionOperator(v)
  27499. return nil
  27500. case sopstage.FieldIndexSort:
  27501. v, ok := value.(int)
  27502. if !ok {
  27503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27504. }
  27505. m.AddIndexSort(v)
  27506. return nil
  27507. }
  27508. return fmt.Errorf("unknown SopStage numeric field %s", name)
  27509. }
  27510. // ClearedFields returns all nullable fields that were cleared during this
  27511. // mutation.
  27512. func (m *SopStageMutation) ClearedFields() []string {
  27513. var fields []string
  27514. if m.FieldCleared(sopstage.FieldStatus) {
  27515. fields = append(fields, sopstage.FieldStatus)
  27516. }
  27517. if m.FieldCleared(sopstage.FieldDeletedAt) {
  27518. fields = append(fields, sopstage.FieldDeletedAt)
  27519. }
  27520. if m.FieldCleared(sopstage.FieldActionMessage) {
  27521. fields = append(fields, sopstage.FieldActionMessage)
  27522. }
  27523. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  27524. fields = append(fields, sopstage.FieldActionLabelAdd)
  27525. }
  27526. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  27527. fields = append(fields, sopstage.FieldActionLabelDel)
  27528. }
  27529. if m.FieldCleared(sopstage.FieldActionForward) {
  27530. fields = append(fields, sopstage.FieldActionForward)
  27531. }
  27532. if m.FieldCleared(sopstage.FieldIndexSort) {
  27533. fields = append(fields, sopstage.FieldIndexSort)
  27534. }
  27535. return fields
  27536. }
  27537. // FieldCleared returns a boolean indicating if a field with the given name was
  27538. // cleared in this mutation.
  27539. func (m *SopStageMutation) FieldCleared(name string) bool {
  27540. _, ok := m.clearedFields[name]
  27541. return ok
  27542. }
  27543. // ClearField clears the value of the field with the given name. It returns an
  27544. // error if the field is not defined in the schema.
  27545. func (m *SopStageMutation) ClearField(name string) error {
  27546. switch name {
  27547. case sopstage.FieldStatus:
  27548. m.ClearStatus()
  27549. return nil
  27550. case sopstage.FieldDeletedAt:
  27551. m.ClearDeletedAt()
  27552. return nil
  27553. case sopstage.FieldActionMessage:
  27554. m.ClearActionMessage()
  27555. return nil
  27556. case sopstage.FieldActionLabelAdd:
  27557. m.ClearActionLabelAdd()
  27558. return nil
  27559. case sopstage.FieldActionLabelDel:
  27560. m.ClearActionLabelDel()
  27561. return nil
  27562. case sopstage.FieldActionForward:
  27563. m.ClearActionForward()
  27564. return nil
  27565. case sopstage.FieldIndexSort:
  27566. m.ClearIndexSort()
  27567. return nil
  27568. }
  27569. return fmt.Errorf("unknown SopStage nullable field %s", name)
  27570. }
  27571. // ResetField resets all changes in the mutation for the field with the given name.
  27572. // It returns an error if the field is not defined in the schema.
  27573. func (m *SopStageMutation) ResetField(name string) error {
  27574. switch name {
  27575. case sopstage.FieldCreatedAt:
  27576. m.ResetCreatedAt()
  27577. return nil
  27578. case sopstage.FieldUpdatedAt:
  27579. m.ResetUpdatedAt()
  27580. return nil
  27581. case sopstage.FieldStatus:
  27582. m.ResetStatus()
  27583. return nil
  27584. case sopstage.FieldDeletedAt:
  27585. m.ResetDeletedAt()
  27586. return nil
  27587. case sopstage.FieldTaskID:
  27588. m.ResetTaskID()
  27589. return nil
  27590. case sopstage.FieldName:
  27591. m.ResetName()
  27592. return nil
  27593. case sopstage.FieldConditionType:
  27594. m.ResetConditionType()
  27595. return nil
  27596. case sopstage.FieldConditionOperator:
  27597. m.ResetConditionOperator()
  27598. return nil
  27599. case sopstage.FieldConditionList:
  27600. m.ResetConditionList()
  27601. return nil
  27602. case sopstage.FieldActionMessage:
  27603. m.ResetActionMessage()
  27604. return nil
  27605. case sopstage.FieldActionLabelAdd:
  27606. m.ResetActionLabelAdd()
  27607. return nil
  27608. case sopstage.FieldActionLabelDel:
  27609. m.ResetActionLabelDel()
  27610. return nil
  27611. case sopstage.FieldActionForward:
  27612. m.ResetActionForward()
  27613. return nil
  27614. case sopstage.FieldIndexSort:
  27615. m.ResetIndexSort()
  27616. return nil
  27617. }
  27618. return fmt.Errorf("unknown SopStage field %s", name)
  27619. }
  27620. // AddedEdges returns all edge names that were set/added in this mutation.
  27621. func (m *SopStageMutation) AddedEdges() []string {
  27622. edges := make([]string, 0, 3)
  27623. if m.sop_task != nil {
  27624. edges = append(edges, sopstage.EdgeSopTask)
  27625. }
  27626. if m.stage_nodes != nil {
  27627. edges = append(edges, sopstage.EdgeStageNodes)
  27628. }
  27629. if m.stage_messages != nil {
  27630. edges = append(edges, sopstage.EdgeStageMessages)
  27631. }
  27632. return edges
  27633. }
  27634. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27635. // name in this mutation.
  27636. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  27637. switch name {
  27638. case sopstage.EdgeSopTask:
  27639. if id := m.sop_task; id != nil {
  27640. return []ent.Value{*id}
  27641. }
  27642. case sopstage.EdgeStageNodes:
  27643. ids := make([]ent.Value, 0, len(m.stage_nodes))
  27644. for id := range m.stage_nodes {
  27645. ids = append(ids, id)
  27646. }
  27647. return ids
  27648. case sopstage.EdgeStageMessages:
  27649. ids := make([]ent.Value, 0, len(m.stage_messages))
  27650. for id := range m.stage_messages {
  27651. ids = append(ids, id)
  27652. }
  27653. return ids
  27654. }
  27655. return nil
  27656. }
  27657. // RemovedEdges returns all edge names that were removed in this mutation.
  27658. func (m *SopStageMutation) RemovedEdges() []string {
  27659. edges := make([]string, 0, 3)
  27660. if m.removedstage_nodes != nil {
  27661. edges = append(edges, sopstage.EdgeStageNodes)
  27662. }
  27663. if m.removedstage_messages != nil {
  27664. edges = append(edges, sopstage.EdgeStageMessages)
  27665. }
  27666. return edges
  27667. }
  27668. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27669. // the given name in this mutation.
  27670. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  27671. switch name {
  27672. case sopstage.EdgeStageNodes:
  27673. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  27674. for id := range m.removedstage_nodes {
  27675. ids = append(ids, id)
  27676. }
  27677. return ids
  27678. case sopstage.EdgeStageMessages:
  27679. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  27680. for id := range m.removedstage_messages {
  27681. ids = append(ids, id)
  27682. }
  27683. return ids
  27684. }
  27685. return nil
  27686. }
  27687. // ClearedEdges returns all edge names that were cleared in this mutation.
  27688. func (m *SopStageMutation) ClearedEdges() []string {
  27689. edges := make([]string, 0, 3)
  27690. if m.clearedsop_task {
  27691. edges = append(edges, sopstage.EdgeSopTask)
  27692. }
  27693. if m.clearedstage_nodes {
  27694. edges = append(edges, sopstage.EdgeStageNodes)
  27695. }
  27696. if m.clearedstage_messages {
  27697. edges = append(edges, sopstage.EdgeStageMessages)
  27698. }
  27699. return edges
  27700. }
  27701. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27702. // was cleared in this mutation.
  27703. func (m *SopStageMutation) EdgeCleared(name string) bool {
  27704. switch name {
  27705. case sopstage.EdgeSopTask:
  27706. return m.clearedsop_task
  27707. case sopstage.EdgeStageNodes:
  27708. return m.clearedstage_nodes
  27709. case sopstage.EdgeStageMessages:
  27710. return m.clearedstage_messages
  27711. }
  27712. return false
  27713. }
  27714. // ClearEdge clears the value of the edge with the given name. It returns an error
  27715. // if that edge is not defined in the schema.
  27716. func (m *SopStageMutation) ClearEdge(name string) error {
  27717. switch name {
  27718. case sopstage.EdgeSopTask:
  27719. m.ClearSopTask()
  27720. return nil
  27721. }
  27722. return fmt.Errorf("unknown SopStage unique edge %s", name)
  27723. }
  27724. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27725. // It returns an error if the edge is not defined in the schema.
  27726. func (m *SopStageMutation) ResetEdge(name string) error {
  27727. switch name {
  27728. case sopstage.EdgeSopTask:
  27729. m.ResetSopTask()
  27730. return nil
  27731. case sopstage.EdgeStageNodes:
  27732. m.ResetStageNodes()
  27733. return nil
  27734. case sopstage.EdgeStageMessages:
  27735. m.ResetStageMessages()
  27736. return nil
  27737. }
  27738. return fmt.Errorf("unknown SopStage edge %s", name)
  27739. }
  27740. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  27741. type SopTaskMutation struct {
  27742. config
  27743. op Op
  27744. typ string
  27745. id *uint64
  27746. created_at *time.Time
  27747. updated_at *time.Time
  27748. status *uint8
  27749. addstatus *int8
  27750. deleted_at *time.Time
  27751. name *string
  27752. bot_wxid_list *[]string
  27753. appendbot_wxid_list []string
  27754. _type *int
  27755. add_type *int
  27756. plan_start_time *time.Time
  27757. plan_end_time *time.Time
  27758. creator_id *string
  27759. organization_id *uint64
  27760. addorganization_id *int64
  27761. token *[]string
  27762. appendtoken []string
  27763. clearedFields map[string]struct{}
  27764. task_stages map[uint64]struct{}
  27765. removedtask_stages map[uint64]struct{}
  27766. clearedtask_stages bool
  27767. done bool
  27768. oldValue func(context.Context) (*SopTask, error)
  27769. predicates []predicate.SopTask
  27770. }
  27771. var _ ent.Mutation = (*SopTaskMutation)(nil)
  27772. // soptaskOption allows management of the mutation configuration using functional options.
  27773. type soptaskOption func(*SopTaskMutation)
  27774. // newSopTaskMutation creates new mutation for the SopTask entity.
  27775. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  27776. m := &SopTaskMutation{
  27777. config: c,
  27778. op: op,
  27779. typ: TypeSopTask,
  27780. clearedFields: make(map[string]struct{}),
  27781. }
  27782. for _, opt := range opts {
  27783. opt(m)
  27784. }
  27785. return m
  27786. }
  27787. // withSopTaskID sets the ID field of the mutation.
  27788. func withSopTaskID(id uint64) soptaskOption {
  27789. return func(m *SopTaskMutation) {
  27790. var (
  27791. err error
  27792. once sync.Once
  27793. value *SopTask
  27794. )
  27795. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  27796. once.Do(func() {
  27797. if m.done {
  27798. err = errors.New("querying old values post mutation is not allowed")
  27799. } else {
  27800. value, err = m.Client().SopTask.Get(ctx, id)
  27801. }
  27802. })
  27803. return value, err
  27804. }
  27805. m.id = &id
  27806. }
  27807. }
  27808. // withSopTask sets the old SopTask of the mutation.
  27809. func withSopTask(node *SopTask) soptaskOption {
  27810. return func(m *SopTaskMutation) {
  27811. m.oldValue = func(context.Context) (*SopTask, error) {
  27812. return node, nil
  27813. }
  27814. m.id = &node.ID
  27815. }
  27816. }
  27817. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27818. // executed in a transaction (ent.Tx), a transactional client is returned.
  27819. func (m SopTaskMutation) Client() *Client {
  27820. client := &Client{config: m.config}
  27821. client.init()
  27822. return client
  27823. }
  27824. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27825. // it returns an error otherwise.
  27826. func (m SopTaskMutation) Tx() (*Tx, error) {
  27827. if _, ok := m.driver.(*txDriver); !ok {
  27828. return nil, errors.New("ent: mutation is not running in a transaction")
  27829. }
  27830. tx := &Tx{config: m.config}
  27831. tx.init()
  27832. return tx, nil
  27833. }
  27834. // SetID sets the value of the id field. Note that this
  27835. // operation is only accepted on creation of SopTask entities.
  27836. func (m *SopTaskMutation) SetID(id uint64) {
  27837. m.id = &id
  27838. }
  27839. // ID returns the ID value in the mutation. Note that the ID is only available
  27840. // if it was provided to the builder or after it was returned from the database.
  27841. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  27842. if m.id == nil {
  27843. return
  27844. }
  27845. return *m.id, true
  27846. }
  27847. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27848. // That means, if the mutation is applied within a transaction with an isolation level such
  27849. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27850. // or updated by the mutation.
  27851. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  27852. switch {
  27853. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27854. id, exists := m.ID()
  27855. if exists {
  27856. return []uint64{id}, nil
  27857. }
  27858. fallthrough
  27859. case m.op.Is(OpUpdate | OpDelete):
  27860. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  27861. default:
  27862. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27863. }
  27864. }
  27865. // SetCreatedAt sets the "created_at" field.
  27866. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  27867. m.created_at = &t
  27868. }
  27869. // CreatedAt returns the value of the "created_at" field in the mutation.
  27870. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  27871. v := m.created_at
  27872. if v == nil {
  27873. return
  27874. }
  27875. return *v, true
  27876. }
  27877. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  27878. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27880. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27881. if !m.op.Is(OpUpdateOne) {
  27882. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27883. }
  27884. if m.id == nil || m.oldValue == nil {
  27885. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27886. }
  27887. oldValue, err := m.oldValue(ctx)
  27888. if err != nil {
  27889. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27890. }
  27891. return oldValue.CreatedAt, nil
  27892. }
  27893. // ResetCreatedAt resets all changes to the "created_at" field.
  27894. func (m *SopTaskMutation) ResetCreatedAt() {
  27895. m.created_at = nil
  27896. }
  27897. // SetUpdatedAt sets the "updated_at" field.
  27898. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  27899. m.updated_at = &t
  27900. }
  27901. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27902. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  27903. v := m.updated_at
  27904. if v == nil {
  27905. return
  27906. }
  27907. return *v, true
  27908. }
  27909. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27913. if !m.op.Is(OpUpdateOne) {
  27914. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27915. }
  27916. if m.id == nil || m.oldValue == nil {
  27917. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  27922. }
  27923. return oldValue.UpdatedAt, nil
  27924. }
  27925. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27926. func (m *SopTaskMutation) ResetUpdatedAt() {
  27927. m.updated_at = nil
  27928. }
  27929. // SetStatus sets the "status" field.
  27930. func (m *SopTaskMutation) SetStatus(u uint8) {
  27931. m.status = &u
  27932. m.addstatus = nil
  27933. }
  27934. // Status returns the value of the "status" field in the mutation.
  27935. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  27936. v := m.status
  27937. if v == nil {
  27938. return
  27939. }
  27940. return *v, true
  27941. }
  27942. // OldStatus returns the old "status" field's value of the SopTask entity.
  27943. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27945. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27946. if !m.op.Is(OpUpdateOne) {
  27947. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27948. }
  27949. if m.id == nil || m.oldValue == nil {
  27950. return v, errors.New("OldStatus requires an ID field in the mutation")
  27951. }
  27952. oldValue, err := m.oldValue(ctx)
  27953. if err != nil {
  27954. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27955. }
  27956. return oldValue.Status, nil
  27957. }
  27958. // AddStatus adds u to the "status" field.
  27959. func (m *SopTaskMutation) AddStatus(u int8) {
  27960. if m.addstatus != nil {
  27961. *m.addstatus += u
  27962. } else {
  27963. m.addstatus = &u
  27964. }
  27965. }
  27966. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27967. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  27968. v := m.addstatus
  27969. if v == nil {
  27970. return
  27971. }
  27972. return *v, true
  27973. }
  27974. // ClearStatus clears the value of the "status" field.
  27975. func (m *SopTaskMutation) ClearStatus() {
  27976. m.status = nil
  27977. m.addstatus = nil
  27978. m.clearedFields[soptask.FieldStatus] = struct{}{}
  27979. }
  27980. // StatusCleared returns if the "status" field was cleared in this mutation.
  27981. func (m *SopTaskMutation) StatusCleared() bool {
  27982. _, ok := m.clearedFields[soptask.FieldStatus]
  27983. return ok
  27984. }
  27985. // ResetStatus resets all changes to the "status" field.
  27986. func (m *SopTaskMutation) ResetStatus() {
  27987. m.status = nil
  27988. m.addstatus = nil
  27989. delete(m.clearedFields, soptask.FieldStatus)
  27990. }
  27991. // SetDeletedAt sets the "deleted_at" field.
  27992. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  27993. m.deleted_at = &t
  27994. }
  27995. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27996. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  27997. v := m.deleted_at
  27998. if v == nil {
  27999. return
  28000. }
  28001. return *v, true
  28002. }
  28003. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  28004. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28006. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28007. if !m.op.Is(OpUpdateOne) {
  28008. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28009. }
  28010. if m.id == nil || m.oldValue == nil {
  28011. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28012. }
  28013. oldValue, err := m.oldValue(ctx)
  28014. if err != nil {
  28015. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28016. }
  28017. return oldValue.DeletedAt, nil
  28018. }
  28019. // ClearDeletedAt clears the value of the "deleted_at" field.
  28020. func (m *SopTaskMutation) ClearDeletedAt() {
  28021. m.deleted_at = nil
  28022. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  28023. }
  28024. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28025. func (m *SopTaskMutation) DeletedAtCleared() bool {
  28026. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  28027. return ok
  28028. }
  28029. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28030. func (m *SopTaskMutation) ResetDeletedAt() {
  28031. m.deleted_at = nil
  28032. delete(m.clearedFields, soptask.FieldDeletedAt)
  28033. }
  28034. // SetName sets the "name" field.
  28035. func (m *SopTaskMutation) SetName(s string) {
  28036. m.name = &s
  28037. }
  28038. // Name returns the value of the "name" field in the mutation.
  28039. func (m *SopTaskMutation) Name() (r string, exists bool) {
  28040. v := m.name
  28041. if v == nil {
  28042. return
  28043. }
  28044. return *v, true
  28045. }
  28046. // OldName returns the old "name" field's value of the SopTask entity.
  28047. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28049. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  28050. if !m.op.Is(OpUpdateOne) {
  28051. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28052. }
  28053. if m.id == nil || m.oldValue == nil {
  28054. return v, errors.New("OldName requires an ID field in the mutation")
  28055. }
  28056. oldValue, err := m.oldValue(ctx)
  28057. if err != nil {
  28058. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28059. }
  28060. return oldValue.Name, nil
  28061. }
  28062. // ResetName resets all changes to the "name" field.
  28063. func (m *SopTaskMutation) ResetName() {
  28064. m.name = nil
  28065. }
  28066. // SetBotWxidList sets the "bot_wxid_list" field.
  28067. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  28068. m.bot_wxid_list = &s
  28069. m.appendbot_wxid_list = nil
  28070. }
  28071. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  28072. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  28073. v := m.bot_wxid_list
  28074. if v == nil {
  28075. return
  28076. }
  28077. return *v, true
  28078. }
  28079. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  28080. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28082. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  28083. if !m.op.Is(OpUpdateOne) {
  28084. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  28085. }
  28086. if m.id == nil || m.oldValue == nil {
  28087. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  28088. }
  28089. oldValue, err := m.oldValue(ctx)
  28090. if err != nil {
  28091. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  28092. }
  28093. return oldValue.BotWxidList, nil
  28094. }
  28095. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  28096. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  28097. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  28098. }
  28099. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  28100. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  28101. if len(m.appendbot_wxid_list) == 0 {
  28102. return nil, false
  28103. }
  28104. return m.appendbot_wxid_list, true
  28105. }
  28106. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  28107. func (m *SopTaskMutation) ClearBotWxidList() {
  28108. m.bot_wxid_list = nil
  28109. m.appendbot_wxid_list = nil
  28110. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  28111. }
  28112. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  28113. func (m *SopTaskMutation) BotWxidListCleared() bool {
  28114. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  28115. return ok
  28116. }
  28117. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  28118. func (m *SopTaskMutation) ResetBotWxidList() {
  28119. m.bot_wxid_list = nil
  28120. m.appendbot_wxid_list = nil
  28121. delete(m.clearedFields, soptask.FieldBotWxidList)
  28122. }
  28123. // SetType sets the "type" field.
  28124. func (m *SopTaskMutation) SetType(i int) {
  28125. m._type = &i
  28126. m.add_type = nil
  28127. }
  28128. // GetType returns the value of the "type" field in the mutation.
  28129. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  28130. v := m._type
  28131. if v == nil {
  28132. return
  28133. }
  28134. return *v, true
  28135. }
  28136. // OldType returns the old "type" field's value of the SopTask entity.
  28137. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28139. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  28140. if !m.op.Is(OpUpdateOne) {
  28141. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28142. }
  28143. if m.id == nil || m.oldValue == nil {
  28144. return v, errors.New("OldType requires an ID field in the mutation")
  28145. }
  28146. oldValue, err := m.oldValue(ctx)
  28147. if err != nil {
  28148. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28149. }
  28150. return oldValue.Type, nil
  28151. }
  28152. // AddType adds i to the "type" field.
  28153. func (m *SopTaskMutation) AddType(i int) {
  28154. if m.add_type != nil {
  28155. *m.add_type += i
  28156. } else {
  28157. m.add_type = &i
  28158. }
  28159. }
  28160. // AddedType returns the value that was added to the "type" field in this mutation.
  28161. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  28162. v := m.add_type
  28163. if v == nil {
  28164. return
  28165. }
  28166. return *v, true
  28167. }
  28168. // ResetType resets all changes to the "type" field.
  28169. func (m *SopTaskMutation) ResetType() {
  28170. m._type = nil
  28171. m.add_type = nil
  28172. }
  28173. // SetPlanStartTime sets the "plan_start_time" field.
  28174. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  28175. m.plan_start_time = &t
  28176. }
  28177. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  28178. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  28179. v := m.plan_start_time
  28180. if v == nil {
  28181. return
  28182. }
  28183. return *v, true
  28184. }
  28185. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  28186. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28188. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  28189. if !m.op.Is(OpUpdateOne) {
  28190. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  28191. }
  28192. if m.id == nil || m.oldValue == nil {
  28193. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  28194. }
  28195. oldValue, err := m.oldValue(ctx)
  28196. if err != nil {
  28197. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  28198. }
  28199. return oldValue.PlanStartTime, nil
  28200. }
  28201. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  28202. func (m *SopTaskMutation) ClearPlanStartTime() {
  28203. m.plan_start_time = nil
  28204. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  28205. }
  28206. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  28207. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  28208. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  28209. return ok
  28210. }
  28211. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  28212. func (m *SopTaskMutation) ResetPlanStartTime() {
  28213. m.plan_start_time = nil
  28214. delete(m.clearedFields, soptask.FieldPlanStartTime)
  28215. }
  28216. // SetPlanEndTime sets the "plan_end_time" field.
  28217. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  28218. m.plan_end_time = &t
  28219. }
  28220. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  28221. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  28222. v := m.plan_end_time
  28223. if v == nil {
  28224. return
  28225. }
  28226. return *v, true
  28227. }
  28228. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  28229. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28231. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  28232. if !m.op.Is(OpUpdateOne) {
  28233. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  28234. }
  28235. if m.id == nil || m.oldValue == nil {
  28236. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  28237. }
  28238. oldValue, err := m.oldValue(ctx)
  28239. if err != nil {
  28240. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  28241. }
  28242. return oldValue.PlanEndTime, nil
  28243. }
  28244. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  28245. func (m *SopTaskMutation) ClearPlanEndTime() {
  28246. m.plan_end_time = nil
  28247. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  28248. }
  28249. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  28250. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  28251. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  28252. return ok
  28253. }
  28254. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  28255. func (m *SopTaskMutation) ResetPlanEndTime() {
  28256. m.plan_end_time = nil
  28257. delete(m.clearedFields, soptask.FieldPlanEndTime)
  28258. }
  28259. // SetCreatorID sets the "creator_id" field.
  28260. func (m *SopTaskMutation) SetCreatorID(s string) {
  28261. m.creator_id = &s
  28262. }
  28263. // CreatorID returns the value of the "creator_id" field in the mutation.
  28264. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  28265. v := m.creator_id
  28266. if v == nil {
  28267. return
  28268. }
  28269. return *v, true
  28270. }
  28271. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  28272. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28274. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  28275. if !m.op.Is(OpUpdateOne) {
  28276. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  28277. }
  28278. if m.id == nil || m.oldValue == nil {
  28279. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  28280. }
  28281. oldValue, err := m.oldValue(ctx)
  28282. if err != nil {
  28283. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  28284. }
  28285. return oldValue.CreatorID, nil
  28286. }
  28287. // ClearCreatorID clears the value of the "creator_id" field.
  28288. func (m *SopTaskMutation) ClearCreatorID() {
  28289. m.creator_id = nil
  28290. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  28291. }
  28292. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  28293. func (m *SopTaskMutation) CreatorIDCleared() bool {
  28294. _, ok := m.clearedFields[soptask.FieldCreatorID]
  28295. return ok
  28296. }
  28297. // ResetCreatorID resets all changes to the "creator_id" field.
  28298. func (m *SopTaskMutation) ResetCreatorID() {
  28299. m.creator_id = nil
  28300. delete(m.clearedFields, soptask.FieldCreatorID)
  28301. }
  28302. // SetOrganizationID sets the "organization_id" field.
  28303. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  28304. m.organization_id = &u
  28305. m.addorganization_id = nil
  28306. }
  28307. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28308. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  28309. v := m.organization_id
  28310. if v == nil {
  28311. return
  28312. }
  28313. return *v, true
  28314. }
  28315. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  28316. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28318. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28319. if !m.op.Is(OpUpdateOne) {
  28320. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28321. }
  28322. if m.id == nil || m.oldValue == nil {
  28323. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28324. }
  28325. oldValue, err := m.oldValue(ctx)
  28326. if err != nil {
  28327. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28328. }
  28329. return oldValue.OrganizationID, nil
  28330. }
  28331. // AddOrganizationID adds u to the "organization_id" field.
  28332. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  28333. if m.addorganization_id != nil {
  28334. *m.addorganization_id += u
  28335. } else {
  28336. m.addorganization_id = &u
  28337. }
  28338. }
  28339. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28340. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  28341. v := m.addorganization_id
  28342. if v == nil {
  28343. return
  28344. }
  28345. return *v, true
  28346. }
  28347. // ClearOrganizationID clears the value of the "organization_id" field.
  28348. func (m *SopTaskMutation) ClearOrganizationID() {
  28349. m.organization_id = nil
  28350. m.addorganization_id = nil
  28351. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  28352. }
  28353. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28354. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  28355. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  28356. return ok
  28357. }
  28358. // ResetOrganizationID resets all changes to the "organization_id" field.
  28359. func (m *SopTaskMutation) ResetOrganizationID() {
  28360. m.organization_id = nil
  28361. m.addorganization_id = nil
  28362. delete(m.clearedFields, soptask.FieldOrganizationID)
  28363. }
  28364. // SetToken sets the "token" field.
  28365. func (m *SopTaskMutation) SetToken(s []string) {
  28366. m.token = &s
  28367. m.appendtoken = nil
  28368. }
  28369. // Token returns the value of the "token" field in the mutation.
  28370. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  28371. v := m.token
  28372. if v == nil {
  28373. return
  28374. }
  28375. return *v, true
  28376. }
  28377. // OldToken returns the old "token" field's value of the SopTask entity.
  28378. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28380. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  28381. if !m.op.Is(OpUpdateOne) {
  28382. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  28383. }
  28384. if m.id == nil || m.oldValue == nil {
  28385. return v, errors.New("OldToken requires an ID field in the mutation")
  28386. }
  28387. oldValue, err := m.oldValue(ctx)
  28388. if err != nil {
  28389. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  28390. }
  28391. return oldValue.Token, nil
  28392. }
  28393. // AppendToken adds s to the "token" field.
  28394. func (m *SopTaskMutation) AppendToken(s []string) {
  28395. m.appendtoken = append(m.appendtoken, s...)
  28396. }
  28397. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  28398. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  28399. if len(m.appendtoken) == 0 {
  28400. return nil, false
  28401. }
  28402. return m.appendtoken, true
  28403. }
  28404. // ClearToken clears the value of the "token" field.
  28405. func (m *SopTaskMutation) ClearToken() {
  28406. m.token = nil
  28407. m.appendtoken = nil
  28408. m.clearedFields[soptask.FieldToken] = struct{}{}
  28409. }
  28410. // TokenCleared returns if the "token" field was cleared in this mutation.
  28411. func (m *SopTaskMutation) TokenCleared() bool {
  28412. _, ok := m.clearedFields[soptask.FieldToken]
  28413. return ok
  28414. }
  28415. // ResetToken resets all changes to the "token" field.
  28416. func (m *SopTaskMutation) ResetToken() {
  28417. m.token = nil
  28418. m.appendtoken = nil
  28419. delete(m.clearedFields, soptask.FieldToken)
  28420. }
  28421. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  28422. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  28423. if m.task_stages == nil {
  28424. m.task_stages = make(map[uint64]struct{})
  28425. }
  28426. for i := range ids {
  28427. m.task_stages[ids[i]] = struct{}{}
  28428. }
  28429. }
  28430. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  28431. func (m *SopTaskMutation) ClearTaskStages() {
  28432. m.clearedtask_stages = true
  28433. }
  28434. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  28435. func (m *SopTaskMutation) TaskStagesCleared() bool {
  28436. return m.clearedtask_stages
  28437. }
  28438. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  28439. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  28440. if m.removedtask_stages == nil {
  28441. m.removedtask_stages = make(map[uint64]struct{})
  28442. }
  28443. for i := range ids {
  28444. delete(m.task_stages, ids[i])
  28445. m.removedtask_stages[ids[i]] = struct{}{}
  28446. }
  28447. }
  28448. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  28449. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  28450. for id := range m.removedtask_stages {
  28451. ids = append(ids, id)
  28452. }
  28453. return
  28454. }
  28455. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  28456. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  28457. for id := range m.task_stages {
  28458. ids = append(ids, id)
  28459. }
  28460. return
  28461. }
  28462. // ResetTaskStages resets all changes to the "task_stages" edge.
  28463. func (m *SopTaskMutation) ResetTaskStages() {
  28464. m.task_stages = nil
  28465. m.clearedtask_stages = false
  28466. m.removedtask_stages = nil
  28467. }
  28468. // Where appends a list predicates to the SopTaskMutation builder.
  28469. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  28470. m.predicates = append(m.predicates, ps...)
  28471. }
  28472. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  28473. // users can use type-assertion to append predicates that do not depend on any generated package.
  28474. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  28475. p := make([]predicate.SopTask, len(ps))
  28476. for i := range ps {
  28477. p[i] = ps[i]
  28478. }
  28479. m.Where(p...)
  28480. }
  28481. // Op returns the operation name.
  28482. func (m *SopTaskMutation) Op() Op {
  28483. return m.op
  28484. }
  28485. // SetOp allows setting the mutation operation.
  28486. func (m *SopTaskMutation) SetOp(op Op) {
  28487. m.op = op
  28488. }
  28489. // Type returns the node type of this mutation (SopTask).
  28490. func (m *SopTaskMutation) Type() string {
  28491. return m.typ
  28492. }
  28493. // Fields returns all fields that were changed during this mutation. Note that in
  28494. // order to get all numeric fields that were incremented/decremented, call
  28495. // AddedFields().
  28496. func (m *SopTaskMutation) Fields() []string {
  28497. fields := make([]string, 0, 12)
  28498. if m.created_at != nil {
  28499. fields = append(fields, soptask.FieldCreatedAt)
  28500. }
  28501. if m.updated_at != nil {
  28502. fields = append(fields, soptask.FieldUpdatedAt)
  28503. }
  28504. if m.status != nil {
  28505. fields = append(fields, soptask.FieldStatus)
  28506. }
  28507. if m.deleted_at != nil {
  28508. fields = append(fields, soptask.FieldDeletedAt)
  28509. }
  28510. if m.name != nil {
  28511. fields = append(fields, soptask.FieldName)
  28512. }
  28513. if m.bot_wxid_list != nil {
  28514. fields = append(fields, soptask.FieldBotWxidList)
  28515. }
  28516. if m._type != nil {
  28517. fields = append(fields, soptask.FieldType)
  28518. }
  28519. if m.plan_start_time != nil {
  28520. fields = append(fields, soptask.FieldPlanStartTime)
  28521. }
  28522. if m.plan_end_time != nil {
  28523. fields = append(fields, soptask.FieldPlanEndTime)
  28524. }
  28525. if m.creator_id != nil {
  28526. fields = append(fields, soptask.FieldCreatorID)
  28527. }
  28528. if m.organization_id != nil {
  28529. fields = append(fields, soptask.FieldOrganizationID)
  28530. }
  28531. if m.token != nil {
  28532. fields = append(fields, soptask.FieldToken)
  28533. }
  28534. return fields
  28535. }
  28536. // Field returns the value of a field with the given name. The second boolean
  28537. // return value indicates that this field was not set, or was not defined in the
  28538. // schema.
  28539. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  28540. switch name {
  28541. case soptask.FieldCreatedAt:
  28542. return m.CreatedAt()
  28543. case soptask.FieldUpdatedAt:
  28544. return m.UpdatedAt()
  28545. case soptask.FieldStatus:
  28546. return m.Status()
  28547. case soptask.FieldDeletedAt:
  28548. return m.DeletedAt()
  28549. case soptask.FieldName:
  28550. return m.Name()
  28551. case soptask.FieldBotWxidList:
  28552. return m.BotWxidList()
  28553. case soptask.FieldType:
  28554. return m.GetType()
  28555. case soptask.FieldPlanStartTime:
  28556. return m.PlanStartTime()
  28557. case soptask.FieldPlanEndTime:
  28558. return m.PlanEndTime()
  28559. case soptask.FieldCreatorID:
  28560. return m.CreatorID()
  28561. case soptask.FieldOrganizationID:
  28562. return m.OrganizationID()
  28563. case soptask.FieldToken:
  28564. return m.Token()
  28565. }
  28566. return nil, false
  28567. }
  28568. // OldField returns the old value of the field from the database. An error is
  28569. // returned if the mutation operation is not UpdateOne, or the query to the
  28570. // database failed.
  28571. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28572. switch name {
  28573. case soptask.FieldCreatedAt:
  28574. return m.OldCreatedAt(ctx)
  28575. case soptask.FieldUpdatedAt:
  28576. return m.OldUpdatedAt(ctx)
  28577. case soptask.FieldStatus:
  28578. return m.OldStatus(ctx)
  28579. case soptask.FieldDeletedAt:
  28580. return m.OldDeletedAt(ctx)
  28581. case soptask.FieldName:
  28582. return m.OldName(ctx)
  28583. case soptask.FieldBotWxidList:
  28584. return m.OldBotWxidList(ctx)
  28585. case soptask.FieldType:
  28586. return m.OldType(ctx)
  28587. case soptask.FieldPlanStartTime:
  28588. return m.OldPlanStartTime(ctx)
  28589. case soptask.FieldPlanEndTime:
  28590. return m.OldPlanEndTime(ctx)
  28591. case soptask.FieldCreatorID:
  28592. return m.OldCreatorID(ctx)
  28593. case soptask.FieldOrganizationID:
  28594. return m.OldOrganizationID(ctx)
  28595. case soptask.FieldToken:
  28596. return m.OldToken(ctx)
  28597. }
  28598. return nil, fmt.Errorf("unknown SopTask field %s", name)
  28599. }
  28600. // SetField sets the value of a field with the given name. It returns an error if
  28601. // the field is not defined in the schema, or if the type mismatched the field
  28602. // type.
  28603. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  28604. switch name {
  28605. case soptask.FieldCreatedAt:
  28606. v, ok := value.(time.Time)
  28607. if !ok {
  28608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28609. }
  28610. m.SetCreatedAt(v)
  28611. return nil
  28612. case soptask.FieldUpdatedAt:
  28613. v, ok := value.(time.Time)
  28614. if !ok {
  28615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28616. }
  28617. m.SetUpdatedAt(v)
  28618. return nil
  28619. case soptask.FieldStatus:
  28620. v, ok := value.(uint8)
  28621. if !ok {
  28622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28623. }
  28624. m.SetStatus(v)
  28625. return nil
  28626. case soptask.FieldDeletedAt:
  28627. v, ok := value.(time.Time)
  28628. if !ok {
  28629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28630. }
  28631. m.SetDeletedAt(v)
  28632. return nil
  28633. case soptask.FieldName:
  28634. v, ok := value.(string)
  28635. if !ok {
  28636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28637. }
  28638. m.SetName(v)
  28639. return nil
  28640. case soptask.FieldBotWxidList:
  28641. v, ok := value.([]string)
  28642. if !ok {
  28643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28644. }
  28645. m.SetBotWxidList(v)
  28646. return nil
  28647. case soptask.FieldType:
  28648. v, ok := value.(int)
  28649. if !ok {
  28650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28651. }
  28652. m.SetType(v)
  28653. return nil
  28654. case soptask.FieldPlanStartTime:
  28655. v, ok := value.(time.Time)
  28656. if !ok {
  28657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28658. }
  28659. m.SetPlanStartTime(v)
  28660. return nil
  28661. case soptask.FieldPlanEndTime:
  28662. v, ok := value.(time.Time)
  28663. if !ok {
  28664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28665. }
  28666. m.SetPlanEndTime(v)
  28667. return nil
  28668. case soptask.FieldCreatorID:
  28669. v, ok := value.(string)
  28670. if !ok {
  28671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28672. }
  28673. m.SetCreatorID(v)
  28674. return nil
  28675. case soptask.FieldOrganizationID:
  28676. v, ok := value.(uint64)
  28677. if !ok {
  28678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28679. }
  28680. m.SetOrganizationID(v)
  28681. return nil
  28682. case soptask.FieldToken:
  28683. v, ok := value.([]string)
  28684. if !ok {
  28685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28686. }
  28687. m.SetToken(v)
  28688. return nil
  28689. }
  28690. return fmt.Errorf("unknown SopTask field %s", name)
  28691. }
  28692. // AddedFields returns all numeric fields that were incremented/decremented during
  28693. // this mutation.
  28694. func (m *SopTaskMutation) AddedFields() []string {
  28695. var fields []string
  28696. if m.addstatus != nil {
  28697. fields = append(fields, soptask.FieldStatus)
  28698. }
  28699. if m.add_type != nil {
  28700. fields = append(fields, soptask.FieldType)
  28701. }
  28702. if m.addorganization_id != nil {
  28703. fields = append(fields, soptask.FieldOrganizationID)
  28704. }
  28705. return fields
  28706. }
  28707. // AddedField returns the numeric value that was incremented/decremented on a field
  28708. // with the given name. The second boolean return value indicates that this field
  28709. // was not set, or was not defined in the schema.
  28710. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  28711. switch name {
  28712. case soptask.FieldStatus:
  28713. return m.AddedStatus()
  28714. case soptask.FieldType:
  28715. return m.AddedType()
  28716. case soptask.FieldOrganizationID:
  28717. return m.AddedOrganizationID()
  28718. }
  28719. return nil, false
  28720. }
  28721. // AddField adds the value to the field with the given name. It returns an error if
  28722. // the field is not defined in the schema, or if the type mismatched the field
  28723. // type.
  28724. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  28725. switch name {
  28726. case soptask.FieldStatus:
  28727. v, ok := value.(int8)
  28728. if !ok {
  28729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28730. }
  28731. m.AddStatus(v)
  28732. return nil
  28733. case soptask.FieldType:
  28734. v, ok := value.(int)
  28735. if !ok {
  28736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28737. }
  28738. m.AddType(v)
  28739. return nil
  28740. case soptask.FieldOrganizationID:
  28741. v, ok := value.(int64)
  28742. if !ok {
  28743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28744. }
  28745. m.AddOrganizationID(v)
  28746. return nil
  28747. }
  28748. return fmt.Errorf("unknown SopTask numeric field %s", name)
  28749. }
  28750. // ClearedFields returns all nullable fields that were cleared during this
  28751. // mutation.
  28752. func (m *SopTaskMutation) ClearedFields() []string {
  28753. var fields []string
  28754. if m.FieldCleared(soptask.FieldStatus) {
  28755. fields = append(fields, soptask.FieldStatus)
  28756. }
  28757. if m.FieldCleared(soptask.FieldDeletedAt) {
  28758. fields = append(fields, soptask.FieldDeletedAt)
  28759. }
  28760. if m.FieldCleared(soptask.FieldBotWxidList) {
  28761. fields = append(fields, soptask.FieldBotWxidList)
  28762. }
  28763. if m.FieldCleared(soptask.FieldPlanStartTime) {
  28764. fields = append(fields, soptask.FieldPlanStartTime)
  28765. }
  28766. if m.FieldCleared(soptask.FieldPlanEndTime) {
  28767. fields = append(fields, soptask.FieldPlanEndTime)
  28768. }
  28769. if m.FieldCleared(soptask.FieldCreatorID) {
  28770. fields = append(fields, soptask.FieldCreatorID)
  28771. }
  28772. if m.FieldCleared(soptask.FieldOrganizationID) {
  28773. fields = append(fields, soptask.FieldOrganizationID)
  28774. }
  28775. if m.FieldCleared(soptask.FieldToken) {
  28776. fields = append(fields, soptask.FieldToken)
  28777. }
  28778. return fields
  28779. }
  28780. // FieldCleared returns a boolean indicating if a field with the given name was
  28781. // cleared in this mutation.
  28782. func (m *SopTaskMutation) FieldCleared(name string) bool {
  28783. _, ok := m.clearedFields[name]
  28784. return ok
  28785. }
  28786. // ClearField clears the value of the field with the given name. It returns an
  28787. // error if the field is not defined in the schema.
  28788. func (m *SopTaskMutation) ClearField(name string) error {
  28789. switch name {
  28790. case soptask.FieldStatus:
  28791. m.ClearStatus()
  28792. return nil
  28793. case soptask.FieldDeletedAt:
  28794. m.ClearDeletedAt()
  28795. return nil
  28796. case soptask.FieldBotWxidList:
  28797. m.ClearBotWxidList()
  28798. return nil
  28799. case soptask.FieldPlanStartTime:
  28800. m.ClearPlanStartTime()
  28801. return nil
  28802. case soptask.FieldPlanEndTime:
  28803. m.ClearPlanEndTime()
  28804. return nil
  28805. case soptask.FieldCreatorID:
  28806. m.ClearCreatorID()
  28807. return nil
  28808. case soptask.FieldOrganizationID:
  28809. m.ClearOrganizationID()
  28810. return nil
  28811. case soptask.FieldToken:
  28812. m.ClearToken()
  28813. return nil
  28814. }
  28815. return fmt.Errorf("unknown SopTask nullable field %s", name)
  28816. }
  28817. // ResetField resets all changes in the mutation for the field with the given name.
  28818. // It returns an error if the field is not defined in the schema.
  28819. func (m *SopTaskMutation) ResetField(name string) error {
  28820. switch name {
  28821. case soptask.FieldCreatedAt:
  28822. m.ResetCreatedAt()
  28823. return nil
  28824. case soptask.FieldUpdatedAt:
  28825. m.ResetUpdatedAt()
  28826. return nil
  28827. case soptask.FieldStatus:
  28828. m.ResetStatus()
  28829. return nil
  28830. case soptask.FieldDeletedAt:
  28831. m.ResetDeletedAt()
  28832. return nil
  28833. case soptask.FieldName:
  28834. m.ResetName()
  28835. return nil
  28836. case soptask.FieldBotWxidList:
  28837. m.ResetBotWxidList()
  28838. return nil
  28839. case soptask.FieldType:
  28840. m.ResetType()
  28841. return nil
  28842. case soptask.FieldPlanStartTime:
  28843. m.ResetPlanStartTime()
  28844. return nil
  28845. case soptask.FieldPlanEndTime:
  28846. m.ResetPlanEndTime()
  28847. return nil
  28848. case soptask.FieldCreatorID:
  28849. m.ResetCreatorID()
  28850. return nil
  28851. case soptask.FieldOrganizationID:
  28852. m.ResetOrganizationID()
  28853. return nil
  28854. case soptask.FieldToken:
  28855. m.ResetToken()
  28856. return nil
  28857. }
  28858. return fmt.Errorf("unknown SopTask field %s", name)
  28859. }
  28860. // AddedEdges returns all edge names that were set/added in this mutation.
  28861. func (m *SopTaskMutation) AddedEdges() []string {
  28862. edges := make([]string, 0, 1)
  28863. if m.task_stages != nil {
  28864. edges = append(edges, soptask.EdgeTaskStages)
  28865. }
  28866. return edges
  28867. }
  28868. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28869. // name in this mutation.
  28870. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  28871. switch name {
  28872. case soptask.EdgeTaskStages:
  28873. ids := make([]ent.Value, 0, len(m.task_stages))
  28874. for id := range m.task_stages {
  28875. ids = append(ids, id)
  28876. }
  28877. return ids
  28878. }
  28879. return nil
  28880. }
  28881. // RemovedEdges returns all edge names that were removed in this mutation.
  28882. func (m *SopTaskMutation) RemovedEdges() []string {
  28883. edges := make([]string, 0, 1)
  28884. if m.removedtask_stages != nil {
  28885. edges = append(edges, soptask.EdgeTaskStages)
  28886. }
  28887. return edges
  28888. }
  28889. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28890. // the given name in this mutation.
  28891. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  28892. switch name {
  28893. case soptask.EdgeTaskStages:
  28894. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  28895. for id := range m.removedtask_stages {
  28896. ids = append(ids, id)
  28897. }
  28898. return ids
  28899. }
  28900. return nil
  28901. }
  28902. // ClearedEdges returns all edge names that were cleared in this mutation.
  28903. func (m *SopTaskMutation) ClearedEdges() []string {
  28904. edges := make([]string, 0, 1)
  28905. if m.clearedtask_stages {
  28906. edges = append(edges, soptask.EdgeTaskStages)
  28907. }
  28908. return edges
  28909. }
  28910. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28911. // was cleared in this mutation.
  28912. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  28913. switch name {
  28914. case soptask.EdgeTaskStages:
  28915. return m.clearedtask_stages
  28916. }
  28917. return false
  28918. }
  28919. // ClearEdge clears the value of the edge with the given name. It returns an error
  28920. // if that edge is not defined in the schema.
  28921. func (m *SopTaskMutation) ClearEdge(name string) error {
  28922. switch name {
  28923. }
  28924. return fmt.Errorf("unknown SopTask unique edge %s", name)
  28925. }
  28926. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28927. // It returns an error if the edge is not defined in the schema.
  28928. func (m *SopTaskMutation) ResetEdge(name string) error {
  28929. switch name {
  28930. case soptask.EdgeTaskStages:
  28931. m.ResetTaskStages()
  28932. return nil
  28933. }
  28934. return fmt.Errorf("unknown SopTask edge %s", name)
  28935. }
  28936. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  28937. type TokenMutation struct {
  28938. config
  28939. op Op
  28940. typ string
  28941. id *uint64
  28942. created_at *time.Time
  28943. updated_at *time.Time
  28944. deleted_at *time.Time
  28945. expire_at *time.Time
  28946. token *string
  28947. mac *string
  28948. organization_id *uint64
  28949. addorganization_id *int64
  28950. custom_agent_base *string
  28951. custom_agent_key *string
  28952. openai_base *string
  28953. openai_key *string
  28954. clearedFields map[string]struct{}
  28955. agent *uint64
  28956. clearedagent bool
  28957. done bool
  28958. oldValue func(context.Context) (*Token, error)
  28959. predicates []predicate.Token
  28960. }
  28961. var _ ent.Mutation = (*TokenMutation)(nil)
  28962. // tokenOption allows management of the mutation configuration using functional options.
  28963. type tokenOption func(*TokenMutation)
  28964. // newTokenMutation creates new mutation for the Token entity.
  28965. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  28966. m := &TokenMutation{
  28967. config: c,
  28968. op: op,
  28969. typ: TypeToken,
  28970. clearedFields: make(map[string]struct{}),
  28971. }
  28972. for _, opt := range opts {
  28973. opt(m)
  28974. }
  28975. return m
  28976. }
  28977. // withTokenID sets the ID field of the mutation.
  28978. func withTokenID(id uint64) tokenOption {
  28979. return func(m *TokenMutation) {
  28980. var (
  28981. err error
  28982. once sync.Once
  28983. value *Token
  28984. )
  28985. m.oldValue = func(ctx context.Context) (*Token, error) {
  28986. once.Do(func() {
  28987. if m.done {
  28988. err = errors.New("querying old values post mutation is not allowed")
  28989. } else {
  28990. value, err = m.Client().Token.Get(ctx, id)
  28991. }
  28992. })
  28993. return value, err
  28994. }
  28995. m.id = &id
  28996. }
  28997. }
  28998. // withToken sets the old Token of the mutation.
  28999. func withToken(node *Token) tokenOption {
  29000. return func(m *TokenMutation) {
  29001. m.oldValue = func(context.Context) (*Token, error) {
  29002. return node, nil
  29003. }
  29004. m.id = &node.ID
  29005. }
  29006. }
  29007. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29008. // executed in a transaction (ent.Tx), a transactional client is returned.
  29009. func (m TokenMutation) Client() *Client {
  29010. client := &Client{config: m.config}
  29011. client.init()
  29012. return client
  29013. }
  29014. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29015. // it returns an error otherwise.
  29016. func (m TokenMutation) Tx() (*Tx, error) {
  29017. if _, ok := m.driver.(*txDriver); !ok {
  29018. return nil, errors.New("ent: mutation is not running in a transaction")
  29019. }
  29020. tx := &Tx{config: m.config}
  29021. tx.init()
  29022. return tx, nil
  29023. }
  29024. // SetID sets the value of the id field. Note that this
  29025. // operation is only accepted on creation of Token entities.
  29026. func (m *TokenMutation) SetID(id uint64) {
  29027. m.id = &id
  29028. }
  29029. // ID returns the ID value in the mutation. Note that the ID is only available
  29030. // if it was provided to the builder or after it was returned from the database.
  29031. func (m *TokenMutation) ID() (id uint64, exists bool) {
  29032. if m.id == nil {
  29033. return
  29034. }
  29035. return *m.id, true
  29036. }
  29037. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29038. // That means, if the mutation is applied within a transaction with an isolation level such
  29039. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29040. // or updated by the mutation.
  29041. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  29042. switch {
  29043. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29044. id, exists := m.ID()
  29045. if exists {
  29046. return []uint64{id}, nil
  29047. }
  29048. fallthrough
  29049. case m.op.Is(OpUpdate | OpDelete):
  29050. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  29051. default:
  29052. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29053. }
  29054. }
  29055. // SetCreatedAt sets the "created_at" field.
  29056. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  29057. m.created_at = &t
  29058. }
  29059. // CreatedAt returns the value of the "created_at" field in the mutation.
  29060. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  29061. v := m.created_at
  29062. if v == nil {
  29063. return
  29064. }
  29065. return *v, true
  29066. }
  29067. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  29068. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29070. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29071. if !m.op.Is(OpUpdateOne) {
  29072. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29073. }
  29074. if m.id == nil || m.oldValue == nil {
  29075. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29076. }
  29077. oldValue, err := m.oldValue(ctx)
  29078. if err != nil {
  29079. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29080. }
  29081. return oldValue.CreatedAt, nil
  29082. }
  29083. // ResetCreatedAt resets all changes to the "created_at" field.
  29084. func (m *TokenMutation) ResetCreatedAt() {
  29085. m.created_at = nil
  29086. }
  29087. // SetUpdatedAt sets the "updated_at" field.
  29088. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  29089. m.updated_at = &t
  29090. }
  29091. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29092. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  29093. v := m.updated_at
  29094. if v == nil {
  29095. return
  29096. }
  29097. return *v, true
  29098. }
  29099. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29103. if !m.op.Is(OpUpdateOne) {
  29104. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29105. }
  29106. if m.id == nil || m.oldValue == nil {
  29107. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  29112. }
  29113. return oldValue.UpdatedAt, nil
  29114. }
  29115. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29116. func (m *TokenMutation) ResetUpdatedAt() {
  29117. m.updated_at = nil
  29118. }
  29119. // SetDeletedAt sets the "deleted_at" field.
  29120. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  29121. m.deleted_at = &t
  29122. }
  29123. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29124. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  29125. v := m.deleted_at
  29126. if v == nil {
  29127. return
  29128. }
  29129. return *v, true
  29130. }
  29131. // OldDeletedAt returns the old "deleted_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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29135. if !m.op.Is(OpUpdateOne) {
  29136. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29137. }
  29138. if m.id == nil || m.oldValue == nil {
  29139. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  29144. }
  29145. return oldValue.DeletedAt, nil
  29146. }
  29147. // ClearDeletedAt clears the value of the "deleted_at" field.
  29148. func (m *TokenMutation) ClearDeletedAt() {
  29149. m.deleted_at = nil
  29150. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  29151. }
  29152. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29153. func (m *TokenMutation) DeletedAtCleared() bool {
  29154. _, ok := m.clearedFields[token.FieldDeletedAt]
  29155. return ok
  29156. }
  29157. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29158. func (m *TokenMutation) ResetDeletedAt() {
  29159. m.deleted_at = nil
  29160. delete(m.clearedFields, token.FieldDeletedAt)
  29161. }
  29162. // SetExpireAt sets the "expire_at" field.
  29163. func (m *TokenMutation) SetExpireAt(t time.Time) {
  29164. m.expire_at = &t
  29165. }
  29166. // ExpireAt returns the value of the "expire_at" field in the mutation.
  29167. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  29168. v := m.expire_at
  29169. if v == nil {
  29170. return
  29171. }
  29172. return *v, true
  29173. }
  29174. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  29175. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29177. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  29178. if !m.op.Is(OpUpdateOne) {
  29179. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  29180. }
  29181. if m.id == nil || m.oldValue == nil {
  29182. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  29183. }
  29184. oldValue, err := m.oldValue(ctx)
  29185. if err != nil {
  29186. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  29187. }
  29188. return oldValue.ExpireAt, nil
  29189. }
  29190. // ClearExpireAt clears the value of the "expire_at" field.
  29191. func (m *TokenMutation) ClearExpireAt() {
  29192. m.expire_at = nil
  29193. m.clearedFields[token.FieldExpireAt] = struct{}{}
  29194. }
  29195. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  29196. func (m *TokenMutation) ExpireAtCleared() bool {
  29197. _, ok := m.clearedFields[token.FieldExpireAt]
  29198. return ok
  29199. }
  29200. // ResetExpireAt resets all changes to the "expire_at" field.
  29201. func (m *TokenMutation) ResetExpireAt() {
  29202. m.expire_at = nil
  29203. delete(m.clearedFields, token.FieldExpireAt)
  29204. }
  29205. // SetToken sets the "token" field.
  29206. func (m *TokenMutation) SetToken(s string) {
  29207. m.token = &s
  29208. }
  29209. // Token returns the value of the "token" field in the mutation.
  29210. func (m *TokenMutation) Token() (r string, exists bool) {
  29211. v := m.token
  29212. if v == nil {
  29213. return
  29214. }
  29215. return *v, true
  29216. }
  29217. // OldToken returns the old "token" field's value of the Token entity.
  29218. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29220. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  29221. if !m.op.Is(OpUpdateOne) {
  29222. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  29223. }
  29224. if m.id == nil || m.oldValue == nil {
  29225. return v, errors.New("OldToken requires an ID field in the mutation")
  29226. }
  29227. oldValue, err := m.oldValue(ctx)
  29228. if err != nil {
  29229. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  29230. }
  29231. return oldValue.Token, nil
  29232. }
  29233. // ClearToken clears the value of the "token" field.
  29234. func (m *TokenMutation) ClearToken() {
  29235. m.token = nil
  29236. m.clearedFields[token.FieldToken] = struct{}{}
  29237. }
  29238. // TokenCleared returns if the "token" field was cleared in this mutation.
  29239. func (m *TokenMutation) TokenCleared() bool {
  29240. _, ok := m.clearedFields[token.FieldToken]
  29241. return ok
  29242. }
  29243. // ResetToken resets all changes to the "token" field.
  29244. func (m *TokenMutation) ResetToken() {
  29245. m.token = nil
  29246. delete(m.clearedFields, token.FieldToken)
  29247. }
  29248. // SetMAC sets the "mac" field.
  29249. func (m *TokenMutation) SetMAC(s string) {
  29250. m.mac = &s
  29251. }
  29252. // MAC returns the value of the "mac" field in the mutation.
  29253. func (m *TokenMutation) MAC() (r string, exists bool) {
  29254. v := m.mac
  29255. if v == nil {
  29256. return
  29257. }
  29258. return *v, true
  29259. }
  29260. // OldMAC returns the old "mac" field's value of the Token entity.
  29261. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29263. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  29264. if !m.op.Is(OpUpdateOne) {
  29265. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  29266. }
  29267. if m.id == nil || m.oldValue == nil {
  29268. return v, errors.New("OldMAC requires an ID field in the mutation")
  29269. }
  29270. oldValue, err := m.oldValue(ctx)
  29271. if err != nil {
  29272. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  29273. }
  29274. return oldValue.MAC, nil
  29275. }
  29276. // ClearMAC clears the value of the "mac" field.
  29277. func (m *TokenMutation) ClearMAC() {
  29278. m.mac = nil
  29279. m.clearedFields[token.FieldMAC] = struct{}{}
  29280. }
  29281. // MACCleared returns if the "mac" field was cleared in this mutation.
  29282. func (m *TokenMutation) MACCleared() bool {
  29283. _, ok := m.clearedFields[token.FieldMAC]
  29284. return ok
  29285. }
  29286. // ResetMAC resets all changes to the "mac" field.
  29287. func (m *TokenMutation) ResetMAC() {
  29288. m.mac = nil
  29289. delete(m.clearedFields, token.FieldMAC)
  29290. }
  29291. // SetOrganizationID sets the "organization_id" field.
  29292. func (m *TokenMutation) SetOrganizationID(u uint64) {
  29293. m.organization_id = &u
  29294. m.addorganization_id = nil
  29295. }
  29296. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29297. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  29298. v := m.organization_id
  29299. if v == nil {
  29300. return
  29301. }
  29302. return *v, true
  29303. }
  29304. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  29305. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29307. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29308. if !m.op.Is(OpUpdateOne) {
  29309. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29310. }
  29311. if m.id == nil || m.oldValue == nil {
  29312. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29313. }
  29314. oldValue, err := m.oldValue(ctx)
  29315. if err != nil {
  29316. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29317. }
  29318. return oldValue.OrganizationID, nil
  29319. }
  29320. // AddOrganizationID adds u to the "organization_id" field.
  29321. func (m *TokenMutation) AddOrganizationID(u int64) {
  29322. if m.addorganization_id != nil {
  29323. *m.addorganization_id += u
  29324. } else {
  29325. m.addorganization_id = &u
  29326. }
  29327. }
  29328. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29329. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  29330. v := m.addorganization_id
  29331. if v == nil {
  29332. return
  29333. }
  29334. return *v, true
  29335. }
  29336. // ResetOrganizationID resets all changes to the "organization_id" field.
  29337. func (m *TokenMutation) ResetOrganizationID() {
  29338. m.organization_id = nil
  29339. m.addorganization_id = nil
  29340. }
  29341. // SetAgentID sets the "agent_id" field.
  29342. func (m *TokenMutation) SetAgentID(u uint64) {
  29343. m.agent = &u
  29344. }
  29345. // AgentID returns the value of the "agent_id" field in the mutation.
  29346. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  29347. v := m.agent
  29348. if v == nil {
  29349. return
  29350. }
  29351. return *v, true
  29352. }
  29353. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  29354. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29356. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  29357. if !m.op.Is(OpUpdateOne) {
  29358. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  29359. }
  29360. if m.id == nil || m.oldValue == nil {
  29361. return v, errors.New("OldAgentID requires an ID field in the mutation")
  29362. }
  29363. oldValue, err := m.oldValue(ctx)
  29364. if err != nil {
  29365. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  29366. }
  29367. return oldValue.AgentID, nil
  29368. }
  29369. // ResetAgentID resets all changes to the "agent_id" field.
  29370. func (m *TokenMutation) ResetAgentID() {
  29371. m.agent = nil
  29372. }
  29373. // SetCustomAgentBase sets the "custom_agent_base" field.
  29374. func (m *TokenMutation) SetCustomAgentBase(s string) {
  29375. m.custom_agent_base = &s
  29376. }
  29377. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  29378. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  29379. v := m.custom_agent_base
  29380. if v == nil {
  29381. return
  29382. }
  29383. return *v, true
  29384. }
  29385. // OldCustomAgentBase returns the old "custom_agent_base" 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) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  29389. if !m.op.Is(OpUpdateOne) {
  29390. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  29391. }
  29392. if m.id == nil || m.oldValue == nil {
  29393. return v, errors.New("OldCustomAgentBase 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 OldCustomAgentBase: %w", err)
  29398. }
  29399. return oldValue.CustomAgentBase, nil
  29400. }
  29401. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  29402. func (m *TokenMutation) ClearCustomAgentBase() {
  29403. m.custom_agent_base = nil
  29404. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  29405. }
  29406. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  29407. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  29408. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  29409. return ok
  29410. }
  29411. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  29412. func (m *TokenMutation) ResetCustomAgentBase() {
  29413. m.custom_agent_base = nil
  29414. delete(m.clearedFields, token.FieldCustomAgentBase)
  29415. }
  29416. // SetCustomAgentKey sets the "custom_agent_key" field.
  29417. func (m *TokenMutation) SetCustomAgentKey(s string) {
  29418. m.custom_agent_key = &s
  29419. }
  29420. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  29421. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  29422. v := m.custom_agent_key
  29423. if v == nil {
  29424. return
  29425. }
  29426. return *v, true
  29427. }
  29428. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  29429. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29431. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  29432. if !m.op.Is(OpUpdateOne) {
  29433. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  29434. }
  29435. if m.id == nil || m.oldValue == nil {
  29436. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  29437. }
  29438. oldValue, err := m.oldValue(ctx)
  29439. if err != nil {
  29440. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  29441. }
  29442. return oldValue.CustomAgentKey, nil
  29443. }
  29444. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  29445. func (m *TokenMutation) ClearCustomAgentKey() {
  29446. m.custom_agent_key = nil
  29447. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  29448. }
  29449. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  29450. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  29451. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  29452. return ok
  29453. }
  29454. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  29455. func (m *TokenMutation) ResetCustomAgentKey() {
  29456. m.custom_agent_key = nil
  29457. delete(m.clearedFields, token.FieldCustomAgentKey)
  29458. }
  29459. // SetOpenaiBase sets the "openai_base" field.
  29460. func (m *TokenMutation) SetOpenaiBase(s string) {
  29461. m.openai_base = &s
  29462. }
  29463. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  29464. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  29465. v := m.openai_base
  29466. if v == nil {
  29467. return
  29468. }
  29469. return *v, true
  29470. }
  29471. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  29472. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29474. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  29475. if !m.op.Is(OpUpdateOne) {
  29476. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  29477. }
  29478. if m.id == nil || m.oldValue == nil {
  29479. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  29480. }
  29481. oldValue, err := m.oldValue(ctx)
  29482. if err != nil {
  29483. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  29484. }
  29485. return oldValue.OpenaiBase, nil
  29486. }
  29487. // ClearOpenaiBase clears the value of the "openai_base" field.
  29488. func (m *TokenMutation) ClearOpenaiBase() {
  29489. m.openai_base = nil
  29490. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  29491. }
  29492. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  29493. func (m *TokenMutation) OpenaiBaseCleared() bool {
  29494. _, ok := m.clearedFields[token.FieldOpenaiBase]
  29495. return ok
  29496. }
  29497. // ResetOpenaiBase resets all changes to the "openai_base" field.
  29498. func (m *TokenMutation) ResetOpenaiBase() {
  29499. m.openai_base = nil
  29500. delete(m.clearedFields, token.FieldOpenaiBase)
  29501. }
  29502. // SetOpenaiKey sets the "openai_key" field.
  29503. func (m *TokenMutation) SetOpenaiKey(s string) {
  29504. m.openai_key = &s
  29505. }
  29506. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  29507. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  29508. v := m.openai_key
  29509. if v == nil {
  29510. return
  29511. }
  29512. return *v, true
  29513. }
  29514. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  29515. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29517. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  29518. if !m.op.Is(OpUpdateOne) {
  29519. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  29520. }
  29521. if m.id == nil || m.oldValue == nil {
  29522. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  29523. }
  29524. oldValue, err := m.oldValue(ctx)
  29525. if err != nil {
  29526. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  29527. }
  29528. return oldValue.OpenaiKey, nil
  29529. }
  29530. // ClearOpenaiKey clears the value of the "openai_key" field.
  29531. func (m *TokenMutation) ClearOpenaiKey() {
  29532. m.openai_key = nil
  29533. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  29534. }
  29535. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  29536. func (m *TokenMutation) OpenaiKeyCleared() bool {
  29537. _, ok := m.clearedFields[token.FieldOpenaiKey]
  29538. return ok
  29539. }
  29540. // ResetOpenaiKey resets all changes to the "openai_key" field.
  29541. func (m *TokenMutation) ResetOpenaiKey() {
  29542. m.openai_key = nil
  29543. delete(m.clearedFields, token.FieldOpenaiKey)
  29544. }
  29545. // ClearAgent clears the "agent" edge to the Agent entity.
  29546. func (m *TokenMutation) ClearAgent() {
  29547. m.clearedagent = true
  29548. m.clearedFields[token.FieldAgentID] = struct{}{}
  29549. }
  29550. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  29551. func (m *TokenMutation) AgentCleared() bool {
  29552. return m.clearedagent
  29553. }
  29554. // AgentIDs returns the "agent" edge IDs in the mutation.
  29555. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29556. // AgentID instead. It exists only for internal usage by the builders.
  29557. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  29558. if id := m.agent; id != nil {
  29559. ids = append(ids, *id)
  29560. }
  29561. return
  29562. }
  29563. // ResetAgent resets all changes to the "agent" edge.
  29564. func (m *TokenMutation) ResetAgent() {
  29565. m.agent = nil
  29566. m.clearedagent = false
  29567. }
  29568. // Where appends a list predicates to the TokenMutation builder.
  29569. func (m *TokenMutation) Where(ps ...predicate.Token) {
  29570. m.predicates = append(m.predicates, ps...)
  29571. }
  29572. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  29573. // users can use type-assertion to append predicates that do not depend on any generated package.
  29574. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  29575. p := make([]predicate.Token, len(ps))
  29576. for i := range ps {
  29577. p[i] = ps[i]
  29578. }
  29579. m.Where(p...)
  29580. }
  29581. // Op returns the operation name.
  29582. func (m *TokenMutation) Op() Op {
  29583. return m.op
  29584. }
  29585. // SetOp allows setting the mutation operation.
  29586. func (m *TokenMutation) SetOp(op Op) {
  29587. m.op = op
  29588. }
  29589. // Type returns the node type of this mutation (Token).
  29590. func (m *TokenMutation) Type() string {
  29591. return m.typ
  29592. }
  29593. // Fields returns all fields that were changed during this mutation. Note that in
  29594. // order to get all numeric fields that were incremented/decremented, call
  29595. // AddedFields().
  29596. func (m *TokenMutation) Fields() []string {
  29597. fields := make([]string, 0, 12)
  29598. if m.created_at != nil {
  29599. fields = append(fields, token.FieldCreatedAt)
  29600. }
  29601. if m.updated_at != nil {
  29602. fields = append(fields, token.FieldUpdatedAt)
  29603. }
  29604. if m.deleted_at != nil {
  29605. fields = append(fields, token.FieldDeletedAt)
  29606. }
  29607. if m.expire_at != nil {
  29608. fields = append(fields, token.FieldExpireAt)
  29609. }
  29610. if m.token != nil {
  29611. fields = append(fields, token.FieldToken)
  29612. }
  29613. if m.mac != nil {
  29614. fields = append(fields, token.FieldMAC)
  29615. }
  29616. if m.organization_id != nil {
  29617. fields = append(fields, token.FieldOrganizationID)
  29618. }
  29619. if m.agent != nil {
  29620. fields = append(fields, token.FieldAgentID)
  29621. }
  29622. if m.custom_agent_base != nil {
  29623. fields = append(fields, token.FieldCustomAgentBase)
  29624. }
  29625. if m.custom_agent_key != nil {
  29626. fields = append(fields, token.FieldCustomAgentKey)
  29627. }
  29628. if m.openai_base != nil {
  29629. fields = append(fields, token.FieldOpenaiBase)
  29630. }
  29631. if m.openai_key != nil {
  29632. fields = append(fields, token.FieldOpenaiKey)
  29633. }
  29634. return fields
  29635. }
  29636. // Field returns the value of a field with the given name. The second boolean
  29637. // return value indicates that this field was not set, or was not defined in the
  29638. // schema.
  29639. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  29640. switch name {
  29641. case token.FieldCreatedAt:
  29642. return m.CreatedAt()
  29643. case token.FieldUpdatedAt:
  29644. return m.UpdatedAt()
  29645. case token.FieldDeletedAt:
  29646. return m.DeletedAt()
  29647. case token.FieldExpireAt:
  29648. return m.ExpireAt()
  29649. case token.FieldToken:
  29650. return m.Token()
  29651. case token.FieldMAC:
  29652. return m.MAC()
  29653. case token.FieldOrganizationID:
  29654. return m.OrganizationID()
  29655. case token.FieldAgentID:
  29656. return m.AgentID()
  29657. case token.FieldCustomAgentBase:
  29658. return m.CustomAgentBase()
  29659. case token.FieldCustomAgentKey:
  29660. return m.CustomAgentKey()
  29661. case token.FieldOpenaiBase:
  29662. return m.OpenaiBase()
  29663. case token.FieldOpenaiKey:
  29664. return m.OpenaiKey()
  29665. }
  29666. return nil, false
  29667. }
  29668. // OldField returns the old value of the field from the database. An error is
  29669. // returned if the mutation operation is not UpdateOne, or the query to the
  29670. // database failed.
  29671. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29672. switch name {
  29673. case token.FieldCreatedAt:
  29674. return m.OldCreatedAt(ctx)
  29675. case token.FieldUpdatedAt:
  29676. return m.OldUpdatedAt(ctx)
  29677. case token.FieldDeletedAt:
  29678. return m.OldDeletedAt(ctx)
  29679. case token.FieldExpireAt:
  29680. return m.OldExpireAt(ctx)
  29681. case token.FieldToken:
  29682. return m.OldToken(ctx)
  29683. case token.FieldMAC:
  29684. return m.OldMAC(ctx)
  29685. case token.FieldOrganizationID:
  29686. return m.OldOrganizationID(ctx)
  29687. case token.FieldAgentID:
  29688. return m.OldAgentID(ctx)
  29689. case token.FieldCustomAgentBase:
  29690. return m.OldCustomAgentBase(ctx)
  29691. case token.FieldCustomAgentKey:
  29692. return m.OldCustomAgentKey(ctx)
  29693. case token.FieldOpenaiBase:
  29694. return m.OldOpenaiBase(ctx)
  29695. case token.FieldOpenaiKey:
  29696. return m.OldOpenaiKey(ctx)
  29697. }
  29698. return nil, fmt.Errorf("unknown Token field %s", name)
  29699. }
  29700. // SetField sets the value of a field with the given name. It returns an error if
  29701. // the field is not defined in the schema, or if the type mismatched the field
  29702. // type.
  29703. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  29704. switch name {
  29705. case token.FieldCreatedAt:
  29706. v, ok := value.(time.Time)
  29707. if !ok {
  29708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29709. }
  29710. m.SetCreatedAt(v)
  29711. return nil
  29712. case token.FieldUpdatedAt:
  29713. v, ok := value.(time.Time)
  29714. if !ok {
  29715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29716. }
  29717. m.SetUpdatedAt(v)
  29718. return nil
  29719. case token.FieldDeletedAt:
  29720. v, ok := value.(time.Time)
  29721. if !ok {
  29722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29723. }
  29724. m.SetDeletedAt(v)
  29725. return nil
  29726. case token.FieldExpireAt:
  29727. v, ok := value.(time.Time)
  29728. if !ok {
  29729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29730. }
  29731. m.SetExpireAt(v)
  29732. return nil
  29733. case token.FieldToken:
  29734. v, ok := value.(string)
  29735. if !ok {
  29736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29737. }
  29738. m.SetToken(v)
  29739. return nil
  29740. case token.FieldMAC:
  29741. v, ok := value.(string)
  29742. if !ok {
  29743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29744. }
  29745. m.SetMAC(v)
  29746. return nil
  29747. case token.FieldOrganizationID:
  29748. v, ok := value.(uint64)
  29749. if !ok {
  29750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29751. }
  29752. m.SetOrganizationID(v)
  29753. return nil
  29754. case token.FieldAgentID:
  29755. v, ok := value.(uint64)
  29756. if !ok {
  29757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29758. }
  29759. m.SetAgentID(v)
  29760. return nil
  29761. case token.FieldCustomAgentBase:
  29762. v, ok := value.(string)
  29763. if !ok {
  29764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29765. }
  29766. m.SetCustomAgentBase(v)
  29767. return nil
  29768. case token.FieldCustomAgentKey:
  29769. v, ok := value.(string)
  29770. if !ok {
  29771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29772. }
  29773. m.SetCustomAgentKey(v)
  29774. return nil
  29775. case token.FieldOpenaiBase:
  29776. v, ok := value.(string)
  29777. if !ok {
  29778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29779. }
  29780. m.SetOpenaiBase(v)
  29781. return nil
  29782. case token.FieldOpenaiKey:
  29783. v, ok := value.(string)
  29784. if !ok {
  29785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29786. }
  29787. m.SetOpenaiKey(v)
  29788. return nil
  29789. }
  29790. return fmt.Errorf("unknown Token field %s", name)
  29791. }
  29792. // AddedFields returns all numeric fields that were incremented/decremented during
  29793. // this mutation.
  29794. func (m *TokenMutation) AddedFields() []string {
  29795. var fields []string
  29796. if m.addorganization_id != nil {
  29797. fields = append(fields, token.FieldOrganizationID)
  29798. }
  29799. return fields
  29800. }
  29801. // AddedField returns the numeric value that was incremented/decremented on a field
  29802. // with the given name. The second boolean return value indicates that this field
  29803. // was not set, or was not defined in the schema.
  29804. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  29805. switch name {
  29806. case token.FieldOrganizationID:
  29807. return m.AddedOrganizationID()
  29808. }
  29809. return nil, false
  29810. }
  29811. // AddField adds the value to the field with the given name. It returns an error if
  29812. // the field is not defined in the schema, or if the type mismatched the field
  29813. // type.
  29814. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  29815. switch name {
  29816. case token.FieldOrganizationID:
  29817. v, ok := value.(int64)
  29818. if !ok {
  29819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29820. }
  29821. m.AddOrganizationID(v)
  29822. return nil
  29823. }
  29824. return fmt.Errorf("unknown Token numeric field %s", name)
  29825. }
  29826. // ClearedFields returns all nullable fields that were cleared during this
  29827. // mutation.
  29828. func (m *TokenMutation) ClearedFields() []string {
  29829. var fields []string
  29830. if m.FieldCleared(token.FieldDeletedAt) {
  29831. fields = append(fields, token.FieldDeletedAt)
  29832. }
  29833. if m.FieldCleared(token.FieldExpireAt) {
  29834. fields = append(fields, token.FieldExpireAt)
  29835. }
  29836. if m.FieldCleared(token.FieldToken) {
  29837. fields = append(fields, token.FieldToken)
  29838. }
  29839. if m.FieldCleared(token.FieldMAC) {
  29840. fields = append(fields, token.FieldMAC)
  29841. }
  29842. if m.FieldCleared(token.FieldCustomAgentBase) {
  29843. fields = append(fields, token.FieldCustomAgentBase)
  29844. }
  29845. if m.FieldCleared(token.FieldCustomAgentKey) {
  29846. fields = append(fields, token.FieldCustomAgentKey)
  29847. }
  29848. if m.FieldCleared(token.FieldOpenaiBase) {
  29849. fields = append(fields, token.FieldOpenaiBase)
  29850. }
  29851. if m.FieldCleared(token.FieldOpenaiKey) {
  29852. fields = append(fields, token.FieldOpenaiKey)
  29853. }
  29854. return fields
  29855. }
  29856. // FieldCleared returns a boolean indicating if a field with the given name was
  29857. // cleared in this mutation.
  29858. func (m *TokenMutation) FieldCleared(name string) bool {
  29859. _, ok := m.clearedFields[name]
  29860. return ok
  29861. }
  29862. // ClearField clears the value of the field with the given name. It returns an
  29863. // error if the field is not defined in the schema.
  29864. func (m *TokenMutation) ClearField(name string) error {
  29865. switch name {
  29866. case token.FieldDeletedAt:
  29867. m.ClearDeletedAt()
  29868. return nil
  29869. case token.FieldExpireAt:
  29870. m.ClearExpireAt()
  29871. return nil
  29872. case token.FieldToken:
  29873. m.ClearToken()
  29874. return nil
  29875. case token.FieldMAC:
  29876. m.ClearMAC()
  29877. return nil
  29878. case token.FieldCustomAgentBase:
  29879. m.ClearCustomAgentBase()
  29880. return nil
  29881. case token.FieldCustomAgentKey:
  29882. m.ClearCustomAgentKey()
  29883. return nil
  29884. case token.FieldOpenaiBase:
  29885. m.ClearOpenaiBase()
  29886. return nil
  29887. case token.FieldOpenaiKey:
  29888. m.ClearOpenaiKey()
  29889. return nil
  29890. }
  29891. return fmt.Errorf("unknown Token nullable field %s", name)
  29892. }
  29893. // ResetField resets all changes in the mutation for the field with the given name.
  29894. // It returns an error if the field is not defined in the schema.
  29895. func (m *TokenMutation) ResetField(name string) error {
  29896. switch name {
  29897. case token.FieldCreatedAt:
  29898. m.ResetCreatedAt()
  29899. return nil
  29900. case token.FieldUpdatedAt:
  29901. m.ResetUpdatedAt()
  29902. return nil
  29903. case token.FieldDeletedAt:
  29904. m.ResetDeletedAt()
  29905. return nil
  29906. case token.FieldExpireAt:
  29907. m.ResetExpireAt()
  29908. return nil
  29909. case token.FieldToken:
  29910. m.ResetToken()
  29911. return nil
  29912. case token.FieldMAC:
  29913. m.ResetMAC()
  29914. return nil
  29915. case token.FieldOrganizationID:
  29916. m.ResetOrganizationID()
  29917. return nil
  29918. case token.FieldAgentID:
  29919. m.ResetAgentID()
  29920. return nil
  29921. case token.FieldCustomAgentBase:
  29922. m.ResetCustomAgentBase()
  29923. return nil
  29924. case token.FieldCustomAgentKey:
  29925. m.ResetCustomAgentKey()
  29926. return nil
  29927. case token.FieldOpenaiBase:
  29928. m.ResetOpenaiBase()
  29929. return nil
  29930. case token.FieldOpenaiKey:
  29931. m.ResetOpenaiKey()
  29932. return nil
  29933. }
  29934. return fmt.Errorf("unknown Token field %s", name)
  29935. }
  29936. // AddedEdges returns all edge names that were set/added in this mutation.
  29937. func (m *TokenMutation) AddedEdges() []string {
  29938. edges := make([]string, 0, 1)
  29939. if m.agent != nil {
  29940. edges = append(edges, token.EdgeAgent)
  29941. }
  29942. return edges
  29943. }
  29944. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29945. // name in this mutation.
  29946. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  29947. switch name {
  29948. case token.EdgeAgent:
  29949. if id := m.agent; id != nil {
  29950. return []ent.Value{*id}
  29951. }
  29952. }
  29953. return nil
  29954. }
  29955. // RemovedEdges returns all edge names that were removed in this mutation.
  29956. func (m *TokenMutation) RemovedEdges() []string {
  29957. edges := make([]string, 0, 1)
  29958. return edges
  29959. }
  29960. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29961. // the given name in this mutation.
  29962. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  29963. return nil
  29964. }
  29965. // ClearedEdges returns all edge names that were cleared in this mutation.
  29966. func (m *TokenMutation) ClearedEdges() []string {
  29967. edges := make([]string, 0, 1)
  29968. if m.clearedagent {
  29969. edges = append(edges, token.EdgeAgent)
  29970. }
  29971. return edges
  29972. }
  29973. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29974. // was cleared in this mutation.
  29975. func (m *TokenMutation) EdgeCleared(name string) bool {
  29976. switch name {
  29977. case token.EdgeAgent:
  29978. return m.clearedagent
  29979. }
  29980. return false
  29981. }
  29982. // ClearEdge clears the value of the edge with the given name. It returns an error
  29983. // if that edge is not defined in the schema.
  29984. func (m *TokenMutation) ClearEdge(name string) error {
  29985. switch name {
  29986. case token.EdgeAgent:
  29987. m.ClearAgent()
  29988. return nil
  29989. }
  29990. return fmt.Errorf("unknown Token unique edge %s", name)
  29991. }
  29992. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29993. // It returns an error if the edge is not defined in the schema.
  29994. func (m *TokenMutation) ResetEdge(name string) error {
  29995. switch name {
  29996. case token.EdgeAgent:
  29997. m.ResetAgent()
  29998. return nil
  29999. }
  30000. return fmt.Errorf("unknown Token edge %s", name)
  30001. }
  30002. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  30003. type TutorialMutation struct {
  30004. config
  30005. op Op
  30006. typ string
  30007. id *uint64
  30008. created_at *time.Time
  30009. updated_at *time.Time
  30010. deleted_at *time.Time
  30011. index *int
  30012. addindex *int
  30013. title *string
  30014. content *string
  30015. organization_id *uint64
  30016. addorganization_id *int64
  30017. clearedFields map[string]struct{}
  30018. employee *uint64
  30019. clearedemployee bool
  30020. done bool
  30021. oldValue func(context.Context) (*Tutorial, error)
  30022. predicates []predicate.Tutorial
  30023. }
  30024. var _ ent.Mutation = (*TutorialMutation)(nil)
  30025. // tutorialOption allows management of the mutation configuration using functional options.
  30026. type tutorialOption func(*TutorialMutation)
  30027. // newTutorialMutation creates new mutation for the Tutorial entity.
  30028. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  30029. m := &TutorialMutation{
  30030. config: c,
  30031. op: op,
  30032. typ: TypeTutorial,
  30033. clearedFields: make(map[string]struct{}),
  30034. }
  30035. for _, opt := range opts {
  30036. opt(m)
  30037. }
  30038. return m
  30039. }
  30040. // withTutorialID sets the ID field of the mutation.
  30041. func withTutorialID(id uint64) tutorialOption {
  30042. return func(m *TutorialMutation) {
  30043. var (
  30044. err error
  30045. once sync.Once
  30046. value *Tutorial
  30047. )
  30048. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  30049. once.Do(func() {
  30050. if m.done {
  30051. err = errors.New("querying old values post mutation is not allowed")
  30052. } else {
  30053. value, err = m.Client().Tutorial.Get(ctx, id)
  30054. }
  30055. })
  30056. return value, err
  30057. }
  30058. m.id = &id
  30059. }
  30060. }
  30061. // withTutorial sets the old Tutorial of the mutation.
  30062. func withTutorial(node *Tutorial) tutorialOption {
  30063. return func(m *TutorialMutation) {
  30064. m.oldValue = func(context.Context) (*Tutorial, error) {
  30065. return node, nil
  30066. }
  30067. m.id = &node.ID
  30068. }
  30069. }
  30070. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30071. // executed in a transaction (ent.Tx), a transactional client is returned.
  30072. func (m TutorialMutation) Client() *Client {
  30073. client := &Client{config: m.config}
  30074. client.init()
  30075. return client
  30076. }
  30077. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30078. // it returns an error otherwise.
  30079. func (m TutorialMutation) Tx() (*Tx, error) {
  30080. if _, ok := m.driver.(*txDriver); !ok {
  30081. return nil, errors.New("ent: mutation is not running in a transaction")
  30082. }
  30083. tx := &Tx{config: m.config}
  30084. tx.init()
  30085. return tx, nil
  30086. }
  30087. // SetID sets the value of the id field. Note that this
  30088. // operation is only accepted on creation of Tutorial entities.
  30089. func (m *TutorialMutation) SetID(id uint64) {
  30090. m.id = &id
  30091. }
  30092. // ID returns the ID value in the mutation. Note that the ID is only available
  30093. // if it was provided to the builder or after it was returned from the database.
  30094. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  30095. if m.id == nil {
  30096. return
  30097. }
  30098. return *m.id, true
  30099. }
  30100. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30101. // That means, if the mutation is applied within a transaction with an isolation level such
  30102. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30103. // or updated by the mutation.
  30104. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  30105. switch {
  30106. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30107. id, exists := m.ID()
  30108. if exists {
  30109. return []uint64{id}, nil
  30110. }
  30111. fallthrough
  30112. case m.op.Is(OpUpdate | OpDelete):
  30113. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  30114. default:
  30115. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30116. }
  30117. }
  30118. // SetCreatedAt sets the "created_at" field.
  30119. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  30120. m.created_at = &t
  30121. }
  30122. // CreatedAt returns the value of the "created_at" field in the mutation.
  30123. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  30124. v := m.created_at
  30125. if v == nil {
  30126. return
  30127. }
  30128. return *v, true
  30129. }
  30130. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  30131. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30133. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30134. if !m.op.Is(OpUpdateOne) {
  30135. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30136. }
  30137. if m.id == nil || m.oldValue == nil {
  30138. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30139. }
  30140. oldValue, err := m.oldValue(ctx)
  30141. if err != nil {
  30142. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30143. }
  30144. return oldValue.CreatedAt, nil
  30145. }
  30146. // ResetCreatedAt resets all changes to the "created_at" field.
  30147. func (m *TutorialMutation) ResetCreatedAt() {
  30148. m.created_at = nil
  30149. }
  30150. // SetUpdatedAt sets the "updated_at" field.
  30151. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  30152. m.updated_at = &t
  30153. }
  30154. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30155. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  30156. v := m.updated_at
  30157. if v == nil {
  30158. return
  30159. }
  30160. return *v, true
  30161. }
  30162. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30166. if !m.op.Is(OpUpdateOne) {
  30167. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30168. }
  30169. if m.id == nil || m.oldValue == nil {
  30170. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  30175. }
  30176. return oldValue.UpdatedAt, nil
  30177. }
  30178. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30179. func (m *TutorialMutation) ResetUpdatedAt() {
  30180. m.updated_at = nil
  30181. }
  30182. // SetDeletedAt sets the "deleted_at" field.
  30183. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  30184. m.deleted_at = &t
  30185. }
  30186. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30187. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  30188. v := m.deleted_at
  30189. if v == nil {
  30190. return
  30191. }
  30192. return *v, true
  30193. }
  30194. // OldDeletedAt returns the old "deleted_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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30198. if !m.op.Is(OpUpdateOne) {
  30199. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30200. }
  30201. if m.id == nil || m.oldValue == nil {
  30202. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  30207. }
  30208. return oldValue.DeletedAt, nil
  30209. }
  30210. // ClearDeletedAt clears the value of the "deleted_at" field.
  30211. func (m *TutorialMutation) ClearDeletedAt() {
  30212. m.deleted_at = nil
  30213. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  30214. }
  30215. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30216. func (m *TutorialMutation) DeletedAtCleared() bool {
  30217. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  30218. return ok
  30219. }
  30220. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30221. func (m *TutorialMutation) ResetDeletedAt() {
  30222. m.deleted_at = nil
  30223. delete(m.clearedFields, tutorial.FieldDeletedAt)
  30224. }
  30225. // SetEmployeeID sets the "employee_id" field.
  30226. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  30227. m.employee = &u
  30228. }
  30229. // EmployeeID returns the value of the "employee_id" field in the mutation.
  30230. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  30231. v := m.employee
  30232. if v == nil {
  30233. return
  30234. }
  30235. return *v, true
  30236. }
  30237. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  30238. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30240. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  30241. if !m.op.Is(OpUpdateOne) {
  30242. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  30243. }
  30244. if m.id == nil || m.oldValue == nil {
  30245. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  30246. }
  30247. oldValue, err := m.oldValue(ctx)
  30248. if err != nil {
  30249. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  30250. }
  30251. return oldValue.EmployeeID, nil
  30252. }
  30253. // ResetEmployeeID resets all changes to the "employee_id" field.
  30254. func (m *TutorialMutation) ResetEmployeeID() {
  30255. m.employee = nil
  30256. }
  30257. // SetIndex sets the "index" field.
  30258. func (m *TutorialMutation) SetIndex(i int) {
  30259. m.index = &i
  30260. m.addindex = nil
  30261. }
  30262. // Index returns the value of the "index" field in the mutation.
  30263. func (m *TutorialMutation) Index() (r int, exists bool) {
  30264. v := m.index
  30265. if v == nil {
  30266. return
  30267. }
  30268. return *v, true
  30269. }
  30270. // OldIndex returns the old "index" field's value of the Tutorial entity.
  30271. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30273. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  30274. if !m.op.Is(OpUpdateOne) {
  30275. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  30276. }
  30277. if m.id == nil || m.oldValue == nil {
  30278. return v, errors.New("OldIndex requires an ID field in the mutation")
  30279. }
  30280. oldValue, err := m.oldValue(ctx)
  30281. if err != nil {
  30282. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  30283. }
  30284. return oldValue.Index, nil
  30285. }
  30286. // AddIndex adds i to the "index" field.
  30287. func (m *TutorialMutation) AddIndex(i int) {
  30288. if m.addindex != nil {
  30289. *m.addindex += i
  30290. } else {
  30291. m.addindex = &i
  30292. }
  30293. }
  30294. // AddedIndex returns the value that was added to the "index" field in this mutation.
  30295. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  30296. v := m.addindex
  30297. if v == nil {
  30298. return
  30299. }
  30300. return *v, true
  30301. }
  30302. // ResetIndex resets all changes to the "index" field.
  30303. func (m *TutorialMutation) ResetIndex() {
  30304. m.index = nil
  30305. m.addindex = nil
  30306. }
  30307. // SetTitle sets the "title" field.
  30308. func (m *TutorialMutation) SetTitle(s string) {
  30309. m.title = &s
  30310. }
  30311. // Title returns the value of the "title" field in the mutation.
  30312. func (m *TutorialMutation) Title() (r string, exists bool) {
  30313. v := m.title
  30314. if v == nil {
  30315. return
  30316. }
  30317. return *v, true
  30318. }
  30319. // OldTitle returns the old "title" field's value of the Tutorial entity.
  30320. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30322. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  30323. if !m.op.Is(OpUpdateOne) {
  30324. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  30325. }
  30326. if m.id == nil || m.oldValue == nil {
  30327. return v, errors.New("OldTitle requires an ID field in the mutation")
  30328. }
  30329. oldValue, err := m.oldValue(ctx)
  30330. if err != nil {
  30331. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  30332. }
  30333. return oldValue.Title, nil
  30334. }
  30335. // ResetTitle resets all changes to the "title" field.
  30336. func (m *TutorialMutation) ResetTitle() {
  30337. m.title = nil
  30338. }
  30339. // SetContent sets the "content" field.
  30340. func (m *TutorialMutation) SetContent(s string) {
  30341. m.content = &s
  30342. }
  30343. // Content returns the value of the "content" field in the mutation.
  30344. func (m *TutorialMutation) Content() (r string, exists bool) {
  30345. v := m.content
  30346. if v == nil {
  30347. return
  30348. }
  30349. return *v, true
  30350. }
  30351. // OldContent returns the old "content" 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) OldContent(ctx context.Context) (v string, err error) {
  30355. if !m.op.Is(OpUpdateOne) {
  30356. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  30357. }
  30358. if m.id == nil || m.oldValue == nil {
  30359. return v, errors.New("OldContent 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 OldContent: %w", err)
  30364. }
  30365. return oldValue.Content, nil
  30366. }
  30367. // ResetContent resets all changes to the "content" field.
  30368. func (m *TutorialMutation) ResetContent() {
  30369. m.content = nil
  30370. }
  30371. // SetOrganizationID sets the "organization_id" field.
  30372. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  30373. m.organization_id = &u
  30374. m.addorganization_id = nil
  30375. }
  30376. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30377. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  30378. v := m.organization_id
  30379. if v == nil {
  30380. return
  30381. }
  30382. return *v, true
  30383. }
  30384. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  30385. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30387. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30388. if !m.op.Is(OpUpdateOne) {
  30389. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30390. }
  30391. if m.id == nil || m.oldValue == nil {
  30392. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30393. }
  30394. oldValue, err := m.oldValue(ctx)
  30395. if err != nil {
  30396. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30397. }
  30398. return oldValue.OrganizationID, nil
  30399. }
  30400. // AddOrganizationID adds u to the "organization_id" field.
  30401. func (m *TutorialMutation) AddOrganizationID(u int64) {
  30402. if m.addorganization_id != nil {
  30403. *m.addorganization_id += u
  30404. } else {
  30405. m.addorganization_id = &u
  30406. }
  30407. }
  30408. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30409. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  30410. v := m.addorganization_id
  30411. if v == nil {
  30412. return
  30413. }
  30414. return *v, true
  30415. }
  30416. // ResetOrganizationID resets all changes to the "organization_id" field.
  30417. func (m *TutorialMutation) ResetOrganizationID() {
  30418. m.organization_id = nil
  30419. m.addorganization_id = nil
  30420. }
  30421. // ClearEmployee clears the "employee" edge to the Employee entity.
  30422. func (m *TutorialMutation) ClearEmployee() {
  30423. m.clearedemployee = true
  30424. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  30425. }
  30426. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  30427. func (m *TutorialMutation) EmployeeCleared() bool {
  30428. return m.clearedemployee
  30429. }
  30430. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  30431. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30432. // EmployeeID instead. It exists only for internal usage by the builders.
  30433. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  30434. if id := m.employee; id != nil {
  30435. ids = append(ids, *id)
  30436. }
  30437. return
  30438. }
  30439. // ResetEmployee resets all changes to the "employee" edge.
  30440. func (m *TutorialMutation) ResetEmployee() {
  30441. m.employee = nil
  30442. m.clearedemployee = false
  30443. }
  30444. // Where appends a list predicates to the TutorialMutation builder.
  30445. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  30446. m.predicates = append(m.predicates, ps...)
  30447. }
  30448. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  30449. // users can use type-assertion to append predicates that do not depend on any generated package.
  30450. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  30451. p := make([]predicate.Tutorial, len(ps))
  30452. for i := range ps {
  30453. p[i] = ps[i]
  30454. }
  30455. m.Where(p...)
  30456. }
  30457. // Op returns the operation name.
  30458. func (m *TutorialMutation) Op() Op {
  30459. return m.op
  30460. }
  30461. // SetOp allows setting the mutation operation.
  30462. func (m *TutorialMutation) SetOp(op Op) {
  30463. m.op = op
  30464. }
  30465. // Type returns the node type of this mutation (Tutorial).
  30466. func (m *TutorialMutation) Type() string {
  30467. return m.typ
  30468. }
  30469. // Fields returns all fields that were changed during this mutation. Note that in
  30470. // order to get all numeric fields that were incremented/decremented, call
  30471. // AddedFields().
  30472. func (m *TutorialMutation) Fields() []string {
  30473. fields := make([]string, 0, 8)
  30474. if m.created_at != nil {
  30475. fields = append(fields, tutorial.FieldCreatedAt)
  30476. }
  30477. if m.updated_at != nil {
  30478. fields = append(fields, tutorial.FieldUpdatedAt)
  30479. }
  30480. if m.deleted_at != nil {
  30481. fields = append(fields, tutorial.FieldDeletedAt)
  30482. }
  30483. if m.employee != nil {
  30484. fields = append(fields, tutorial.FieldEmployeeID)
  30485. }
  30486. if m.index != nil {
  30487. fields = append(fields, tutorial.FieldIndex)
  30488. }
  30489. if m.title != nil {
  30490. fields = append(fields, tutorial.FieldTitle)
  30491. }
  30492. if m.content != nil {
  30493. fields = append(fields, tutorial.FieldContent)
  30494. }
  30495. if m.organization_id != nil {
  30496. fields = append(fields, tutorial.FieldOrganizationID)
  30497. }
  30498. return fields
  30499. }
  30500. // Field returns the value of a field with the given name. The second boolean
  30501. // return value indicates that this field was not set, or was not defined in the
  30502. // schema.
  30503. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  30504. switch name {
  30505. case tutorial.FieldCreatedAt:
  30506. return m.CreatedAt()
  30507. case tutorial.FieldUpdatedAt:
  30508. return m.UpdatedAt()
  30509. case tutorial.FieldDeletedAt:
  30510. return m.DeletedAt()
  30511. case tutorial.FieldEmployeeID:
  30512. return m.EmployeeID()
  30513. case tutorial.FieldIndex:
  30514. return m.Index()
  30515. case tutorial.FieldTitle:
  30516. return m.Title()
  30517. case tutorial.FieldContent:
  30518. return m.Content()
  30519. case tutorial.FieldOrganizationID:
  30520. return m.OrganizationID()
  30521. }
  30522. return nil, false
  30523. }
  30524. // OldField returns the old value of the field from the database. An error is
  30525. // returned if the mutation operation is not UpdateOne, or the query to the
  30526. // database failed.
  30527. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30528. switch name {
  30529. case tutorial.FieldCreatedAt:
  30530. return m.OldCreatedAt(ctx)
  30531. case tutorial.FieldUpdatedAt:
  30532. return m.OldUpdatedAt(ctx)
  30533. case tutorial.FieldDeletedAt:
  30534. return m.OldDeletedAt(ctx)
  30535. case tutorial.FieldEmployeeID:
  30536. return m.OldEmployeeID(ctx)
  30537. case tutorial.FieldIndex:
  30538. return m.OldIndex(ctx)
  30539. case tutorial.FieldTitle:
  30540. return m.OldTitle(ctx)
  30541. case tutorial.FieldContent:
  30542. return m.OldContent(ctx)
  30543. case tutorial.FieldOrganizationID:
  30544. return m.OldOrganizationID(ctx)
  30545. }
  30546. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  30547. }
  30548. // SetField sets the value of a field with the given name. It returns an error if
  30549. // the field is not defined in the schema, or if the type mismatched the field
  30550. // type.
  30551. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  30552. switch name {
  30553. case tutorial.FieldCreatedAt:
  30554. v, ok := value.(time.Time)
  30555. if !ok {
  30556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30557. }
  30558. m.SetCreatedAt(v)
  30559. return nil
  30560. case tutorial.FieldUpdatedAt:
  30561. v, ok := value.(time.Time)
  30562. if !ok {
  30563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30564. }
  30565. m.SetUpdatedAt(v)
  30566. return nil
  30567. case tutorial.FieldDeletedAt:
  30568. v, ok := value.(time.Time)
  30569. if !ok {
  30570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30571. }
  30572. m.SetDeletedAt(v)
  30573. return nil
  30574. case tutorial.FieldEmployeeID:
  30575. v, ok := value.(uint64)
  30576. if !ok {
  30577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30578. }
  30579. m.SetEmployeeID(v)
  30580. return nil
  30581. case tutorial.FieldIndex:
  30582. v, ok := value.(int)
  30583. if !ok {
  30584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30585. }
  30586. m.SetIndex(v)
  30587. return nil
  30588. case tutorial.FieldTitle:
  30589. v, ok := value.(string)
  30590. if !ok {
  30591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30592. }
  30593. m.SetTitle(v)
  30594. return nil
  30595. case tutorial.FieldContent:
  30596. v, ok := value.(string)
  30597. if !ok {
  30598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30599. }
  30600. m.SetContent(v)
  30601. return nil
  30602. case tutorial.FieldOrganizationID:
  30603. v, ok := value.(uint64)
  30604. if !ok {
  30605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30606. }
  30607. m.SetOrganizationID(v)
  30608. return nil
  30609. }
  30610. return fmt.Errorf("unknown Tutorial field %s", name)
  30611. }
  30612. // AddedFields returns all numeric fields that were incremented/decremented during
  30613. // this mutation.
  30614. func (m *TutorialMutation) AddedFields() []string {
  30615. var fields []string
  30616. if m.addindex != nil {
  30617. fields = append(fields, tutorial.FieldIndex)
  30618. }
  30619. if m.addorganization_id != nil {
  30620. fields = append(fields, tutorial.FieldOrganizationID)
  30621. }
  30622. return fields
  30623. }
  30624. // AddedField returns the numeric value that was incremented/decremented on a field
  30625. // with the given name. The second boolean return value indicates that this field
  30626. // was not set, or was not defined in the schema.
  30627. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  30628. switch name {
  30629. case tutorial.FieldIndex:
  30630. return m.AddedIndex()
  30631. case tutorial.FieldOrganizationID:
  30632. return m.AddedOrganizationID()
  30633. }
  30634. return nil, false
  30635. }
  30636. // AddField adds the value to the field with the given name. It returns an error if
  30637. // the field is not defined in the schema, or if the type mismatched the field
  30638. // type.
  30639. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  30640. switch name {
  30641. case tutorial.FieldIndex:
  30642. v, ok := value.(int)
  30643. if !ok {
  30644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30645. }
  30646. m.AddIndex(v)
  30647. return nil
  30648. case tutorial.FieldOrganizationID:
  30649. v, ok := value.(int64)
  30650. if !ok {
  30651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30652. }
  30653. m.AddOrganizationID(v)
  30654. return nil
  30655. }
  30656. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  30657. }
  30658. // ClearedFields returns all nullable fields that were cleared during this
  30659. // mutation.
  30660. func (m *TutorialMutation) ClearedFields() []string {
  30661. var fields []string
  30662. if m.FieldCleared(tutorial.FieldDeletedAt) {
  30663. fields = append(fields, tutorial.FieldDeletedAt)
  30664. }
  30665. return fields
  30666. }
  30667. // FieldCleared returns a boolean indicating if a field with the given name was
  30668. // cleared in this mutation.
  30669. func (m *TutorialMutation) FieldCleared(name string) bool {
  30670. _, ok := m.clearedFields[name]
  30671. return ok
  30672. }
  30673. // ClearField clears the value of the field with the given name. It returns an
  30674. // error if the field is not defined in the schema.
  30675. func (m *TutorialMutation) ClearField(name string) error {
  30676. switch name {
  30677. case tutorial.FieldDeletedAt:
  30678. m.ClearDeletedAt()
  30679. return nil
  30680. }
  30681. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  30682. }
  30683. // ResetField resets all changes in the mutation for the field with the given name.
  30684. // It returns an error if the field is not defined in the schema.
  30685. func (m *TutorialMutation) ResetField(name string) error {
  30686. switch name {
  30687. case tutorial.FieldCreatedAt:
  30688. m.ResetCreatedAt()
  30689. return nil
  30690. case tutorial.FieldUpdatedAt:
  30691. m.ResetUpdatedAt()
  30692. return nil
  30693. case tutorial.FieldDeletedAt:
  30694. m.ResetDeletedAt()
  30695. return nil
  30696. case tutorial.FieldEmployeeID:
  30697. m.ResetEmployeeID()
  30698. return nil
  30699. case tutorial.FieldIndex:
  30700. m.ResetIndex()
  30701. return nil
  30702. case tutorial.FieldTitle:
  30703. m.ResetTitle()
  30704. return nil
  30705. case tutorial.FieldContent:
  30706. m.ResetContent()
  30707. return nil
  30708. case tutorial.FieldOrganizationID:
  30709. m.ResetOrganizationID()
  30710. return nil
  30711. }
  30712. return fmt.Errorf("unknown Tutorial field %s", name)
  30713. }
  30714. // AddedEdges returns all edge names that were set/added in this mutation.
  30715. func (m *TutorialMutation) AddedEdges() []string {
  30716. edges := make([]string, 0, 1)
  30717. if m.employee != nil {
  30718. edges = append(edges, tutorial.EdgeEmployee)
  30719. }
  30720. return edges
  30721. }
  30722. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30723. // name in this mutation.
  30724. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  30725. switch name {
  30726. case tutorial.EdgeEmployee:
  30727. if id := m.employee; id != nil {
  30728. return []ent.Value{*id}
  30729. }
  30730. }
  30731. return nil
  30732. }
  30733. // RemovedEdges returns all edge names that were removed in this mutation.
  30734. func (m *TutorialMutation) RemovedEdges() []string {
  30735. edges := make([]string, 0, 1)
  30736. return edges
  30737. }
  30738. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30739. // the given name in this mutation.
  30740. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  30741. return nil
  30742. }
  30743. // ClearedEdges returns all edge names that were cleared in this mutation.
  30744. func (m *TutorialMutation) ClearedEdges() []string {
  30745. edges := make([]string, 0, 1)
  30746. if m.clearedemployee {
  30747. edges = append(edges, tutorial.EdgeEmployee)
  30748. }
  30749. return edges
  30750. }
  30751. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30752. // was cleared in this mutation.
  30753. func (m *TutorialMutation) EdgeCleared(name string) bool {
  30754. switch name {
  30755. case tutorial.EdgeEmployee:
  30756. return m.clearedemployee
  30757. }
  30758. return false
  30759. }
  30760. // ClearEdge clears the value of the edge with the given name. It returns an error
  30761. // if that edge is not defined in the schema.
  30762. func (m *TutorialMutation) ClearEdge(name string) error {
  30763. switch name {
  30764. case tutorial.EdgeEmployee:
  30765. m.ClearEmployee()
  30766. return nil
  30767. }
  30768. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  30769. }
  30770. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30771. // It returns an error if the edge is not defined in the schema.
  30772. func (m *TutorialMutation) ResetEdge(name string) error {
  30773. switch name {
  30774. case tutorial.EdgeEmployee:
  30775. m.ResetEmployee()
  30776. return nil
  30777. }
  30778. return fmt.Errorf("unknown Tutorial edge %s", name)
  30779. }
  30780. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  30781. type UsageDetailMutation struct {
  30782. config
  30783. op Op
  30784. typ string
  30785. id *uint64
  30786. created_at *time.Time
  30787. updated_at *time.Time
  30788. status *uint8
  30789. addstatus *int8
  30790. _type *int
  30791. add_type *int
  30792. bot_id *string
  30793. receiver_id *string
  30794. app *int
  30795. addapp *int
  30796. session_id *uint64
  30797. addsession_id *int64
  30798. request *string
  30799. response *string
  30800. original_data *custom_types.OriginalData
  30801. total_tokens *uint64
  30802. addtotal_tokens *int64
  30803. prompt_tokens *uint64
  30804. addprompt_tokens *int64
  30805. completion_tokens *uint64
  30806. addcompletion_tokens *int64
  30807. organization_id *uint64
  30808. addorganization_id *int64
  30809. clearedFields map[string]struct{}
  30810. done bool
  30811. oldValue func(context.Context) (*UsageDetail, error)
  30812. predicates []predicate.UsageDetail
  30813. }
  30814. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  30815. // usagedetailOption allows management of the mutation configuration using functional options.
  30816. type usagedetailOption func(*UsageDetailMutation)
  30817. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  30818. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  30819. m := &UsageDetailMutation{
  30820. config: c,
  30821. op: op,
  30822. typ: TypeUsageDetail,
  30823. clearedFields: make(map[string]struct{}),
  30824. }
  30825. for _, opt := range opts {
  30826. opt(m)
  30827. }
  30828. return m
  30829. }
  30830. // withUsageDetailID sets the ID field of the mutation.
  30831. func withUsageDetailID(id uint64) usagedetailOption {
  30832. return func(m *UsageDetailMutation) {
  30833. var (
  30834. err error
  30835. once sync.Once
  30836. value *UsageDetail
  30837. )
  30838. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  30839. once.Do(func() {
  30840. if m.done {
  30841. err = errors.New("querying old values post mutation is not allowed")
  30842. } else {
  30843. value, err = m.Client().UsageDetail.Get(ctx, id)
  30844. }
  30845. })
  30846. return value, err
  30847. }
  30848. m.id = &id
  30849. }
  30850. }
  30851. // withUsageDetail sets the old UsageDetail of the mutation.
  30852. func withUsageDetail(node *UsageDetail) usagedetailOption {
  30853. return func(m *UsageDetailMutation) {
  30854. m.oldValue = func(context.Context) (*UsageDetail, error) {
  30855. return node, nil
  30856. }
  30857. m.id = &node.ID
  30858. }
  30859. }
  30860. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30861. // executed in a transaction (ent.Tx), a transactional client is returned.
  30862. func (m UsageDetailMutation) Client() *Client {
  30863. client := &Client{config: m.config}
  30864. client.init()
  30865. return client
  30866. }
  30867. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30868. // it returns an error otherwise.
  30869. func (m UsageDetailMutation) Tx() (*Tx, error) {
  30870. if _, ok := m.driver.(*txDriver); !ok {
  30871. return nil, errors.New("ent: mutation is not running in a transaction")
  30872. }
  30873. tx := &Tx{config: m.config}
  30874. tx.init()
  30875. return tx, nil
  30876. }
  30877. // SetID sets the value of the id field. Note that this
  30878. // operation is only accepted on creation of UsageDetail entities.
  30879. func (m *UsageDetailMutation) SetID(id uint64) {
  30880. m.id = &id
  30881. }
  30882. // ID returns the ID value in the mutation. Note that the ID is only available
  30883. // if it was provided to the builder or after it was returned from the database.
  30884. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  30885. if m.id == nil {
  30886. return
  30887. }
  30888. return *m.id, true
  30889. }
  30890. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30891. // That means, if the mutation is applied within a transaction with an isolation level such
  30892. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30893. // or updated by the mutation.
  30894. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  30895. switch {
  30896. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30897. id, exists := m.ID()
  30898. if exists {
  30899. return []uint64{id}, nil
  30900. }
  30901. fallthrough
  30902. case m.op.Is(OpUpdate | OpDelete):
  30903. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  30904. default:
  30905. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30906. }
  30907. }
  30908. // SetCreatedAt sets the "created_at" field.
  30909. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  30910. m.created_at = &t
  30911. }
  30912. // CreatedAt returns the value of the "created_at" field in the mutation.
  30913. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  30914. v := m.created_at
  30915. if v == nil {
  30916. return
  30917. }
  30918. return *v, true
  30919. }
  30920. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  30921. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30923. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30924. if !m.op.Is(OpUpdateOne) {
  30925. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30926. }
  30927. if m.id == nil || m.oldValue == nil {
  30928. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30929. }
  30930. oldValue, err := m.oldValue(ctx)
  30931. if err != nil {
  30932. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30933. }
  30934. return oldValue.CreatedAt, nil
  30935. }
  30936. // ResetCreatedAt resets all changes to the "created_at" field.
  30937. func (m *UsageDetailMutation) ResetCreatedAt() {
  30938. m.created_at = nil
  30939. }
  30940. // SetUpdatedAt sets the "updated_at" field.
  30941. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  30942. m.updated_at = &t
  30943. }
  30944. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30945. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  30946. v := m.updated_at
  30947. if v == nil {
  30948. return
  30949. }
  30950. return *v, true
  30951. }
  30952. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30956. if !m.op.Is(OpUpdateOne) {
  30957. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30958. }
  30959. if m.id == nil || m.oldValue == nil {
  30960. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  30965. }
  30966. return oldValue.UpdatedAt, nil
  30967. }
  30968. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30969. func (m *UsageDetailMutation) ResetUpdatedAt() {
  30970. m.updated_at = nil
  30971. }
  30972. // SetStatus sets the "status" field.
  30973. func (m *UsageDetailMutation) SetStatus(u uint8) {
  30974. m.status = &u
  30975. m.addstatus = nil
  30976. }
  30977. // Status returns the value of the "status" field in the mutation.
  30978. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  30979. v := m.status
  30980. if v == nil {
  30981. return
  30982. }
  30983. return *v, true
  30984. }
  30985. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  30986. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30988. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30989. if !m.op.Is(OpUpdateOne) {
  30990. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30991. }
  30992. if m.id == nil || m.oldValue == nil {
  30993. return v, errors.New("OldStatus requires an ID field in the mutation")
  30994. }
  30995. oldValue, err := m.oldValue(ctx)
  30996. if err != nil {
  30997. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30998. }
  30999. return oldValue.Status, nil
  31000. }
  31001. // AddStatus adds u to the "status" field.
  31002. func (m *UsageDetailMutation) AddStatus(u int8) {
  31003. if m.addstatus != nil {
  31004. *m.addstatus += u
  31005. } else {
  31006. m.addstatus = &u
  31007. }
  31008. }
  31009. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31010. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  31011. v := m.addstatus
  31012. if v == nil {
  31013. return
  31014. }
  31015. return *v, true
  31016. }
  31017. // ClearStatus clears the value of the "status" field.
  31018. func (m *UsageDetailMutation) ClearStatus() {
  31019. m.status = nil
  31020. m.addstatus = nil
  31021. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  31022. }
  31023. // StatusCleared returns if the "status" field was cleared in this mutation.
  31024. func (m *UsageDetailMutation) StatusCleared() bool {
  31025. _, ok := m.clearedFields[usagedetail.FieldStatus]
  31026. return ok
  31027. }
  31028. // ResetStatus resets all changes to the "status" field.
  31029. func (m *UsageDetailMutation) ResetStatus() {
  31030. m.status = nil
  31031. m.addstatus = nil
  31032. delete(m.clearedFields, usagedetail.FieldStatus)
  31033. }
  31034. // SetType sets the "type" field.
  31035. func (m *UsageDetailMutation) SetType(i int) {
  31036. m._type = &i
  31037. m.add_type = nil
  31038. }
  31039. // GetType returns the value of the "type" field in the mutation.
  31040. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  31041. v := m._type
  31042. if v == nil {
  31043. return
  31044. }
  31045. return *v, true
  31046. }
  31047. // OldType returns the old "type" field's value of the UsageDetail entity.
  31048. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31050. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  31051. if !m.op.Is(OpUpdateOne) {
  31052. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31053. }
  31054. if m.id == nil || m.oldValue == nil {
  31055. return v, errors.New("OldType requires an ID field in the mutation")
  31056. }
  31057. oldValue, err := m.oldValue(ctx)
  31058. if err != nil {
  31059. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31060. }
  31061. return oldValue.Type, nil
  31062. }
  31063. // AddType adds i to the "type" field.
  31064. func (m *UsageDetailMutation) AddType(i int) {
  31065. if m.add_type != nil {
  31066. *m.add_type += i
  31067. } else {
  31068. m.add_type = &i
  31069. }
  31070. }
  31071. // AddedType returns the value that was added to the "type" field in this mutation.
  31072. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  31073. v := m.add_type
  31074. if v == nil {
  31075. return
  31076. }
  31077. return *v, true
  31078. }
  31079. // ClearType clears the value of the "type" field.
  31080. func (m *UsageDetailMutation) ClearType() {
  31081. m._type = nil
  31082. m.add_type = nil
  31083. m.clearedFields[usagedetail.FieldType] = struct{}{}
  31084. }
  31085. // TypeCleared returns if the "type" field was cleared in this mutation.
  31086. func (m *UsageDetailMutation) TypeCleared() bool {
  31087. _, ok := m.clearedFields[usagedetail.FieldType]
  31088. return ok
  31089. }
  31090. // ResetType resets all changes to the "type" field.
  31091. func (m *UsageDetailMutation) ResetType() {
  31092. m._type = nil
  31093. m.add_type = nil
  31094. delete(m.clearedFields, usagedetail.FieldType)
  31095. }
  31096. // SetBotID sets the "bot_id" field.
  31097. func (m *UsageDetailMutation) SetBotID(s string) {
  31098. m.bot_id = &s
  31099. }
  31100. // BotID returns the value of the "bot_id" field in the mutation.
  31101. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  31102. v := m.bot_id
  31103. if v == nil {
  31104. return
  31105. }
  31106. return *v, true
  31107. }
  31108. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  31109. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31111. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  31112. if !m.op.Is(OpUpdateOne) {
  31113. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31114. }
  31115. if m.id == nil || m.oldValue == nil {
  31116. return v, errors.New("OldBotID requires an ID field in the mutation")
  31117. }
  31118. oldValue, err := m.oldValue(ctx)
  31119. if err != nil {
  31120. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31121. }
  31122. return oldValue.BotID, nil
  31123. }
  31124. // ResetBotID resets all changes to the "bot_id" field.
  31125. func (m *UsageDetailMutation) ResetBotID() {
  31126. m.bot_id = nil
  31127. }
  31128. // SetReceiverID sets the "receiver_id" field.
  31129. func (m *UsageDetailMutation) SetReceiverID(s string) {
  31130. m.receiver_id = &s
  31131. }
  31132. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  31133. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  31134. v := m.receiver_id
  31135. if v == nil {
  31136. return
  31137. }
  31138. return *v, true
  31139. }
  31140. // OldReceiverID returns the old "receiver_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) OldReceiverID(ctx context.Context) (v string, err error) {
  31144. if !m.op.Is(OpUpdateOne) {
  31145. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  31146. }
  31147. if m.id == nil || m.oldValue == nil {
  31148. return v, errors.New("OldReceiverID 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 OldReceiverID: %w", err)
  31153. }
  31154. return oldValue.ReceiverID, nil
  31155. }
  31156. // ResetReceiverID resets all changes to the "receiver_id" field.
  31157. func (m *UsageDetailMutation) ResetReceiverID() {
  31158. m.receiver_id = nil
  31159. }
  31160. // SetApp sets the "app" field.
  31161. func (m *UsageDetailMutation) SetApp(i int) {
  31162. m.app = &i
  31163. m.addapp = nil
  31164. }
  31165. // App returns the value of the "app" field in the mutation.
  31166. func (m *UsageDetailMutation) App() (r int, exists bool) {
  31167. v := m.app
  31168. if v == nil {
  31169. return
  31170. }
  31171. return *v, true
  31172. }
  31173. // OldApp returns the old "app" field's value of the UsageDetail entity.
  31174. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31176. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  31177. if !m.op.Is(OpUpdateOne) {
  31178. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  31179. }
  31180. if m.id == nil || m.oldValue == nil {
  31181. return v, errors.New("OldApp requires an ID field in the mutation")
  31182. }
  31183. oldValue, err := m.oldValue(ctx)
  31184. if err != nil {
  31185. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  31186. }
  31187. return oldValue.App, nil
  31188. }
  31189. // AddApp adds i to the "app" field.
  31190. func (m *UsageDetailMutation) AddApp(i int) {
  31191. if m.addapp != nil {
  31192. *m.addapp += i
  31193. } else {
  31194. m.addapp = &i
  31195. }
  31196. }
  31197. // AddedApp returns the value that was added to the "app" field in this mutation.
  31198. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  31199. v := m.addapp
  31200. if v == nil {
  31201. return
  31202. }
  31203. return *v, true
  31204. }
  31205. // ClearApp clears the value of the "app" field.
  31206. func (m *UsageDetailMutation) ClearApp() {
  31207. m.app = nil
  31208. m.addapp = nil
  31209. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  31210. }
  31211. // AppCleared returns if the "app" field was cleared in this mutation.
  31212. func (m *UsageDetailMutation) AppCleared() bool {
  31213. _, ok := m.clearedFields[usagedetail.FieldApp]
  31214. return ok
  31215. }
  31216. // ResetApp resets all changes to the "app" field.
  31217. func (m *UsageDetailMutation) ResetApp() {
  31218. m.app = nil
  31219. m.addapp = nil
  31220. delete(m.clearedFields, usagedetail.FieldApp)
  31221. }
  31222. // SetSessionID sets the "session_id" field.
  31223. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  31224. m.session_id = &u
  31225. m.addsession_id = nil
  31226. }
  31227. // SessionID returns the value of the "session_id" field in the mutation.
  31228. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  31229. v := m.session_id
  31230. if v == nil {
  31231. return
  31232. }
  31233. return *v, true
  31234. }
  31235. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  31236. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31238. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  31239. if !m.op.Is(OpUpdateOne) {
  31240. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  31241. }
  31242. if m.id == nil || m.oldValue == nil {
  31243. return v, errors.New("OldSessionID requires an ID field in the mutation")
  31244. }
  31245. oldValue, err := m.oldValue(ctx)
  31246. if err != nil {
  31247. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  31248. }
  31249. return oldValue.SessionID, nil
  31250. }
  31251. // AddSessionID adds u to the "session_id" field.
  31252. func (m *UsageDetailMutation) AddSessionID(u int64) {
  31253. if m.addsession_id != nil {
  31254. *m.addsession_id += u
  31255. } else {
  31256. m.addsession_id = &u
  31257. }
  31258. }
  31259. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  31260. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  31261. v := m.addsession_id
  31262. if v == nil {
  31263. return
  31264. }
  31265. return *v, true
  31266. }
  31267. // ClearSessionID clears the value of the "session_id" field.
  31268. func (m *UsageDetailMutation) ClearSessionID() {
  31269. m.session_id = nil
  31270. m.addsession_id = nil
  31271. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  31272. }
  31273. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  31274. func (m *UsageDetailMutation) SessionIDCleared() bool {
  31275. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  31276. return ok
  31277. }
  31278. // ResetSessionID resets all changes to the "session_id" field.
  31279. func (m *UsageDetailMutation) ResetSessionID() {
  31280. m.session_id = nil
  31281. m.addsession_id = nil
  31282. delete(m.clearedFields, usagedetail.FieldSessionID)
  31283. }
  31284. // SetRequest sets the "request" field.
  31285. func (m *UsageDetailMutation) SetRequest(s string) {
  31286. m.request = &s
  31287. }
  31288. // Request returns the value of the "request" field in the mutation.
  31289. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  31290. v := m.request
  31291. if v == nil {
  31292. return
  31293. }
  31294. return *v, true
  31295. }
  31296. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  31297. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31299. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  31300. if !m.op.Is(OpUpdateOne) {
  31301. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  31302. }
  31303. if m.id == nil || m.oldValue == nil {
  31304. return v, errors.New("OldRequest requires an ID field in the mutation")
  31305. }
  31306. oldValue, err := m.oldValue(ctx)
  31307. if err != nil {
  31308. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  31309. }
  31310. return oldValue.Request, nil
  31311. }
  31312. // ResetRequest resets all changes to the "request" field.
  31313. func (m *UsageDetailMutation) ResetRequest() {
  31314. m.request = nil
  31315. }
  31316. // SetResponse sets the "response" field.
  31317. func (m *UsageDetailMutation) SetResponse(s string) {
  31318. m.response = &s
  31319. }
  31320. // Response returns the value of the "response" field in the mutation.
  31321. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  31322. v := m.response
  31323. if v == nil {
  31324. return
  31325. }
  31326. return *v, true
  31327. }
  31328. // OldResponse returns the old "response" 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) OldResponse(ctx context.Context) (v string, err error) {
  31332. if !m.op.Is(OpUpdateOne) {
  31333. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  31334. }
  31335. if m.id == nil || m.oldValue == nil {
  31336. return v, errors.New("OldResponse 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 OldResponse: %w", err)
  31341. }
  31342. return oldValue.Response, nil
  31343. }
  31344. // ResetResponse resets all changes to the "response" field.
  31345. func (m *UsageDetailMutation) ResetResponse() {
  31346. m.response = nil
  31347. }
  31348. // SetOriginalData sets the "original_data" field.
  31349. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  31350. m.original_data = &ctd
  31351. }
  31352. // OriginalData returns the value of the "original_data" field in the mutation.
  31353. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  31354. v := m.original_data
  31355. if v == nil {
  31356. return
  31357. }
  31358. return *v, true
  31359. }
  31360. // OldOriginalData returns the old "original_data" 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) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  31364. if !m.op.Is(OpUpdateOne) {
  31365. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  31366. }
  31367. if m.id == nil || m.oldValue == nil {
  31368. return v, errors.New("OldOriginalData 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 OldOriginalData: %w", err)
  31373. }
  31374. return oldValue.OriginalData, nil
  31375. }
  31376. // ResetOriginalData resets all changes to the "original_data" field.
  31377. func (m *UsageDetailMutation) ResetOriginalData() {
  31378. m.original_data = nil
  31379. }
  31380. // SetTotalTokens sets the "total_tokens" field.
  31381. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  31382. m.total_tokens = &u
  31383. m.addtotal_tokens = nil
  31384. }
  31385. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  31386. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  31387. v := m.total_tokens
  31388. if v == nil {
  31389. return
  31390. }
  31391. return *v, true
  31392. }
  31393. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  31394. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31396. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  31397. if !m.op.Is(OpUpdateOne) {
  31398. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  31399. }
  31400. if m.id == nil || m.oldValue == nil {
  31401. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  31402. }
  31403. oldValue, err := m.oldValue(ctx)
  31404. if err != nil {
  31405. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  31406. }
  31407. return oldValue.TotalTokens, nil
  31408. }
  31409. // AddTotalTokens adds u to the "total_tokens" field.
  31410. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  31411. if m.addtotal_tokens != nil {
  31412. *m.addtotal_tokens += u
  31413. } else {
  31414. m.addtotal_tokens = &u
  31415. }
  31416. }
  31417. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  31418. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  31419. v := m.addtotal_tokens
  31420. if v == nil {
  31421. return
  31422. }
  31423. return *v, true
  31424. }
  31425. // ClearTotalTokens clears the value of the "total_tokens" field.
  31426. func (m *UsageDetailMutation) ClearTotalTokens() {
  31427. m.total_tokens = nil
  31428. m.addtotal_tokens = nil
  31429. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  31430. }
  31431. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  31432. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  31433. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  31434. return ok
  31435. }
  31436. // ResetTotalTokens resets all changes to the "total_tokens" field.
  31437. func (m *UsageDetailMutation) ResetTotalTokens() {
  31438. m.total_tokens = nil
  31439. m.addtotal_tokens = nil
  31440. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  31441. }
  31442. // SetPromptTokens sets the "prompt_tokens" field.
  31443. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  31444. m.prompt_tokens = &u
  31445. m.addprompt_tokens = nil
  31446. }
  31447. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  31448. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  31449. v := m.prompt_tokens
  31450. if v == nil {
  31451. return
  31452. }
  31453. return *v, true
  31454. }
  31455. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  31456. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31458. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  31459. if !m.op.Is(OpUpdateOne) {
  31460. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  31461. }
  31462. if m.id == nil || m.oldValue == nil {
  31463. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  31464. }
  31465. oldValue, err := m.oldValue(ctx)
  31466. if err != nil {
  31467. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  31468. }
  31469. return oldValue.PromptTokens, nil
  31470. }
  31471. // AddPromptTokens adds u to the "prompt_tokens" field.
  31472. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  31473. if m.addprompt_tokens != nil {
  31474. *m.addprompt_tokens += u
  31475. } else {
  31476. m.addprompt_tokens = &u
  31477. }
  31478. }
  31479. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  31480. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  31481. v := m.addprompt_tokens
  31482. if v == nil {
  31483. return
  31484. }
  31485. return *v, true
  31486. }
  31487. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  31488. func (m *UsageDetailMutation) ClearPromptTokens() {
  31489. m.prompt_tokens = nil
  31490. m.addprompt_tokens = nil
  31491. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  31492. }
  31493. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  31494. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  31495. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  31496. return ok
  31497. }
  31498. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  31499. func (m *UsageDetailMutation) ResetPromptTokens() {
  31500. m.prompt_tokens = nil
  31501. m.addprompt_tokens = nil
  31502. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  31503. }
  31504. // SetCompletionTokens sets the "completion_tokens" field.
  31505. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  31506. m.completion_tokens = &u
  31507. m.addcompletion_tokens = nil
  31508. }
  31509. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  31510. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  31511. v := m.completion_tokens
  31512. if v == nil {
  31513. return
  31514. }
  31515. return *v, true
  31516. }
  31517. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  31518. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31520. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  31521. if !m.op.Is(OpUpdateOne) {
  31522. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  31523. }
  31524. if m.id == nil || m.oldValue == nil {
  31525. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  31526. }
  31527. oldValue, err := m.oldValue(ctx)
  31528. if err != nil {
  31529. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  31530. }
  31531. return oldValue.CompletionTokens, nil
  31532. }
  31533. // AddCompletionTokens adds u to the "completion_tokens" field.
  31534. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  31535. if m.addcompletion_tokens != nil {
  31536. *m.addcompletion_tokens += u
  31537. } else {
  31538. m.addcompletion_tokens = &u
  31539. }
  31540. }
  31541. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  31542. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  31543. v := m.addcompletion_tokens
  31544. if v == nil {
  31545. return
  31546. }
  31547. return *v, true
  31548. }
  31549. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  31550. func (m *UsageDetailMutation) ClearCompletionTokens() {
  31551. m.completion_tokens = nil
  31552. m.addcompletion_tokens = nil
  31553. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  31554. }
  31555. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  31556. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  31557. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  31558. return ok
  31559. }
  31560. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  31561. func (m *UsageDetailMutation) ResetCompletionTokens() {
  31562. m.completion_tokens = nil
  31563. m.addcompletion_tokens = nil
  31564. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  31565. }
  31566. // SetOrganizationID sets the "organization_id" field.
  31567. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  31568. m.organization_id = &u
  31569. m.addorganization_id = nil
  31570. }
  31571. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31572. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  31573. v := m.organization_id
  31574. if v == nil {
  31575. return
  31576. }
  31577. return *v, true
  31578. }
  31579. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  31580. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31582. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31583. if !m.op.Is(OpUpdateOne) {
  31584. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31585. }
  31586. if m.id == nil || m.oldValue == nil {
  31587. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31588. }
  31589. oldValue, err := m.oldValue(ctx)
  31590. if err != nil {
  31591. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31592. }
  31593. return oldValue.OrganizationID, nil
  31594. }
  31595. // AddOrganizationID adds u to the "organization_id" field.
  31596. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  31597. if m.addorganization_id != nil {
  31598. *m.addorganization_id += u
  31599. } else {
  31600. m.addorganization_id = &u
  31601. }
  31602. }
  31603. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31604. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  31605. v := m.addorganization_id
  31606. if v == nil {
  31607. return
  31608. }
  31609. return *v, true
  31610. }
  31611. // ClearOrganizationID clears the value of the "organization_id" field.
  31612. func (m *UsageDetailMutation) ClearOrganizationID() {
  31613. m.organization_id = nil
  31614. m.addorganization_id = nil
  31615. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  31616. }
  31617. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31618. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  31619. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  31620. return ok
  31621. }
  31622. // ResetOrganizationID resets all changes to the "organization_id" field.
  31623. func (m *UsageDetailMutation) ResetOrganizationID() {
  31624. m.organization_id = nil
  31625. m.addorganization_id = nil
  31626. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  31627. }
  31628. // Where appends a list predicates to the UsageDetailMutation builder.
  31629. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  31630. m.predicates = append(m.predicates, ps...)
  31631. }
  31632. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  31633. // users can use type-assertion to append predicates that do not depend on any generated package.
  31634. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  31635. p := make([]predicate.UsageDetail, len(ps))
  31636. for i := range ps {
  31637. p[i] = ps[i]
  31638. }
  31639. m.Where(p...)
  31640. }
  31641. // Op returns the operation name.
  31642. func (m *UsageDetailMutation) Op() Op {
  31643. return m.op
  31644. }
  31645. // SetOp allows setting the mutation operation.
  31646. func (m *UsageDetailMutation) SetOp(op Op) {
  31647. m.op = op
  31648. }
  31649. // Type returns the node type of this mutation (UsageDetail).
  31650. func (m *UsageDetailMutation) Type() string {
  31651. return m.typ
  31652. }
  31653. // Fields returns all fields that were changed during this mutation. Note that in
  31654. // order to get all numeric fields that were incremented/decremented, call
  31655. // AddedFields().
  31656. func (m *UsageDetailMutation) Fields() []string {
  31657. fields := make([]string, 0, 15)
  31658. if m.created_at != nil {
  31659. fields = append(fields, usagedetail.FieldCreatedAt)
  31660. }
  31661. if m.updated_at != nil {
  31662. fields = append(fields, usagedetail.FieldUpdatedAt)
  31663. }
  31664. if m.status != nil {
  31665. fields = append(fields, usagedetail.FieldStatus)
  31666. }
  31667. if m._type != nil {
  31668. fields = append(fields, usagedetail.FieldType)
  31669. }
  31670. if m.bot_id != nil {
  31671. fields = append(fields, usagedetail.FieldBotID)
  31672. }
  31673. if m.receiver_id != nil {
  31674. fields = append(fields, usagedetail.FieldReceiverID)
  31675. }
  31676. if m.app != nil {
  31677. fields = append(fields, usagedetail.FieldApp)
  31678. }
  31679. if m.session_id != nil {
  31680. fields = append(fields, usagedetail.FieldSessionID)
  31681. }
  31682. if m.request != nil {
  31683. fields = append(fields, usagedetail.FieldRequest)
  31684. }
  31685. if m.response != nil {
  31686. fields = append(fields, usagedetail.FieldResponse)
  31687. }
  31688. if m.original_data != nil {
  31689. fields = append(fields, usagedetail.FieldOriginalData)
  31690. }
  31691. if m.total_tokens != nil {
  31692. fields = append(fields, usagedetail.FieldTotalTokens)
  31693. }
  31694. if m.prompt_tokens != nil {
  31695. fields = append(fields, usagedetail.FieldPromptTokens)
  31696. }
  31697. if m.completion_tokens != nil {
  31698. fields = append(fields, usagedetail.FieldCompletionTokens)
  31699. }
  31700. if m.organization_id != nil {
  31701. fields = append(fields, usagedetail.FieldOrganizationID)
  31702. }
  31703. return fields
  31704. }
  31705. // Field returns the value of a field with the given name. The second boolean
  31706. // return value indicates that this field was not set, or was not defined in the
  31707. // schema.
  31708. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  31709. switch name {
  31710. case usagedetail.FieldCreatedAt:
  31711. return m.CreatedAt()
  31712. case usagedetail.FieldUpdatedAt:
  31713. return m.UpdatedAt()
  31714. case usagedetail.FieldStatus:
  31715. return m.Status()
  31716. case usagedetail.FieldType:
  31717. return m.GetType()
  31718. case usagedetail.FieldBotID:
  31719. return m.BotID()
  31720. case usagedetail.FieldReceiverID:
  31721. return m.ReceiverID()
  31722. case usagedetail.FieldApp:
  31723. return m.App()
  31724. case usagedetail.FieldSessionID:
  31725. return m.SessionID()
  31726. case usagedetail.FieldRequest:
  31727. return m.Request()
  31728. case usagedetail.FieldResponse:
  31729. return m.Response()
  31730. case usagedetail.FieldOriginalData:
  31731. return m.OriginalData()
  31732. case usagedetail.FieldTotalTokens:
  31733. return m.TotalTokens()
  31734. case usagedetail.FieldPromptTokens:
  31735. return m.PromptTokens()
  31736. case usagedetail.FieldCompletionTokens:
  31737. return m.CompletionTokens()
  31738. case usagedetail.FieldOrganizationID:
  31739. return m.OrganizationID()
  31740. }
  31741. return nil, false
  31742. }
  31743. // OldField returns the old value of the field from the database. An error is
  31744. // returned if the mutation operation is not UpdateOne, or the query to the
  31745. // database failed.
  31746. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31747. switch name {
  31748. case usagedetail.FieldCreatedAt:
  31749. return m.OldCreatedAt(ctx)
  31750. case usagedetail.FieldUpdatedAt:
  31751. return m.OldUpdatedAt(ctx)
  31752. case usagedetail.FieldStatus:
  31753. return m.OldStatus(ctx)
  31754. case usagedetail.FieldType:
  31755. return m.OldType(ctx)
  31756. case usagedetail.FieldBotID:
  31757. return m.OldBotID(ctx)
  31758. case usagedetail.FieldReceiverID:
  31759. return m.OldReceiverID(ctx)
  31760. case usagedetail.FieldApp:
  31761. return m.OldApp(ctx)
  31762. case usagedetail.FieldSessionID:
  31763. return m.OldSessionID(ctx)
  31764. case usagedetail.FieldRequest:
  31765. return m.OldRequest(ctx)
  31766. case usagedetail.FieldResponse:
  31767. return m.OldResponse(ctx)
  31768. case usagedetail.FieldOriginalData:
  31769. return m.OldOriginalData(ctx)
  31770. case usagedetail.FieldTotalTokens:
  31771. return m.OldTotalTokens(ctx)
  31772. case usagedetail.FieldPromptTokens:
  31773. return m.OldPromptTokens(ctx)
  31774. case usagedetail.FieldCompletionTokens:
  31775. return m.OldCompletionTokens(ctx)
  31776. case usagedetail.FieldOrganizationID:
  31777. return m.OldOrganizationID(ctx)
  31778. }
  31779. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  31780. }
  31781. // SetField sets the value of a field with the given name. It returns an error if
  31782. // the field is not defined in the schema, or if the type mismatched the field
  31783. // type.
  31784. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  31785. switch name {
  31786. case usagedetail.FieldCreatedAt:
  31787. v, ok := value.(time.Time)
  31788. if !ok {
  31789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31790. }
  31791. m.SetCreatedAt(v)
  31792. return nil
  31793. case usagedetail.FieldUpdatedAt:
  31794. v, ok := value.(time.Time)
  31795. if !ok {
  31796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31797. }
  31798. m.SetUpdatedAt(v)
  31799. return nil
  31800. case usagedetail.FieldStatus:
  31801. v, ok := value.(uint8)
  31802. if !ok {
  31803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31804. }
  31805. m.SetStatus(v)
  31806. return nil
  31807. case usagedetail.FieldType:
  31808. v, ok := value.(int)
  31809. if !ok {
  31810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31811. }
  31812. m.SetType(v)
  31813. return nil
  31814. case usagedetail.FieldBotID:
  31815. v, ok := value.(string)
  31816. if !ok {
  31817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31818. }
  31819. m.SetBotID(v)
  31820. return nil
  31821. case usagedetail.FieldReceiverID:
  31822. v, ok := value.(string)
  31823. if !ok {
  31824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31825. }
  31826. m.SetReceiverID(v)
  31827. return nil
  31828. case usagedetail.FieldApp:
  31829. v, ok := value.(int)
  31830. if !ok {
  31831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31832. }
  31833. m.SetApp(v)
  31834. return nil
  31835. case usagedetail.FieldSessionID:
  31836. v, ok := value.(uint64)
  31837. if !ok {
  31838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31839. }
  31840. m.SetSessionID(v)
  31841. return nil
  31842. case usagedetail.FieldRequest:
  31843. v, ok := value.(string)
  31844. if !ok {
  31845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31846. }
  31847. m.SetRequest(v)
  31848. return nil
  31849. case usagedetail.FieldResponse:
  31850. v, ok := value.(string)
  31851. if !ok {
  31852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31853. }
  31854. m.SetResponse(v)
  31855. return nil
  31856. case usagedetail.FieldOriginalData:
  31857. v, ok := value.(custom_types.OriginalData)
  31858. if !ok {
  31859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31860. }
  31861. m.SetOriginalData(v)
  31862. return nil
  31863. case usagedetail.FieldTotalTokens:
  31864. v, ok := value.(uint64)
  31865. if !ok {
  31866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31867. }
  31868. m.SetTotalTokens(v)
  31869. return nil
  31870. case usagedetail.FieldPromptTokens:
  31871. v, ok := value.(uint64)
  31872. if !ok {
  31873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31874. }
  31875. m.SetPromptTokens(v)
  31876. return nil
  31877. case usagedetail.FieldCompletionTokens:
  31878. v, ok := value.(uint64)
  31879. if !ok {
  31880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31881. }
  31882. m.SetCompletionTokens(v)
  31883. return nil
  31884. case usagedetail.FieldOrganizationID:
  31885. v, ok := value.(uint64)
  31886. if !ok {
  31887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31888. }
  31889. m.SetOrganizationID(v)
  31890. return nil
  31891. }
  31892. return fmt.Errorf("unknown UsageDetail field %s", name)
  31893. }
  31894. // AddedFields returns all numeric fields that were incremented/decremented during
  31895. // this mutation.
  31896. func (m *UsageDetailMutation) AddedFields() []string {
  31897. var fields []string
  31898. if m.addstatus != nil {
  31899. fields = append(fields, usagedetail.FieldStatus)
  31900. }
  31901. if m.add_type != nil {
  31902. fields = append(fields, usagedetail.FieldType)
  31903. }
  31904. if m.addapp != nil {
  31905. fields = append(fields, usagedetail.FieldApp)
  31906. }
  31907. if m.addsession_id != nil {
  31908. fields = append(fields, usagedetail.FieldSessionID)
  31909. }
  31910. if m.addtotal_tokens != nil {
  31911. fields = append(fields, usagedetail.FieldTotalTokens)
  31912. }
  31913. if m.addprompt_tokens != nil {
  31914. fields = append(fields, usagedetail.FieldPromptTokens)
  31915. }
  31916. if m.addcompletion_tokens != nil {
  31917. fields = append(fields, usagedetail.FieldCompletionTokens)
  31918. }
  31919. if m.addorganization_id != nil {
  31920. fields = append(fields, usagedetail.FieldOrganizationID)
  31921. }
  31922. return fields
  31923. }
  31924. // AddedField returns the numeric value that was incremented/decremented on a field
  31925. // with the given name. The second boolean return value indicates that this field
  31926. // was not set, or was not defined in the schema.
  31927. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  31928. switch name {
  31929. case usagedetail.FieldStatus:
  31930. return m.AddedStatus()
  31931. case usagedetail.FieldType:
  31932. return m.AddedType()
  31933. case usagedetail.FieldApp:
  31934. return m.AddedApp()
  31935. case usagedetail.FieldSessionID:
  31936. return m.AddedSessionID()
  31937. case usagedetail.FieldTotalTokens:
  31938. return m.AddedTotalTokens()
  31939. case usagedetail.FieldPromptTokens:
  31940. return m.AddedPromptTokens()
  31941. case usagedetail.FieldCompletionTokens:
  31942. return m.AddedCompletionTokens()
  31943. case usagedetail.FieldOrganizationID:
  31944. return m.AddedOrganizationID()
  31945. }
  31946. return nil, false
  31947. }
  31948. // AddField adds the value to the field with the given name. It returns an error if
  31949. // the field is not defined in the schema, or if the type mismatched the field
  31950. // type.
  31951. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  31952. switch name {
  31953. case usagedetail.FieldStatus:
  31954. v, ok := value.(int8)
  31955. if !ok {
  31956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31957. }
  31958. m.AddStatus(v)
  31959. return nil
  31960. case usagedetail.FieldType:
  31961. v, ok := value.(int)
  31962. if !ok {
  31963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31964. }
  31965. m.AddType(v)
  31966. return nil
  31967. case usagedetail.FieldApp:
  31968. v, ok := value.(int)
  31969. if !ok {
  31970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31971. }
  31972. m.AddApp(v)
  31973. return nil
  31974. case usagedetail.FieldSessionID:
  31975. v, ok := value.(int64)
  31976. if !ok {
  31977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31978. }
  31979. m.AddSessionID(v)
  31980. return nil
  31981. case usagedetail.FieldTotalTokens:
  31982. v, ok := value.(int64)
  31983. if !ok {
  31984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31985. }
  31986. m.AddTotalTokens(v)
  31987. return nil
  31988. case usagedetail.FieldPromptTokens:
  31989. v, ok := value.(int64)
  31990. if !ok {
  31991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31992. }
  31993. m.AddPromptTokens(v)
  31994. return nil
  31995. case usagedetail.FieldCompletionTokens:
  31996. v, ok := value.(int64)
  31997. if !ok {
  31998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31999. }
  32000. m.AddCompletionTokens(v)
  32001. return nil
  32002. case usagedetail.FieldOrganizationID:
  32003. v, ok := value.(int64)
  32004. if !ok {
  32005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32006. }
  32007. m.AddOrganizationID(v)
  32008. return nil
  32009. }
  32010. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  32011. }
  32012. // ClearedFields returns all nullable fields that were cleared during this
  32013. // mutation.
  32014. func (m *UsageDetailMutation) ClearedFields() []string {
  32015. var fields []string
  32016. if m.FieldCleared(usagedetail.FieldStatus) {
  32017. fields = append(fields, usagedetail.FieldStatus)
  32018. }
  32019. if m.FieldCleared(usagedetail.FieldType) {
  32020. fields = append(fields, usagedetail.FieldType)
  32021. }
  32022. if m.FieldCleared(usagedetail.FieldApp) {
  32023. fields = append(fields, usagedetail.FieldApp)
  32024. }
  32025. if m.FieldCleared(usagedetail.FieldSessionID) {
  32026. fields = append(fields, usagedetail.FieldSessionID)
  32027. }
  32028. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  32029. fields = append(fields, usagedetail.FieldTotalTokens)
  32030. }
  32031. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  32032. fields = append(fields, usagedetail.FieldPromptTokens)
  32033. }
  32034. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  32035. fields = append(fields, usagedetail.FieldCompletionTokens)
  32036. }
  32037. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  32038. fields = append(fields, usagedetail.FieldOrganizationID)
  32039. }
  32040. return fields
  32041. }
  32042. // FieldCleared returns a boolean indicating if a field with the given name was
  32043. // cleared in this mutation.
  32044. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  32045. _, ok := m.clearedFields[name]
  32046. return ok
  32047. }
  32048. // ClearField clears the value of the field with the given name. It returns an
  32049. // error if the field is not defined in the schema.
  32050. func (m *UsageDetailMutation) ClearField(name string) error {
  32051. switch name {
  32052. case usagedetail.FieldStatus:
  32053. m.ClearStatus()
  32054. return nil
  32055. case usagedetail.FieldType:
  32056. m.ClearType()
  32057. return nil
  32058. case usagedetail.FieldApp:
  32059. m.ClearApp()
  32060. return nil
  32061. case usagedetail.FieldSessionID:
  32062. m.ClearSessionID()
  32063. return nil
  32064. case usagedetail.FieldTotalTokens:
  32065. m.ClearTotalTokens()
  32066. return nil
  32067. case usagedetail.FieldPromptTokens:
  32068. m.ClearPromptTokens()
  32069. return nil
  32070. case usagedetail.FieldCompletionTokens:
  32071. m.ClearCompletionTokens()
  32072. return nil
  32073. case usagedetail.FieldOrganizationID:
  32074. m.ClearOrganizationID()
  32075. return nil
  32076. }
  32077. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  32078. }
  32079. // ResetField resets all changes in the mutation for the field with the given name.
  32080. // It returns an error if the field is not defined in the schema.
  32081. func (m *UsageDetailMutation) ResetField(name string) error {
  32082. switch name {
  32083. case usagedetail.FieldCreatedAt:
  32084. m.ResetCreatedAt()
  32085. return nil
  32086. case usagedetail.FieldUpdatedAt:
  32087. m.ResetUpdatedAt()
  32088. return nil
  32089. case usagedetail.FieldStatus:
  32090. m.ResetStatus()
  32091. return nil
  32092. case usagedetail.FieldType:
  32093. m.ResetType()
  32094. return nil
  32095. case usagedetail.FieldBotID:
  32096. m.ResetBotID()
  32097. return nil
  32098. case usagedetail.FieldReceiverID:
  32099. m.ResetReceiverID()
  32100. return nil
  32101. case usagedetail.FieldApp:
  32102. m.ResetApp()
  32103. return nil
  32104. case usagedetail.FieldSessionID:
  32105. m.ResetSessionID()
  32106. return nil
  32107. case usagedetail.FieldRequest:
  32108. m.ResetRequest()
  32109. return nil
  32110. case usagedetail.FieldResponse:
  32111. m.ResetResponse()
  32112. return nil
  32113. case usagedetail.FieldOriginalData:
  32114. m.ResetOriginalData()
  32115. return nil
  32116. case usagedetail.FieldTotalTokens:
  32117. m.ResetTotalTokens()
  32118. return nil
  32119. case usagedetail.FieldPromptTokens:
  32120. m.ResetPromptTokens()
  32121. return nil
  32122. case usagedetail.FieldCompletionTokens:
  32123. m.ResetCompletionTokens()
  32124. return nil
  32125. case usagedetail.FieldOrganizationID:
  32126. m.ResetOrganizationID()
  32127. return nil
  32128. }
  32129. return fmt.Errorf("unknown UsageDetail field %s", name)
  32130. }
  32131. // AddedEdges returns all edge names that were set/added in this mutation.
  32132. func (m *UsageDetailMutation) AddedEdges() []string {
  32133. edges := make([]string, 0, 0)
  32134. return edges
  32135. }
  32136. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32137. // name in this mutation.
  32138. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  32139. return nil
  32140. }
  32141. // RemovedEdges returns all edge names that were removed in this mutation.
  32142. func (m *UsageDetailMutation) RemovedEdges() []string {
  32143. edges := make([]string, 0, 0)
  32144. return edges
  32145. }
  32146. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32147. // the given name in this mutation.
  32148. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  32149. return nil
  32150. }
  32151. // ClearedEdges returns all edge names that were cleared in this mutation.
  32152. func (m *UsageDetailMutation) ClearedEdges() []string {
  32153. edges := make([]string, 0, 0)
  32154. return edges
  32155. }
  32156. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32157. // was cleared in this mutation.
  32158. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  32159. return false
  32160. }
  32161. // ClearEdge clears the value of the edge with the given name. It returns an error
  32162. // if that edge is not defined in the schema.
  32163. func (m *UsageDetailMutation) ClearEdge(name string) error {
  32164. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  32165. }
  32166. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32167. // It returns an error if the edge is not defined in the schema.
  32168. func (m *UsageDetailMutation) ResetEdge(name string) error {
  32169. return fmt.Errorf("unknown UsageDetail edge %s", name)
  32170. }
  32171. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  32172. type UsageStatisticDayMutation struct {
  32173. config
  32174. op Op
  32175. typ string
  32176. id *uint64
  32177. created_at *time.Time
  32178. updated_at *time.Time
  32179. status *uint8
  32180. addstatus *int8
  32181. deleted_at *time.Time
  32182. addtime *uint64
  32183. addaddtime *int64
  32184. _type *int
  32185. add_type *int
  32186. bot_id *string
  32187. organization_id *uint64
  32188. addorganization_id *int64
  32189. ai_response *uint64
  32190. addai_response *int64
  32191. sop_run *uint64
  32192. addsop_run *int64
  32193. total_friend *uint64
  32194. addtotal_friend *int64
  32195. total_group *uint64
  32196. addtotal_group *int64
  32197. account_balance *uint64
  32198. addaccount_balance *int64
  32199. consume_token *uint64
  32200. addconsume_token *int64
  32201. active_user *uint64
  32202. addactive_user *int64
  32203. new_user *int64
  32204. addnew_user *int64
  32205. label_dist *[]custom_types.LabelDist
  32206. appendlabel_dist []custom_types.LabelDist
  32207. clearedFields map[string]struct{}
  32208. done bool
  32209. oldValue func(context.Context) (*UsageStatisticDay, error)
  32210. predicates []predicate.UsageStatisticDay
  32211. }
  32212. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  32213. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  32214. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  32215. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  32216. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  32217. m := &UsageStatisticDayMutation{
  32218. config: c,
  32219. op: op,
  32220. typ: TypeUsageStatisticDay,
  32221. clearedFields: make(map[string]struct{}),
  32222. }
  32223. for _, opt := range opts {
  32224. opt(m)
  32225. }
  32226. return m
  32227. }
  32228. // withUsageStatisticDayID sets the ID field of the mutation.
  32229. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  32230. return func(m *UsageStatisticDayMutation) {
  32231. var (
  32232. err error
  32233. once sync.Once
  32234. value *UsageStatisticDay
  32235. )
  32236. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  32237. once.Do(func() {
  32238. if m.done {
  32239. err = errors.New("querying old values post mutation is not allowed")
  32240. } else {
  32241. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  32242. }
  32243. })
  32244. return value, err
  32245. }
  32246. m.id = &id
  32247. }
  32248. }
  32249. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  32250. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  32251. return func(m *UsageStatisticDayMutation) {
  32252. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  32253. return node, nil
  32254. }
  32255. m.id = &node.ID
  32256. }
  32257. }
  32258. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32259. // executed in a transaction (ent.Tx), a transactional client is returned.
  32260. func (m UsageStatisticDayMutation) Client() *Client {
  32261. client := &Client{config: m.config}
  32262. client.init()
  32263. return client
  32264. }
  32265. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32266. // it returns an error otherwise.
  32267. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  32268. if _, ok := m.driver.(*txDriver); !ok {
  32269. return nil, errors.New("ent: mutation is not running in a transaction")
  32270. }
  32271. tx := &Tx{config: m.config}
  32272. tx.init()
  32273. return tx, nil
  32274. }
  32275. // SetID sets the value of the id field. Note that this
  32276. // operation is only accepted on creation of UsageStatisticDay entities.
  32277. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  32278. m.id = &id
  32279. }
  32280. // ID returns the ID value in the mutation. Note that the ID is only available
  32281. // if it was provided to the builder or after it was returned from the database.
  32282. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  32283. if m.id == nil {
  32284. return
  32285. }
  32286. return *m.id, true
  32287. }
  32288. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32289. // That means, if the mutation is applied within a transaction with an isolation level such
  32290. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32291. // or updated by the mutation.
  32292. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  32293. switch {
  32294. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32295. id, exists := m.ID()
  32296. if exists {
  32297. return []uint64{id}, nil
  32298. }
  32299. fallthrough
  32300. case m.op.Is(OpUpdate | OpDelete):
  32301. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  32302. default:
  32303. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32304. }
  32305. }
  32306. // SetCreatedAt sets the "created_at" field.
  32307. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  32308. m.created_at = &t
  32309. }
  32310. // CreatedAt returns the value of the "created_at" field in the mutation.
  32311. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  32312. v := m.created_at
  32313. if v == nil {
  32314. return
  32315. }
  32316. return *v, true
  32317. }
  32318. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  32319. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32321. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32322. if !m.op.Is(OpUpdateOne) {
  32323. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32324. }
  32325. if m.id == nil || m.oldValue == nil {
  32326. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32327. }
  32328. oldValue, err := m.oldValue(ctx)
  32329. if err != nil {
  32330. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32331. }
  32332. return oldValue.CreatedAt, nil
  32333. }
  32334. // ResetCreatedAt resets all changes to the "created_at" field.
  32335. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  32336. m.created_at = nil
  32337. }
  32338. // SetUpdatedAt sets the "updated_at" field.
  32339. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  32340. m.updated_at = &t
  32341. }
  32342. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32343. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  32344. v := m.updated_at
  32345. if v == nil {
  32346. return
  32347. }
  32348. return *v, true
  32349. }
  32350. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32354. if !m.op.Is(OpUpdateOne) {
  32355. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32356. }
  32357. if m.id == nil || m.oldValue == nil {
  32358. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  32363. }
  32364. return oldValue.UpdatedAt, nil
  32365. }
  32366. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32367. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  32368. m.updated_at = nil
  32369. }
  32370. // SetStatus sets the "status" field.
  32371. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  32372. m.status = &u
  32373. m.addstatus = nil
  32374. }
  32375. // Status returns the value of the "status" field in the mutation.
  32376. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  32377. v := m.status
  32378. if v == nil {
  32379. return
  32380. }
  32381. return *v, true
  32382. }
  32383. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  32384. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32386. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32387. if !m.op.Is(OpUpdateOne) {
  32388. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32389. }
  32390. if m.id == nil || m.oldValue == nil {
  32391. return v, errors.New("OldStatus requires an ID field in the mutation")
  32392. }
  32393. oldValue, err := m.oldValue(ctx)
  32394. if err != nil {
  32395. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32396. }
  32397. return oldValue.Status, nil
  32398. }
  32399. // AddStatus adds u to the "status" field.
  32400. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  32401. if m.addstatus != nil {
  32402. *m.addstatus += u
  32403. } else {
  32404. m.addstatus = &u
  32405. }
  32406. }
  32407. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32408. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  32409. v := m.addstatus
  32410. if v == nil {
  32411. return
  32412. }
  32413. return *v, true
  32414. }
  32415. // ClearStatus clears the value of the "status" field.
  32416. func (m *UsageStatisticDayMutation) ClearStatus() {
  32417. m.status = nil
  32418. m.addstatus = nil
  32419. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  32420. }
  32421. // StatusCleared returns if the "status" field was cleared in this mutation.
  32422. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  32423. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  32424. return ok
  32425. }
  32426. // ResetStatus resets all changes to the "status" field.
  32427. func (m *UsageStatisticDayMutation) ResetStatus() {
  32428. m.status = nil
  32429. m.addstatus = nil
  32430. delete(m.clearedFields, usagestatisticday.FieldStatus)
  32431. }
  32432. // SetDeletedAt sets the "deleted_at" field.
  32433. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  32434. m.deleted_at = &t
  32435. }
  32436. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32437. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  32438. v := m.deleted_at
  32439. if v == nil {
  32440. return
  32441. }
  32442. return *v, true
  32443. }
  32444. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  32445. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32447. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32448. if !m.op.Is(OpUpdateOne) {
  32449. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32450. }
  32451. if m.id == nil || m.oldValue == nil {
  32452. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32453. }
  32454. oldValue, err := m.oldValue(ctx)
  32455. if err != nil {
  32456. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32457. }
  32458. return oldValue.DeletedAt, nil
  32459. }
  32460. // ClearDeletedAt clears the value of the "deleted_at" field.
  32461. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  32462. m.deleted_at = nil
  32463. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  32464. }
  32465. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32466. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  32467. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  32468. return ok
  32469. }
  32470. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32471. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  32472. m.deleted_at = nil
  32473. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  32474. }
  32475. // SetAddtime sets the "addtime" field.
  32476. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  32477. m.addtime = &u
  32478. m.addaddtime = nil
  32479. }
  32480. // Addtime returns the value of the "addtime" field in the mutation.
  32481. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  32482. v := m.addtime
  32483. if v == nil {
  32484. return
  32485. }
  32486. return *v, true
  32487. }
  32488. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  32489. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32491. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32492. if !m.op.Is(OpUpdateOne) {
  32493. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32494. }
  32495. if m.id == nil || m.oldValue == nil {
  32496. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32497. }
  32498. oldValue, err := m.oldValue(ctx)
  32499. if err != nil {
  32500. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32501. }
  32502. return oldValue.Addtime, nil
  32503. }
  32504. // AddAddtime adds u to the "addtime" field.
  32505. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  32506. if m.addaddtime != nil {
  32507. *m.addaddtime += u
  32508. } else {
  32509. m.addaddtime = &u
  32510. }
  32511. }
  32512. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32513. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  32514. v := m.addaddtime
  32515. if v == nil {
  32516. return
  32517. }
  32518. return *v, true
  32519. }
  32520. // ResetAddtime resets all changes to the "addtime" field.
  32521. func (m *UsageStatisticDayMutation) ResetAddtime() {
  32522. m.addtime = nil
  32523. m.addaddtime = nil
  32524. }
  32525. // SetType sets the "type" field.
  32526. func (m *UsageStatisticDayMutation) SetType(i int) {
  32527. m._type = &i
  32528. m.add_type = nil
  32529. }
  32530. // GetType returns the value of the "type" field in the mutation.
  32531. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  32532. v := m._type
  32533. if v == nil {
  32534. return
  32535. }
  32536. return *v, true
  32537. }
  32538. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  32539. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32541. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  32542. if !m.op.Is(OpUpdateOne) {
  32543. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32544. }
  32545. if m.id == nil || m.oldValue == nil {
  32546. return v, errors.New("OldType requires an ID field in the mutation")
  32547. }
  32548. oldValue, err := m.oldValue(ctx)
  32549. if err != nil {
  32550. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32551. }
  32552. return oldValue.Type, nil
  32553. }
  32554. // AddType adds i to the "type" field.
  32555. func (m *UsageStatisticDayMutation) AddType(i int) {
  32556. if m.add_type != nil {
  32557. *m.add_type += i
  32558. } else {
  32559. m.add_type = &i
  32560. }
  32561. }
  32562. // AddedType returns the value that was added to the "type" field in this mutation.
  32563. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  32564. v := m.add_type
  32565. if v == nil {
  32566. return
  32567. }
  32568. return *v, true
  32569. }
  32570. // ResetType resets all changes to the "type" field.
  32571. func (m *UsageStatisticDayMutation) ResetType() {
  32572. m._type = nil
  32573. m.add_type = nil
  32574. }
  32575. // SetBotID sets the "bot_id" field.
  32576. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  32577. m.bot_id = &s
  32578. }
  32579. // BotID returns the value of the "bot_id" field in the mutation.
  32580. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  32581. v := m.bot_id
  32582. if v == nil {
  32583. return
  32584. }
  32585. return *v, true
  32586. }
  32587. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  32588. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32590. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  32591. if !m.op.Is(OpUpdateOne) {
  32592. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32593. }
  32594. if m.id == nil || m.oldValue == nil {
  32595. return v, errors.New("OldBotID requires an ID field in the mutation")
  32596. }
  32597. oldValue, err := m.oldValue(ctx)
  32598. if err != nil {
  32599. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32600. }
  32601. return oldValue.BotID, nil
  32602. }
  32603. // ClearBotID clears the value of the "bot_id" field.
  32604. func (m *UsageStatisticDayMutation) ClearBotID() {
  32605. m.bot_id = nil
  32606. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  32607. }
  32608. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32609. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  32610. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  32611. return ok
  32612. }
  32613. // ResetBotID resets all changes to the "bot_id" field.
  32614. func (m *UsageStatisticDayMutation) ResetBotID() {
  32615. m.bot_id = nil
  32616. delete(m.clearedFields, usagestatisticday.FieldBotID)
  32617. }
  32618. // SetOrganizationID sets the "organization_id" field.
  32619. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  32620. m.organization_id = &u
  32621. m.addorganization_id = nil
  32622. }
  32623. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32624. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  32625. v := m.organization_id
  32626. if v == nil {
  32627. return
  32628. }
  32629. return *v, true
  32630. }
  32631. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  32632. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32634. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32635. if !m.op.Is(OpUpdateOne) {
  32636. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32637. }
  32638. if m.id == nil || m.oldValue == nil {
  32639. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32640. }
  32641. oldValue, err := m.oldValue(ctx)
  32642. if err != nil {
  32643. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32644. }
  32645. return oldValue.OrganizationID, nil
  32646. }
  32647. // AddOrganizationID adds u to the "organization_id" field.
  32648. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  32649. if m.addorganization_id != nil {
  32650. *m.addorganization_id += u
  32651. } else {
  32652. m.addorganization_id = &u
  32653. }
  32654. }
  32655. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32656. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  32657. v := m.addorganization_id
  32658. if v == nil {
  32659. return
  32660. }
  32661. return *v, true
  32662. }
  32663. // ClearOrganizationID clears the value of the "organization_id" field.
  32664. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  32665. m.organization_id = nil
  32666. m.addorganization_id = nil
  32667. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  32668. }
  32669. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32670. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  32671. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  32672. return ok
  32673. }
  32674. // ResetOrganizationID resets all changes to the "organization_id" field.
  32675. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  32676. m.organization_id = nil
  32677. m.addorganization_id = nil
  32678. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  32679. }
  32680. // SetAiResponse sets the "ai_response" field.
  32681. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  32682. m.ai_response = &u
  32683. m.addai_response = nil
  32684. }
  32685. // AiResponse returns the value of the "ai_response" field in the mutation.
  32686. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  32687. v := m.ai_response
  32688. if v == nil {
  32689. return
  32690. }
  32691. return *v, true
  32692. }
  32693. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  32694. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32696. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32697. if !m.op.Is(OpUpdateOne) {
  32698. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32699. }
  32700. if m.id == nil || m.oldValue == nil {
  32701. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32702. }
  32703. oldValue, err := m.oldValue(ctx)
  32704. if err != nil {
  32705. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32706. }
  32707. return oldValue.AiResponse, nil
  32708. }
  32709. // AddAiResponse adds u to the "ai_response" field.
  32710. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  32711. if m.addai_response != nil {
  32712. *m.addai_response += u
  32713. } else {
  32714. m.addai_response = &u
  32715. }
  32716. }
  32717. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32718. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  32719. v := m.addai_response
  32720. if v == nil {
  32721. return
  32722. }
  32723. return *v, true
  32724. }
  32725. // ResetAiResponse resets all changes to the "ai_response" field.
  32726. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  32727. m.ai_response = nil
  32728. m.addai_response = nil
  32729. }
  32730. // SetSopRun sets the "sop_run" field.
  32731. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  32732. m.sop_run = &u
  32733. m.addsop_run = nil
  32734. }
  32735. // SopRun returns the value of the "sop_run" field in the mutation.
  32736. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  32737. v := m.sop_run
  32738. if v == nil {
  32739. return
  32740. }
  32741. return *v, true
  32742. }
  32743. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  32744. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32746. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32747. if !m.op.Is(OpUpdateOne) {
  32748. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32749. }
  32750. if m.id == nil || m.oldValue == nil {
  32751. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32752. }
  32753. oldValue, err := m.oldValue(ctx)
  32754. if err != nil {
  32755. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32756. }
  32757. return oldValue.SopRun, nil
  32758. }
  32759. // AddSopRun adds u to the "sop_run" field.
  32760. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  32761. if m.addsop_run != nil {
  32762. *m.addsop_run += u
  32763. } else {
  32764. m.addsop_run = &u
  32765. }
  32766. }
  32767. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32768. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  32769. v := m.addsop_run
  32770. if v == nil {
  32771. return
  32772. }
  32773. return *v, true
  32774. }
  32775. // ResetSopRun resets all changes to the "sop_run" field.
  32776. func (m *UsageStatisticDayMutation) ResetSopRun() {
  32777. m.sop_run = nil
  32778. m.addsop_run = nil
  32779. }
  32780. // SetTotalFriend sets the "total_friend" field.
  32781. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  32782. m.total_friend = &u
  32783. m.addtotal_friend = nil
  32784. }
  32785. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32786. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  32787. v := m.total_friend
  32788. if v == nil {
  32789. return
  32790. }
  32791. return *v, true
  32792. }
  32793. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  32794. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32796. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32797. if !m.op.Is(OpUpdateOne) {
  32798. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32799. }
  32800. if m.id == nil || m.oldValue == nil {
  32801. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32802. }
  32803. oldValue, err := m.oldValue(ctx)
  32804. if err != nil {
  32805. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32806. }
  32807. return oldValue.TotalFriend, nil
  32808. }
  32809. // AddTotalFriend adds u to the "total_friend" field.
  32810. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  32811. if m.addtotal_friend != nil {
  32812. *m.addtotal_friend += u
  32813. } else {
  32814. m.addtotal_friend = &u
  32815. }
  32816. }
  32817. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32818. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  32819. v := m.addtotal_friend
  32820. if v == nil {
  32821. return
  32822. }
  32823. return *v, true
  32824. }
  32825. // ResetTotalFriend resets all changes to the "total_friend" field.
  32826. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  32827. m.total_friend = nil
  32828. m.addtotal_friend = nil
  32829. }
  32830. // SetTotalGroup sets the "total_group" field.
  32831. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  32832. m.total_group = &u
  32833. m.addtotal_group = nil
  32834. }
  32835. // TotalGroup returns the value of the "total_group" field in the mutation.
  32836. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  32837. v := m.total_group
  32838. if v == nil {
  32839. return
  32840. }
  32841. return *v, true
  32842. }
  32843. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  32844. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32846. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32847. if !m.op.Is(OpUpdateOne) {
  32848. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32849. }
  32850. if m.id == nil || m.oldValue == nil {
  32851. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32852. }
  32853. oldValue, err := m.oldValue(ctx)
  32854. if err != nil {
  32855. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32856. }
  32857. return oldValue.TotalGroup, nil
  32858. }
  32859. // AddTotalGroup adds u to the "total_group" field.
  32860. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  32861. if m.addtotal_group != nil {
  32862. *m.addtotal_group += u
  32863. } else {
  32864. m.addtotal_group = &u
  32865. }
  32866. }
  32867. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32868. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  32869. v := m.addtotal_group
  32870. if v == nil {
  32871. return
  32872. }
  32873. return *v, true
  32874. }
  32875. // ResetTotalGroup resets all changes to the "total_group" field.
  32876. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  32877. m.total_group = nil
  32878. m.addtotal_group = nil
  32879. }
  32880. // SetAccountBalance sets the "account_balance" field.
  32881. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  32882. m.account_balance = &u
  32883. m.addaccount_balance = nil
  32884. }
  32885. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32886. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  32887. v := m.account_balance
  32888. if v == nil {
  32889. return
  32890. }
  32891. return *v, true
  32892. }
  32893. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  32894. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32896. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32897. if !m.op.Is(OpUpdateOne) {
  32898. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32899. }
  32900. if m.id == nil || m.oldValue == nil {
  32901. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32902. }
  32903. oldValue, err := m.oldValue(ctx)
  32904. if err != nil {
  32905. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32906. }
  32907. return oldValue.AccountBalance, nil
  32908. }
  32909. // AddAccountBalance adds u to the "account_balance" field.
  32910. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  32911. if m.addaccount_balance != nil {
  32912. *m.addaccount_balance += u
  32913. } else {
  32914. m.addaccount_balance = &u
  32915. }
  32916. }
  32917. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32918. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  32919. v := m.addaccount_balance
  32920. if v == nil {
  32921. return
  32922. }
  32923. return *v, true
  32924. }
  32925. // ResetAccountBalance resets all changes to the "account_balance" field.
  32926. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  32927. m.account_balance = nil
  32928. m.addaccount_balance = nil
  32929. }
  32930. // SetConsumeToken sets the "consume_token" field.
  32931. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  32932. m.consume_token = &u
  32933. m.addconsume_token = nil
  32934. }
  32935. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32936. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  32937. v := m.consume_token
  32938. if v == nil {
  32939. return
  32940. }
  32941. return *v, true
  32942. }
  32943. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  32944. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32946. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32947. if !m.op.Is(OpUpdateOne) {
  32948. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32949. }
  32950. if m.id == nil || m.oldValue == nil {
  32951. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32952. }
  32953. oldValue, err := m.oldValue(ctx)
  32954. if err != nil {
  32955. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32956. }
  32957. return oldValue.ConsumeToken, nil
  32958. }
  32959. // AddConsumeToken adds u to the "consume_token" field.
  32960. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  32961. if m.addconsume_token != nil {
  32962. *m.addconsume_token += u
  32963. } else {
  32964. m.addconsume_token = &u
  32965. }
  32966. }
  32967. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32968. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  32969. v := m.addconsume_token
  32970. if v == nil {
  32971. return
  32972. }
  32973. return *v, true
  32974. }
  32975. // ResetConsumeToken resets all changes to the "consume_token" field.
  32976. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  32977. m.consume_token = nil
  32978. m.addconsume_token = nil
  32979. }
  32980. // SetActiveUser sets the "active_user" field.
  32981. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  32982. m.active_user = &u
  32983. m.addactive_user = nil
  32984. }
  32985. // ActiveUser returns the value of the "active_user" field in the mutation.
  32986. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  32987. v := m.active_user
  32988. if v == nil {
  32989. return
  32990. }
  32991. return *v, true
  32992. }
  32993. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  32994. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32996. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32997. if !m.op.Is(OpUpdateOne) {
  32998. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32999. }
  33000. if m.id == nil || m.oldValue == nil {
  33001. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33002. }
  33003. oldValue, err := m.oldValue(ctx)
  33004. if err != nil {
  33005. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33006. }
  33007. return oldValue.ActiveUser, nil
  33008. }
  33009. // AddActiveUser adds u to the "active_user" field.
  33010. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  33011. if m.addactive_user != nil {
  33012. *m.addactive_user += u
  33013. } else {
  33014. m.addactive_user = &u
  33015. }
  33016. }
  33017. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33018. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  33019. v := m.addactive_user
  33020. if v == nil {
  33021. return
  33022. }
  33023. return *v, true
  33024. }
  33025. // ResetActiveUser resets all changes to the "active_user" field.
  33026. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  33027. m.active_user = nil
  33028. m.addactive_user = nil
  33029. }
  33030. // SetNewUser sets the "new_user" field.
  33031. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  33032. m.new_user = &i
  33033. m.addnew_user = nil
  33034. }
  33035. // NewUser returns the value of the "new_user" field in the mutation.
  33036. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  33037. v := m.new_user
  33038. if v == nil {
  33039. return
  33040. }
  33041. return *v, true
  33042. }
  33043. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  33044. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33046. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33047. if !m.op.Is(OpUpdateOne) {
  33048. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33049. }
  33050. if m.id == nil || m.oldValue == nil {
  33051. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33052. }
  33053. oldValue, err := m.oldValue(ctx)
  33054. if err != nil {
  33055. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33056. }
  33057. return oldValue.NewUser, nil
  33058. }
  33059. // AddNewUser adds i to the "new_user" field.
  33060. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  33061. if m.addnew_user != nil {
  33062. *m.addnew_user += i
  33063. } else {
  33064. m.addnew_user = &i
  33065. }
  33066. }
  33067. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33068. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  33069. v := m.addnew_user
  33070. if v == nil {
  33071. return
  33072. }
  33073. return *v, true
  33074. }
  33075. // ResetNewUser resets all changes to the "new_user" field.
  33076. func (m *UsageStatisticDayMutation) ResetNewUser() {
  33077. m.new_user = nil
  33078. m.addnew_user = nil
  33079. }
  33080. // SetLabelDist sets the "label_dist" field.
  33081. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33082. m.label_dist = &ctd
  33083. m.appendlabel_dist = nil
  33084. }
  33085. // LabelDist returns the value of the "label_dist" field in the mutation.
  33086. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33087. v := m.label_dist
  33088. if v == nil {
  33089. return
  33090. }
  33091. return *v, true
  33092. }
  33093. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  33094. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33096. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33097. if !m.op.Is(OpUpdateOne) {
  33098. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33099. }
  33100. if m.id == nil || m.oldValue == nil {
  33101. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33102. }
  33103. oldValue, err := m.oldValue(ctx)
  33104. if err != nil {
  33105. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33106. }
  33107. return oldValue.LabelDist, nil
  33108. }
  33109. // AppendLabelDist adds ctd to the "label_dist" field.
  33110. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33111. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33112. }
  33113. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33114. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33115. if len(m.appendlabel_dist) == 0 {
  33116. return nil, false
  33117. }
  33118. return m.appendlabel_dist, true
  33119. }
  33120. // ResetLabelDist resets all changes to the "label_dist" field.
  33121. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  33122. m.label_dist = nil
  33123. m.appendlabel_dist = nil
  33124. }
  33125. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  33126. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  33127. m.predicates = append(m.predicates, ps...)
  33128. }
  33129. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  33130. // users can use type-assertion to append predicates that do not depend on any generated package.
  33131. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  33132. p := make([]predicate.UsageStatisticDay, len(ps))
  33133. for i := range ps {
  33134. p[i] = ps[i]
  33135. }
  33136. m.Where(p...)
  33137. }
  33138. // Op returns the operation name.
  33139. func (m *UsageStatisticDayMutation) Op() Op {
  33140. return m.op
  33141. }
  33142. // SetOp allows setting the mutation operation.
  33143. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  33144. m.op = op
  33145. }
  33146. // Type returns the node type of this mutation (UsageStatisticDay).
  33147. func (m *UsageStatisticDayMutation) Type() string {
  33148. return m.typ
  33149. }
  33150. // Fields returns all fields that were changed during this mutation. Note that in
  33151. // order to get all numeric fields that were incremented/decremented, call
  33152. // AddedFields().
  33153. func (m *UsageStatisticDayMutation) Fields() []string {
  33154. fields := make([]string, 0, 17)
  33155. if m.created_at != nil {
  33156. fields = append(fields, usagestatisticday.FieldCreatedAt)
  33157. }
  33158. if m.updated_at != nil {
  33159. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  33160. }
  33161. if m.status != nil {
  33162. fields = append(fields, usagestatisticday.FieldStatus)
  33163. }
  33164. if m.deleted_at != nil {
  33165. fields = append(fields, usagestatisticday.FieldDeletedAt)
  33166. }
  33167. if m.addtime != nil {
  33168. fields = append(fields, usagestatisticday.FieldAddtime)
  33169. }
  33170. if m._type != nil {
  33171. fields = append(fields, usagestatisticday.FieldType)
  33172. }
  33173. if m.bot_id != nil {
  33174. fields = append(fields, usagestatisticday.FieldBotID)
  33175. }
  33176. if m.organization_id != nil {
  33177. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33178. }
  33179. if m.ai_response != nil {
  33180. fields = append(fields, usagestatisticday.FieldAiResponse)
  33181. }
  33182. if m.sop_run != nil {
  33183. fields = append(fields, usagestatisticday.FieldSopRun)
  33184. }
  33185. if m.total_friend != nil {
  33186. fields = append(fields, usagestatisticday.FieldTotalFriend)
  33187. }
  33188. if m.total_group != nil {
  33189. fields = append(fields, usagestatisticday.FieldTotalGroup)
  33190. }
  33191. if m.account_balance != nil {
  33192. fields = append(fields, usagestatisticday.FieldAccountBalance)
  33193. }
  33194. if m.consume_token != nil {
  33195. fields = append(fields, usagestatisticday.FieldConsumeToken)
  33196. }
  33197. if m.active_user != nil {
  33198. fields = append(fields, usagestatisticday.FieldActiveUser)
  33199. }
  33200. if m.new_user != nil {
  33201. fields = append(fields, usagestatisticday.FieldNewUser)
  33202. }
  33203. if m.label_dist != nil {
  33204. fields = append(fields, usagestatisticday.FieldLabelDist)
  33205. }
  33206. return fields
  33207. }
  33208. // Field returns the value of a field with the given name. The second boolean
  33209. // return value indicates that this field was not set, or was not defined in the
  33210. // schema.
  33211. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  33212. switch name {
  33213. case usagestatisticday.FieldCreatedAt:
  33214. return m.CreatedAt()
  33215. case usagestatisticday.FieldUpdatedAt:
  33216. return m.UpdatedAt()
  33217. case usagestatisticday.FieldStatus:
  33218. return m.Status()
  33219. case usagestatisticday.FieldDeletedAt:
  33220. return m.DeletedAt()
  33221. case usagestatisticday.FieldAddtime:
  33222. return m.Addtime()
  33223. case usagestatisticday.FieldType:
  33224. return m.GetType()
  33225. case usagestatisticday.FieldBotID:
  33226. return m.BotID()
  33227. case usagestatisticday.FieldOrganizationID:
  33228. return m.OrganizationID()
  33229. case usagestatisticday.FieldAiResponse:
  33230. return m.AiResponse()
  33231. case usagestatisticday.FieldSopRun:
  33232. return m.SopRun()
  33233. case usagestatisticday.FieldTotalFriend:
  33234. return m.TotalFriend()
  33235. case usagestatisticday.FieldTotalGroup:
  33236. return m.TotalGroup()
  33237. case usagestatisticday.FieldAccountBalance:
  33238. return m.AccountBalance()
  33239. case usagestatisticday.FieldConsumeToken:
  33240. return m.ConsumeToken()
  33241. case usagestatisticday.FieldActiveUser:
  33242. return m.ActiveUser()
  33243. case usagestatisticday.FieldNewUser:
  33244. return m.NewUser()
  33245. case usagestatisticday.FieldLabelDist:
  33246. return m.LabelDist()
  33247. }
  33248. return nil, false
  33249. }
  33250. // OldField returns the old value of the field from the database. An error is
  33251. // returned if the mutation operation is not UpdateOne, or the query to the
  33252. // database failed.
  33253. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33254. switch name {
  33255. case usagestatisticday.FieldCreatedAt:
  33256. return m.OldCreatedAt(ctx)
  33257. case usagestatisticday.FieldUpdatedAt:
  33258. return m.OldUpdatedAt(ctx)
  33259. case usagestatisticday.FieldStatus:
  33260. return m.OldStatus(ctx)
  33261. case usagestatisticday.FieldDeletedAt:
  33262. return m.OldDeletedAt(ctx)
  33263. case usagestatisticday.FieldAddtime:
  33264. return m.OldAddtime(ctx)
  33265. case usagestatisticday.FieldType:
  33266. return m.OldType(ctx)
  33267. case usagestatisticday.FieldBotID:
  33268. return m.OldBotID(ctx)
  33269. case usagestatisticday.FieldOrganizationID:
  33270. return m.OldOrganizationID(ctx)
  33271. case usagestatisticday.FieldAiResponse:
  33272. return m.OldAiResponse(ctx)
  33273. case usagestatisticday.FieldSopRun:
  33274. return m.OldSopRun(ctx)
  33275. case usagestatisticday.FieldTotalFriend:
  33276. return m.OldTotalFriend(ctx)
  33277. case usagestatisticday.FieldTotalGroup:
  33278. return m.OldTotalGroup(ctx)
  33279. case usagestatisticday.FieldAccountBalance:
  33280. return m.OldAccountBalance(ctx)
  33281. case usagestatisticday.FieldConsumeToken:
  33282. return m.OldConsumeToken(ctx)
  33283. case usagestatisticday.FieldActiveUser:
  33284. return m.OldActiveUser(ctx)
  33285. case usagestatisticday.FieldNewUser:
  33286. return m.OldNewUser(ctx)
  33287. case usagestatisticday.FieldLabelDist:
  33288. return m.OldLabelDist(ctx)
  33289. }
  33290. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33291. }
  33292. // SetField sets the value of a field with the given name. It returns an error if
  33293. // the field is not defined in the schema, or if the type mismatched the field
  33294. // type.
  33295. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  33296. switch name {
  33297. case usagestatisticday.FieldCreatedAt:
  33298. v, ok := value.(time.Time)
  33299. if !ok {
  33300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33301. }
  33302. m.SetCreatedAt(v)
  33303. return nil
  33304. case usagestatisticday.FieldUpdatedAt:
  33305. v, ok := value.(time.Time)
  33306. if !ok {
  33307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33308. }
  33309. m.SetUpdatedAt(v)
  33310. return nil
  33311. case usagestatisticday.FieldStatus:
  33312. v, ok := value.(uint8)
  33313. if !ok {
  33314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33315. }
  33316. m.SetStatus(v)
  33317. return nil
  33318. case usagestatisticday.FieldDeletedAt:
  33319. v, ok := value.(time.Time)
  33320. if !ok {
  33321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33322. }
  33323. m.SetDeletedAt(v)
  33324. return nil
  33325. case usagestatisticday.FieldAddtime:
  33326. v, ok := value.(uint64)
  33327. if !ok {
  33328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33329. }
  33330. m.SetAddtime(v)
  33331. return nil
  33332. case usagestatisticday.FieldType:
  33333. v, ok := value.(int)
  33334. if !ok {
  33335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33336. }
  33337. m.SetType(v)
  33338. return nil
  33339. case usagestatisticday.FieldBotID:
  33340. v, ok := value.(string)
  33341. if !ok {
  33342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33343. }
  33344. m.SetBotID(v)
  33345. return nil
  33346. case usagestatisticday.FieldOrganizationID:
  33347. v, ok := value.(uint64)
  33348. if !ok {
  33349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33350. }
  33351. m.SetOrganizationID(v)
  33352. return nil
  33353. case usagestatisticday.FieldAiResponse:
  33354. v, ok := value.(uint64)
  33355. if !ok {
  33356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33357. }
  33358. m.SetAiResponse(v)
  33359. return nil
  33360. case usagestatisticday.FieldSopRun:
  33361. v, ok := value.(uint64)
  33362. if !ok {
  33363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33364. }
  33365. m.SetSopRun(v)
  33366. return nil
  33367. case usagestatisticday.FieldTotalFriend:
  33368. v, ok := value.(uint64)
  33369. if !ok {
  33370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33371. }
  33372. m.SetTotalFriend(v)
  33373. return nil
  33374. case usagestatisticday.FieldTotalGroup:
  33375. v, ok := value.(uint64)
  33376. if !ok {
  33377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33378. }
  33379. m.SetTotalGroup(v)
  33380. return nil
  33381. case usagestatisticday.FieldAccountBalance:
  33382. v, ok := value.(uint64)
  33383. if !ok {
  33384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33385. }
  33386. m.SetAccountBalance(v)
  33387. return nil
  33388. case usagestatisticday.FieldConsumeToken:
  33389. v, ok := value.(uint64)
  33390. if !ok {
  33391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33392. }
  33393. m.SetConsumeToken(v)
  33394. return nil
  33395. case usagestatisticday.FieldActiveUser:
  33396. v, ok := value.(uint64)
  33397. if !ok {
  33398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33399. }
  33400. m.SetActiveUser(v)
  33401. return nil
  33402. case usagestatisticday.FieldNewUser:
  33403. v, ok := value.(int64)
  33404. if !ok {
  33405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33406. }
  33407. m.SetNewUser(v)
  33408. return nil
  33409. case usagestatisticday.FieldLabelDist:
  33410. v, ok := value.([]custom_types.LabelDist)
  33411. if !ok {
  33412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33413. }
  33414. m.SetLabelDist(v)
  33415. return nil
  33416. }
  33417. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33418. }
  33419. // AddedFields returns all numeric fields that were incremented/decremented during
  33420. // this mutation.
  33421. func (m *UsageStatisticDayMutation) AddedFields() []string {
  33422. var fields []string
  33423. if m.addstatus != nil {
  33424. fields = append(fields, usagestatisticday.FieldStatus)
  33425. }
  33426. if m.addaddtime != nil {
  33427. fields = append(fields, usagestatisticday.FieldAddtime)
  33428. }
  33429. if m.add_type != nil {
  33430. fields = append(fields, usagestatisticday.FieldType)
  33431. }
  33432. if m.addorganization_id != nil {
  33433. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33434. }
  33435. if m.addai_response != nil {
  33436. fields = append(fields, usagestatisticday.FieldAiResponse)
  33437. }
  33438. if m.addsop_run != nil {
  33439. fields = append(fields, usagestatisticday.FieldSopRun)
  33440. }
  33441. if m.addtotal_friend != nil {
  33442. fields = append(fields, usagestatisticday.FieldTotalFriend)
  33443. }
  33444. if m.addtotal_group != nil {
  33445. fields = append(fields, usagestatisticday.FieldTotalGroup)
  33446. }
  33447. if m.addaccount_balance != nil {
  33448. fields = append(fields, usagestatisticday.FieldAccountBalance)
  33449. }
  33450. if m.addconsume_token != nil {
  33451. fields = append(fields, usagestatisticday.FieldConsumeToken)
  33452. }
  33453. if m.addactive_user != nil {
  33454. fields = append(fields, usagestatisticday.FieldActiveUser)
  33455. }
  33456. if m.addnew_user != nil {
  33457. fields = append(fields, usagestatisticday.FieldNewUser)
  33458. }
  33459. return fields
  33460. }
  33461. // AddedField returns the numeric value that was incremented/decremented on a field
  33462. // with the given name. The second boolean return value indicates that this field
  33463. // was not set, or was not defined in the schema.
  33464. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  33465. switch name {
  33466. case usagestatisticday.FieldStatus:
  33467. return m.AddedStatus()
  33468. case usagestatisticday.FieldAddtime:
  33469. return m.AddedAddtime()
  33470. case usagestatisticday.FieldType:
  33471. return m.AddedType()
  33472. case usagestatisticday.FieldOrganizationID:
  33473. return m.AddedOrganizationID()
  33474. case usagestatisticday.FieldAiResponse:
  33475. return m.AddedAiResponse()
  33476. case usagestatisticday.FieldSopRun:
  33477. return m.AddedSopRun()
  33478. case usagestatisticday.FieldTotalFriend:
  33479. return m.AddedTotalFriend()
  33480. case usagestatisticday.FieldTotalGroup:
  33481. return m.AddedTotalGroup()
  33482. case usagestatisticday.FieldAccountBalance:
  33483. return m.AddedAccountBalance()
  33484. case usagestatisticday.FieldConsumeToken:
  33485. return m.AddedConsumeToken()
  33486. case usagestatisticday.FieldActiveUser:
  33487. return m.AddedActiveUser()
  33488. case usagestatisticday.FieldNewUser:
  33489. return m.AddedNewUser()
  33490. }
  33491. return nil, false
  33492. }
  33493. // AddField adds the value to the field with the given name. It returns an error if
  33494. // the field is not defined in the schema, or if the type mismatched the field
  33495. // type.
  33496. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  33497. switch name {
  33498. case usagestatisticday.FieldStatus:
  33499. v, ok := value.(int8)
  33500. if !ok {
  33501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33502. }
  33503. m.AddStatus(v)
  33504. return nil
  33505. case usagestatisticday.FieldAddtime:
  33506. v, ok := value.(int64)
  33507. if !ok {
  33508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33509. }
  33510. m.AddAddtime(v)
  33511. return nil
  33512. case usagestatisticday.FieldType:
  33513. v, ok := value.(int)
  33514. if !ok {
  33515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33516. }
  33517. m.AddType(v)
  33518. return nil
  33519. case usagestatisticday.FieldOrganizationID:
  33520. v, ok := value.(int64)
  33521. if !ok {
  33522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33523. }
  33524. m.AddOrganizationID(v)
  33525. return nil
  33526. case usagestatisticday.FieldAiResponse:
  33527. v, ok := value.(int64)
  33528. if !ok {
  33529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33530. }
  33531. m.AddAiResponse(v)
  33532. return nil
  33533. case usagestatisticday.FieldSopRun:
  33534. v, ok := value.(int64)
  33535. if !ok {
  33536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33537. }
  33538. m.AddSopRun(v)
  33539. return nil
  33540. case usagestatisticday.FieldTotalFriend:
  33541. v, ok := value.(int64)
  33542. if !ok {
  33543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33544. }
  33545. m.AddTotalFriend(v)
  33546. return nil
  33547. case usagestatisticday.FieldTotalGroup:
  33548. v, ok := value.(int64)
  33549. if !ok {
  33550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33551. }
  33552. m.AddTotalGroup(v)
  33553. return nil
  33554. case usagestatisticday.FieldAccountBalance:
  33555. v, ok := value.(int64)
  33556. if !ok {
  33557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33558. }
  33559. m.AddAccountBalance(v)
  33560. return nil
  33561. case usagestatisticday.FieldConsumeToken:
  33562. v, ok := value.(int64)
  33563. if !ok {
  33564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33565. }
  33566. m.AddConsumeToken(v)
  33567. return nil
  33568. case usagestatisticday.FieldActiveUser:
  33569. v, ok := value.(int64)
  33570. if !ok {
  33571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33572. }
  33573. m.AddActiveUser(v)
  33574. return nil
  33575. case usagestatisticday.FieldNewUser:
  33576. v, ok := value.(int64)
  33577. if !ok {
  33578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33579. }
  33580. m.AddNewUser(v)
  33581. return nil
  33582. }
  33583. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  33584. }
  33585. // ClearedFields returns all nullable fields that were cleared during this
  33586. // mutation.
  33587. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  33588. var fields []string
  33589. if m.FieldCleared(usagestatisticday.FieldStatus) {
  33590. fields = append(fields, usagestatisticday.FieldStatus)
  33591. }
  33592. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  33593. fields = append(fields, usagestatisticday.FieldDeletedAt)
  33594. }
  33595. if m.FieldCleared(usagestatisticday.FieldBotID) {
  33596. fields = append(fields, usagestatisticday.FieldBotID)
  33597. }
  33598. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  33599. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33600. }
  33601. return fields
  33602. }
  33603. // FieldCleared returns a boolean indicating if a field with the given name was
  33604. // cleared in this mutation.
  33605. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  33606. _, ok := m.clearedFields[name]
  33607. return ok
  33608. }
  33609. // ClearField clears the value of the field with the given name. It returns an
  33610. // error if the field is not defined in the schema.
  33611. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  33612. switch name {
  33613. case usagestatisticday.FieldStatus:
  33614. m.ClearStatus()
  33615. return nil
  33616. case usagestatisticday.FieldDeletedAt:
  33617. m.ClearDeletedAt()
  33618. return nil
  33619. case usagestatisticday.FieldBotID:
  33620. m.ClearBotID()
  33621. return nil
  33622. case usagestatisticday.FieldOrganizationID:
  33623. m.ClearOrganizationID()
  33624. return nil
  33625. }
  33626. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  33627. }
  33628. // ResetField resets all changes in the mutation for the field with the given name.
  33629. // It returns an error if the field is not defined in the schema.
  33630. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  33631. switch name {
  33632. case usagestatisticday.FieldCreatedAt:
  33633. m.ResetCreatedAt()
  33634. return nil
  33635. case usagestatisticday.FieldUpdatedAt:
  33636. m.ResetUpdatedAt()
  33637. return nil
  33638. case usagestatisticday.FieldStatus:
  33639. m.ResetStatus()
  33640. return nil
  33641. case usagestatisticday.FieldDeletedAt:
  33642. m.ResetDeletedAt()
  33643. return nil
  33644. case usagestatisticday.FieldAddtime:
  33645. m.ResetAddtime()
  33646. return nil
  33647. case usagestatisticday.FieldType:
  33648. m.ResetType()
  33649. return nil
  33650. case usagestatisticday.FieldBotID:
  33651. m.ResetBotID()
  33652. return nil
  33653. case usagestatisticday.FieldOrganizationID:
  33654. m.ResetOrganizationID()
  33655. return nil
  33656. case usagestatisticday.FieldAiResponse:
  33657. m.ResetAiResponse()
  33658. return nil
  33659. case usagestatisticday.FieldSopRun:
  33660. m.ResetSopRun()
  33661. return nil
  33662. case usagestatisticday.FieldTotalFriend:
  33663. m.ResetTotalFriend()
  33664. return nil
  33665. case usagestatisticday.FieldTotalGroup:
  33666. m.ResetTotalGroup()
  33667. return nil
  33668. case usagestatisticday.FieldAccountBalance:
  33669. m.ResetAccountBalance()
  33670. return nil
  33671. case usagestatisticday.FieldConsumeToken:
  33672. m.ResetConsumeToken()
  33673. return nil
  33674. case usagestatisticday.FieldActiveUser:
  33675. m.ResetActiveUser()
  33676. return nil
  33677. case usagestatisticday.FieldNewUser:
  33678. m.ResetNewUser()
  33679. return nil
  33680. case usagestatisticday.FieldLabelDist:
  33681. m.ResetLabelDist()
  33682. return nil
  33683. }
  33684. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33685. }
  33686. // AddedEdges returns all edge names that were set/added in this mutation.
  33687. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  33688. edges := make([]string, 0, 0)
  33689. return edges
  33690. }
  33691. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33692. // name in this mutation.
  33693. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  33694. return nil
  33695. }
  33696. // RemovedEdges returns all edge names that were removed in this mutation.
  33697. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  33698. edges := make([]string, 0, 0)
  33699. return edges
  33700. }
  33701. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33702. // the given name in this mutation.
  33703. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  33704. return nil
  33705. }
  33706. // ClearedEdges returns all edge names that were cleared in this mutation.
  33707. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  33708. edges := make([]string, 0, 0)
  33709. return edges
  33710. }
  33711. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33712. // was cleared in this mutation.
  33713. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  33714. return false
  33715. }
  33716. // ClearEdge clears the value of the edge with the given name. It returns an error
  33717. // if that edge is not defined in the schema.
  33718. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  33719. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  33720. }
  33721. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33722. // It returns an error if the edge is not defined in the schema.
  33723. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  33724. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  33725. }
  33726. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  33727. type UsageStatisticHourMutation struct {
  33728. config
  33729. op Op
  33730. typ string
  33731. id *uint64
  33732. created_at *time.Time
  33733. updated_at *time.Time
  33734. status *uint8
  33735. addstatus *int8
  33736. deleted_at *time.Time
  33737. addtime *uint64
  33738. addaddtime *int64
  33739. _type *int
  33740. add_type *int
  33741. bot_id *string
  33742. organization_id *uint64
  33743. addorganization_id *int64
  33744. ai_response *uint64
  33745. addai_response *int64
  33746. sop_run *uint64
  33747. addsop_run *int64
  33748. total_friend *uint64
  33749. addtotal_friend *int64
  33750. total_group *uint64
  33751. addtotal_group *int64
  33752. account_balance *uint64
  33753. addaccount_balance *int64
  33754. consume_token *uint64
  33755. addconsume_token *int64
  33756. active_user *uint64
  33757. addactive_user *int64
  33758. new_user *int64
  33759. addnew_user *int64
  33760. label_dist *[]custom_types.LabelDist
  33761. appendlabel_dist []custom_types.LabelDist
  33762. clearedFields map[string]struct{}
  33763. done bool
  33764. oldValue func(context.Context) (*UsageStatisticHour, error)
  33765. predicates []predicate.UsageStatisticHour
  33766. }
  33767. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  33768. // usagestatistichourOption allows management of the mutation configuration using functional options.
  33769. type usagestatistichourOption func(*UsageStatisticHourMutation)
  33770. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  33771. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  33772. m := &UsageStatisticHourMutation{
  33773. config: c,
  33774. op: op,
  33775. typ: TypeUsageStatisticHour,
  33776. clearedFields: make(map[string]struct{}),
  33777. }
  33778. for _, opt := range opts {
  33779. opt(m)
  33780. }
  33781. return m
  33782. }
  33783. // withUsageStatisticHourID sets the ID field of the mutation.
  33784. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  33785. return func(m *UsageStatisticHourMutation) {
  33786. var (
  33787. err error
  33788. once sync.Once
  33789. value *UsageStatisticHour
  33790. )
  33791. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  33792. once.Do(func() {
  33793. if m.done {
  33794. err = errors.New("querying old values post mutation is not allowed")
  33795. } else {
  33796. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  33797. }
  33798. })
  33799. return value, err
  33800. }
  33801. m.id = &id
  33802. }
  33803. }
  33804. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  33805. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  33806. return func(m *UsageStatisticHourMutation) {
  33807. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  33808. return node, nil
  33809. }
  33810. m.id = &node.ID
  33811. }
  33812. }
  33813. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33814. // executed in a transaction (ent.Tx), a transactional client is returned.
  33815. func (m UsageStatisticHourMutation) Client() *Client {
  33816. client := &Client{config: m.config}
  33817. client.init()
  33818. return client
  33819. }
  33820. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33821. // it returns an error otherwise.
  33822. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  33823. if _, ok := m.driver.(*txDriver); !ok {
  33824. return nil, errors.New("ent: mutation is not running in a transaction")
  33825. }
  33826. tx := &Tx{config: m.config}
  33827. tx.init()
  33828. return tx, nil
  33829. }
  33830. // SetID sets the value of the id field. Note that this
  33831. // operation is only accepted on creation of UsageStatisticHour entities.
  33832. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  33833. m.id = &id
  33834. }
  33835. // ID returns the ID value in the mutation. Note that the ID is only available
  33836. // if it was provided to the builder or after it was returned from the database.
  33837. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  33838. if m.id == nil {
  33839. return
  33840. }
  33841. return *m.id, true
  33842. }
  33843. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33844. // That means, if the mutation is applied within a transaction with an isolation level such
  33845. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33846. // or updated by the mutation.
  33847. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  33848. switch {
  33849. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33850. id, exists := m.ID()
  33851. if exists {
  33852. return []uint64{id}, nil
  33853. }
  33854. fallthrough
  33855. case m.op.Is(OpUpdate | OpDelete):
  33856. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  33857. default:
  33858. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33859. }
  33860. }
  33861. // SetCreatedAt sets the "created_at" field.
  33862. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  33863. m.created_at = &t
  33864. }
  33865. // CreatedAt returns the value of the "created_at" field in the mutation.
  33866. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  33867. v := m.created_at
  33868. if v == nil {
  33869. return
  33870. }
  33871. return *v, true
  33872. }
  33873. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  33874. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33876. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33877. if !m.op.Is(OpUpdateOne) {
  33878. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33879. }
  33880. if m.id == nil || m.oldValue == nil {
  33881. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33882. }
  33883. oldValue, err := m.oldValue(ctx)
  33884. if err != nil {
  33885. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33886. }
  33887. return oldValue.CreatedAt, nil
  33888. }
  33889. // ResetCreatedAt resets all changes to the "created_at" field.
  33890. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  33891. m.created_at = nil
  33892. }
  33893. // SetUpdatedAt sets the "updated_at" field.
  33894. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  33895. m.updated_at = &t
  33896. }
  33897. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33898. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  33899. v := m.updated_at
  33900. if v == nil {
  33901. return
  33902. }
  33903. return *v, true
  33904. }
  33905. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33909. if !m.op.Is(OpUpdateOne) {
  33910. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33911. }
  33912. if m.id == nil || m.oldValue == nil {
  33913. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  33918. }
  33919. return oldValue.UpdatedAt, nil
  33920. }
  33921. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33922. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  33923. m.updated_at = nil
  33924. }
  33925. // SetStatus sets the "status" field.
  33926. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  33927. m.status = &u
  33928. m.addstatus = nil
  33929. }
  33930. // Status returns the value of the "status" field in the mutation.
  33931. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  33932. v := m.status
  33933. if v == nil {
  33934. return
  33935. }
  33936. return *v, true
  33937. }
  33938. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  33939. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33941. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33942. if !m.op.Is(OpUpdateOne) {
  33943. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33944. }
  33945. if m.id == nil || m.oldValue == nil {
  33946. return v, errors.New("OldStatus requires an ID field in the mutation")
  33947. }
  33948. oldValue, err := m.oldValue(ctx)
  33949. if err != nil {
  33950. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33951. }
  33952. return oldValue.Status, nil
  33953. }
  33954. // AddStatus adds u to the "status" field.
  33955. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  33956. if m.addstatus != nil {
  33957. *m.addstatus += u
  33958. } else {
  33959. m.addstatus = &u
  33960. }
  33961. }
  33962. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33963. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  33964. v := m.addstatus
  33965. if v == nil {
  33966. return
  33967. }
  33968. return *v, true
  33969. }
  33970. // ClearStatus clears the value of the "status" field.
  33971. func (m *UsageStatisticHourMutation) ClearStatus() {
  33972. m.status = nil
  33973. m.addstatus = nil
  33974. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  33975. }
  33976. // StatusCleared returns if the "status" field was cleared in this mutation.
  33977. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  33978. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  33979. return ok
  33980. }
  33981. // ResetStatus resets all changes to the "status" field.
  33982. func (m *UsageStatisticHourMutation) ResetStatus() {
  33983. m.status = nil
  33984. m.addstatus = nil
  33985. delete(m.clearedFields, usagestatistichour.FieldStatus)
  33986. }
  33987. // SetDeletedAt sets the "deleted_at" field.
  33988. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  33989. m.deleted_at = &t
  33990. }
  33991. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33992. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  33993. v := m.deleted_at
  33994. if v == nil {
  33995. return
  33996. }
  33997. return *v, true
  33998. }
  33999. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  34000. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34002. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34003. if !m.op.Is(OpUpdateOne) {
  34004. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34005. }
  34006. if m.id == nil || m.oldValue == nil {
  34007. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34008. }
  34009. oldValue, err := m.oldValue(ctx)
  34010. if err != nil {
  34011. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34012. }
  34013. return oldValue.DeletedAt, nil
  34014. }
  34015. // ClearDeletedAt clears the value of the "deleted_at" field.
  34016. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  34017. m.deleted_at = nil
  34018. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  34019. }
  34020. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34021. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  34022. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  34023. return ok
  34024. }
  34025. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34026. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  34027. m.deleted_at = nil
  34028. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  34029. }
  34030. // SetAddtime sets the "addtime" field.
  34031. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  34032. m.addtime = &u
  34033. m.addaddtime = nil
  34034. }
  34035. // Addtime returns the value of the "addtime" field in the mutation.
  34036. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  34037. v := m.addtime
  34038. if v == nil {
  34039. return
  34040. }
  34041. return *v, true
  34042. }
  34043. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  34044. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34046. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34047. if !m.op.Is(OpUpdateOne) {
  34048. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34049. }
  34050. if m.id == nil || m.oldValue == nil {
  34051. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34052. }
  34053. oldValue, err := m.oldValue(ctx)
  34054. if err != nil {
  34055. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34056. }
  34057. return oldValue.Addtime, nil
  34058. }
  34059. // AddAddtime adds u to the "addtime" field.
  34060. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  34061. if m.addaddtime != nil {
  34062. *m.addaddtime += u
  34063. } else {
  34064. m.addaddtime = &u
  34065. }
  34066. }
  34067. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34068. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  34069. v := m.addaddtime
  34070. if v == nil {
  34071. return
  34072. }
  34073. return *v, true
  34074. }
  34075. // ResetAddtime resets all changes to the "addtime" field.
  34076. func (m *UsageStatisticHourMutation) ResetAddtime() {
  34077. m.addtime = nil
  34078. m.addaddtime = nil
  34079. }
  34080. // SetType sets the "type" field.
  34081. func (m *UsageStatisticHourMutation) SetType(i int) {
  34082. m._type = &i
  34083. m.add_type = nil
  34084. }
  34085. // GetType returns the value of the "type" field in the mutation.
  34086. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  34087. v := m._type
  34088. if v == nil {
  34089. return
  34090. }
  34091. return *v, true
  34092. }
  34093. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  34094. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34096. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  34097. if !m.op.Is(OpUpdateOne) {
  34098. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34099. }
  34100. if m.id == nil || m.oldValue == nil {
  34101. return v, errors.New("OldType requires an ID field in the mutation")
  34102. }
  34103. oldValue, err := m.oldValue(ctx)
  34104. if err != nil {
  34105. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34106. }
  34107. return oldValue.Type, nil
  34108. }
  34109. // AddType adds i to the "type" field.
  34110. func (m *UsageStatisticHourMutation) AddType(i int) {
  34111. if m.add_type != nil {
  34112. *m.add_type += i
  34113. } else {
  34114. m.add_type = &i
  34115. }
  34116. }
  34117. // AddedType returns the value that was added to the "type" field in this mutation.
  34118. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  34119. v := m.add_type
  34120. if v == nil {
  34121. return
  34122. }
  34123. return *v, true
  34124. }
  34125. // ResetType resets all changes to the "type" field.
  34126. func (m *UsageStatisticHourMutation) ResetType() {
  34127. m._type = nil
  34128. m.add_type = nil
  34129. }
  34130. // SetBotID sets the "bot_id" field.
  34131. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  34132. m.bot_id = &s
  34133. }
  34134. // BotID returns the value of the "bot_id" field in the mutation.
  34135. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  34136. v := m.bot_id
  34137. if v == nil {
  34138. return
  34139. }
  34140. return *v, true
  34141. }
  34142. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  34143. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34145. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  34146. if !m.op.Is(OpUpdateOne) {
  34147. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34148. }
  34149. if m.id == nil || m.oldValue == nil {
  34150. return v, errors.New("OldBotID requires an ID field in the mutation")
  34151. }
  34152. oldValue, err := m.oldValue(ctx)
  34153. if err != nil {
  34154. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34155. }
  34156. return oldValue.BotID, nil
  34157. }
  34158. // ClearBotID clears the value of the "bot_id" field.
  34159. func (m *UsageStatisticHourMutation) ClearBotID() {
  34160. m.bot_id = nil
  34161. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  34162. }
  34163. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34164. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  34165. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  34166. return ok
  34167. }
  34168. // ResetBotID resets all changes to the "bot_id" field.
  34169. func (m *UsageStatisticHourMutation) ResetBotID() {
  34170. m.bot_id = nil
  34171. delete(m.clearedFields, usagestatistichour.FieldBotID)
  34172. }
  34173. // SetOrganizationID sets the "organization_id" field.
  34174. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  34175. m.organization_id = &u
  34176. m.addorganization_id = nil
  34177. }
  34178. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34179. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  34180. v := m.organization_id
  34181. if v == nil {
  34182. return
  34183. }
  34184. return *v, true
  34185. }
  34186. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  34187. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34189. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34190. if !m.op.Is(OpUpdateOne) {
  34191. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34192. }
  34193. if m.id == nil || m.oldValue == nil {
  34194. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34195. }
  34196. oldValue, err := m.oldValue(ctx)
  34197. if err != nil {
  34198. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34199. }
  34200. return oldValue.OrganizationID, nil
  34201. }
  34202. // AddOrganizationID adds u to the "organization_id" field.
  34203. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  34204. if m.addorganization_id != nil {
  34205. *m.addorganization_id += u
  34206. } else {
  34207. m.addorganization_id = &u
  34208. }
  34209. }
  34210. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34211. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  34212. v := m.addorganization_id
  34213. if v == nil {
  34214. return
  34215. }
  34216. return *v, true
  34217. }
  34218. // ClearOrganizationID clears the value of the "organization_id" field.
  34219. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  34220. m.organization_id = nil
  34221. m.addorganization_id = nil
  34222. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  34223. }
  34224. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34225. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  34226. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  34227. return ok
  34228. }
  34229. // ResetOrganizationID resets all changes to the "organization_id" field.
  34230. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  34231. m.organization_id = nil
  34232. m.addorganization_id = nil
  34233. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  34234. }
  34235. // SetAiResponse sets the "ai_response" field.
  34236. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  34237. m.ai_response = &u
  34238. m.addai_response = nil
  34239. }
  34240. // AiResponse returns the value of the "ai_response" field in the mutation.
  34241. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  34242. v := m.ai_response
  34243. if v == nil {
  34244. return
  34245. }
  34246. return *v, true
  34247. }
  34248. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  34249. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34251. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34252. if !m.op.Is(OpUpdateOne) {
  34253. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34254. }
  34255. if m.id == nil || m.oldValue == nil {
  34256. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34257. }
  34258. oldValue, err := m.oldValue(ctx)
  34259. if err != nil {
  34260. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34261. }
  34262. return oldValue.AiResponse, nil
  34263. }
  34264. // AddAiResponse adds u to the "ai_response" field.
  34265. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  34266. if m.addai_response != nil {
  34267. *m.addai_response += u
  34268. } else {
  34269. m.addai_response = &u
  34270. }
  34271. }
  34272. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34273. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  34274. v := m.addai_response
  34275. if v == nil {
  34276. return
  34277. }
  34278. return *v, true
  34279. }
  34280. // ResetAiResponse resets all changes to the "ai_response" field.
  34281. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  34282. m.ai_response = nil
  34283. m.addai_response = nil
  34284. }
  34285. // SetSopRun sets the "sop_run" field.
  34286. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  34287. m.sop_run = &u
  34288. m.addsop_run = nil
  34289. }
  34290. // SopRun returns the value of the "sop_run" field in the mutation.
  34291. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  34292. v := m.sop_run
  34293. if v == nil {
  34294. return
  34295. }
  34296. return *v, true
  34297. }
  34298. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  34299. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34301. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34302. if !m.op.Is(OpUpdateOne) {
  34303. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34304. }
  34305. if m.id == nil || m.oldValue == nil {
  34306. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34307. }
  34308. oldValue, err := m.oldValue(ctx)
  34309. if err != nil {
  34310. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34311. }
  34312. return oldValue.SopRun, nil
  34313. }
  34314. // AddSopRun adds u to the "sop_run" field.
  34315. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  34316. if m.addsop_run != nil {
  34317. *m.addsop_run += u
  34318. } else {
  34319. m.addsop_run = &u
  34320. }
  34321. }
  34322. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34323. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  34324. v := m.addsop_run
  34325. if v == nil {
  34326. return
  34327. }
  34328. return *v, true
  34329. }
  34330. // ResetSopRun resets all changes to the "sop_run" field.
  34331. func (m *UsageStatisticHourMutation) ResetSopRun() {
  34332. m.sop_run = nil
  34333. m.addsop_run = nil
  34334. }
  34335. // SetTotalFriend sets the "total_friend" field.
  34336. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  34337. m.total_friend = &u
  34338. m.addtotal_friend = nil
  34339. }
  34340. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34341. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  34342. v := m.total_friend
  34343. if v == nil {
  34344. return
  34345. }
  34346. return *v, true
  34347. }
  34348. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  34349. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34351. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34352. if !m.op.Is(OpUpdateOne) {
  34353. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34354. }
  34355. if m.id == nil || m.oldValue == nil {
  34356. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34357. }
  34358. oldValue, err := m.oldValue(ctx)
  34359. if err != nil {
  34360. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34361. }
  34362. return oldValue.TotalFriend, nil
  34363. }
  34364. // AddTotalFriend adds u to the "total_friend" field.
  34365. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  34366. if m.addtotal_friend != nil {
  34367. *m.addtotal_friend += u
  34368. } else {
  34369. m.addtotal_friend = &u
  34370. }
  34371. }
  34372. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34373. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  34374. v := m.addtotal_friend
  34375. if v == nil {
  34376. return
  34377. }
  34378. return *v, true
  34379. }
  34380. // ResetTotalFriend resets all changes to the "total_friend" field.
  34381. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  34382. m.total_friend = nil
  34383. m.addtotal_friend = nil
  34384. }
  34385. // SetTotalGroup sets the "total_group" field.
  34386. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  34387. m.total_group = &u
  34388. m.addtotal_group = nil
  34389. }
  34390. // TotalGroup returns the value of the "total_group" field in the mutation.
  34391. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  34392. v := m.total_group
  34393. if v == nil {
  34394. return
  34395. }
  34396. return *v, true
  34397. }
  34398. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  34399. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34401. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34402. if !m.op.Is(OpUpdateOne) {
  34403. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34404. }
  34405. if m.id == nil || m.oldValue == nil {
  34406. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34407. }
  34408. oldValue, err := m.oldValue(ctx)
  34409. if err != nil {
  34410. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34411. }
  34412. return oldValue.TotalGroup, nil
  34413. }
  34414. // AddTotalGroup adds u to the "total_group" field.
  34415. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  34416. if m.addtotal_group != nil {
  34417. *m.addtotal_group += u
  34418. } else {
  34419. m.addtotal_group = &u
  34420. }
  34421. }
  34422. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34423. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  34424. v := m.addtotal_group
  34425. if v == nil {
  34426. return
  34427. }
  34428. return *v, true
  34429. }
  34430. // ResetTotalGroup resets all changes to the "total_group" field.
  34431. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  34432. m.total_group = nil
  34433. m.addtotal_group = nil
  34434. }
  34435. // SetAccountBalance sets the "account_balance" field.
  34436. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  34437. m.account_balance = &u
  34438. m.addaccount_balance = nil
  34439. }
  34440. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34441. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  34442. v := m.account_balance
  34443. if v == nil {
  34444. return
  34445. }
  34446. return *v, true
  34447. }
  34448. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  34449. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34451. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34452. if !m.op.Is(OpUpdateOne) {
  34453. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34454. }
  34455. if m.id == nil || m.oldValue == nil {
  34456. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34457. }
  34458. oldValue, err := m.oldValue(ctx)
  34459. if err != nil {
  34460. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34461. }
  34462. return oldValue.AccountBalance, nil
  34463. }
  34464. // AddAccountBalance adds u to the "account_balance" field.
  34465. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  34466. if m.addaccount_balance != nil {
  34467. *m.addaccount_balance += u
  34468. } else {
  34469. m.addaccount_balance = &u
  34470. }
  34471. }
  34472. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34473. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  34474. v := m.addaccount_balance
  34475. if v == nil {
  34476. return
  34477. }
  34478. return *v, true
  34479. }
  34480. // ResetAccountBalance resets all changes to the "account_balance" field.
  34481. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  34482. m.account_balance = nil
  34483. m.addaccount_balance = nil
  34484. }
  34485. // SetConsumeToken sets the "consume_token" field.
  34486. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  34487. m.consume_token = &u
  34488. m.addconsume_token = nil
  34489. }
  34490. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34491. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  34492. v := m.consume_token
  34493. if v == nil {
  34494. return
  34495. }
  34496. return *v, true
  34497. }
  34498. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  34499. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34501. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34502. if !m.op.Is(OpUpdateOne) {
  34503. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34504. }
  34505. if m.id == nil || m.oldValue == nil {
  34506. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34507. }
  34508. oldValue, err := m.oldValue(ctx)
  34509. if err != nil {
  34510. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34511. }
  34512. return oldValue.ConsumeToken, nil
  34513. }
  34514. // AddConsumeToken adds u to the "consume_token" field.
  34515. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  34516. if m.addconsume_token != nil {
  34517. *m.addconsume_token += u
  34518. } else {
  34519. m.addconsume_token = &u
  34520. }
  34521. }
  34522. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34523. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  34524. v := m.addconsume_token
  34525. if v == nil {
  34526. return
  34527. }
  34528. return *v, true
  34529. }
  34530. // ResetConsumeToken resets all changes to the "consume_token" field.
  34531. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  34532. m.consume_token = nil
  34533. m.addconsume_token = nil
  34534. }
  34535. // SetActiveUser sets the "active_user" field.
  34536. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  34537. m.active_user = &u
  34538. m.addactive_user = nil
  34539. }
  34540. // ActiveUser returns the value of the "active_user" field in the mutation.
  34541. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  34542. v := m.active_user
  34543. if v == nil {
  34544. return
  34545. }
  34546. return *v, true
  34547. }
  34548. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  34549. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34551. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34552. if !m.op.Is(OpUpdateOne) {
  34553. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34554. }
  34555. if m.id == nil || m.oldValue == nil {
  34556. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34557. }
  34558. oldValue, err := m.oldValue(ctx)
  34559. if err != nil {
  34560. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34561. }
  34562. return oldValue.ActiveUser, nil
  34563. }
  34564. // AddActiveUser adds u to the "active_user" field.
  34565. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  34566. if m.addactive_user != nil {
  34567. *m.addactive_user += u
  34568. } else {
  34569. m.addactive_user = &u
  34570. }
  34571. }
  34572. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34573. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  34574. v := m.addactive_user
  34575. if v == nil {
  34576. return
  34577. }
  34578. return *v, true
  34579. }
  34580. // ResetActiveUser resets all changes to the "active_user" field.
  34581. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  34582. m.active_user = nil
  34583. m.addactive_user = nil
  34584. }
  34585. // SetNewUser sets the "new_user" field.
  34586. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  34587. m.new_user = &i
  34588. m.addnew_user = nil
  34589. }
  34590. // NewUser returns the value of the "new_user" field in the mutation.
  34591. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  34592. v := m.new_user
  34593. if v == nil {
  34594. return
  34595. }
  34596. return *v, true
  34597. }
  34598. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  34599. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34601. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34602. if !m.op.Is(OpUpdateOne) {
  34603. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34604. }
  34605. if m.id == nil || m.oldValue == nil {
  34606. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34607. }
  34608. oldValue, err := m.oldValue(ctx)
  34609. if err != nil {
  34610. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34611. }
  34612. return oldValue.NewUser, nil
  34613. }
  34614. // AddNewUser adds i to the "new_user" field.
  34615. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  34616. if m.addnew_user != nil {
  34617. *m.addnew_user += i
  34618. } else {
  34619. m.addnew_user = &i
  34620. }
  34621. }
  34622. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34623. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  34624. v := m.addnew_user
  34625. if v == nil {
  34626. return
  34627. }
  34628. return *v, true
  34629. }
  34630. // ResetNewUser resets all changes to the "new_user" field.
  34631. func (m *UsageStatisticHourMutation) ResetNewUser() {
  34632. m.new_user = nil
  34633. m.addnew_user = nil
  34634. }
  34635. // SetLabelDist sets the "label_dist" field.
  34636. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34637. m.label_dist = &ctd
  34638. m.appendlabel_dist = nil
  34639. }
  34640. // LabelDist returns the value of the "label_dist" field in the mutation.
  34641. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34642. v := m.label_dist
  34643. if v == nil {
  34644. return
  34645. }
  34646. return *v, true
  34647. }
  34648. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  34649. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34651. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34652. if !m.op.Is(OpUpdateOne) {
  34653. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34654. }
  34655. if m.id == nil || m.oldValue == nil {
  34656. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34657. }
  34658. oldValue, err := m.oldValue(ctx)
  34659. if err != nil {
  34660. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34661. }
  34662. return oldValue.LabelDist, nil
  34663. }
  34664. // AppendLabelDist adds ctd to the "label_dist" field.
  34665. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34666. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34667. }
  34668. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34669. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34670. if len(m.appendlabel_dist) == 0 {
  34671. return nil, false
  34672. }
  34673. return m.appendlabel_dist, true
  34674. }
  34675. // ResetLabelDist resets all changes to the "label_dist" field.
  34676. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  34677. m.label_dist = nil
  34678. m.appendlabel_dist = nil
  34679. }
  34680. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  34681. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  34682. m.predicates = append(m.predicates, ps...)
  34683. }
  34684. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  34685. // users can use type-assertion to append predicates that do not depend on any generated package.
  34686. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  34687. p := make([]predicate.UsageStatisticHour, len(ps))
  34688. for i := range ps {
  34689. p[i] = ps[i]
  34690. }
  34691. m.Where(p...)
  34692. }
  34693. // Op returns the operation name.
  34694. func (m *UsageStatisticHourMutation) Op() Op {
  34695. return m.op
  34696. }
  34697. // SetOp allows setting the mutation operation.
  34698. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  34699. m.op = op
  34700. }
  34701. // Type returns the node type of this mutation (UsageStatisticHour).
  34702. func (m *UsageStatisticHourMutation) Type() string {
  34703. return m.typ
  34704. }
  34705. // Fields returns all fields that were changed during this mutation. Note that in
  34706. // order to get all numeric fields that were incremented/decremented, call
  34707. // AddedFields().
  34708. func (m *UsageStatisticHourMutation) Fields() []string {
  34709. fields := make([]string, 0, 17)
  34710. if m.created_at != nil {
  34711. fields = append(fields, usagestatistichour.FieldCreatedAt)
  34712. }
  34713. if m.updated_at != nil {
  34714. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  34715. }
  34716. if m.status != nil {
  34717. fields = append(fields, usagestatistichour.FieldStatus)
  34718. }
  34719. if m.deleted_at != nil {
  34720. fields = append(fields, usagestatistichour.FieldDeletedAt)
  34721. }
  34722. if m.addtime != nil {
  34723. fields = append(fields, usagestatistichour.FieldAddtime)
  34724. }
  34725. if m._type != nil {
  34726. fields = append(fields, usagestatistichour.FieldType)
  34727. }
  34728. if m.bot_id != nil {
  34729. fields = append(fields, usagestatistichour.FieldBotID)
  34730. }
  34731. if m.organization_id != nil {
  34732. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34733. }
  34734. if m.ai_response != nil {
  34735. fields = append(fields, usagestatistichour.FieldAiResponse)
  34736. }
  34737. if m.sop_run != nil {
  34738. fields = append(fields, usagestatistichour.FieldSopRun)
  34739. }
  34740. if m.total_friend != nil {
  34741. fields = append(fields, usagestatistichour.FieldTotalFriend)
  34742. }
  34743. if m.total_group != nil {
  34744. fields = append(fields, usagestatistichour.FieldTotalGroup)
  34745. }
  34746. if m.account_balance != nil {
  34747. fields = append(fields, usagestatistichour.FieldAccountBalance)
  34748. }
  34749. if m.consume_token != nil {
  34750. fields = append(fields, usagestatistichour.FieldConsumeToken)
  34751. }
  34752. if m.active_user != nil {
  34753. fields = append(fields, usagestatistichour.FieldActiveUser)
  34754. }
  34755. if m.new_user != nil {
  34756. fields = append(fields, usagestatistichour.FieldNewUser)
  34757. }
  34758. if m.label_dist != nil {
  34759. fields = append(fields, usagestatistichour.FieldLabelDist)
  34760. }
  34761. return fields
  34762. }
  34763. // Field returns the value of a field with the given name. The second boolean
  34764. // return value indicates that this field was not set, or was not defined in the
  34765. // schema.
  34766. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  34767. switch name {
  34768. case usagestatistichour.FieldCreatedAt:
  34769. return m.CreatedAt()
  34770. case usagestatistichour.FieldUpdatedAt:
  34771. return m.UpdatedAt()
  34772. case usagestatistichour.FieldStatus:
  34773. return m.Status()
  34774. case usagestatistichour.FieldDeletedAt:
  34775. return m.DeletedAt()
  34776. case usagestatistichour.FieldAddtime:
  34777. return m.Addtime()
  34778. case usagestatistichour.FieldType:
  34779. return m.GetType()
  34780. case usagestatistichour.FieldBotID:
  34781. return m.BotID()
  34782. case usagestatistichour.FieldOrganizationID:
  34783. return m.OrganizationID()
  34784. case usagestatistichour.FieldAiResponse:
  34785. return m.AiResponse()
  34786. case usagestatistichour.FieldSopRun:
  34787. return m.SopRun()
  34788. case usagestatistichour.FieldTotalFriend:
  34789. return m.TotalFriend()
  34790. case usagestatistichour.FieldTotalGroup:
  34791. return m.TotalGroup()
  34792. case usagestatistichour.FieldAccountBalance:
  34793. return m.AccountBalance()
  34794. case usagestatistichour.FieldConsumeToken:
  34795. return m.ConsumeToken()
  34796. case usagestatistichour.FieldActiveUser:
  34797. return m.ActiveUser()
  34798. case usagestatistichour.FieldNewUser:
  34799. return m.NewUser()
  34800. case usagestatistichour.FieldLabelDist:
  34801. return m.LabelDist()
  34802. }
  34803. return nil, false
  34804. }
  34805. // OldField returns the old value of the field from the database. An error is
  34806. // returned if the mutation operation is not UpdateOne, or the query to the
  34807. // database failed.
  34808. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34809. switch name {
  34810. case usagestatistichour.FieldCreatedAt:
  34811. return m.OldCreatedAt(ctx)
  34812. case usagestatistichour.FieldUpdatedAt:
  34813. return m.OldUpdatedAt(ctx)
  34814. case usagestatistichour.FieldStatus:
  34815. return m.OldStatus(ctx)
  34816. case usagestatistichour.FieldDeletedAt:
  34817. return m.OldDeletedAt(ctx)
  34818. case usagestatistichour.FieldAddtime:
  34819. return m.OldAddtime(ctx)
  34820. case usagestatistichour.FieldType:
  34821. return m.OldType(ctx)
  34822. case usagestatistichour.FieldBotID:
  34823. return m.OldBotID(ctx)
  34824. case usagestatistichour.FieldOrganizationID:
  34825. return m.OldOrganizationID(ctx)
  34826. case usagestatistichour.FieldAiResponse:
  34827. return m.OldAiResponse(ctx)
  34828. case usagestatistichour.FieldSopRun:
  34829. return m.OldSopRun(ctx)
  34830. case usagestatistichour.FieldTotalFriend:
  34831. return m.OldTotalFriend(ctx)
  34832. case usagestatistichour.FieldTotalGroup:
  34833. return m.OldTotalGroup(ctx)
  34834. case usagestatistichour.FieldAccountBalance:
  34835. return m.OldAccountBalance(ctx)
  34836. case usagestatistichour.FieldConsumeToken:
  34837. return m.OldConsumeToken(ctx)
  34838. case usagestatistichour.FieldActiveUser:
  34839. return m.OldActiveUser(ctx)
  34840. case usagestatistichour.FieldNewUser:
  34841. return m.OldNewUser(ctx)
  34842. case usagestatistichour.FieldLabelDist:
  34843. return m.OldLabelDist(ctx)
  34844. }
  34845. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34846. }
  34847. // SetField sets the value of a field with the given name. It returns an error if
  34848. // the field is not defined in the schema, or if the type mismatched the field
  34849. // type.
  34850. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  34851. switch name {
  34852. case usagestatistichour.FieldCreatedAt:
  34853. v, ok := value.(time.Time)
  34854. if !ok {
  34855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34856. }
  34857. m.SetCreatedAt(v)
  34858. return nil
  34859. case usagestatistichour.FieldUpdatedAt:
  34860. v, ok := value.(time.Time)
  34861. if !ok {
  34862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34863. }
  34864. m.SetUpdatedAt(v)
  34865. return nil
  34866. case usagestatistichour.FieldStatus:
  34867. v, ok := value.(uint8)
  34868. if !ok {
  34869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34870. }
  34871. m.SetStatus(v)
  34872. return nil
  34873. case usagestatistichour.FieldDeletedAt:
  34874. v, ok := value.(time.Time)
  34875. if !ok {
  34876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34877. }
  34878. m.SetDeletedAt(v)
  34879. return nil
  34880. case usagestatistichour.FieldAddtime:
  34881. v, ok := value.(uint64)
  34882. if !ok {
  34883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34884. }
  34885. m.SetAddtime(v)
  34886. return nil
  34887. case usagestatistichour.FieldType:
  34888. v, ok := value.(int)
  34889. if !ok {
  34890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34891. }
  34892. m.SetType(v)
  34893. return nil
  34894. case usagestatistichour.FieldBotID:
  34895. v, ok := value.(string)
  34896. if !ok {
  34897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34898. }
  34899. m.SetBotID(v)
  34900. return nil
  34901. case usagestatistichour.FieldOrganizationID:
  34902. v, ok := value.(uint64)
  34903. if !ok {
  34904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34905. }
  34906. m.SetOrganizationID(v)
  34907. return nil
  34908. case usagestatistichour.FieldAiResponse:
  34909. v, ok := value.(uint64)
  34910. if !ok {
  34911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34912. }
  34913. m.SetAiResponse(v)
  34914. return nil
  34915. case usagestatistichour.FieldSopRun:
  34916. v, ok := value.(uint64)
  34917. if !ok {
  34918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34919. }
  34920. m.SetSopRun(v)
  34921. return nil
  34922. case usagestatistichour.FieldTotalFriend:
  34923. v, ok := value.(uint64)
  34924. if !ok {
  34925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34926. }
  34927. m.SetTotalFriend(v)
  34928. return nil
  34929. case usagestatistichour.FieldTotalGroup:
  34930. v, ok := value.(uint64)
  34931. if !ok {
  34932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34933. }
  34934. m.SetTotalGroup(v)
  34935. return nil
  34936. case usagestatistichour.FieldAccountBalance:
  34937. v, ok := value.(uint64)
  34938. if !ok {
  34939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34940. }
  34941. m.SetAccountBalance(v)
  34942. return nil
  34943. case usagestatistichour.FieldConsumeToken:
  34944. v, ok := value.(uint64)
  34945. if !ok {
  34946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34947. }
  34948. m.SetConsumeToken(v)
  34949. return nil
  34950. case usagestatistichour.FieldActiveUser:
  34951. v, ok := value.(uint64)
  34952. if !ok {
  34953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34954. }
  34955. m.SetActiveUser(v)
  34956. return nil
  34957. case usagestatistichour.FieldNewUser:
  34958. v, ok := value.(int64)
  34959. if !ok {
  34960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34961. }
  34962. m.SetNewUser(v)
  34963. return nil
  34964. case usagestatistichour.FieldLabelDist:
  34965. v, ok := value.([]custom_types.LabelDist)
  34966. if !ok {
  34967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34968. }
  34969. m.SetLabelDist(v)
  34970. return nil
  34971. }
  34972. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34973. }
  34974. // AddedFields returns all numeric fields that were incremented/decremented during
  34975. // this mutation.
  34976. func (m *UsageStatisticHourMutation) AddedFields() []string {
  34977. var fields []string
  34978. if m.addstatus != nil {
  34979. fields = append(fields, usagestatistichour.FieldStatus)
  34980. }
  34981. if m.addaddtime != nil {
  34982. fields = append(fields, usagestatistichour.FieldAddtime)
  34983. }
  34984. if m.add_type != nil {
  34985. fields = append(fields, usagestatistichour.FieldType)
  34986. }
  34987. if m.addorganization_id != nil {
  34988. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34989. }
  34990. if m.addai_response != nil {
  34991. fields = append(fields, usagestatistichour.FieldAiResponse)
  34992. }
  34993. if m.addsop_run != nil {
  34994. fields = append(fields, usagestatistichour.FieldSopRun)
  34995. }
  34996. if m.addtotal_friend != nil {
  34997. fields = append(fields, usagestatistichour.FieldTotalFriend)
  34998. }
  34999. if m.addtotal_group != nil {
  35000. fields = append(fields, usagestatistichour.FieldTotalGroup)
  35001. }
  35002. if m.addaccount_balance != nil {
  35003. fields = append(fields, usagestatistichour.FieldAccountBalance)
  35004. }
  35005. if m.addconsume_token != nil {
  35006. fields = append(fields, usagestatistichour.FieldConsumeToken)
  35007. }
  35008. if m.addactive_user != nil {
  35009. fields = append(fields, usagestatistichour.FieldActiveUser)
  35010. }
  35011. if m.addnew_user != nil {
  35012. fields = append(fields, usagestatistichour.FieldNewUser)
  35013. }
  35014. return fields
  35015. }
  35016. // AddedField returns the numeric value that was incremented/decremented on a field
  35017. // with the given name. The second boolean return value indicates that this field
  35018. // was not set, or was not defined in the schema.
  35019. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  35020. switch name {
  35021. case usagestatistichour.FieldStatus:
  35022. return m.AddedStatus()
  35023. case usagestatistichour.FieldAddtime:
  35024. return m.AddedAddtime()
  35025. case usagestatistichour.FieldType:
  35026. return m.AddedType()
  35027. case usagestatistichour.FieldOrganizationID:
  35028. return m.AddedOrganizationID()
  35029. case usagestatistichour.FieldAiResponse:
  35030. return m.AddedAiResponse()
  35031. case usagestatistichour.FieldSopRun:
  35032. return m.AddedSopRun()
  35033. case usagestatistichour.FieldTotalFriend:
  35034. return m.AddedTotalFriend()
  35035. case usagestatistichour.FieldTotalGroup:
  35036. return m.AddedTotalGroup()
  35037. case usagestatistichour.FieldAccountBalance:
  35038. return m.AddedAccountBalance()
  35039. case usagestatistichour.FieldConsumeToken:
  35040. return m.AddedConsumeToken()
  35041. case usagestatistichour.FieldActiveUser:
  35042. return m.AddedActiveUser()
  35043. case usagestatistichour.FieldNewUser:
  35044. return m.AddedNewUser()
  35045. }
  35046. return nil, false
  35047. }
  35048. // AddField adds the value to the field with the given name. It returns an error if
  35049. // the field is not defined in the schema, or if the type mismatched the field
  35050. // type.
  35051. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  35052. switch name {
  35053. case usagestatistichour.FieldStatus:
  35054. v, ok := value.(int8)
  35055. if !ok {
  35056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35057. }
  35058. m.AddStatus(v)
  35059. return nil
  35060. case usagestatistichour.FieldAddtime:
  35061. v, ok := value.(int64)
  35062. if !ok {
  35063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35064. }
  35065. m.AddAddtime(v)
  35066. return nil
  35067. case usagestatistichour.FieldType:
  35068. v, ok := value.(int)
  35069. if !ok {
  35070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35071. }
  35072. m.AddType(v)
  35073. return nil
  35074. case usagestatistichour.FieldOrganizationID:
  35075. v, ok := value.(int64)
  35076. if !ok {
  35077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35078. }
  35079. m.AddOrganizationID(v)
  35080. return nil
  35081. case usagestatistichour.FieldAiResponse:
  35082. v, ok := value.(int64)
  35083. if !ok {
  35084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35085. }
  35086. m.AddAiResponse(v)
  35087. return nil
  35088. case usagestatistichour.FieldSopRun:
  35089. v, ok := value.(int64)
  35090. if !ok {
  35091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35092. }
  35093. m.AddSopRun(v)
  35094. return nil
  35095. case usagestatistichour.FieldTotalFriend:
  35096. v, ok := value.(int64)
  35097. if !ok {
  35098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35099. }
  35100. m.AddTotalFriend(v)
  35101. return nil
  35102. case usagestatistichour.FieldTotalGroup:
  35103. v, ok := value.(int64)
  35104. if !ok {
  35105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35106. }
  35107. m.AddTotalGroup(v)
  35108. return nil
  35109. case usagestatistichour.FieldAccountBalance:
  35110. v, ok := value.(int64)
  35111. if !ok {
  35112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35113. }
  35114. m.AddAccountBalance(v)
  35115. return nil
  35116. case usagestatistichour.FieldConsumeToken:
  35117. v, ok := value.(int64)
  35118. if !ok {
  35119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35120. }
  35121. m.AddConsumeToken(v)
  35122. return nil
  35123. case usagestatistichour.FieldActiveUser:
  35124. v, ok := value.(int64)
  35125. if !ok {
  35126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35127. }
  35128. m.AddActiveUser(v)
  35129. return nil
  35130. case usagestatistichour.FieldNewUser:
  35131. v, ok := value.(int64)
  35132. if !ok {
  35133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35134. }
  35135. m.AddNewUser(v)
  35136. return nil
  35137. }
  35138. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  35139. }
  35140. // ClearedFields returns all nullable fields that were cleared during this
  35141. // mutation.
  35142. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  35143. var fields []string
  35144. if m.FieldCleared(usagestatistichour.FieldStatus) {
  35145. fields = append(fields, usagestatistichour.FieldStatus)
  35146. }
  35147. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  35148. fields = append(fields, usagestatistichour.FieldDeletedAt)
  35149. }
  35150. if m.FieldCleared(usagestatistichour.FieldBotID) {
  35151. fields = append(fields, usagestatistichour.FieldBotID)
  35152. }
  35153. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  35154. fields = append(fields, usagestatistichour.FieldOrganizationID)
  35155. }
  35156. return fields
  35157. }
  35158. // FieldCleared returns a boolean indicating if a field with the given name was
  35159. // cleared in this mutation.
  35160. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  35161. _, ok := m.clearedFields[name]
  35162. return ok
  35163. }
  35164. // ClearField clears the value of the field with the given name. It returns an
  35165. // error if the field is not defined in the schema.
  35166. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  35167. switch name {
  35168. case usagestatistichour.FieldStatus:
  35169. m.ClearStatus()
  35170. return nil
  35171. case usagestatistichour.FieldDeletedAt:
  35172. m.ClearDeletedAt()
  35173. return nil
  35174. case usagestatistichour.FieldBotID:
  35175. m.ClearBotID()
  35176. return nil
  35177. case usagestatistichour.FieldOrganizationID:
  35178. m.ClearOrganizationID()
  35179. return nil
  35180. }
  35181. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  35182. }
  35183. // ResetField resets all changes in the mutation for the field with the given name.
  35184. // It returns an error if the field is not defined in the schema.
  35185. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  35186. switch name {
  35187. case usagestatistichour.FieldCreatedAt:
  35188. m.ResetCreatedAt()
  35189. return nil
  35190. case usagestatistichour.FieldUpdatedAt:
  35191. m.ResetUpdatedAt()
  35192. return nil
  35193. case usagestatistichour.FieldStatus:
  35194. m.ResetStatus()
  35195. return nil
  35196. case usagestatistichour.FieldDeletedAt:
  35197. m.ResetDeletedAt()
  35198. return nil
  35199. case usagestatistichour.FieldAddtime:
  35200. m.ResetAddtime()
  35201. return nil
  35202. case usagestatistichour.FieldType:
  35203. m.ResetType()
  35204. return nil
  35205. case usagestatistichour.FieldBotID:
  35206. m.ResetBotID()
  35207. return nil
  35208. case usagestatistichour.FieldOrganizationID:
  35209. m.ResetOrganizationID()
  35210. return nil
  35211. case usagestatistichour.FieldAiResponse:
  35212. m.ResetAiResponse()
  35213. return nil
  35214. case usagestatistichour.FieldSopRun:
  35215. m.ResetSopRun()
  35216. return nil
  35217. case usagestatistichour.FieldTotalFriend:
  35218. m.ResetTotalFriend()
  35219. return nil
  35220. case usagestatistichour.FieldTotalGroup:
  35221. m.ResetTotalGroup()
  35222. return nil
  35223. case usagestatistichour.FieldAccountBalance:
  35224. m.ResetAccountBalance()
  35225. return nil
  35226. case usagestatistichour.FieldConsumeToken:
  35227. m.ResetConsumeToken()
  35228. return nil
  35229. case usagestatistichour.FieldActiveUser:
  35230. m.ResetActiveUser()
  35231. return nil
  35232. case usagestatistichour.FieldNewUser:
  35233. m.ResetNewUser()
  35234. return nil
  35235. case usagestatistichour.FieldLabelDist:
  35236. m.ResetLabelDist()
  35237. return nil
  35238. }
  35239. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  35240. }
  35241. // AddedEdges returns all edge names that were set/added in this mutation.
  35242. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  35243. edges := make([]string, 0, 0)
  35244. return edges
  35245. }
  35246. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35247. // name in this mutation.
  35248. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  35249. return nil
  35250. }
  35251. // RemovedEdges returns all edge names that were removed in this mutation.
  35252. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  35253. edges := make([]string, 0, 0)
  35254. return edges
  35255. }
  35256. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35257. // the given name in this mutation.
  35258. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  35259. return nil
  35260. }
  35261. // ClearedEdges returns all edge names that were cleared in this mutation.
  35262. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  35263. edges := make([]string, 0, 0)
  35264. return edges
  35265. }
  35266. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35267. // was cleared in this mutation.
  35268. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  35269. return false
  35270. }
  35271. // ClearEdge clears the value of the edge with the given name. It returns an error
  35272. // if that edge is not defined in the schema.
  35273. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  35274. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  35275. }
  35276. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35277. // It returns an error if the edge is not defined in the schema.
  35278. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  35279. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  35280. }
  35281. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  35282. type UsageStatisticMonthMutation struct {
  35283. config
  35284. op Op
  35285. typ string
  35286. id *uint64
  35287. created_at *time.Time
  35288. updated_at *time.Time
  35289. status *uint8
  35290. addstatus *int8
  35291. deleted_at *time.Time
  35292. addtime *uint64
  35293. addaddtime *int64
  35294. _type *int
  35295. add_type *int
  35296. bot_id *string
  35297. organization_id *uint64
  35298. addorganization_id *int64
  35299. ai_response *uint64
  35300. addai_response *int64
  35301. sop_run *uint64
  35302. addsop_run *int64
  35303. total_friend *uint64
  35304. addtotal_friend *int64
  35305. total_group *uint64
  35306. addtotal_group *int64
  35307. account_balance *uint64
  35308. addaccount_balance *int64
  35309. consume_token *uint64
  35310. addconsume_token *int64
  35311. active_user *uint64
  35312. addactive_user *int64
  35313. new_user *int64
  35314. addnew_user *int64
  35315. label_dist *[]custom_types.LabelDist
  35316. appendlabel_dist []custom_types.LabelDist
  35317. clearedFields map[string]struct{}
  35318. done bool
  35319. oldValue func(context.Context) (*UsageStatisticMonth, error)
  35320. predicates []predicate.UsageStatisticMonth
  35321. }
  35322. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  35323. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  35324. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  35325. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  35326. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  35327. m := &UsageStatisticMonthMutation{
  35328. config: c,
  35329. op: op,
  35330. typ: TypeUsageStatisticMonth,
  35331. clearedFields: make(map[string]struct{}),
  35332. }
  35333. for _, opt := range opts {
  35334. opt(m)
  35335. }
  35336. return m
  35337. }
  35338. // withUsageStatisticMonthID sets the ID field of the mutation.
  35339. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  35340. return func(m *UsageStatisticMonthMutation) {
  35341. var (
  35342. err error
  35343. once sync.Once
  35344. value *UsageStatisticMonth
  35345. )
  35346. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  35347. once.Do(func() {
  35348. if m.done {
  35349. err = errors.New("querying old values post mutation is not allowed")
  35350. } else {
  35351. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  35352. }
  35353. })
  35354. return value, err
  35355. }
  35356. m.id = &id
  35357. }
  35358. }
  35359. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  35360. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  35361. return func(m *UsageStatisticMonthMutation) {
  35362. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  35363. return node, nil
  35364. }
  35365. m.id = &node.ID
  35366. }
  35367. }
  35368. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35369. // executed in a transaction (ent.Tx), a transactional client is returned.
  35370. func (m UsageStatisticMonthMutation) Client() *Client {
  35371. client := &Client{config: m.config}
  35372. client.init()
  35373. return client
  35374. }
  35375. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35376. // it returns an error otherwise.
  35377. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  35378. if _, ok := m.driver.(*txDriver); !ok {
  35379. return nil, errors.New("ent: mutation is not running in a transaction")
  35380. }
  35381. tx := &Tx{config: m.config}
  35382. tx.init()
  35383. return tx, nil
  35384. }
  35385. // SetID sets the value of the id field. Note that this
  35386. // operation is only accepted on creation of UsageStatisticMonth entities.
  35387. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  35388. m.id = &id
  35389. }
  35390. // ID returns the ID value in the mutation. Note that the ID is only available
  35391. // if it was provided to the builder or after it was returned from the database.
  35392. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  35393. if m.id == nil {
  35394. return
  35395. }
  35396. return *m.id, true
  35397. }
  35398. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35399. // That means, if the mutation is applied within a transaction with an isolation level such
  35400. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35401. // or updated by the mutation.
  35402. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  35403. switch {
  35404. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35405. id, exists := m.ID()
  35406. if exists {
  35407. return []uint64{id}, nil
  35408. }
  35409. fallthrough
  35410. case m.op.Is(OpUpdate | OpDelete):
  35411. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  35412. default:
  35413. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35414. }
  35415. }
  35416. // SetCreatedAt sets the "created_at" field.
  35417. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  35418. m.created_at = &t
  35419. }
  35420. // CreatedAt returns the value of the "created_at" field in the mutation.
  35421. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  35422. v := m.created_at
  35423. if v == nil {
  35424. return
  35425. }
  35426. return *v, true
  35427. }
  35428. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  35429. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35431. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35432. if !m.op.Is(OpUpdateOne) {
  35433. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35434. }
  35435. if m.id == nil || m.oldValue == nil {
  35436. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35437. }
  35438. oldValue, err := m.oldValue(ctx)
  35439. if err != nil {
  35440. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35441. }
  35442. return oldValue.CreatedAt, nil
  35443. }
  35444. // ResetCreatedAt resets all changes to the "created_at" field.
  35445. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  35446. m.created_at = nil
  35447. }
  35448. // SetUpdatedAt sets the "updated_at" field.
  35449. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  35450. m.updated_at = &t
  35451. }
  35452. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35453. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  35454. v := m.updated_at
  35455. if v == nil {
  35456. return
  35457. }
  35458. return *v, true
  35459. }
  35460. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35464. if !m.op.Is(OpUpdateOne) {
  35465. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35466. }
  35467. if m.id == nil || m.oldValue == nil {
  35468. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  35473. }
  35474. return oldValue.UpdatedAt, nil
  35475. }
  35476. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35477. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  35478. m.updated_at = nil
  35479. }
  35480. // SetStatus sets the "status" field.
  35481. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  35482. m.status = &u
  35483. m.addstatus = nil
  35484. }
  35485. // Status returns the value of the "status" field in the mutation.
  35486. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  35487. v := m.status
  35488. if v == nil {
  35489. return
  35490. }
  35491. return *v, true
  35492. }
  35493. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  35494. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35496. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35497. if !m.op.Is(OpUpdateOne) {
  35498. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35499. }
  35500. if m.id == nil || m.oldValue == nil {
  35501. return v, errors.New("OldStatus requires an ID field in the mutation")
  35502. }
  35503. oldValue, err := m.oldValue(ctx)
  35504. if err != nil {
  35505. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35506. }
  35507. return oldValue.Status, nil
  35508. }
  35509. // AddStatus adds u to the "status" field.
  35510. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  35511. if m.addstatus != nil {
  35512. *m.addstatus += u
  35513. } else {
  35514. m.addstatus = &u
  35515. }
  35516. }
  35517. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35518. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  35519. v := m.addstatus
  35520. if v == nil {
  35521. return
  35522. }
  35523. return *v, true
  35524. }
  35525. // ClearStatus clears the value of the "status" field.
  35526. func (m *UsageStatisticMonthMutation) ClearStatus() {
  35527. m.status = nil
  35528. m.addstatus = nil
  35529. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  35530. }
  35531. // StatusCleared returns if the "status" field was cleared in this mutation.
  35532. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  35533. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  35534. return ok
  35535. }
  35536. // ResetStatus resets all changes to the "status" field.
  35537. func (m *UsageStatisticMonthMutation) ResetStatus() {
  35538. m.status = nil
  35539. m.addstatus = nil
  35540. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  35541. }
  35542. // SetDeletedAt sets the "deleted_at" field.
  35543. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  35544. m.deleted_at = &t
  35545. }
  35546. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35547. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  35548. v := m.deleted_at
  35549. if v == nil {
  35550. return
  35551. }
  35552. return *v, true
  35553. }
  35554. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  35555. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35557. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35558. if !m.op.Is(OpUpdateOne) {
  35559. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35560. }
  35561. if m.id == nil || m.oldValue == nil {
  35562. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35563. }
  35564. oldValue, err := m.oldValue(ctx)
  35565. if err != nil {
  35566. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35567. }
  35568. return oldValue.DeletedAt, nil
  35569. }
  35570. // ClearDeletedAt clears the value of the "deleted_at" field.
  35571. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  35572. m.deleted_at = nil
  35573. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  35574. }
  35575. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35576. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  35577. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  35578. return ok
  35579. }
  35580. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35581. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  35582. m.deleted_at = nil
  35583. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  35584. }
  35585. // SetAddtime sets the "addtime" field.
  35586. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  35587. m.addtime = &u
  35588. m.addaddtime = nil
  35589. }
  35590. // Addtime returns the value of the "addtime" field in the mutation.
  35591. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  35592. v := m.addtime
  35593. if v == nil {
  35594. return
  35595. }
  35596. return *v, true
  35597. }
  35598. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  35599. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35601. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35602. if !m.op.Is(OpUpdateOne) {
  35603. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35604. }
  35605. if m.id == nil || m.oldValue == nil {
  35606. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35607. }
  35608. oldValue, err := m.oldValue(ctx)
  35609. if err != nil {
  35610. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35611. }
  35612. return oldValue.Addtime, nil
  35613. }
  35614. // AddAddtime adds u to the "addtime" field.
  35615. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  35616. if m.addaddtime != nil {
  35617. *m.addaddtime += u
  35618. } else {
  35619. m.addaddtime = &u
  35620. }
  35621. }
  35622. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35623. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  35624. v := m.addaddtime
  35625. if v == nil {
  35626. return
  35627. }
  35628. return *v, true
  35629. }
  35630. // ResetAddtime resets all changes to the "addtime" field.
  35631. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  35632. m.addtime = nil
  35633. m.addaddtime = nil
  35634. }
  35635. // SetType sets the "type" field.
  35636. func (m *UsageStatisticMonthMutation) SetType(i int) {
  35637. m._type = &i
  35638. m.add_type = nil
  35639. }
  35640. // GetType returns the value of the "type" field in the mutation.
  35641. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  35642. v := m._type
  35643. if v == nil {
  35644. return
  35645. }
  35646. return *v, true
  35647. }
  35648. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  35649. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35651. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  35652. if !m.op.Is(OpUpdateOne) {
  35653. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35654. }
  35655. if m.id == nil || m.oldValue == nil {
  35656. return v, errors.New("OldType requires an ID field in the mutation")
  35657. }
  35658. oldValue, err := m.oldValue(ctx)
  35659. if err != nil {
  35660. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35661. }
  35662. return oldValue.Type, nil
  35663. }
  35664. // AddType adds i to the "type" field.
  35665. func (m *UsageStatisticMonthMutation) AddType(i int) {
  35666. if m.add_type != nil {
  35667. *m.add_type += i
  35668. } else {
  35669. m.add_type = &i
  35670. }
  35671. }
  35672. // AddedType returns the value that was added to the "type" field in this mutation.
  35673. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  35674. v := m.add_type
  35675. if v == nil {
  35676. return
  35677. }
  35678. return *v, true
  35679. }
  35680. // ResetType resets all changes to the "type" field.
  35681. func (m *UsageStatisticMonthMutation) ResetType() {
  35682. m._type = nil
  35683. m.add_type = nil
  35684. }
  35685. // SetBotID sets the "bot_id" field.
  35686. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  35687. m.bot_id = &s
  35688. }
  35689. // BotID returns the value of the "bot_id" field in the mutation.
  35690. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  35691. v := m.bot_id
  35692. if v == nil {
  35693. return
  35694. }
  35695. return *v, true
  35696. }
  35697. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  35698. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35700. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  35701. if !m.op.Is(OpUpdateOne) {
  35702. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35703. }
  35704. if m.id == nil || m.oldValue == nil {
  35705. return v, errors.New("OldBotID requires an ID field in the mutation")
  35706. }
  35707. oldValue, err := m.oldValue(ctx)
  35708. if err != nil {
  35709. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35710. }
  35711. return oldValue.BotID, nil
  35712. }
  35713. // ClearBotID clears the value of the "bot_id" field.
  35714. func (m *UsageStatisticMonthMutation) ClearBotID() {
  35715. m.bot_id = nil
  35716. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  35717. }
  35718. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  35719. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  35720. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  35721. return ok
  35722. }
  35723. // ResetBotID resets all changes to the "bot_id" field.
  35724. func (m *UsageStatisticMonthMutation) ResetBotID() {
  35725. m.bot_id = nil
  35726. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  35727. }
  35728. // SetOrganizationID sets the "organization_id" field.
  35729. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  35730. m.organization_id = &u
  35731. m.addorganization_id = nil
  35732. }
  35733. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35734. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  35735. v := m.organization_id
  35736. if v == nil {
  35737. return
  35738. }
  35739. return *v, true
  35740. }
  35741. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  35742. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35744. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35745. if !m.op.Is(OpUpdateOne) {
  35746. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35747. }
  35748. if m.id == nil || m.oldValue == nil {
  35749. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35750. }
  35751. oldValue, err := m.oldValue(ctx)
  35752. if err != nil {
  35753. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35754. }
  35755. return oldValue.OrganizationID, nil
  35756. }
  35757. // AddOrganizationID adds u to the "organization_id" field.
  35758. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  35759. if m.addorganization_id != nil {
  35760. *m.addorganization_id += u
  35761. } else {
  35762. m.addorganization_id = &u
  35763. }
  35764. }
  35765. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35766. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  35767. v := m.addorganization_id
  35768. if v == nil {
  35769. return
  35770. }
  35771. return *v, true
  35772. }
  35773. // ClearOrganizationID clears the value of the "organization_id" field.
  35774. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  35775. m.organization_id = nil
  35776. m.addorganization_id = nil
  35777. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  35778. }
  35779. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35780. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  35781. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  35782. return ok
  35783. }
  35784. // ResetOrganizationID resets all changes to the "organization_id" field.
  35785. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  35786. m.organization_id = nil
  35787. m.addorganization_id = nil
  35788. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  35789. }
  35790. // SetAiResponse sets the "ai_response" field.
  35791. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  35792. m.ai_response = &u
  35793. m.addai_response = nil
  35794. }
  35795. // AiResponse returns the value of the "ai_response" field in the mutation.
  35796. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  35797. v := m.ai_response
  35798. if v == nil {
  35799. return
  35800. }
  35801. return *v, true
  35802. }
  35803. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  35804. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35806. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  35807. if !m.op.Is(OpUpdateOne) {
  35808. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  35809. }
  35810. if m.id == nil || m.oldValue == nil {
  35811. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  35812. }
  35813. oldValue, err := m.oldValue(ctx)
  35814. if err != nil {
  35815. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  35816. }
  35817. return oldValue.AiResponse, nil
  35818. }
  35819. // AddAiResponse adds u to the "ai_response" field.
  35820. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  35821. if m.addai_response != nil {
  35822. *m.addai_response += u
  35823. } else {
  35824. m.addai_response = &u
  35825. }
  35826. }
  35827. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  35828. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  35829. v := m.addai_response
  35830. if v == nil {
  35831. return
  35832. }
  35833. return *v, true
  35834. }
  35835. // ResetAiResponse resets all changes to the "ai_response" field.
  35836. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  35837. m.ai_response = nil
  35838. m.addai_response = nil
  35839. }
  35840. // SetSopRun sets the "sop_run" field.
  35841. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  35842. m.sop_run = &u
  35843. m.addsop_run = nil
  35844. }
  35845. // SopRun returns the value of the "sop_run" field in the mutation.
  35846. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  35847. v := m.sop_run
  35848. if v == nil {
  35849. return
  35850. }
  35851. return *v, true
  35852. }
  35853. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  35854. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35856. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  35857. if !m.op.Is(OpUpdateOne) {
  35858. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  35859. }
  35860. if m.id == nil || m.oldValue == nil {
  35861. return v, errors.New("OldSopRun requires an ID field in the mutation")
  35862. }
  35863. oldValue, err := m.oldValue(ctx)
  35864. if err != nil {
  35865. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  35866. }
  35867. return oldValue.SopRun, nil
  35868. }
  35869. // AddSopRun adds u to the "sop_run" field.
  35870. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  35871. if m.addsop_run != nil {
  35872. *m.addsop_run += u
  35873. } else {
  35874. m.addsop_run = &u
  35875. }
  35876. }
  35877. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  35878. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  35879. v := m.addsop_run
  35880. if v == nil {
  35881. return
  35882. }
  35883. return *v, true
  35884. }
  35885. // ResetSopRun resets all changes to the "sop_run" field.
  35886. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  35887. m.sop_run = nil
  35888. m.addsop_run = nil
  35889. }
  35890. // SetTotalFriend sets the "total_friend" field.
  35891. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  35892. m.total_friend = &u
  35893. m.addtotal_friend = nil
  35894. }
  35895. // TotalFriend returns the value of the "total_friend" field in the mutation.
  35896. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  35897. v := m.total_friend
  35898. if v == nil {
  35899. return
  35900. }
  35901. return *v, true
  35902. }
  35903. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  35904. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35906. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  35907. if !m.op.Is(OpUpdateOne) {
  35908. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  35909. }
  35910. if m.id == nil || m.oldValue == nil {
  35911. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  35912. }
  35913. oldValue, err := m.oldValue(ctx)
  35914. if err != nil {
  35915. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  35916. }
  35917. return oldValue.TotalFriend, nil
  35918. }
  35919. // AddTotalFriend adds u to the "total_friend" field.
  35920. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  35921. if m.addtotal_friend != nil {
  35922. *m.addtotal_friend += u
  35923. } else {
  35924. m.addtotal_friend = &u
  35925. }
  35926. }
  35927. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  35928. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  35929. v := m.addtotal_friend
  35930. if v == nil {
  35931. return
  35932. }
  35933. return *v, true
  35934. }
  35935. // ResetTotalFriend resets all changes to the "total_friend" field.
  35936. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  35937. m.total_friend = nil
  35938. m.addtotal_friend = nil
  35939. }
  35940. // SetTotalGroup sets the "total_group" field.
  35941. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  35942. m.total_group = &u
  35943. m.addtotal_group = nil
  35944. }
  35945. // TotalGroup returns the value of the "total_group" field in the mutation.
  35946. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  35947. v := m.total_group
  35948. if v == nil {
  35949. return
  35950. }
  35951. return *v, true
  35952. }
  35953. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  35954. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35956. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  35957. if !m.op.Is(OpUpdateOne) {
  35958. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  35959. }
  35960. if m.id == nil || m.oldValue == nil {
  35961. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  35962. }
  35963. oldValue, err := m.oldValue(ctx)
  35964. if err != nil {
  35965. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  35966. }
  35967. return oldValue.TotalGroup, nil
  35968. }
  35969. // AddTotalGroup adds u to the "total_group" field.
  35970. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  35971. if m.addtotal_group != nil {
  35972. *m.addtotal_group += u
  35973. } else {
  35974. m.addtotal_group = &u
  35975. }
  35976. }
  35977. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  35978. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  35979. v := m.addtotal_group
  35980. if v == nil {
  35981. return
  35982. }
  35983. return *v, true
  35984. }
  35985. // ResetTotalGroup resets all changes to the "total_group" field.
  35986. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  35987. m.total_group = nil
  35988. m.addtotal_group = nil
  35989. }
  35990. // SetAccountBalance sets the "account_balance" field.
  35991. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  35992. m.account_balance = &u
  35993. m.addaccount_balance = nil
  35994. }
  35995. // AccountBalance returns the value of the "account_balance" field in the mutation.
  35996. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  35997. v := m.account_balance
  35998. if v == nil {
  35999. return
  36000. }
  36001. return *v, true
  36002. }
  36003. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  36004. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36006. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36007. if !m.op.Is(OpUpdateOne) {
  36008. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36009. }
  36010. if m.id == nil || m.oldValue == nil {
  36011. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36012. }
  36013. oldValue, err := m.oldValue(ctx)
  36014. if err != nil {
  36015. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36016. }
  36017. return oldValue.AccountBalance, nil
  36018. }
  36019. // AddAccountBalance adds u to the "account_balance" field.
  36020. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  36021. if m.addaccount_balance != nil {
  36022. *m.addaccount_balance += u
  36023. } else {
  36024. m.addaccount_balance = &u
  36025. }
  36026. }
  36027. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36028. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  36029. v := m.addaccount_balance
  36030. if v == nil {
  36031. return
  36032. }
  36033. return *v, true
  36034. }
  36035. // ResetAccountBalance resets all changes to the "account_balance" field.
  36036. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  36037. m.account_balance = nil
  36038. m.addaccount_balance = nil
  36039. }
  36040. // SetConsumeToken sets the "consume_token" field.
  36041. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  36042. m.consume_token = &u
  36043. m.addconsume_token = nil
  36044. }
  36045. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36046. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  36047. v := m.consume_token
  36048. if v == nil {
  36049. return
  36050. }
  36051. return *v, true
  36052. }
  36053. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  36054. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36056. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36057. if !m.op.Is(OpUpdateOne) {
  36058. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36059. }
  36060. if m.id == nil || m.oldValue == nil {
  36061. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36062. }
  36063. oldValue, err := m.oldValue(ctx)
  36064. if err != nil {
  36065. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36066. }
  36067. return oldValue.ConsumeToken, nil
  36068. }
  36069. // AddConsumeToken adds u to the "consume_token" field.
  36070. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  36071. if m.addconsume_token != nil {
  36072. *m.addconsume_token += u
  36073. } else {
  36074. m.addconsume_token = &u
  36075. }
  36076. }
  36077. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36078. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  36079. v := m.addconsume_token
  36080. if v == nil {
  36081. return
  36082. }
  36083. return *v, true
  36084. }
  36085. // ResetConsumeToken resets all changes to the "consume_token" field.
  36086. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  36087. m.consume_token = nil
  36088. m.addconsume_token = nil
  36089. }
  36090. // SetActiveUser sets the "active_user" field.
  36091. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  36092. m.active_user = &u
  36093. m.addactive_user = nil
  36094. }
  36095. // ActiveUser returns the value of the "active_user" field in the mutation.
  36096. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  36097. v := m.active_user
  36098. if v == nil {
  36099. return
  36100. }
  36101. return *v, true
  36102. }
  36103. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  36104. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36106. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36107. if !m.op.Is(OpUpdateOne) {
  36108. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36109. }
  36110. if m.id == nil || m.oldValue == nil {
  36111. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36112. }
  36113. oldValue, err := m.oldValue(ctx)
  36114. if err != nil {
  36115. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36116. }
  36117. return oldValue.ActiveUser, nil
  36118. }
  36119. // AddActiveUser adds u to the "active_user" field.
  36120. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  36121. if m.addactive_user != nil {
  36122. *m.addactive_user += u
  36123. } else {
  36124. m.addactive_user = &u
  36125. }
  36126. }
  36127. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36128. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  36129. v := m.addactive_user
  36130. if v == nil {
  36131. return
  36132. }
  36133. return *v, true
  36134. }
  36135. // ResetActiveUser resets all changes to the "active_user" field.
  36136. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  36137. m.active_user = nil
  36138. m.addactive_user = nil
  36139. }
  36140. // SetNewUser sets the "new_user" field.
  36141. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  36142. m.new_user = &i
  36143. m.addnew_user = nil
  36144. }
  36145. // NewUser returns the value of the "new_user" field in the mutation.
  36146. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  36147. v := m.new_user
  36148. if v == nil {
  36149. return
  36150. }
  36151. return *v, true
  36152. }
  36153. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  36154. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36156. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36157. if !m.op.Is(OpUpdateOne) {
  36158. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36159. }
  36160. if m.id == nil || m.oldValue == nil {
  36161. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36162. }
  36163. oldValue, err := m.oldValue(ctx)
  36164. if err != nil {
  36165. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36166. }
  36167. return oldValue.NewUser, nil
  36168. }
  36169. // AddNewUser adds i to the "new_user" field.
  36170. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  36171. if m.addnew_user != nil {
  36172. *m.addnew_user += i
  36173. } else {
  36174. m.addnew_user = &i
  36175. }
  36176. }
  36177. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36178. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  36179. v := m.addnew_user
  36180. if v == nil {
  36181. return
  36182. }
  36183. return *v, true
  36184. }
  36185. // ResetNewUser resets all changes to the "new_user" field.
  36186. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  36187. m.new_user = nil
  36188. m.addnew_user = nil
  36189. }
  36190. // SetLabelDist sets the "label_dist" field.
  36191. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36192. m.label_dist = &ctd
  36193. m.appendlabel_dist = nil
  36194. }
  36195. // LabelDist returns the value of the "label_dist" field in the mutation.
  36196. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36197. v := m.label_dist
  36198. if v == nil {
  36199. return
  36200. }
  36201. return *v, true
  36202. }
  36203. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  36204. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36206. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36207. if !m.op.Is(OpUpdateOne) {
  36208. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36209. }
  36210. if m.id == nil || m.oldValue == nil {
  36211. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36212. }
  36213. oldValue, err := m.oldValue(ctx)
  36214. if err != nil {
  36215. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36216. }
  36217. return oldValue.LabelDist, nil
  36218. }
  36219. // AppendLabelDist adds ctd to the "label_dist" field.
  36220. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36221. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36222. }
  36223. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36224. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36225. if len(m.appendlabel_dist) == 0 {
  36226. return nil, false
  36227. }
  36228. return m.appendlabel_dist, true
  36229. }
  36230. // ResetLabelDist resets all changes to the "label_dist" field.
  36231. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  36232. m.label_dist = nil
  36233. m.appendlabel_dist = nil
  36234. }
  36235. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  36236. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  36237. m.predicates = append(m.predicates, ps...)
  36238. }
  36239. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  36240. // users can use type-assertion to append predicates that do not depend on any generated package.
  36241. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  36242. p := make([]predicate.UsageStatisticMonth, len(ps))
  36243. for i := range ps {
  36244. p[i] = ps[i]
  36245. }
  36246. m.Where(p...)
  36247. }
  36248. // Op returns the operation name.
  36249. func (m *UsageStatisticMonthMutation) Op() Op {
  36250. return m.op
  36251. }
  36252. // SetOp allows setting the mutation operation.
  36253. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  36254. m.op = op
  36255. }
  36256. // Type returns the node type of this mutation (UsageStatisticMonth).
  36257. func (m *UsageStatisticMonthMutation) Type() string {
  36258. return m.typ
  36259. }
  36260. // Fields returns all fields that were changed during this mutation. Note that in
  36261. // order to get all numeric fields that were incremented/decremented, call
  36262. // AddedFields().
  36263. func (m *UsageStatisticMonthMutation) Fields() []string {
  36264. fields := make([]string, 0, 17)
  36265. if m.created_at != nil {
  36266. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  36267. }
  36268. if m.updated_at != nil {
  36269. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  36270. }
  36271. if m.status != nil {
  36272. fields = append(fields, usagestatisticmonth.FieldStatus)
  36273. }
  36274. if m.deleted_at != nil {
  36275. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  36276. }
  36277. if m.addtime != nil {
  36278. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36279. }
  36280. if m._type != nil {
  36281. fields = append(fields, usagestatisticmonth.FieldType)
  36282. }
  36283. if m.bot_id != nil {
  36284. fields = append(fields, usagestatisticmonth.FieldBotID)
  36285. }
  36286. if m.organization_id != nil {
  36287. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36288. }
  36289. if m.ai_response != nil {
  36290. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36291. }
  36292. if m.sop_run != nil {
  36293. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36294. }
  36295. if m.total_friend != nil {
  36296. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36297. }
  36298. if m.total_group != nil {
  36299. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36300. }
  36301. if m.account_balance != nil {
  36302. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36303. }
  36304. if m.consume_token != nil {
  36305. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36306. }
  36307. if m.active_user != nil {
  36308. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36309. }
  36310. if m.new_user != nil {
  36311. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36312. }
  36313. if m.label_dist != nil {
  36314. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  36315. }
  36316. return fields
  36317. }
  36318. // Field returns the value of a field with the given name. The second boolean
  36319. // return value indicates that this field was not set, or was not defined in the
  36320. // schema.
  36321. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  36322. switch name {
  36323. case usagestatisticmonth.FieldCreatedAt:
  36324. return m.CreatedAt()
  36325. case usagestatisticmonth.FieldUpdatedAt:
  36326. return m.UpdatedAt()
  36327. case usagestatisticmonth.FieldStatus:
  36328. return m.Status()
  36329. case usagestatisticmonth.FieldDeletedAt:
  36330. return m.DeletedAt()
  36331. case usagestatisticmonth.FieldAddtime:
  36332. return m.Addtime()
  36333. case usagestatisticmonth.FieldType:
  36334. return m.GetType()
  36335. case usagestatisticmonth.FieldBotID:
  36336. return m.BotID()
  36337. case usagestatisticmonth.FieldOrganizationID:
  36338. return m.OrganizationID()
  36339. case usagestatisticmonth.FieldAiResponse:
  36340. return m.AiResponse()
  36341. case usagestatisticmonth.FieldSopRun:
  36342. return m.SopRun()
  36343. case usagestatisticmonth.FieldTotalFriend:
  36344. return m.TotalFriend()
  36345. case usagestatisticmonth.FieldTotalGroup:
  36346. return m.TotalGroup()
  36347. case usagestatisticmonth.FieldAccountBalance:
  36348. return m.AccountBalance()
  36349. case usagestatisticmonth.FieldConsumeToken:
  36350. return m.ConsumeToken()
  36351. case usagestatisticmonth.FieldActiveUser:
  36352. return m.ActiveUser()
  36353. case usagestatisticmonth.FieldNewUser:
  36354. return m.NewUser()
  36355. case usagestatisticmonth.FieldLabelDist:
  36356. return m.LabelDist()
  36357. }
  36358. return nil, false
  36359. }
  36360. // OldField returns the old value of the field from the database. An error is
  36361. // returned if the mutation operation is not UpdateOne, or the query to the
  36362. // database failed.
  36363. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36364. switch name {
  36365. case usagestatisticmonth.FieldCreatedAt:
  36366. return m.OldCreatedAt(ctx)
  36367. case usagestatisticmonth.FieldUpdatedAt:
  36368. return m.OldUpdatedAt(ctx)
  36369. case usagestatisticmonth.FieldStatus:
  36370. return m.OldStatus(ctx)
  36371. case usagestatisticmonth.FieldDeletedAt:
  36372. return m.OldDeletedAt(ctx)
  36373. case usagestatisticmonth.FieldAddtime:
  36374. return m.OldAddtime(ctx)
  36375. case usagestatisticmonth.FieldType:
  36376. return m.OldType(ctx)
  36377. case usagestatisticmonth.FieldBotID:
  36378. return m.OldBotID(ctx)
  36379. case usagestatisticmonth.FieldOrganizationID:
  36380. return m.OldOrganizationID(ctx)
  36381. case usagestatisticmonth.FieldAiResponse:
  36382. return m.OldAiResponse(ctx)
  36383. case usagestatisticmonth.FieldSopRun:
  36384. return m.OldSopRun(ctx)
  36385. case usagestatisticmonth.FieldTotalFriend:
  36386. return m.OldTotalFriend(ctx)
  36387. case usagestatisticmonth.FieldTotalGroup:
  36388. return m.OldTotalGroup(ctx)
  36389. case usagestatisticmonth.FieldAccountBalance:
  36390. return m.OldAccountBalance(ctx)
  36391. case usagestatisticmonth.FieldConsumeToken:
  36392. return m.OldConsumeToken(ctx)
  36393. case usagestatisticmonth.FieldActiveUser:
  36394. return m.OldActiveUser(ctx)
  36395. case usagestatisticmonth.FieldNewUser:
  36396. return m.OldNewUser(ctx)
  36397. case usagestatisticmonth.FieldLabelDist:
  36398. return m.OldLabelDist(ctx)
  36399. }
  36400. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36401. }
  36402. // SetField sets the value of a field with the given name. It returns an error if
  36403. // the field is not defined in the schema, or if the type mismatched the field
  36404. // type.
  36405. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  36406. switch name {
  36407. case usagestatisticmonth.FieldCreatedAt:
  36408. v, ok := value.(time.Time)
  36409. if !ok {
  36410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36411. }
  36412. m.SetCreatedAt(v)
  36413. return nil
  36414. case usagestatisticmonth.FieldUpdatedAt:
  36415. v, ok := value.(time.Time)
  36416. if !ok {
  36417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36418. }
  36419. m.SetUpdatedAt(v)
  36420. return nil
  36421. case usagestatisticmonth.FieldStatus:
  36422. v, ok := value.(uint8)
  36423. if !ok {
  36424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36425. }
  36426. m.SetStatus(v)
  36427. return nil
  36428. case usagestatisticmonth.FieldDeletedAt:
  36429. v, ok := value.(time.Time)
  36430. if !ok {
  36431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36432. }
  36433. m.SetDeletedAt(v)
  36434. return nil
  36435. case usagestatisticmonth.FieldAddtime:
  36436. v, ok := value.(uint64)
  36437. if !ok {
  36438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36439. }
  36440. m.SetAddtime(v)
  36441. return nil
  36442. case usagestatisticmonth.FieldType:
  36443. v, ok := value.(int)
  36444. if !ok {
  36445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36446. }
  36447. m.SetType(v)
  36448. return nil
  36449. case usagestatisticmonth.FieldBotID:
  36450. v, ok := value.(string)
  36451. if !ok {
  36452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36453. }
  36454. m.SetBotID(v)
  36455. return nil
  36456. case usagestatisticmonth.FieldOrganizationID:
  36457. v, ok := value.(uint64)
  36458. if !ok {
  36459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36460. }
  36461. m.SetOrganizationID(v)
  36462. return nil
  36463. case usagestatisticmonth.FieldAiResponse:
  36464. v, ok := value.(uint64)
  36465. if !ok {
  36466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36467. }
  36468. m.SetAiResponse(v)
  36469. return nil
  36470. case usagestatisticmonth.FieldSopRun:
  36471. v, ok := value.(uint64)
  36472. if !ok {
  36473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36474. }
  36475. m.SetSopRun(v)
  36476. return nil
  36477. case usagestatisticmonth.FieldTotalFriend:
  36478. v, ok := value.(uint64)
  36479. if !ok {
  36480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36481. }
  36482. m.SetTotalFriend(v)
  36483. return nil
  36484. case usagestatisticmonth.FieldTotalGroup:
  36485. v, ok := value.(uint64)
  36486. if !ok {
  36487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36488. }
  36489. m.SetTotalGroup(v)
  36490. return nil
  36491. case usagestatisticmonth.FieldAccountBalance:
  36492. v, ok := value.(uint64)
  36493. if !ok {
  36494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36495. }
  36496. m.SetAccountBalance(v)
  36497. return nil
  36498. case usagestatisticmonth.FieldConsumeToken:
  36499. v, ok := value.(uint64)
  36500. if !ok {
  36501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36502. }
  36503. m.SetConsumeToken(v)
  36504. return nil
  36505. case usagestatisticmonth.FieldActiveUser:
  36506. v, ok := value.(uint64)
  36507. if !ok {
  36508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36509. }
  36510. m.SetActiveUser(v)
  36511. return nil
  36512. case usagestatisticmonth.FieldNewUser:
  36513. v, ok := value.(int64)
  36514. if !ok {
  36515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36516. }
  36517. m.SetNewUser(v)
  36518. return nil
  36519. case usagestatisticmonth.FieldLabelDist:
  36520. v, ok := value.([]custom_types.LabelDist)
  36521. if !ok {
  36522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36523. }
  36524. m.SetLabelDist(v)
  36525. return nil
  36526. }
  36527. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36528. }
  36529. // AddedFields returns all numeric fields that were incremented/decremented during
  36530. // this mutation.
  36531. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  36532. var fields []string
  36533. if m.addstatus != nil {
  36534. fields = append(fields, usagestatisticmonth.FieldStatus)
  36535. }
  36536. if m.addaddtime != nil {
  36537. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36538. }
  36539. if m.add_type != nil {
  36540. fields = append(fields, usagestatisticmonth.FieldType)
  36541. }
  36542. if m.addorganization_id != nil {
  36543. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36544. }
  36545. if m.addai_response != nil {
  36546. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36547. }
  36548. if m.addsop_run != nil {
  36549. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36550. }
  36551. if m.addtotal_friend != nil {
  36552. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36553. }
  36554. if m.addtotal_group != nil {
  36555. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36556. }
  36557. if m.addaccount_balance != nil {
  36558. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36559. }
  36560. if m.addconsume_token != nil {
  36561. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36562. }
  36563. if m.addactive_user != nil {
  36564. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36565. }
  36566. if m.addnew_user != nil {
  36567. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36568. }
  36569. return fields
  36570. }
  36571. // AddedField returns the numeric value that was incremented/decremented on a field
  36572. // with the given name. The second boolean return value indicates that this field
  36573. // was not set, or was not defined in the schema.
  36574. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  36575. switch name {
  36576. case usagestatisticmonth.FieldStatus:
  36577. return m.AddedStatus()
  36578. case usagestatisticmonth.FieldAddtime:
  36579. return m.AddedAddtime()
  36580. case usagestatisticmonth.FieldType:
  36581. return m.AddedType()
  36582. case usagestatisticmonth.FieldOrganizationID:
  36583. return m.AddedOrganizationID()
  36584. case usagestatisticmonth.FieldAiResponse:
  36585. return m.AddedAiResponse()
  36586. case usagestatisticmonth.FieldSopRun:
  36587. return m.AddedSopRun()
  36588. case usagestatisticmonth.FieldTotalFriend:
  36589. return m.AddedTotalFriend()
  36590. case usagestatisticmonth.FieldTotalGroup:
  36591. return m.AddedTotalGroup()
  36592. case usagestatisticmonth.FieldAccountBalance:
  36593. return m.AddedAccountBalance()
  36594. case usagestatisticmonth.FieldConsumeToken:
  36595. return m.AddedConsumeToken()
  36596. case usagestatisticmonth.FieldActiveUser:
  36597. return m.AddedActiveUser()
  36598. case usagestatisticmonth.FieldNewUser:
  36599. return m.AddedNewUser()
  36600. }
  36601. return nil, false
  36602. }
  36603. // AddField adds the value to the field with the given name. It returns an error if
  36604. // the field is not defined in the schema, or if the type mismatched the field
  36605. // type.
  36606. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  36607. switch name {
  36608. case usagestatisticmonth.FieldStatus:
  36609. v, ok := value.(int8)
  36610. if !ok {
  36611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36612. }
  36613. m.AddStatus(v)
  36614. return nil
  36615. case usagestatisticmonth.FieldAddtime:
  36616. v, ok := value.(int64)
  36617. if !ok {
  36618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36619. }
  36620. m.AddAddtime(v)
  36621. return nil
  36622. case usagestatisticmonth.FieldType:
  36623. v, ok := value.(int)
  36624. if !ok {
  36625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36626. }
  36627. m.AddType(v)
  36628. return nil
  36629. case usagestatisticmonth.FieldOrganizationID:
  36630. v, ok := value.(int64)
  36631. if !ok {
  36632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36633. }
  36634. m.AddOrganizationID(v)
  36635. return nil
  36636. case usagestatisticmonth.FieldAiResponse:
  36637. v, ok := value.(int64)
  36638. if !ok {
  36639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36640. }
  36641. m.AddAiResponse(v)
  36642. return nil
  36643. case usagestatisticmonth.FieldSopRun:
  36644. v, ok := value.(int64)
  36645. if !ok {
  36646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36647. }
  36648. m.AddSopRun(v)
  36649. return nil
  36650. case usagestatisticmonth.FieldTotalFriend:
  36651. v, ok := value.(int64)
  36652. if !ok {
  36653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36654. }
  36655. m.AddTotalFriend(v)
  36656. return nil
  36657. case usagestatisticmonth.FieldTotalGroup:
  36658. v, ok := value.(int64)
  36659. if !ok {
  36660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36661. }
  36662. m.AddTotalGroup(v)
  36663. return nil
  36664. case usagestatisticmonth.FieldAccountBalance:
  36665. v, ok := value.(int64)
  36666. if !ok {
  36667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36668. }
  36669. m.AddAccountBalance(v)
  36670. return nil
  36671. case usagestatisticmonth.FieldConsumeToken:
  36672. v, ok := value.(int64)
  36673. if !ok {
  36674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36675. }
  36676. m.AddConsumeToken(v)
  36677. return nil
  36678. case usagestatisticmonth.FieldActiveUser:
  36679. v, ok := value.(int64)
  36680. if !ok {
  36681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36682. }
  36683. m.AddActiveUser(v)
  36684. return nil
  36685. case usagestatisticmonth.FieldNewUser:
  36686. v, ok := value.(int64)
  36687. if !ok {
  36688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36689. }
  36690. m.AddNewUser(v)
  36691. return nil
  36692. }
  36693. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  36694. }
  36695. // ClearedFields returns all nullable fields that were cleared during this
  36696. // mutation.
  36697. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  36698. var fields []string
  36699. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  36700. fields = append(fields, usagestatisticmonth.FieldStatus)
  36701. }
  36702. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  36703. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  36704. }
  36705. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  36706. fields = append(fields, usagestatisticmonth.FieldBotID)
  36707. }
  36708. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  36709. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36710. }
  36711. return fields
  36712. }
  36713. // FieldCleared returns a boolean indicating if a field with the given name was
  36714. // cleared in this mutation.
  36715. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  36716. _, ok := m.clearedFields[name]
  36717. return ok
  36718. }
  36719. // ClearField clears the value of the field with the given name. It returns an
  36720. // error if the field is not defined in the schema.
  36721. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  36722. switch name {
  36723. case usagestatisticmonth.FieldStatus:
  36724. m.ClearStatus()
  36725. return nil
  36726. case usagestatisticmonth.FieldDeletedAt:
  36727. m.ClearDeletedAt()
  36728. return nil
  36729. case usagestatisticmonth.FieldBotID:
  36730. m.ClearBotID()
  36731. return nil
  36732. case usagestatisticmonth.FieldOrganizationID:
  36733. m.ClearOrganizationID()
  36734. return nil
  36735. }
  36736. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  36737. }
  36738. // ResetField resets all changes in the mutation for the field with the given name.
  36739. // It returns an error if the field is not defined in the schema.
  36740. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  36741. switch name {
  36742. case usagestatisticmonth.FieldCreatedAt:
  36743. m.ResetCreatedAt()
  36744. return nil
  36745. case usagestatisticmonth.FieldUpdatedAt:
  36746. m.ResetUpdatedAt()
  36747. return nil
  36748. case usagestatisticmonth.FieldStatus:
  36749. m.ResetStatus()
  36750. return nil
  36751. case usagestatisticmonth.FieldDeletedAt:
  36752. m.ResetDeletedAt()
  36753. return nil
  36754. case usagestatisticmonth.FieldAddtime:
  36755. m.ResetAddtime()
  36756. return nil
  36757. case usagestatisticmonth.FieldType:
  36758. m.ResetType()
  36759. return nil
  36760. case usagestatisticmonth.FieldBotID:
  36761. m.ResetBotID()
  36762. return nil
  36763. case usagestatisticmonth.FieldOrganizationID:
  36764. m.ResetOrganizationID()
  36765. return nil
  36766. case usagestatisticmonth.FieldAiResponse:
  36767. m.ResetAiResponse()
  36768. return nil
  36769. case usagestatisticmonth.FieldSopRun:
  36770. m.ResetSopRun()
  36771. return nil
  36772. case usagestatisticmonth.FieldTotalFriend:
  36773. m.ResetTotalFriend()
  36774. return nil
  36775. case usagestatisticmonth.FieldTotalGroup:
  36776. m.ResetTotalGroup()
  36777. return nil
  36778. case usagestatisticmonth.FieldAccountBalance:
  36779. m.ResetAccountBalance()
  36780. return nil
  36781. case usagestatisticmonth.FieldConsumeToken:
  36782. m.ResetConsumeToken()
  36783. return nil
  36784. case usagestatisticmonth.FieldActiveUser:
  36785. m.ResetActiveUser()
  36786. return nil
  36787. case usagestatisticmonth.FieldNewUser:
  36788. m.ResetNewUser()
  36789. return nil
  36790. case usagestatisticmonth.FieldLabelDist:
  36791. m.ResetLabelDist()
  36792. return nil
  36793. }
  36794. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36795. }
  36796. // AddedEdges returns all edge names that were set/added in this mutation.
  36797. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  36798. edges := make([]string, 0, 0)
  36799. return edges
  36800. }
  36801. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36802. // name in this mutation.
  36803. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  36804. return nil
  36805. }
  36806. // RemovedEdges returns all edge names that were removed in this mutation.
  36807. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  36808. edges := make([]string, 0, 0)
  36809. return edges
  36810. }
  36811. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36812. // the given name in this mutation.
  36813. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  36814. return nil
  36815. }
  36816. // ClearedEdges returns all edge names that were cleared in this mutation.
  36817. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  36818. edges := make([]string, 0, 0)
  36819. return edges
  36820. }
  36821. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36822. // was cleared in this mutation.
  36823. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  36824. return false
  36825. }
  36826. // ClearEdge clears the value of the edge with the given name. It returns an error
  36827. // if that edge is not defined in the schema.
  36828. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  36829. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  36830. }
  36831. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36832. // It returns an error if the edge is not defined in the schema.
  36833. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  36834. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  36835. }
  36836. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  36837. type UsageTotalMutation struct {
  36838. config
  36839. op Op
  36840. typ string
  36841. id *uint64
  36842. created_at *time.Time
  36843. updated_at *time.Time
  36844. status *uint8
  36845. addstatus *int8
  36846. _type *int
  36847. add_type *int
  36848. bot_id *string
  36849. total_tokens *uint64
  36850. addtotal_tokens *int64
  36851. start_index *uint64
  36852. addstart_index *int64
  36853. end_index *uint64
  36854. addend_index *int64
  36855. organization_id *uint64
  36856. addorganization_id *int64
  36857. clearedFields map[string]struct{}
  36858. done bool
  36859. oldValue func(context.Context) (*UsageTotal, error)
  36860. predicates []predicate.UsageTotal
  36861. }
  36862. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  36863. // usagetotalOption allows management of the mutation configuration using functional options.
  36864. type usagetotalOption func(*UsageTotalMutation)
  36865. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  36866. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  36867. m := &UsageTotalMutation{
  36868. config: c,
  36869. op: op,
  36870. typ: TypeUsageTotal,
  36871. clearedFields: make(map[string]struct{}),
  36872. }
  36873. for _, opt := range opts {
  36874. opt(m)
  36875. }
  36876. return m
  36877. }
  36878. // withUsageTotalID sets the ID field of the mutation.
  36879. func withUsageTotalID(id uint64) usagetotalOption {
  36880. return func(m *UsageTotalMutation) {
  36881. var (
  36882. err error
  36883. once sync.Once
  36884. value *UsageTotal
  36885. )
  36886. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  36887. once.Do(func() {
  36888. if m.done {
  36889. err = errors.New("querying old values post mutation is not allowed")
  36890. } else {
  36891. value, err = m.Client().UsageTotal.Get(ctx, id)
  36892. }
  36893. })
  36894. return value, err
  36895. }
  36896. m.id = &id
  36897. }
  36898. }
  36899. // withUsageTotal sets the old UsageTotal of the mutation.
  36900. func withUsageTotal(node *UsageTotal) usagetotalOption {
  36901. return func(m *UsageTotalMutation) {
  36902. m.oldValue = func(context.Context) (*UsageTotal, error) {
  36903. return node, nil
  36904. }
  36905. m.id = &node.ID
  36906. }
  36907. }
  36908. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36909. // executed in a transaction (ent.Tx), a transactional client is returned.
  36910. func (m UsageTotalMutation) Client() *Client {
  36911. client := &Client{config: m.config}
  36912. client.init()
  36913. return client
  36914. }
  36915. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36916. // it returns an error otherwise.
  36917. func (m UsageTotalMutation) Tx() (*Tx, error) {
  36918. if _, ok := m.driver.(*txDriver); !ok {
  36919. return nil, errors.New("ent: mutation is not running in a transaction")
  36920. }
  36921. tx := &Tx{config: m.config}
  36922. tx.init()
  36923. return tx, nil
  36924. }
  36925. // SetID sets the value of the id field. Note that this
  36926. // operation is only accepted on creation of UsageTotal entities.
  36927. func (m *UsageTotalMutation) SetID(id uint64) {
  36928. m.id = &id
  36929. }
  36930. // ID returns the ID value in the mutation. Note that the ID is only available
  36931. // if it was provided to the builder or after it was returned from the database.
  36932. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  36933. if m.id == nil {
  36934. return
  36935. }
  36936. return *m.id, true
  36937. }
  36938. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36939. // That means, if the mutation is applied within a transaction with an isolation level such
  36940. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36941. // or updated by the mutation.
  36942. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  36943. switch {
  36944. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36945. id, exists := m.ID()
  36946. if exists {
  36947. return []uint64{id}, nil
  36948. }
  36949. fallthrough
  36950. case m.op.Is(OpUpdate | OpDelete):
  36951. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  36952. default:
  36953. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36954. }
  36955. }
  36956. // SetCreatedAt sets the "created_at" field.
  36957. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  36958. m.created_at = &t
  36959. }
  36960. // CreatedAt returns the value of the "created_at" field in the mutation.
  36961. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  36962. v := m.created_at
  36963. if v == nil {
  36964. return
  36965. }
  36966. return *v, true
  36967. }
  36968. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  36969. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36971. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36972. if !m.op.Is(OpUpdateOne) {
  36973. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36974. }
  36975. if m.id == nil || m.oldValue == nil {
  36976. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36977. }
  36978. oldValue, err := m.oldValue(ctx)
  36979. if err != nil {
  36980. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36981. }
  36982. return oldValue.CreatedAt, nil
  36983. }
  36984. // ResetCreatedAt resets all changes to the "created_at" field.
  36985. func (m *UsageTotalMutation) ResetCreatedAt() {
  36986. m.created_at = nil
  36987. }
  36988. // SetUpdatedAt sets the "updated_at" field.
  36989. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  36990. m.updated_at = &t
  36991. }
  36992. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36993. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  36994. v := m.updated_at
  36995. if v == nil {
  36996. return
  36997. }
  36998. return *v, true
  36999. }
  37000. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37004. if !m.op.Is(OpUpdateOne) {
  37005. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37006. }
  37007. if m.id == nil || m.oldValue == nil {
  37008. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  37013. }
  37014. return oldValue.UpdatedAt, nil
  37015. }
  37016. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37017. func (m *UsageTotalMutation) ResetUpdatedAt() {
  37018. m.updated_at = nil
  37019. }
  37020. // SetStatus sets the "status" field.
  37021. func (m *UsageTotalMutation) SetStatus(u uint8) {
  37022. m.status = &u
  37023. m.addstatus = nil
  37024. }
  37025. // Status returns the value of the "status" field in the mutation.
  37026. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  37027. v := m.status
  37028. if v == nil {
  37029. return
  37030. }
  37031. return *v, true
  37032. }
  37033. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  37034. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37036. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37037. if !m.op.Is(OpUpdateOne) {
  37038. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37039. }
  37040. if m.id == nil || m.oldValue == nil {
  37041. return v, errors.New("OldStatus requires an ID field in the mutation")
  37042. }
  37043. oldValue, err := m.oldValue(ctx)
  37044. if err != nil {
  37045. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37046. }
  37047. return oldValue.Status, nil
  37048. }
  37049. // AddStatus adds u to the "status" field.
  37050. func (m *UsageTotalMutation) AddStatus(u int8) {
  37051. if m.addstatus != nil {
  37052. *m.addstatus += u
  37053. } else {
  37054. m.addstatus = &u
  37055. }
  37056. }
  37057. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37058. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  37059. v := m.addstatus
  37060. if v == nil {
  37061. return
  37062. }
  37063. return *v, true
  37064. }
  37065. // ClearStatus clears the value of the "status" field.
  37066. func (m *UsageTotalMutation) ClearStatus() {
  37067. m.status = nil
  37068. m.addstatus = nil
  37069. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  37070. }
  37071. // StatusCleared returns if the "status" field was cleared in this mutation.
  37072. func (m *UsageTotalMutation) StatusCleared() bool {
  37073. _, ok := m.clearedFields[usagetotal.FieldStatus]
  37074. return ok
  37075. }
  37076. // ResetStatus resets all changes to the "status" field.
  37077. func (m *UsageTotalMutation) ResetStatus() {
  37078. m.status = nil
  37079. m.addstatus = nil
  37080. delete(m.clearedFields, usagetotal.FieldStatus)
  37081. }
  37082. // SetType sets the "type" field.
  37083. func (m *UsageTotalMutation) SetType(i int) {
  37084. m._type = &i
  37085. m.add_type = nil
  37086. }
  37087. // GetType returns the value of the "type" field in the mutation.
  37088. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  37089. v := m._type
  37090. if v == nil {
  37091. return
  37092. }
  37093. return *v, true
  37094. }
  37095. // OldType returns the old "type" field's value of the UsageTotal entity.
  37096. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37098. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  37099. if !m.op.Is(OpUpdateOne) {
  37100. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37101. }
  37102. if m.id == nil || m.oldValue == nil {
  37103. return v, errors.New("OldType requires an ID field in the mutation")
  37104. }
  37105. oldValue, err := m.oldValue(ctx)
  37106. if err != nil {
  37107. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37108. }
  37109. return oldValue.Type, nil
  37110. }
  37111. // AddType adds i to the "type" field.
  37112. func (m *UsageTotalMutation) AddType(i int) {
  37113. if m.add_type != nil {
  37114. *m.add_type += i
  37115. } else {
  37116. m.add_type = &i
  37117. }
  37118. }
  37119. // AddedType returns the value that was added to the "type" field in this mutation.
  37120. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  37121. v := m.add_type
  37122. if v == nil {
  37123. return
  37124. }
  37125. return *v, true
  37126. }
  37127. // ClearType clears the value of the "type" field.
  37128. func (m *UsageTotalMutation) ClearType() {
  37129. m._type = nil
  37130. m.add_type = nil
  37131. m.clearedFields[usagetotal.FieldType] = struct{}{}
  37132. }
  37133. // TypeCleared returns if the "type" field was cleared in this mutation.
  37134. func (m *UsageTotalMutation) TypeCleared() bool {
  37135. _, ok := m.clearedFields[usagetotal.FieldType]
  37136. return ok
  37137. }
  37138. // ResetType resets all changes to the "type" field.
  37139. func (m *UsageTotalMutation) ResetType() {
  37140. m._type = nil
  37141. m.add_type = nil
  37142. delete(m.clearedFields, usagetotal.FieldType)
  37143. }
  37144. // SetBotID sets the "bot_id" field.
  37145. func (m *UsageTotalMutation) SetBotID(s string) {
  37146. m.bot_id = &s
  37147. }
  37148. // BotID returns the value of the "bot_id" field in the mutation.
  37149. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  37150. v := m.bot_id
  37151. if v == nil {
  37152. return
  37153. }
  37154. return *v, true
  37155. }
  37156. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  37157. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37159. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  37160. if !m.op.Is(OpUpdateOne) {
  37161. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37162. }
  37163. if m.id == nil || m.oldValue == nil {
  37164. return v, errors.New("OldBotID requires an ID field in the mutation")
  37165. }
  37166. oldValue, err := m.oldValue(ctx)
  37167. if err != nil {
  37168. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37169. }
  37170. return oldValue.BotID, nil
  37171. }
  37172. // ResetBotID resets all changes to the "bot_id" field.
  37173. func (m *UsageTotalMutation) ResetBotID() {
  37174. m.bot_id = nil
  37175. }
  37176. // SetTotalTokens sets the "total_tokens" field.
  37177. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  37178. m.total_tokens = &u
  37179. m.addtotal_tokens = nil
  37180. }
  37181. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  37182. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  37183. v := m.total_tokens
  37184. if v == nil {
  37185. return
  37186. }
  37187. return *v, true
  37188. }
  37189. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  37190. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37192. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  37193. if !m.op.Is(OpUpdateOne) {
  37194. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  37195. }
  37196. if m.id == nil || m.oldValue == nil {
  37197. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  37198. }
  37199. oldValue, err := m.oldValue(ctx)
  37200. if err != nil {
  37201. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  37202. }
  37203. return oldValue.TotalTokens, nil
  37204. }
  37205. // AddTotalTokens adds u to the "total_tokens" field.
  37206. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  37207. if m.addtotal_tokens != nil {
  37208. *m.addtotal_tokens += u
  37209. } else {
  37210. m.addtotal_tokens = &u
  37211. }
  37212. }
  37213. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  37214. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  37215. v := m.addtotal_tokens
  37216. if v == nil {
  37217. return
  37218. }
  37219. return *v, true
  37220. }
  37221. // ClearTotalTokens clears the value of the "total_tokens" field.
  37222. func (m *UsageTotalMutation) ClearTotalTokens() {
  37223. m.total_tokens = nil
  37224. m.addtotal_tokens = nil
  37225. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  37226. }
  37227. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  37228. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  37229. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  37230. return ok
  37231. }
  37232. // ResetTotalTokens resets all changes to the "total_tokens" field.
  37233. func (m *UsageTotalMutation) ResetTotalTokens() {
  37234. m.total_tokens = nil
  37235. m.addtotal_tokens = nil
  37236. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  37237. }
  37238. // SetStartIndex sets the "start_index" field.
  37239. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  37240. m.start_index = &u
  37241. m.addstart_index = nil
  37242. }
  37243. // StartIndex returns the value of the "start_index" field in the mutation.
  37244. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  37245. v := m.start_index
  37246. if v == nil {
  37247. return
  37248. }
  37249. return *v, true
  37250. }
  37251. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  37252. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37254. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  37255. if !m.op.Is(OpUpdateOne) {
  37256. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  37257. }
  37258. if m.id == nil || m.oldValue == nil {
  37259. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  37260. }
  37261. oldValue, err := m.oldValue(ctx)
  37262. if err != nil {
  37263. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  37264. }
  37265. return oldValue.StartIndex, nil
  37266. }
  37267. // AddStartIndex adds u to the "start_index" field.
  37268. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  37269. if m.addstart_index != nil {
  37270. *m.addstart_index += u
  37271. } else {
  37272. m.addstart_index = &u
  37273. }
  37274. }
  37275. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  37276. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  37277. v := m.addstart_index
  37278. if v == nil {
  37279. return
  37280. }
  37281. return *v, true
  37282. }
  37283. // ClearStartIndex clears the value of the "start_index" field.
  37284. func (m *UsageTotalMutation) ClearStartIndex() {
  37285. m.start_index = nil
  37286. m.addstart_index = nil
  37287. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  37288. }
  37289. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  37290. func (m *UsageTotalMutation) StartIndexCleared() bool {
  37291. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  37292. return ok
  37293. }
  37294. // ResetStartIndex resets all changes to the "start_index" field.
  37295. func (m *UsageTotalMutation) ResetStartIndex() {
  37296. m.start_index = nil
  37297. m.addstart_index = nil
  37298. delete(m.clearedFields, usagetotal.FieldStartIndex)
  37299. }
  37300. // SetEndIndex sets the "end_index" field.
  37301. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  37302. m.end_index = &u
  37303. m.addend_index = nil
  37304. }
  37305. // EndIndex returns the value of the "end_index" field in the mutation.
  37306. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  37307. v := m.end_index
  37308. if v == nil {
  37309. return
  37310. }
  37311. return *v, true
  37312. }
  37313. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  37314. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37316. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  37317. if !m.op.Is(OpUpdateOne) {
  37318. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  37319. }
  37320. if m.id == nil || m.oldValue == nil {
  37321. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  37322. }
  37323. oldValue, err := m.oldValue(ctx)
  37324. if err != nil {
  37325. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  37326. }
  37327. return oldValue.EndIndex, nil
  37328. }
  37329. // AddEndIndex adds u to the "end_index" field.
  37330. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  37331. if m.addend_index != nil {
  37332. *m.addend_index += u
  37333. } else {
  37334. m.addend_index = &u
  37335. }
  37336. }
  37337. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  37338. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  37339. v := m.addend_index
  37340. if v == nil {
  37341. return
  37342. }
  37343. return *v, true
  37344. }
  37345. // ClearEndIndex clears the value of the "end_index" field.
  37346. func (m *UsageTotalMutation) ClearEndIndex() {
  37347. m.end_index = nil
  37348. m.addend_index = nil
  37349. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  37350. }
  37351. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  37352. func (m *UsageTotalMutation) EndIndexCleared() bool {
  37353. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  37354. return ok
  37355. }
  37356. // ResetEndIndex resets all changes to the "end_index" field.
  37357. func (m *UsageTotalMutation) ResetEndIndex() {
  37358. m.end_index = nil
  37359. m.addend_index = nil
  37360. delete(m.clearedFields, usagetotal.FieldEndIndex)
  37361. }
  37362. // SetOrganizationID sets the "organization_id" field.
  37363. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  37364. m.organization_id = &u
  37365. m.addorganization_id = nil
  37366. }
  37367. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37368. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  37369. v := m.organization_id
  37370. if v == nil {
  37371. return
  37372. }
  37373. return *v, true
  37374. }
  37375. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  37376. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37378. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37379. if !m.op.Is(OpUpdateOne) {
  37380. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37381. }
  37382. if m.id == nil || m.oldValue == nil {
  37383. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37384. }
  37385. oldValue, err := m.oldValue(ctx)
  37386. if err != nil {
  37387. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37388. }
  37389. return oldValue.OrganizationID, nil
  37390. }
  37391. // AddOrganizationID adds u to the "organization_id" field.
  37392. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  37393. if m.addorganization_id != nil {
  37394. *m.addorganization_id += u
  37395. } else {
  37396. m.addorganization_id = &u
  37397. }
  37398. }
  37399. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37400. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  37401. v := m.addorganization_id
  37402. if v == nil {
  37403. return
  37404. }
  37405. return *v, true
  37406. }
  37407. // ClearOrganizationID clears the value of the "organization_id" field.
  37408. func (m *UsageTotalMutation) ClearOrganizationID() {
  37409. m.organization_id = nil
  37410. m.addorganization_id = nil
  37411. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  37412. }
  37413. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37414. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  37415. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  37416. return ok
  37417. }
  37418. // ResetOrganizationID resets all changes to the "organization_id" field.
  37419. func (m *UsageTotalMutation) ResetOrganizationID() {
  37420. m.organization_id = nil
  37421. m.addorganization_id = nil
  37422. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  37423. }
  37424. // Where appends a list predicates to the UsageTotalMutation builder.
  37425. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  37426. m.predicates = append(m.predicates, ps...)
  37427. }
  37428. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  37429. // users can use type-assertion to append predicates that do not depend on any generated package.
  37430. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  37431. p := make([]predicate.UsageTotal, len(ps))
  37432. for i := range ps {
  37433. p[i] = ps[i]
  37434. }
  37435. m.Where(p...)
  37436. }
  37437. // Op returns the operation name.
  37438. func (m *UsageTotalMutation) Op() Op {
  37439. return m.op
  37440. }
  37441. // SetOp allows setting the mutation operation.
  37442. func (m *UsageTotalMutation) SetOp(op Op) {
  37443. m.op = op
  37444. }
  37445. // Type returns the node type of this mutation (UsageTotal).
  37446. func (m *UsageTotalMutation) Type() string {
  37447. return m.typ
  37448. }
  37449. // Fields returns all fields that were changed during this mutation. Note that in
  37450. // order to get all numeric fields that were incremented/decremented, call
  37451. // AddedFields().
  37452. func (m *UsageTotalMutation) Fields() []string {
  37453. fields := make([]string, 0, 9)
  37454. if m.created_at != nil {
  37455. fields = append(fields, usagetotal.FieldCreatedAt)
  37456. }
  37457. if m.updated_at != nil {
  37458. fields = append(fields, usagetotal.FieldUpdatedAt)
  37459. }
  37460. if m.status != nil {
  37461. fields = append(fields, usagetotal.FieldStatus)
  37462. }
  37463. if m._type != nil {
  37464. fields = append(fields, usagetotal.FieldType)
  37465. }
  37466. if m.bot_id != nil {
  37467. fields = append(fields, usagetotal.FieldBotID)
  37468. }
  37469. if m.total_tokens != nil {
  37470. fields = append(fields, usagetotal.FieldTotalTokens)
  37471. }
  37472. if m.start_index != nil {
  37473. fields = append(fields, usagetotal.FieldStartIndex)
  37474. }
  37475. if m.end_index != nil {
  37476. fields = append(fields, usagetotal.FieldEndIndex)
  37477. }
  37478. if m.organization_id != nil {
  37479. fields = append(fields, usagetotal.FieldOrganizationID)
  37480. }
  37481. return fields
  37482. }
  37483. // Field returns the value of a field with the given name. The second boolean
  37484. // return value indicates that this field was not set, or was not defined in the
  37485. // schema.
  37486. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  37487. switch name {
  37488. case usagetotal.FieldCreatedAt:
  37489. return m.CreatedAt()
  37490. case usagetotal.FieldUpdatedAt:
  37491. return m.UpdatedAt()
  37492. case usagetotal.FieldStatus:
  37493. return m.Status()
  37494. case usagetotal.FieldType:
  37495. return m.GetType()
  37496. case usagetotal.FieldBotID:
  37497. return m.BotID()
  37498. case usagetotal.FieldTotalTokens:
  37499. return m.TotalTokens()
  37500. case usagetotal.FieldStartIndex:
  37501. return m.StartIndex()
  37502. case usagetotal.FieldEndIndex:
  37503. return m.EndIndex()
  37504. case usagetotal.FieldOrganizationID:
  37505. return m.OrganizationID()
  37506. }
  37507. return nil, false
  37508. }
  37509. // OldField returns the old value of the field from the database. An error is
  37510. // returned if the mutation operation is not UpdateOne, or the query to the
  37511. // database failed.
  37512. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37513. switch name {
  37514. case usagetotal.FieldCreatedAt:
  37515. return m.OldCreatedAt(ctx)
  37516. case usagetotal.FieldUpdatedAt:
  37517. return m.OldUpdatedAt(ctx)
  37518. case usagetotal.FieldStatus:
  37519. return m.OldStatus(ctx)
  37520. case usagetotal.FieldType:
  37521. return m.OldType(ctx)
  37522. case usagetotal.FieldBotID:
  37523. return m.OldBotID(ctx)
  37524. case usagetotal.FieldTotalTokens:
  37525. return m.OldTotalTokens(ctx)
  37526. case usagetotal.FieldStartIndex:
  37527. return m.OldStartIndex(ctx)
  37528. case usagetotal.FieldEndIndex:
  37529. return m.OldEndIndex(ctx)
  37530. case usagetotal.FieldOrganizationID:
  37531. return m.OldOrganizationID(ctx)
  37532. }
  37533. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  37534. }
  37535. // SetField sets the value of a field with the given name. It returns an error if
  37536. // the field is not defined in the schema, or if the type mismatched the field
  37537. // type.
  37538. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  37539. switch name {
  37540. case usagetotal.FieldCreatedAt:
  37541. v, ok := value.(time.Time)
  37542. if !ok {
  37543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37544. }
  37545. m.SetCreatedAt(v)
  37546. return nil
  37547. case usagetotal.FieldUpdatedAt:
  37548. v, ok := value.(time.Time)
  37549. if !ok {
  37550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37551. }
  37552. m.SetUpdatedAt(v)
  37553. return nil
  37554. case usagetotal.FieldStatus:
  37555. v, ok := value.(uint8)
  37556. if !ok {
  37557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37558. }
  37559. m.SetStatus(v)
  37560. return nil
  37561. case usagetotal.FieldType:
  37562. v, ok := value.(int)
  37563. if !ok {
  37564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37565. }
  37566. m.SetType(v)
  37567. return nil
  37568. case usagetotal.FieldBotID:
  37569. v, ok := value.(string)
  37570. if !ok {
  37571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37572. }
  37573. m.SetBotID(v)
  37574. return nil
  37575. case usagetotal.FieldTotalTokens:
  37576. v, ok := value.(uint64)
  37577. if !ok {
  37578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37579. }
  37580. m.SetTotalTokens(v)
  37581. return nil
  37582. case usagetotal.FieldStartIndex:
  37583. v, ok := value.(uint64)
  37584. if !ok {
  37585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37586. }
  37587. m.SetStartIndex(v)
  37588. return nil
  37589. case usagetotal.FieldEndIndex:
  37590. v, ok := value.(uint64)
  37591. if !ok {
  37592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37593. }
  37594. m.SetEndIndex(v)
  37595. return nil
  37596. case usagetotal.FieldOrganizationID:
  37597. v, ok := value.(uint64)
  37598. if !ok {
  37599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37600. }
  37601. m.SetOrganizationID(v)
  37602. return nil
  37603. }
  37604. return fmt.Errorf("unknown UsageTotal field %s", name)
  37605. }
  37606. // AddedFields returns all numeric fields that were incremented/decremented during
  37607. // this mutation.
  37608. func (m *UsageTotalMutation) AddedFields() []string {
  37609. var fields []string
  37610. if m.addstatus != nil {
  37611. fields = append(fields, usagetotal.FieldStatus)
  37612. }
  37613. if m.add_type != nil {
  37614. fields = append(fields, usagetotal.FieldType)
  37615. }
  37616. if m.addtotal_tokens != nil {
  37617. fields = append(fields, usagetotal.FieldTotalTokens)
  37618. }
  37619. if m.addstart_index != nil {
  37620. fields = append(fields, usagetotal.FieldStartIndex)
  37621. }
  37622. if m.addend_index != nil {
  37623. fields = append(fields, usagetotal.FieldEndIndex)
  37624. }
  37625. if m.addorganization_id != nil {
  37626. fields = append(fields, usagetotal.FieldOrganizationID)
  37627. }
  37628. return fields
  37629. }
  37630. // AddedField returns the numeric value that was incremented/decremented on a field
  37631. // with the given name. The second boolean return value indicates that this field
  37632. // was not set, or was not defined in the schema.
  37633. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  37634. switch name {
  37635. case usagetotal.FieldStatus:
  37636. return m.AddedStatus()
  37637. case usagetotal.FieldType:
  37638. return m.AddedType()
  37639. case usagetotal.FieldTotalTokens:
  37640. return m.AddedTotalTokens()
  37641. case usagetotal.FieldStartIndex:
  37642. return m.AddedStartIndex()
  37643. case usagetotal.FieldEndIndex:
  37644. return m.AddedEndIndex()
  37645. case usagetotal.FieldOrganizationID:
  37646. return m.AddedOrganizationID()
  37647. }
  37648. return nil, false
  37649. }
  37650. // AddField adds the value to the field with the given name. It returns an error if
  37651. // the field is not defined in the schema, or if the type mismatched the field
  37652. // type.
  37653. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  37654. switch name {
  37655. case usagetotal.FieldStatus:
  37656. v, ok := value.(int8)
  37657. if !ok {
  37658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37659. }
  37660. m.AddStatus(v)
  37661. return nil
  37662. case usagetotal.FieldType:
  37663. v, ok := value.(int)
  37664. if !ok {
  37665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37666. }
  37667. m.AddType(v)
  37668. return nil
  37669. case usagetotal.FieldTotalTokens:
  37670. v, ok := value.(int64)
  37671. if !ok {
  37672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37673. }
  37674. m.AddTotalTokens(v)
  37675. return nil
  37676. case usagetotal.FieldStartIndex:
  37677. v, ok := value.(int64)
  37678. if !ok {
  37679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37680. }
  37681. m.AddStartIndex(v)
  37682. return nil
  37683. case usagetotal.FieldEndIndex:
  37684. v, ok := value.(int64)
  37685. if !ok {
  37686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37687. }
  37688. m.AddEndIndex(v)
  37689. return nil
  37690. case usagetotal.FieldOrganizationID:
  37691. v, ok := value.(int64)
  37692. if !ok {
  37693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37694. }
  37695. m.AddOrganizationID(v)
  37696. return nil
  37697. }
  37698. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  37699. }
  37700. // ClearedFields returns all nullable fields that were cleared during this
  37701. // mutation.
  37702. func (m *UsageTotalMutation) ClearedFields() []string {
  37703. var fields []string
  37704. if m.FieldCleared(usagetotal.FieldStatus) {
  37705. fields = append(fields, usagetotal.FieldStatus)
  37706. }
  37707. if m.FieldCleared(usagetotal.FieldType) {
  37708. fields = append(fields, usagetotal.FieldType)
  37709. }
  37710. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  37711. fields = append(fields, usagetotal.FieldTotalTokens)
  37712. }
  37713. if m.FieldCleared(usagetotal.FieldStartIndex) {
  37714. fields = append(fields, usagetotal.FieldStartIndex)
  37715. }
  37716. if m.FieldCleared(usagetotal.FieldEndIndex) {
  37717. fields = append(fields, usagetotal.FieldEndIndex)
  37718. }
  37719. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  37720. fields = append(fields, usagetotal.FieldOrganizationID)
  37721. }
  37722. return fields
  37723. }
  37724. // FieldCleared returns a boolean indicating if a field with the given name was
  37725. // cleared in this mutation.
  37726. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  37727. _, ok := m.clearedFields[name]
  37728. return ok
  37729. }
  37730. // ClearField clears the value of the field with the given name. It returns an
  37731. // error if the field is not defined in the schema.
  37732. func (m *UsageTotalMutation) ClearField(name string) error {
  37733. switch name {
  37734. case usagetotal.FieldStatus:
  37735. m.ClearStatus()
  37736. return nil
  37737. case usagetotal.FieldType:
  37738. m.ClearType()
  37739. return nil
  37740. case usagetotal.FieldTotalTokens:
  37741. m.ClearTotalTokens()
  37742. return nil
  37743. case usagetotal.FieldStartIndex:
  37744. m.ClearStartIndex()
  37745. return nil
  37746. case usagetotal.FieldEndIndex:
  37747. m.ClearEndIndex()
  37748. return nil
  37749. case usagetotal.FieldOrganizationID:
  37750. m.ClearOrganizationID()
  37751. return nil
  37752. }
  37753. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  37754. }
  37755. // ResetField resets all changes in the mutation for the field with the given name.
  37756. // It returns an error if the field is not defined in the schema.
  37757. func (m *UsageTotalMutation) ResetField(name string) error {
  37758. switch name {
  37759. case usagetotal.FieldCreatedAt:
  37760. m.ResetCreatedAt()
  37761. return nil
  37762. case usagetotal.FieldUpdatedAt:
  37763. m.ResetUpdatedAt()
  37764. return nil
  37765. case usagetotal.FieldStatus:
  37766. m.ResetStatus()
  37767. return nil
  37768. case usagetotal.FieldType:
  37769. m.ResetType()
  37770. return nil
  37771. case usagetotal.FieldBotID:
  37772. m.ResetBotID()
  37773. return nil
  37774. case usagetotal.FieldTotalTokens:
  37775. m.ResetTotalTokens()
  37776. return nil
  37777. case usagetotal.FieldStartIndex:
  37778. m.ResetStartIndex()
  37779. return nil
  37780. case usagetotal.FieldEndIndex:
  37781. m.ResetEndIndex()
  37782. return nil
  37783. case usagetotal.FieldOrganizationID:
  37784. m.ResetOrganizationID()
  37785. return nil
  37786. }
  37787. return fmt.Errorf("unknown UsageTotal field %s", name)
  37788. }
  37789. // AddedEdges returns all edge names that were set/added in this mutation.
  37790. func (m *UsageTotalMutation) AddedEdges() []string {
  37791. edges := make([]string, 0, 0)
  37792. return edges
  37793. }
  37794. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37795. // name in this mutation.
  37796. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  37797. return nil
  37798. }
  37799. // RemovedEdges returns all edge names that were removed in this mutation.
  37800. func (m *UsageTotalMutation) RemovedEdges() []string {
  37801. edges := make([]string, 0, 0)
  37802. return edges
  37803. }
  37804. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37805. // the given name in this mutation.
  37806. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  37807. return nil
  37808. }
  37809. // ClearedEdges returns all edge names that were cleared in this mutation.
  37810. func (m *UsageTotalMutation) ClearedEdges() []string {
  37811. edges := make([]string, 0, 0)
  37812. return edges
  37813. }
  37814. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37815. // was cleared in this mutation.
  37816. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  37817. return false
  37818. }
  37819. // ClearEdge clears the value of the edge with the given name. It returns an error
  37820. // if that edge is not defined in the schema.
  37821. func (m *UsageTotalMutation) ClearEdge(name string) error {
  37822. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  37823. }
  37824. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37825. // It returns an error if the edge is not defined in the schema.
  37826. func (m *UsageTotalMutation) ResetEdge(name string) error {
  37827. return fmt.Errorf("unknown UsageTotal edge %s", name)
  37828. }
  37829. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  37830. type WhatsappMutation struct {
  37831. config
  37832. op Op
  37833. typ string
  37834. id *uint64
  37835. created_at *time.Time
  37836. updated_at *time.Time
  37837. status *uint8
  37838. addstatus *int8
  37839. deleted_at *time.Time
  37840. wa_id *string
  37841. wa_name *string
  37842. callback *string
  37843. account *string
  37844. cc *string
  37845. phone *string
  37846. cc_phone *string
  37847. phone_name *string
  37848. phone_status *int8
  37849. addphone_status *int8
  37850. organization_id *uint64
  37851. addorganization_id *int64
  37852. api_base *string
  37853. api_key *string
  37854. allow_list *[]string
  37855. appendallow_list []string
  37856. group_allow_list *[]string
  37857. appendgroup_allow_list []string
  37858. block_list *[]string
  37859. appendblock_list []string
  37860. group_block_list *[]string
  37861. appendgroup_block_list []string
  37862. clearedFields map[string]struct{}
  37863. agent *uint64
  37864. clearedagent bool
  37865. done bool
  37866. oldValue func(context.Context) (*Whatsapp, error)
  37867. predicates []predicate.Whatsapp
  37868. }
  37869. var _ ent.Mutation = (*WhatsappMutation)(nil)
  37870. // whatsappOption allows management of the mutation configuration using functional options.
  37871. type whatsappOption func(*WhatsappMutation)
  37872. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  37873. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  37874. m := &WhatsappMutation{
  37875. config: c,
  37876. op: op,
  37877. typ: TypeWhatsapp,
  37878. clearedFields: make(map[string]struct{}),
  37879. }
  37880. for _, opt := range opts {
  37881. opt(m)
  37882. }
  37883. return m
  37884. }
  37885. // withWhatsappID sets the ID field of the mutation.
  37886. func withWhatsappID(id uint64) whatsappOption {
  37887. return func(m *WhatsappMutation) {
  37888. var (
  37889. err error
  37890. once sync.Once
  37891. value *Whatsapp
  37892. )
  37893. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  37894. once.Do(func() {
  37895. if m.done {
  37896. err = errors.New("querying old values post mutation is not allowed")
  37897. } else {
  37898. value, err = m.Client().Whatsapp.Get(ctx, id)
  37899. }
  37900. })
  37901. return value, err
  37902. }
  37903. m.id = &id
  37904. }
  37905. }
  37906. // withWhatsapp sets the old Whatsapp of the mutation.
  37907. func withWhatsapp(node *Whatsapp) whatsappOption {
  37908. return func(m *WhatsappMutation) {
  37909. m.oldValue = func(context.Context) (*Whatsapp, error) {
  37910. return node, nil
  37911. }
  37912. m.id = &node.ID
  37913. }
  37914. }
  37915. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37916. // executed in a transaction (ent.Tx), a transactional client is returned.
  37917. func (m WhatsappMutation) Client() *Client {
  37918. client := &Client{config: m.config}
  37919. client.init()
  37920. return client
  37921. }
  37922. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37923. // it returns an error otherwise.
  37924. func (m WhatsappMutation) Tx() (*Tx, error) {
  37925. if _, ok := m.driver.(*txDriver); !ok {
  37926. return nil, errors.New("ent: mutation is not running in a transaction")
  37927. }
  37928. tx := &Tx{config: m.config}
  37929. tx.init()
  37930. return tx, nil
  37931. }
  37932. // SetID sets the value of the id field. Note that this
  37933. // operation is only accepted on creation of Whatsapp entities.
  37934. func (m *WhatsappMutation) SetID(id uint64) {
  37935. m.id = &id
  37936. }
  37937. // ID returns the ID value in the mutation. Note that the ID is only available
  37938. // if it was provided to the builder or after it was returned from the database.
  37939. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  37940. if m.id == nil {
  37941. return
  37942. }
  37943. return *m.id, true
  37944. }
  37945. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37946. // That means, if the mutation is applied within a transaction with an isolation level such
  37947. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37948. // or updated by the mutation.
  37949. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  37950. switch {
  37951. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37952. id, exists := m.ID()
  37953. if exists {
  37954. return []uint64{id}, nil
  37955. }
  37956. fallthrough
  37957. case m.op.Is(OpUpdate | OpDelete):
  37958. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  37959. default:
  37960. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37961. }
  37962. }
  37963. // SetCreatedAt sets the "created_at" field.
  37964. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  37965. m.created_at = &t
  37966. }
  37967. // CreatedAt returns the value of the "created_at" field in the mutation.
  37968. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  37969. v := m.created_at
  37970. if v == nil {
  37971. return
  37972. }
  37973. return *v, true
  37974. }
  37975. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  37976. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37978. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37979. if !m.op.Is(OpUpdateOne) {
  37980. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37981. }
  37982. if m.id == nil || m.oldValue == nil {
  37983. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37984. }
  37985. oldValue, err := m.oldValue(ctx)
  37986. if err != nil {
  37987. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37988. }
  37989. return oldValue.CreatedAt, nil
  37990. }
  37991. // ResetCreatedAt resets all changes to the "created_at" field.
  37992. func (m *WhatsappMutation) ResetCreatedAt() {
  37993. m.created_at = nil
  37994. }
  37995. // SetUpdatedAt sets the "updated_at" field.
  37996. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  37997. m.updated_at = &t
  37998. }
  37999. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38000. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  38001. v := m.updated_at
  38002. if v == nil {
  38003. return
  38004. }
  38005. return *v, true
  38006. }
  38007. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38011. if !m.op.Is(OpUpdateOne) {
  38012. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38013. }
  38014. if m.id == nil || m.oldValue == nil {
  38015. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  38020. }
  38021. return oldValue.UpdatedAt, nil
  38022. }
  38023. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38024. func (m *WhatsappMutation) ResetUpdatedAt() {
  38025. m.updated_at = nil
  38026. }
  38027. // SetStatus sets the "status" field.
  38028. func (m *WhatsappMutation) SetStatus(u uint8) {
  38029. m.status = &u
  38030. m.addstatus = nil
  38031. }
  38032. // Status returns the value of the "status" field in the mutation.
  38033. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  38034. v := m.status
  38035. if v == nil {
  38036. return
  38037. }
  38038. return *v, true
  38039. }
  38040. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  38041. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38043. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38044. if !m.op.Is(OpUpdateOne) {
  38045. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38046. }
  38047. if m.id == nil || m.oldValue == nil {
  38048. return v, errors.New("OldStatus requires an ID field in the mutation")
  38049. }
  38050. oldValue, err := m.oldValue(ctx)
  38051. if err != nil {
  38052. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38053. }
  38054. return oldValue.Status, nil
  38055. }
  38056. // AddStatus adds u to the "status" field.
  38057. func (m *WhatsappMutation) AddStatus(u int8) {
  38058. if m.addstatus != nil {
  38059. *m.addstatus += u
  38060. } else {
  38061. m.addstatus = &u
  38062. }
  38063. }
  38064. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38065. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  38066. v := m.addstatus
  38067. if v == nil {
  38068. return
  38069. }
  38070. return *v, true
  38071. }
  38072. // ClearStatus clears the value of the "status" field.
  38073. func (m *WhatsappMutation) ClearStatus() {
  38074. m.status = nil
  38075. m.addstatus = nil
  38076. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  38077. }
  38078. // StatusCleared returns if the "status" field was cleared in this mutation.
  38079. func (m *WhatsappMutation) StatusCleared() bool {
  38080. _, ok := m.clearedFields[whatsapp.FieldStatus]
  38081. return ok
  38082. }
  38083. // ResetStatus resets all changes to the "status" field.
  38084. func (m *WhatsappMutation) ResetStatus() {
  38085. m.status = nil
  38086. m.addstatus = nil
  38087. delete(m.clearedFields, whatsapp.FieldStatus)
  38088. }
  38089. // SetDeletedAt sets the "deleted_at" field.
  38090. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  38091. m.deleted_at = &t
  38092. }
  38093. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38094. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  38095. v := m.deleted_at
  38096. if v == nil {
  38097. return
  38098. }
  38099. return *v, true
  38100. }
  38101. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  38102. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38104. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38105. if !m.op.Is(OpUpdateOne) {
  38106. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38107. }
  38108. if m.id == nil || m.oldValue == nil {
  38109. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38110. }
  38111. oldValue, err := m.oldValue(ctx)
  38112. if err != nil {
  38113. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38114. }
  38115. return oldValue.DeletedAt, nil
  38116. }
  38117. // ClearDeletedAt clears the value of the "deleted_at" field.
  38118. func (m *WhatsappMutation) ClearDeletedAt() {
  38119. m.deleted_at = nil
  38120. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  38121. }
  38122. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38123. func (m *WhatsappMutation) DeletedAtCleared() bool {
  38124. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  38125. return ok
  38126. }
  38127. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38128. func (m *WhatsappMutation) ResetDeletedAt() {
  38129. m.deleted_at = nil
  38130. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  38131. }
  38132. // SetWaID sets the "wa_id" field.
  38133. func (m *WhatsappMutation) SetWaID(s string) {
  38134. m.wa_id = &s
  38135. }
  38136. // WaID returns the value of the "wa_id" field in the mutation.
  38137. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  38138. v := m.wa_id
  38139. if v == nil {
  38140. return
  38141. }
  38142. return *v, true
  38143. }
  38144. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  38145. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38147. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  38148. if !m.op.Is(OpUpdateOne) {
  38149. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38150. }
  38151. if m.id == nil || m.oldValue == nil {
  38152. return v, errors.New("OldWaID requires an ID field in the mutation")
  38153. }
  38154. oldValue, err := m.oldValue(ctx)
  38155. if err != nil {
  38156. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38157. }
  38158. return oldValue.WaID, nil
  38159. }
  38160. // ClearWaID clears the value of the "wa_id" field.
  38161. func (m *WhatsappMutation) ClearWaID() {
  38162. m.wa_id = nil
  38163. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  38164. }
  38165. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38166. func (m *WhatsappMutation) WaIDCleared() bool {
  38167. _, ok := m.clearedFields[whatsapp.FieldWaID]
  38168. return ok
  38169. }
  38170. // ResetWaID resets all changes to the "wa_id" field.
  38171. func (m *WhatsappMutation) ResetWaID() {
  38172. m.wa_id = nil
  38173. delete(m.clearedFields, whatsapp.FieldWaID)
  38174. }
  38175. // SetWaName sets the "wa_name" field.
  38176. func (m *WhatsappMutation) SetWaName(s string) {
  38177. m.wa_name = &s
  38178. }
  38179. // WaName returns the value of the "wa_name" field in the mutation.
  38180. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  38181. v := m.wa_name
  38182. if v == nil {
  38183. return
  38184. }
  38185. return *v, true
  38186. }
  38187. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  38188. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38190. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  38191. if !m.op.Is(OpUpdateOne) {
  38192. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38193. }
  38194. if m.id == nil || m.oldValue == nil {
  38195. return v, errors.New("OldWaName requires an ID field in the mutation")
  38196. }
  38197. oldValue, err := m.oldValue(ctx)
  38198. if err != nil {
  38199. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38200. }
  38201. return oldValue.WaName, nil
  38202. }
  38203. // ClearWaName clears the value of the "wa_name" field.
  38204. func (m *WhatsappMutation) ClearWaName() {
  38205. m.wa_name = nil
  38206. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  38207. }
  38208. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38209. func (m *WhatsappMutation) WaNameCleared() bool {
  38210. _, ok := m.clearedFields[whatsapp.FieldWaName]
  38211. return ok
  38212. }
  38213. // ResetWaName resets all changes to the "wa_name" field.
  38214. func (m *WhatsappMutation) ResetWaName() {
  38215. m.wa_name = nil
  38216. delete(m.clearedFields, whatsapp.FieldWaName)
  38217. }
  38218. // SetCallback sets the "callback" field.
  38219. func (m *WhatsappMutation) SetCallback(s string) {
  38220. m.callback = &s
  38221. }
  38222. // Callback returns the value of the "callback" field in the mutation.
  38223. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  38224. v := m.callback
  38225. if v == nil {
  38226. return
  38227. }
  38228. return *v, true
  38229. }
  38230. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  38231. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38233. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  38234. if !m.op.Is(OpUpdateOne) {
  38235. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  38236. }
  38237. if m.id == nil || m.oldValue == nil {
  38238. return v, errors.New("OldCallback requires an ID field in the mutation")
  38239. }
  38240. oldValue, err := m.oldValue(ctx)
  38241. if err != nil {
  38242. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  38243. }
  38244. return oldValue.Callback, nil
  38245. }
  38246. // ClearCallback clears the value of the "callback" field.
  38247. func (m *WhatsappMutation) ClearCallback() {
  38248. m.callback = nil
  38249. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  38250. }
  38251. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  38252. func (m *WhatsappMutation) CallbackCleared() bool {
  38253. _, ok := m.clearedFields[whatsapp.FieldCallback]
  38254. return ok
  38255. }
  38256. // ResetCallback resets all changes to the "callback" field.
  38257. func (m *WhatsappMutation) ResetCallback() {
  38258. m.callback = nil
  38259. delete(m.clearedFields, whatsapp.FieldCallback)
  38260. }
  38261. // SetAgentID sets the "agent_id" field.
  38262. func (m *WhatsappMutation) SetAgentID(u uint64) {
  38263. m.agent = &u
  38264. }
  38265. // AgentID returns the value of the "agent_id" field in the mutation.
  38266. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  38267. v := m.agent
  38268. if v == nil {
  38269. return
  38270. }
  38271. return *v, true
  38272. }
  38273. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  38274. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38276. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  38277. if !m.op.Is(OpUpdateOne) {
  38278. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  38279. }
  38280. if m.id == nil || m.oldValue == nil {
  38281. return v, errors.New("OldAgentID requires an ID field in the mutation")
  38282. }
  38283. oldValue, err := m.oldValue(ctx)
  38284. if err != nil {
  38285. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  38286. }
  38287. return oldValue.AgentID, nil
  38288. }
  38289. // ResetAgentID resets all changes to the "agent_id" field.
  38290. func (m *WhatsappMutation) ResetAgentID() {
  38291. m.agent = nil
  38292. }
  38293. // SetAccount sets the "account" field.
  38294. func (m *WhatsappMutation) SetAccount(s string) {
  38295. m.account = &s
  38296. }
  38297. // Account returns the value of the "account" field in the mutation.
  38298. func (m *WhatsappMutation) Account() (r string, exists bool) {
  38299. v := m.account
  38300. if v == nil {
  38301. return
  38302. }
  38303. return *v, true
  38304. }
  38305. // OldAccount returns the old "account" 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) OldAccount(ctx context.Context) (v string, err error) {
  38309. if !m.op.Is(OpUpdateOne) {
  38310. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  38311. }
  38312. if m.id == nil || m.oldValue == nil {
  38313. return v, errors.New("OldAccount 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 OldAccount: %w", err)
  38318. }
  38319. return oldValue.Account, nil
  38320. }
  38321. // ClearAccount clears the value of the "account" field.
  38322. func (m *WhatsappMutation) ClearAccount() {
  38323. m.account = nil
  38324. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  38325. }
  38326. // AccountCleared returns if the "account" field was cleared in this mutation.
  38327. func (m *WhatsappMutation) AccountCleared() bool {
  38328. _, ok := m.clearedFields[whatsapp.FieldAccount]
  38329. return ok
  38330. }
  38331. // ResetAccount resets all changes to the "account" field.
  38332. func (m *WhatsappMutation) ResetAccount() {
  38333. m.account = nil
  38334. delete(m.clearedFields, whatsapp.FieldAccount)
  38335. }
  38336. // SetCc sets the "cc" field.
  38337. func (m *WhatsappMutation) SetCc(s string) {
  38338. m.cc = &s
  38339. }
  38340. // Cc returns the value of the "cc" field in the mutation.
  38341. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  38342. v := m.cc
  38343. if v == nil {
  38344. return
  38345. }
  38346. return *v, true
  38347. }
  38348. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  38349. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38351. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  38352. if !m.op.Is(OpUpdateOne) {
  38353. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  38354. }
  38355. if m.id == nil || m.oldValue == nil {
  38356. return v, errors.New("OldCc requires an ID field in the mutation")
  38357. }
  38358. oldValue, err := m.oldValue(ctx)
  38359. if err != nil {
  38360. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  38361. }
  38362. return oldValue.Cc, nil
  38363. }
  38364. // ResetCc resets all changes to the "cc" field.
  38365. func (m *WhatsappMutation) ResetCc() {
  38366. m.cc = nil
  38367. }
  38368. // SetPhone sets the "phone" field.
  38369. func (m *WhatsappMutation) SetPhone(s string) {
  38370. m.phone = &s
  38371. }
  38372. // Phone returns the value of the "phone" field in the mutation.
  38373. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  38374. v := m.phone
  38375. if v == nil {
  38376. return
  38377. }
  38378. return *v, true
  38379. }
  38380. // OldPhone returns the old "phone" 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) OldPhone(ctx context.Context) (v string, err error) {
  38384. if !m.op.Is(OpUpdateOne) {
  38385. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  38386. }
  38387. if m.id == nil || m.oldValue == nil {
  38388. return v, errors.New("OldPhone 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 OldPhone: %w", err)
  38393. }
  38394. return oldValue.Phone, nil
  38395. }
  38396. // ResetPhone resets all changes to the "phone" field.
  38397. func (m *WhatsappMutation) ResetPhone() {
  38398. m.phone = nil
  38399. }
  38400. // SetCcPhone sets the "cc_phone" field.
  38401. func (m *WhatsappMutation) SetCcPhone(s string) {
  38402. m.cc_phone = &s
  38403. }
  38404. // CcPhone returns the value of the "cc_phone" field in the mutation.
  38405. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  38406. v := m.cc_phone
  38407. if v == nil {
  38408. return
  38409. }
  38410. return *v, true
  38411. }
  38412. // OldCcPhone returns the old "cc_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) OldCcPhone(ctx context.Context) (v string, err error) {
  38416. if !m.op.Is(OpUpdateOne) {
  38417. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  38418. }
  38419. if m.id == nil || m.oldValue == nil {
  38420. return v, errors.New("OldCcPhone 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 OldCcPhone: %w", err)
  38425. }
  38426. return oldValue.CcPhone, nil
  38427. }
  38428. // ResetCcPhone resets all changes to the "cc_phone" field.
  38429. func (m *WhatsappMutation) ResetCcPhone() {
  38430. m.cc_phone = nil
  38431. }
  38432. // SetPhoneName sets the "phone_name" field.
  38433. func (m *WhatsappMutation) SetPhoneName(s string) {
  38434. m.phone_name = &s
  38435. }
  38436. // PhoneName returns the value of the "phone_name" field in the mutation.
  38437. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  38438. v := m.phone_name
  38439. if v == nil {
  38440. return
  38441. }
  38442. return *v, true
  38443. }
  38444. // OldPhoneName returns the old "phone_name" 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) OldPhoneName(ctx context.Context) (v string, err error) {
  38448. if !m.op.Is(OpUpdateOne) {
  38449. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  38450. }
  38451. if m.id == nil || m.oldValue == nil {
  38452. return v, errors.New("OldPhoneName 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 OldPhoneName: %w", err)
  38457. }
  38458. return oldValue.PhoneName, nil
  38459. }
  38460. // ResetPhoneName resets all changes to the "phone_name" field.
  38461. func (m *WhatsappMutation) ResetPhoneName() {
  38462. m.phone_name = nil
  38463. }
  38464. // SetPhoneStatus sets the "phone_status" field.
  38465. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  38466. m.phone_status = &i
  38467. m.addphone_status = nil
  38468. }
  38469. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  38470. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  38471. v := m.phone_status
  38472. if v == nil {
  38473. return
  38474. }
  38475. return *v, true
  38476. }
  38477. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  38478. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38480. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  38481. if !m.op.Is(OpUpdateOne) {
  38482. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  38483. }
  38484. if m.id == nil || m.oldValue == nil {
  38485. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  38486. }
  38487. oldValue, err := m.oldValue(ctx)
  38488. if err != nil {
  38489. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  38490. }
  38491. return oldValue.PhoneStatus, nil
  38492. }
  38493. // AddPhoneStatus adds i to the "phone_status" field.
  38494. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  38495. if m.addphone_status != nil {
  38496. *m.addphone_status += i
  38497. } else {
  38498. m.addphone_status = &i
  38499. }
  38500. }
  38501. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  38502. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  38503. v := m.addphone_status
  38504. if v == nil {
  38505. return
  38506. }
  38507. return *v, true
  38508. }
  38509. // ResetPhoneStatus resets all changes to the "phone_status" field.
  38510. func (m *WhatsappMutation) ResetPhoneStatus() {
  38511. m.phone_status = nil
  38512. m.addphone_status = nil
  38513. }
  38514. // SetOrganizationID sets the "organization_id" field.
  38515. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  38516. m.organization_id = &u
  38517. m.addorganization_id = nil
  38518. }
  38519. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38520. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  38521. v := m.organization_id
  38522. if v == nil {
  38523. return
  38524. }
  38525. return *v, true
  38526. }
  38527. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  38528. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38530. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38531. if !m.op.Is(OpUpdateOne) {
  38532. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38533. }
  38534. if m.id == nil || m.oldValue == nil {
  38535. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38536. }
  38537. oldValue, err := m.oldValue(ctx)
  38538. if err != nil {
  38539. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38540. }
  38541. return oldValue.OrganizationID, nil
  38542. }
  38543. // AddOrganizationID adds u to the "organization_id" field.
  38544. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  38545. if m.addorganization_id != nil {
  38546. *m.addorganization_id += u
  38547. } else {
  38548. m.addorganization_id = &u
  38549. }
  38550. }
  38551. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38552. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  38553. v := m.addorganization_id
  38554. if v == nil {
  38555. return
  38556. }
  38557. return *v, true
  38558. }
  38559. // ClearOrganizationID clears the value of the "organization_id" field.
  38560. func (m *WhatsappMutation) ClearOrganizationID() {
  38561. m.organization_id = nil
  38562. m.addorganization_id = nil
  38563. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  38564. }
  38565. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38566. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  38567. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  38568. return ok
  38569. }
  38570. // ResetOrganizationID resets all changes to the "organization_id" field.
  38571. func (m *WhatsappMutation) ResetOrganizationID() {
  38572. m.organization_id = nil
  38573. m.addorganization_id = nil
  38574. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  38575. }
  38576. // SetAPIBase sets the "api_base" field.
  38577. func (m *WhatsappMutation) SetAPIBase(s string) {
  38578. m.api_base = &s
  38579. }
  38580. // APIBase returns the value of the "api_base" field in the mutation.
  38581. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  38582. v := m.api_base
  38583. if v == nil {
  38584. return
  38585. }
  38586. return *v, true
  38587. }
  38588. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  38589. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38591. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38592. if !m.op.Is(OpUpdateOne) {
  38593. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38594. }
  38595. if m.id == nil || m.oldValue == nil {
  38596. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38597. }
  38598. oldValue, err := m.oldValue(ctx)
  38599. if err != nil {
  38600. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38601. }
  38602. return oldValue.APIBase, nil
  38603. }
  38604. // ClearAPIBase clears the value of the "api_base" field.
  38605. func (m *WhatsappMutation) ClearAPIBase() {
  38606. m.api_base = nil
  38607. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  38608. }
  38609. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38610. func (m *WhatsappMutation) APIBaseCleared() bool {
  38611. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  38612. return ok
  38613. }
  38614. // ResetAPIBase resets all changes to the "api_base" field.
  38615. func (m *WhatsappMutation) ResetAPIBase() {
  38616. m.api_base = nil
  38617. delete(m.clearedFields, whatsapp.FieldAPIBase)
  38618. }
  38619. // SetAPIKey sets the "api_key" field.
  38620. func (m *WhatsappMutation) SetAPIKey(s string) {
  38621. m.api_key = &s
  38622. }
  38623. // APIKey returns the value of the "api_key" field in the mutation.
  38624. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  38625. v := m.api_key
  38626. if v == nil {
  38627. return
  38628. }
  38629. return *v, true
  38630. }
  38631. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  38632. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38634. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38635. if !m.op.Is(OpUpdateOne) {
  38636. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38637. }
  38638. if m.id == nil || m.oldValue == nil {
  38639. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38640. }
  38641. oldValue, err := m.oldValue(ctx)
  38642. if err != nil {
  38643. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38644. }
  38645. return oldValue.APIKey, nil
  38646. }
  38647. // ClearAPIKey clears the value of the "api_key" field.
  38648. func (m *WhatsappMutation) ClearAPIKey() {
  38649. m.api_key = nil
  38650. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  38651. }
  38652. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38653. func (m *WhatsappMutation) APIKeyCleared() bool {
  38654. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  38655. return ok
  38656. }
  38657. // ResetAPIKey resets all changes to the "api_key" field.
  38658. func (m *WhatsappMutation) ResetAPIKey() {
  38659. m.api_key = nil
  38660. delete(m.clearedFields, whatsapp.FieldAPIKey)
  38661. }
  38662. // SetAllowList sets the "allow_list" field.
  38663. func (m *WhatsappMutation) SetAllowList(s []string) {
  38664. m.allow_list = &s
  38665. m.appendallow_list = nil
  38666. }
  38667. // AllowList returns the value of the "allow_list" field in the mutation.
  38668. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  38669. v := m.allow_list
  38670. if v == nil {
  38671. return
  38672. }
  38673. return *v, true
  38674. }
  38675. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  38676. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38678. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38679. if !m.op.Is(OpUpdateOne) {
  38680. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38681. }
  38682. if m.id == nil || m.oldValue == nil {
  38683. return v, errors.New("OldAllowList requires an ID field in the mutation")
  38684. }
  38685. oldValue, err := m.oldValue(ctx)
  38686. if err != nil {
  38687. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  38688. }
  38689. return oldValue.AllowList, nil
  38690. }
  38691. // AppendAllowList adds s to the "allow_list" field.
  38692. func (m *WhatsappMutation) AppendAllowList(s []string) {
  38693. m.appendallow_list = append(m.appendallow_list, s...)
  38694. }
  38695. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  38696. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  38697. if len(m.appendallow_list) == 0 {
  38698. return nil, false
  38699. }
  38700. return m.appendallow_list, true
  38701. }
  38702. // ClearAllowList clears the value of the "allow_list" field.
  38703. func (m *WhatsappMutation) ClearAllowList() {
  38704. m.allow_list = nil
  38705. m.appendallow_list = nil
  38706. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  38707. }
  38708. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  38709. func (m *WhatsappMutation) AllowListCleared() bool {
  38710. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  38711. return ok
  38712. }
  38713. // ResetAllowList resets all changes to the "allow_list" field.
  38714. func (m *WhatsappMutation) ResetAllowList() {
  38715. m.allow_list = nil
  38716. m.appendallow_list = nil
  38717. delete(m.clearedFields, whatsapp.FieldAllowList)
  38718. }
  38719. // SetGroupAllowList sets the "group_allow_list" field.
  38720. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  38721. m.group_allow_list = &s
  38722. m.appendgroup_allow_list = nil
  38723. }
  38724. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  38725. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  38726. v := m.group_allow_list
  38727. if v == nil {
  38728. return
  38729. }
  38730. return *v, true
  38731. }
  38732. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  38733. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38735. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  38736. if !m.op.Is(OpUpdateOne) {
  38737. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  38738. }
  38739. if m.id == nil || m.oldValue == nil {
  38740. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  38741. }
  38742. oldValue, err := m.oldValue(ctx)
  38743. if err != nil {
  38744. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  38745. }
  38746. return oldValue.GroupAllowList, nil
  38747. }
  38748. // AppendGroupAllowList adds s to the "group_allow_list" field.
  38749. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  38750. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  38751. }
  38752. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  38753. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  38754. if len(m.appendgroup_allow_list) == 0 {
  38755. return nil, false
  38756. }
  38757. return m.appendgroup_allow_list, true
  38758. }
  38759. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  38760. func (m *WhatsappMutation) ClearGroupAllowList() {
  38761. m.group_allow_list = nil
  38762. m.appendgroup_allow_list = nil
  38763. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  38764. }
  38765. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  38766. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  38767. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  38768. return ok
  38769. }
  38770. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  38771. func (m *WhatsappMutation) ResetGroupAllowList() {
  38772. m.group_allow_list = nil
  38773. m.appendgroup_allow_list = nil
  38774. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  38775. }
  38776. // SetBlockList sets the "block_list" field.
  38777. func (m *WhatsappMutation) SetBlockList(s []string) {
  38778. m.block_list = &s
  38779. m.appendblock_list = nil
  38780. }
  38781. // BlockList returns the value of the "block_list" field in the mutation.
  38782. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  38783. v := m.block_list
  38784. if v == nil {
  38785. return
  38786. }
  38787. return *v, true
  38788. }
  38789. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  38790. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38792. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38793. if !m.op.Is(OpUpdateOne) {
  38794. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38795. }
  38796. if m.id == nil || m.oldValue == nil {
  38797. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38798. }
  38799. oldValue, err := m.oldValue(ctx)
  38800. if err != nil {
  38801. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38802. }
  38803. return oldValue.BlockList, nil
  38804. }
  38805. // AppendBlockList adds s to the "block_list" field.
  38806. func (m *WhatsappMutation) AppendBlockList(s []string) {
  38807. m.appendblock_list = append(m.appendblock_list, s...)
  38808. }
  38809. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38810. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  38811. if len(m.appendblock_list) == 0 {
  38812. return nil, false
  38813. }
  38814. return m.appendblock_list, true
  38815. }
  38816. // ClearBlockList clears the value of the "block_list" field.
  38817. func (m *WhatsappMutation) ClearBlockList() {
  38818. m.block_list = nil
  38819. m.appendblock_list = nil
  38820. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  38821. }
  38822. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  38823. func (m *WhatsappMutation) BlockListCleared() bool {
  38824. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  38825. return ok
  38826. }
  38827. // ResetBlockList resets all changes to the "block_list" field.
  38828. func (m *WhatsappMutation) ResetBlockList() {
  38829. m.block_list = nil
  38830. m.appendblock_list = nil
  38831. delete(m.clearedFields, whatsapp.FieldBlockList)
  38832. }
  38833. // SetGroupBlockList sets the "group_block_list" field.
  38834. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  38835. m.group_block_list = &s
  38836. m.appendgroup_block_list = nil
  38837. }
  38838. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38839. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  38840. v := m.group_block_list
  38841. if v == nil {
  38842. return
  38843. }
  38844. return *v, true
  38845. }
  38846. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  38847. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38849. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38850. if !m.op.Is(OpUpdateOne) {
  38851. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38852. }
  38853. if m.id == nil || m.oldValue == nil {
  38854. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38855. }
  38856. oldValue, err := m.oldValue(ctx)
  38857. if err != nil {
  38858. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38859. }
  38860. return oldValue.GroupBlockList, nil
  38861. }
  38862. // AppendGroupBlockList adds s to the "group_block_list" field.
  38863. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  38864. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38865. }
  38866. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38867. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  38868. if len(m.appendgroup_block_list) == 0 {
  38869. return nil, false
  38870. }
  38871. return m.appendgroup_block_list, true
  38872. }
  38873. // ClearGroupBlockList clears the value of the "group_block_list" field.
  38874. func (m *WhatsappMutation) ClearGroupBlockList() {
  38875. m.group_block_list = nil
  38876. m.appendgroup_block_list = nil
  38877. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  38878. }
  38879. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  38880. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  38881. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  38882. return ok
  38883. }
  38884. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38885. func (m *WhatsappMutation) ResetGroupBlockList() {
  38886. m.group_block_list = nil
  38887. m.appendgroup_block_list = nil
  38888. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  38889. }
  38890. // ClearAgent clears the "agent" edge to the Agent entity.
  38891. func (m *WhatsappMutation) ClearAgent() {
  38892. m.clearedagent = true
  38893. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  38894. }
  38895. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38896. func (m *WhatsappMutation) AgentCleared() bool {
  38897. return m.clearedagent
  38898. }
  38899. // AgentIDs returns the "agent" edge IDs in the mutation.
  38900. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38901. // AgentID instead. It exists only for internal usage by the builders.
  38902. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  38903. if id := m.agent; id != nil {
  38904. ids = append(ids, *id)
  38905. }
  38906. return
  38907. }
  38908. // ResetAgent resets all changes to the "agent" edge.
  38909. func (m *WhatsappMutation) ResetAgent() {
  38910. m.agent = nil
  38911. m.clearedagent = false
  38912. }
  38913. // Where appends a list predicates to the WhatsappMutation builder.
  38914. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  38915. m.predicates = append(m.predicates, ps...)
  38916. }
  38917. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  38918. // users can use type-assertion to append predicates that do not depend on any generated package.
  38919. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  38920. p := make([]predicate.Whatsapp, len(ps))
  38921. for i := range ps {
  38922. p[i] = ps[i]
  38923. }
  38924. m.Where(p...)
  38925. }
  38926. // Op returns the operation name.
  38927. func (m *WhatsappMutation) Op() Op {
  38928. return m.op
  38929. }
  38930. // SetOp allows setting the mutation operation.
  38931. func (m *WhatsappMutation) SetOp(op Op) {
  38932. m.op = op
  38933. }
  38934. // Type returns the node type of this mutation (Whatsapp).
  38935. func (m *WhatsappMutation) Type() string {
  38936. return m.typ
  38937. }
  38938. // Fields returns all fields that were changed during this mutation. Note that in
  38939. // order to get all numeric fields that were incremented/decremented, call
  38940. // AddedFields().
  38941. func (m *WhatsappMutation) Fields() []string {
  38942. fields := make([]string, 0, 21)
  38943. if m.created_at != nil {
  38944. fields = append(fields, whatsapp.FieldCreatedAt)
  38945. }
  38946. if m.updated_at != nil {
  38947. fields = append(fields, whatsapp.FieldUpdatedAt)
  38948. }
  38949. if m.status != nil {
  38950. fields = append(fields, whatsapp.FieldStatus)
  38951. }
  38952. if m.deleted_at != nil {
  38953. fields = append(fields, whatsapp.FieldDeletedAt)
  38954. }
  38955. if m.wa_id != nil {
  38956. fields = append(fields, whatsapp.FieldWaID)
  38957. }
  38958. if m.wa_name != nil {
  38959. fields = append(fields, whatsapp.FieldWaName)
  38960. }
  38961. if m.callback != nil {
  38962. fields = append(fields, whatsapp.FieldCallback)
  38963. }
  38964. if m.agent != nil {
  38965. fields = append(fields, whatsapp.FieldAgentID)
  38966. }
  38967. if m.account != nil {
  38968. fields = append(fields, whatsapp.FieldAccount)
  38969. }
  38970. if m.cc != nil {
  38971. fields = append(fields, whatsapp.FieldCc)
  38972. }
  38973. if m.phone != nil {
  38974. fields = append(fields, whatsapp.FieldPhone)
  38975. }
  38976. if m.cc_phone != nil {
  38977. fields = append(fields, whatsapp.FieldCcPhone)
  38978. }
  38979. if m.phone_name != nil {
  38980. fields = append(fields, whatsapp.FieldPhoneName)
  38981. }
  38982. if m.phone_status != nil {
  38983. fields = append(fields, whatsapp.FieldPhoneStatus)
  38984. }
  38985. if m.organization_id != nil {
  38986. fields = append(fields, whatsapp.FieldOrganizationID)
  38987. }
  38988. if m.api_base != nil {
  38989. fields = append(fields, whatsapp.FieldAPIBase)
  38990. }
  38991. if m.api_key != nil {
  38992. fields = append(fields, whatsapp.FieldAPIKey)
  38993. }
  38994. if m.allow_list != nil {
  38995. fields = append(fields, whatsapp.FieldAllowList)
  38996. }
  38997. if m.group_allow_list != nil {
  38998. fields = append(fields, whatsapp.FieldGroupAllowList)
  38999. }
  39000. if m.block_list != nil {
  39001. fields = append(fields, whatsapp.FieldBlockList)
  39002. }
  39003. if m.group_block_list != nil {
  39004. fields = append(fields, whatsapp.FieldGroupBlockList)
  39005. }
  39006. return fields
  39007. }
  39008. // Field returns the value of a field with the given name. The second boolean
  39009. // return value indicates that this field was not set, or was not defined in the
  39010. // schema.
  39011. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  39012. switch name {
  39013. case whatsapp.FieldCreatedAt:
  39014. return m.CreatedAt()
  39015. case whatsapp.FieldUpdatedAt:
  39016. return m.UpdatedAt()
  39017. case whatsapp.FieldStatus:
  39018. return m.Status()
  39019. case whatsapp.FieldDeletedAt:
  39020. return m.DeletedAt()
  39021. case whatsapp.FieldWaID:
  39022. return m.WaID()
  39023. case whatsapp.FieldWaName:
  39024. return m.WaName()
  39025. case whatsapp.FieldCallback:
  39026. return m.Callback()
  39027. case whatsapp.FieldAgentID:
  39028. return m.AgentID()
  39029. case whatsapp.FieldAccount:
  39030. return m.Account()
  39031. case whatsapp.FieldCc:
  39032. return m.Cc()
  39033. case whatsapp.FieldPhone:
  39034. return m.Phone()
  39035. case whatsapp.FieldCcPhone:
  39036. return m.CcPhone()
  39037. case whatsapp.FieldPhoneName:
  39038. return m.PhoneName()
  39039. case whatsapp.FieldPhoneStatus:
  39040. return m.PhoneStatus()
  39041. case whatsapp.FieldOrganizationID:
  39042. return m.OrganizationID()
  39043. case whatsapp.FieldAPIBase:
  39044. return m.APIBase()
  39045. case whatsapp.FieldAPIKey:
  39046. return m.APIKey()
  39047. case whatsapp.FieldAllowList:
  39048. return m.AllowList()
  39049. case whatsapp.FieldGroupAllowList:
  39050. return m.GroupAllowList()
  39051. case whatsapp.FieldBlockList:
  39052. return m.BlockList()
  39053. case whatsapp.FieldGroupBlockList:
  39054. return m.GroupBlockList()
  39055. }
  39056. return nil, false
  39057. }
  39058. // OldField returns the old value of the field from the database. An error is
  39059. // returned if the mutation operation is not UpdateOne, or the query to the
  39060. // database failed.
  39061. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39062. switch name {
  39063. case whatsapp.FieldCreatedAt:
  39064. return m.OldCreatedAt(ctx)
  39065. case whatsapp.FieldUpdatedAt:
  39066. return m.OldUpdatedAt(ctx)
  39067. case whatsapp.FieldStatus:
  39068. return m.OldStatus(ctx)
  39069. case whatsapp.FieldDeletedAt:
  39070. return m.OldDeletedAt(ctx)
  39071. case whatsapp.FieldWaID:
  39072. return m.OldWaID(ctx)
  39073. case whatsapp.FieldWaName:
  39074. return m.OldWaName(ctx)
  39075. case whatsapp.FieldCallback:
  39076. return m.OldCallback(ctx)
  39077. case whatsapp.FieldAgentID:
  39078. return m.OldAgentID(ctx)
  39079. case whatsapp.FieldAccount:
  39080. return m.OldAccount(ctx)
  39081. case whatsapp.FieldCc:
  39082. return m.OldCc(ctx)
  39083. case whatsapp.FieldPhone:
  39084. return m.OldPhone(ctx)
  39085. case whatsapp.FieldCcPhone:
  39086. return m.OldCcPhone(ctx)
  39087. case whatsapp.FieldPhoneName:
  39088. return m.OldPhoneName(ctx)
  39089. case whatsapp.FieldPhoneStatus:
  39090. return m.OldPhoneStatus(ctx)
  39091. case whatsapp.FieldOrganizationID:
  39092. return m.OldOrganizationID(ctx)
  39093. case whatsapp.FieldAPIBase:
  39094. return m.OldAPIBase(ctx)
  39095. case whatsapp.FieldAPIKey:
  39096. return m.OldAPIKey(ctx)
  39097. case whatsapp.FieldAllowList:
  39098. return m.OldAllowList(ctx)
  39099. case whatsapp.FieldGroupAllowList:
  39100. return m.OldGroupAllowList(ctx)
  39101. case whatsapp.FieldBlockList:
  39102. return m.OldBlockList(ctx)
  39103. case whatsapp.FieldGroupBlockList:
  39104. return m.OldGroupBlockList(ctx)
  39105. }
  39106. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  39107. }
  39108. // SetField sets the value of a field with the given name. It returns an error if
  39109. // the field is not defined in the schema, or if the type mismatched the field
  39110. // type.
  39111. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  39112. switch name {
  39113. case whatsapp.FieldCreatedAt:
  39114. v, ok := value.(time.Time)
  39115. if !ok {
  39116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39117. }
  39118. m.SetCreatedAt(v)
  39119. return nil
  39120. case whatsapp.FieldUpdatedAt:
  39121. v, ok := value.(time.Time)
  39122. if !ok {
  39123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39124. }
  39125. m.SetUpdatedAt(v)
  39126. return nil
  39127. case whatsapp.FieldStatus:
  39128. v, ok := value.(uint8)
  39129. if !ok {
  39130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39131. }
  39132. m.SetStatus(v)
  39133. return nil
  39134. case whatsapp.FieldDeletedAt:
  39135. v, ok := value.(time.Time)
  39136. if !ok {
  39137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39138. }
  39139. m.SetDeletedAt(v)
  39140. return nil
  39141. case whatsapp.FieldWaID:
  39142. v, ok := value.(string)
  39143. if !ok {
  39144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39145. }
  39146. m.SetWaID(v)
  39147. return nil
  39148. case whatsapp.FieldWaName:
  39149. v, ok := value.(string)
  39150. if !ok {
  39151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39152. }
  39153. m.SetWaName(v)
  39154. return nil
  39155. case whatsapp.FieldCallback:
  39156. v, ok := value.(string)
  39157. if !ok {
  39158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39159. }
  39160. m.SetCallback(v)
  39161. return nil
  39162. case whatsapp.FieldAgentID:
  39163. v, ok := value.(uint64)
  39164. if !ok {
  39165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39166. }
  39167. m.SetAgentID(v)
  39168. return nil
  39169. case whatsapp.FieldAccount:
  39170. v, ok := value.(string)
  39171. if !ok {
  39172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39173. }
  39174. m.SetAccount(v)
  39175. return nil
  39176. case whatsapp.FieldCc:
  39177. v, ok := value.(string)
  39178. if !ok {
  39179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39180. }
  39181. m.SetCc(v)
  39182. return nil
  39183. case whatsapp.FieldPhone:
  39184. v, ok := value.(string)
  39185. if !ok {
  39186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39187. }
  39188. m.SetPhone(v)
  39189. return nil
  39190. case whatsapp.FieldCcPhone:
  39191. v, ok := value.(string)
  39192. if !ok {
  39193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39194. }
  39195. m.SetCcPhone(v)
  39196. return nil
  39197. case whatsapp.FieldPhoneName:
  39198. v, ok := value.(string)
  39199. if !ok {
  39200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39201. }
  39202. m.SetPhoneName(v)
  39203. return nil
  39204. case whatsapp.FieldPhoneStatus:
  39205. v, ok := value.(int8)
  39206. if !ok {
  39207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39208. }
  39209. m.SetPhoneStatus(v)
  39210. return nil
  39211. case whatsapp.FieldOrganizationID:
  39212. v, ok := value.(uint64)
  39213. if !ok {
  39214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39215. }
  39216. m.SetOrganizationID(v)
  39217. return nil
  39218. case whatsapp.FieldAPIBase:
  39219. v, ok := value.(string)
  39220. if !ok {
  39221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39222. }
  39223. m.SetAPIBase(v)
  39224. return nil
  39225. case whatsapp.FieldAPIKey:
  39226. v, ok := value.(string)
  39227. if !ok {
  39228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39229. }
  39230. m.SetAPIKey(v)
  39231. return nil
  39232. case whatsapp.FieldAllowList:
  39233. v, ok := value.([]string)
  39234. if !ok {
  39235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39236. }
  39237. m.SetAllowList(v)
  39238. return nil
  39239. case whatsapp.FieldGroupAllowList:
  39240. v, ok := value.([]string)
  39241. if !ok {
  39242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39243. }
  39244. m.SetGroupAllowList(v)
  39245. return nil
  39246. case whatsapp.FieldBlockList:
  39247. v, ok := value.([]string)
  39248. if !ok {
  39249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39250. }
  39251. m.SetBlockList(v)
  39252. return nil
  39253. case whatsapp.FieldGroupBlockList:
  39254. v, ok := value.([]string)
  39255. if !ok {
  39256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39257. }
  39258. m.SetGroupBlockList(v)
  39259. return nil
  39260. }
  39261. return fmt.Errorf("unknown Whatsapp field %s", name)
  39262. }
  39263. // AddedFields returns all numeric fields that were incremented/decremented during
  39264. // this mutation.
  39265. func (m *WhatsappMutation) AddedFields() []string {
  39266. var fields []string
  39267. if m.addstatus != nil {
  39268. fields = append(fields, whatsapp.FieldStatus)
  39269. }
  39270. if m.addphone_status != nil {
  39271. fields = append(fields, whatsapp.FieldPhoneStatus)
  39272. }
  39273. if m.addorganization_id != nil {
  39274. fields = append(fields, whatsapp.FieldOrganizationID)
  39275. }
  39276. return fields
  39277. }
  39278. // AddedField returns the numeric value that was incremented/decremented on a field
  39279. // with the given name. The second boolean return value indicates that this field
  39280. // was not set, or was not defined in the schema.
  39281. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  39282. switch name {
  39283. case whatsapp.FieldStatus:
  39284. return m.AddedStatus()
  39285. case whatsapp.FieldPhoneStatus:
  39286. return m.AddedPhoneStatus()
  39287. case whatsapp.FieldOrganizationID:
  39288. return m.AddedOrganizationID()
  39289. }
  39290. return nil, false
  39291. }
  39292. // AddField adds the value to the field with the given name. It returns an error if
  39293. // the field is not defined in the schema, or if the type mismatched the field
  39294. // type.
  39295. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  39296. switch name {
  39297. case whatsapp.FieldStatus:
  39298. v, ok := value.(int8)
  39299. if !ok {
  39300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39301. }
  39302. m.AddStatus(v)
  39303. return nil
  39304. case whatsapp.FieldPhoneStatus:
  39305. v, ok := value.(int8)
  39306. if !ok {
  39307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39308. }
  39309. m.AddPhoneStatus(v)
  39310. return nil
  39311. case whatsapp.FieldOrganizationID:
  39312. v, ok := value.(int64)
  39313. if !ok {
  39314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39315. }
  39316. m.AddOrganizationID(v)
  39317. return nil
  39318. }
  39319. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  39320. }
  39321. // ClearedFields returns all nullable fields that were cleared during this
  39322. // mutation.
  39323. func (m *WhatsappMutation) ClearedFields() []string {
  39324. var fields []string
  39325. if m.FieldCleared(whatsapp.FieldStatus) {
  39326. fields = append(fields, whatsapp.FieldStatus)
  39327. }
  39328. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  39329. fields = append(fields, whatsapp.FieldDeletedAt)
  39330. }
  39331. if m.FieldCleared(whatsapp.FieldWaID) {
  39332. fields = append(fields, whatsapp.FieldWaID)
  39333. }
  39334. if m.FieldCleared(whatsapp.FieldWaName) {
  39335. fields = append(fields, whatsapp.FieldWaName)
  39336. }
  39337. if m.FieldCleared(whatsapp.FieldCallback) {
  39338. fields = append(fields, whatsapp.FieldCallback)
  39339. }
  39340. if m.FieldCleared(whatsapp.FieldAccount) {
  39341. fields = append(fields, whatsapp.FieldAccount)
  39342. }
  39343. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  39344. fields = append(fields, whatsapp.FieldOrganizationID)
  39345. }
  39346. if m.FieldCleared(whatsapp.FieldAPIBase) {
  39347. fields = append(fields, whatsapp.FieldAPIBase)
  39348. }
  39349. if m.FieldCleared(whatsapp.FieldAPIKey) {
  39350. fields = append(fields, whatsapp.FieldAPIKey)
  39351. }
  39352. if m.FieldCleared(whatsapp.FieldAllowList) {
  39353. fields = append(fields, whatsapp.FieldAllowList)
  39354. }
  39355. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  39356. fields = append(fields, whatsapp.FieldGroupAllowList)
  39357. }
  39358. if m.FieldCleared(whatsapp.FieldBlockList) {
  39359. fields = append(fields, whatsapp.FieldBlockList)
  39360. }
  39361. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  39362. fields = append(fields, whatsapp.FieldGroupBlockList)
  39363. }
  39364. return fields
  39365. }
  39366. // FieldCleared returns a boolean indicating if a field with the given name was
  39367. // cleared in this mutation.
  39368. func (m *WhatsappMutation) FieldCleared(name string) bool {
  39369. _, ok := m.clearedFields[name]
  39370. return ok
  39371. }
  39372. // ClearField clears the value of the field with the given name. It returns an
  39373. // error if the field is not defined in the schema.
  39374. func (m *WhatsappMutation) ClearField(name string) error {
  39375. switch name {
  39376. case whatsapp.FieldStatus:
  39377. m.ClearStatus()
  39378. return nil
  39379. case whatsapp.FieldDeletedAt:
  39380. m.ClearDeletedAt()
  39381. return nil
  39382. case whatsapp.FieldWaID:
  39383. m.ClearWaID()
  39384. return nil
  39385. case whatsapp.FieldWaName:
  39386. m.ClearWaName()
  39387. return nil
  39388. case whatsapp.FieldCallback:
  39389. m.ClearCallback()
  39390. return nil
  39391. case whatsapp.FieldAccount:
  39392. m.ClearAccount()
  39393. return nil
  39394. case whatsapp.FieldOrganizationID:
  39395. m.ClearOrganizationID()
  39396. return nil
  39397. case whatsapp.FieldAPIBase:
  39398. m.ClearAPIBase()
  39399. return nil
  39400. case whatsapp.FieldAPIKey:
  39401. m.ClearAPIKey()
  39402. return nil
  39403. case whatsapp.FieldAllowList:
  39404. m.ClearAllowList()
  39405. return nil
  39406. case whatsapp.FieldGroupAllowList:
  39407. m.ClearGroupAllowList()
  39408. return nil
  39409. case whatsapp.FieldBlockList:
  39410. m.ClearBlockList()
  39411. return nil
  39412. case whatsapp.FieldGroupBlockList:
  39413. m.ClearGroupBlockList()
  39414. return nil
  39415. }
  39416. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  39417. }
  39418. // ResetField resets all changes in the mutation for the field with the given name.
  39419. // It returns an error if the field is not defined in the schema.
  39420. func (m *WhatsappMutation) ResetField(name string) error {
  39421. switch name {
  39422. case whatsapp.FieldCreatedAt:
  39423. m.ResetCreatedAt()
  39424. return nil
  39425. case whatsapp.FieldUpdatedAt:
  39426. m.ResetUpdatedAt()
  39427. return nil
  39428. case whatsapp.FieldStatus:
  39429. m.ResetStatus()
  39430. return nil
  39431. case whatsapp.FieldDeletedAt:
  39432. m.ResetDeletedAt()
  39433. return nil
  39434. case whatsapp.FieldWaID:
  39435. m.ResetWaID()
  39436. return nil
  39437. case whatsapp.FieldWaName:
  39438. m.ResetWaName()
  39439. return nil
  39440. case whatsapp.FieldCallback:
  39441. m.ResetCallback()
  39442. return nil
  39443. case whatsapp.FieldAgentID:
  39444. m.ResetAgentID()
  39445. return nil
  39446. case whatsapp.FieldAccount:
  39447. m.ResetAccount()
  39448. return nil
  39449. case whatsapp.FieldCc:
  39450. m.ResetCc()
  39451. return nil
  39452. case whatsapp.FieldPhone:
  39453. m.ResetPhone()
  39454. return nil
  39455. case whatsapp.FieldCcPhone:
  39456. m.ResetCcPhone()
  39457. return nil
  39458. case whatsapp.FieldPhoneName:
  39459. m.ResetPhoneName()
  39460. return nil
  39461. case whatsapp.FieldPhoneStatus:
  39462. m.ResetPhoneStatus()
  39463. return nil
  39464. case whatsapp.FieldOrganizationID:
  39465. m.ResetOrganizationID()
  39466. return nil
  39467. case whatsapp.FieldAPIBase:
  39468. m.ResetAPIBase()
  39469. return nil
  39470. case whatsapp.FieldAPIKey:
  39471. m.ResetAPIKey()
  39472. return nil
  39473. case whatsapp.FieldAllowList:
  39474. m.ResetAllowList()
  39475. return nil
  39476. case whatsapp.FieldGroupAllowList:
  39477. m.ResetGroupAllowList()
  39478. return nil
  39479. case whatsapp.FieldBlockList:
  39480. m.ResetBlockList()
  39481. return nil
  39482. case whatsapp.FieldGroupBlockList:
  39483. m.ResetGroupBlockList()
  39484. return nil
  39485. }
  39486. return fmt.Errorf("unknown Whatsapp field %s", name)
  39487. }
  39488. // AddedEdges returns all edge names that were set/added in this mutation.
  39489. func (m *WhatsappMutation) AddedEdges() []string {
  39490. edges := make([]string, 0, 1)
  39491. if m.agent != nil {
  39492. edges = append(edges, whatsapp.EdgeAgent)
  39493. }
  39494. return edges
  39495. }
  39496. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39497. // name in this mutation.
  39498. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  39499. switch name {
  39500. case whatsapp.EdgeAgent:
  39501. if id := m.agent; id != nil {
  39502. return []ent.Value{*id}
  39503. }
  39504. }
  39505. return nil
  39506. }
  39507. // RemovedEdges returns all edge names that were removed in this mutation.
  39508. func (m *WhatsappMutation) RemovedEdges() []string {
  39509. edges := make([]string, 0, 1)
  39510. return edges
  39511. }
  39512. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39513. // the given name in this mutation.
  39514. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  39515. return nil
  39516. }
  39517. // ClearedEdges returns all edge names that were cleared in this mutation.
  39518. func (m *WhatsappMutation) ClearedEdges() []string {
  39519. edges := make([]string, 0, 1)
  39520. if m.clearedagent {
  39521. edges = append(edges, whatsapp.EdgeAgent)
  39522. }
  39523. return edges
  39524. }
  39525. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39526. // was cleared in this mutation.
  39527. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  39528. switch name {
  39529. case whatsapp.EdgeAgent:
  39530. return m.clearedagent
  39531. }
  39532. return false
  39533. }
  39534. // ClearEdge clears the value of the edge with the given name. It returns an error
  39535. // if that edge is not defined in the schema.
  39536. func (m *WhatsappMutation) ClearEdge(name string) error {
  39537. switch name {
  39538. case whatsapp.EdgeAgent:
  39539. m.ClearAgent()
  39540. return nil
  39541. }
  39542. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  39543. }
  39544. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39545. // It returns an error if the edge is not defined in the schema.
  39546. func (m *WhatsappMutation) ResetEdge(name string) error {
  39547. switch name {
  39548. case whatsapp.EdgeAgent:
  39549. m.ResetAgent()
  39550. return nil
  39551. }
  39552. return fmt.Errorf("unknown Whatsapp edge %s", name)
  39553. }
  39554. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  39555. type WhatsappChannelMutation struct {
  39556. config
  39557. op Op
  39558. typ string
  39559. id *uint64
  39560. created_at *time.Time
  39561. updated_at *time.Time
  39562. status *uint8
  39563. addstatus *int8
  39564. deleted_at *time.Time
  39565. ak *string
  39566. sk *string
  39567. wa_id *string
  39568. wa_name *string
  39569. waba_id *uint64
  39570. addwaba_id *int64
  39571. business_id *uint64
  39572. addbusiness_id *int64
  39573. organization_id *uint64
  39574. addorganization_id *int64
  39575. verify_account *string
  39576. clearedFields map[string]struct{}
  39577. done bool
  39578. oldValue func(context.Context) (*WhatsappChannel, error)
  39579. predicates []predicate.WhatsappChannel
  39580. }
  39581. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  39582. // whatsappchannelOption allows management of the mutation configuration using functional options.
  39583. type whatsappchannelOption func(*WhatsappChannelMutation)
  39584. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  39585. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  39586. m := &WhatsappChannelMutation{
  39587. config: c,
  39588. op: op,
  39589. typ: TypeWhatsappChannel,
  39590. clearedFields: make(map[string]struct{}),
  39591. }
  39592. for _, opt := range opts {
  39593. opt(m)
  39594. }
  39595. return m
  39596. }
  39597. // withWhatsappChannelID sets the ID field of the mutation.
  39598. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  39599. return func(m *WhatsappChannelMutation) {
  39600. var (
  39601. err error
  39602. once sync.Once
  39603. value *WhatsappChannel
  39604. )
  39605. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  39606. once.Do(func() {
  39607. if m.done {
  39608. err = errors.New("querying old values post mutation is not allowed")
  39609. } else {
  39610. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  39611. }
  39612. })
  39613. return value, err
  39614. }
  39615. m.id = &id
  39616. }
  39617. }
  39618. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  39619. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  39620. return func(m *WhatsappChannelMutation) {
  39621. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  39622. return node, nil
  39623. }
  39624. m.id = &node.ID
  39625. }
  39626. }
  39627. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39628. // executed in a transaction (ent.Tx), a transactional client is returned.
  39629. func (m WhatsappChannelMutation) Client() *Client {
  39630. client := &Client{config: m.config}
  39631. client.init()
  39632. return client
  39633. }
  39634. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39635. // it returns an error otherwise.
  39636. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  39637. if _, ok := m.driver.(*txDriver); !ok {
  39638. return nil, errors.New("ent: mutation is not running in a transaction")
  39639. }
  39640. tx := &Tx{config: m.config}
  39641. tx.init()
  39642. return tx, nil
  39643. }
  39644. // SetID sets the value of the id field. Note that this
  39645. // operation is only accepted on creation of WhatsappChannel entities.
  39646. func (m *WhatsappChannelMutation) SetID(id uint64) {
  39647. m.id = &id
  39648. }
  39649. // ID returns the ID value in the mutation. Note that the ID is only available
  39650. // if it was provided to the builder or after it was returned from the database.
  39651. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  39652. if m.id == nil {
  39653. return
  39654. }
  39655. return *m.id, true
  39656. }
  39657. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39658. // That means, if the mutation is applied within a transaction with an isolation level such
  39659. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39660. // or updated by the mutation.
  39661. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  39662. switch {
  39663. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39664. id, exists := m.ID()
  39665. if exists {
  39666. return []uint64{id}, nil
  39667. }
  39668. fallthrough
  39669. case m.op.Is(OpUpdate | OpDelete):
  39670. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  39671. default:
  39672. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39673. }
  39674. }
  39675. // SetCreatedAt sets the "created_at" field.
  39676. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  39677. m.created_at = &t
  39678. }
  39679. // CreatedAt returns the value of the "created_at" field in the mutation.
  39680. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  39681. v := m.created_at
  39682. if v == nil {
  39683. return
  39684. }
  39685. return *v, true
  39686. }
  39687. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  39688. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39690. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39691. if !m.op.Is(OpUpdateOne) {
  39692. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39693. }
  39694. if m.id == nil || m.oldValue == nil {
  39695. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39696. }
  39697. oldValue, err := m.oldValue(ctx)
  39698. if err != nil {
  39699. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39700. }
  39701. return oldValue.CreatedAt, nil
  39702. }
  39703. // ResetCreatedAt resets all changes to the "created_at" field.
  39704. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  39705. m.created_at = nil
  39706. }
  39707. // SetUpdatedAt sets the "updated_at" field.
  39708. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  39709. m.updated_at = &t
  39710. }
  39711. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39712. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  39713. v := m.updated_at
  39714. if v == nil {
  39715. return
  39716. }
  39717. return *v, true
  39718. }
  39719. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39723. if !m.op.Is(OpUpdateOne) {
  39724. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39725. }
  39726. if m.id == nil || m.oldValue == nil {
  39727. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  39732. }
  39733. return oldValue.UpdatedAt, nil
  39734. }
  39735. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39736. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  39737. m.updated_at = nil
  39738. }
  39739. // SetStatus sets the "status" field.
  39740. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  39741. m.status = &u
  39742. m.addstatus = nil
  39743. }
  39744. // Status returns the value of the "status" field in the mutation.
  39745. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  39746. v := m.status
  39747. if v == nil {
  39748. return
  39749. }
  39750. return *v, true
  39751. }
  39752. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  39753. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39755. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39756. if !m.op.Is(OpUpdateOne) {
  39757. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39758. }
  39759. if m.id == nil || m.oldValue == nil {
  39760. return v, errors.New("OldStatus requires an ID field in the mutation")
  39761. }
  39762. oldValue, err := m.oldValue(ctx)
  39763. if err != nil {
  39764. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39765. }
  39766. return oldValue.Status, nil
  39767. }
  39768. // AddStatus adds u to the "status" field.
  39769. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  39770. if m.addstatus != nil {
  39771. *m.addstatus += u
  39772. } else {
  39773. m.addstatus = &u
  39774. }
  39775. }
  39776. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39777. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  39778. v := m.addstatus
  39779. if v == nil {
  39780. return
  39781. }
  39782. return *v, true
  39783. }
  39784. // ClearStatus clears the value of the "status" field.
  39785. func (m *WhatsappChannelMutation) ClearStatus() {
  39786. m.status = nil
  39787. m.addstatus = nil
  39788. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  39789. }
  39790. // StatusCleared returns if the "status" field was cleared in this mutation.
  39791. func (m *WhatsappChannelMutation) StatusCleared() bool {
  39792. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  39793. return ok
  39794. }
  39795. // ResetStatus resets all changes to the "status" field.
  39796. func (m *WhatsappChannelMutation) ResetStatus() {
  39797. m.status = nil
  39798. m.addstatus = nil
  39799. delete(m.clearedFields, whatsappchannel.FieldStatus)
  39800. }
  39801. // SetDeletedAt sets the "deleted_at" field.
  39802. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  39803. m.deleted_at = &t
  39804. }
  39805. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39806. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  39807. v := m.deleted_at
  39808. if v == nil {
  39809. return
  39810. }
  39811. return *v, true
  39812. }
  39813. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  39814. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39816. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39817. if !m.op.Is(OpUpdateOne) {
  39818. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39819. }
  39820. if m.id == nil || m.oldValue == nil {
  39821. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39822. }
  39823. oldValue, err := m.oldValue(ctx)
  39824. if err != nil {
  39825. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39826. }
  39827. return oldValue.DeletedAt, nil
  39828. }
  39829. // ClearDeletedAt clears the value of the "deleted_at" field.
  39830. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  39831. m.deleted_at = nil
  39832. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  39833. }
  39834. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39835. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  39836. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  39837. return ok
  39838. }
  39839. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39840. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  39841. m.deleted_at = nil
  39842. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  39843. }
  39844. // SetAk sets the "ak" field.
  39845. func (m *WhatsappChannelMutation) SetAk(s string) {
  39846. m.ak = &s
  39847. }
  39848. // Ak returns the value of the "ak" field in the mutation.
  39849. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  39850. v := m.ak
  39851. if v == nil {
  39852. return
  39853. }
  39854. return *v, true
  39855. }
  39856. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  39857. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39859. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  39860. if !m.op.Is(OpUpdateOne) {
  39861. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  39862. }
  39863. if m.id == nil || m.oldValue == nil {
  39864. return v, errors.New("OldAk requires an ID field in the mutation")
  39865. }
  39866. oldValue, err := m.oldValue(ctx)
  39867. if err != nil {
  39868. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  39869. }
  39870. return oldValue.Ak, nil
  39871. }
  39872. // ClearAk clears the value of the "ak" field.
  39873. func (m *WhatsappChannelMutation) ClearAk() {
  39874. m.ak = nil
  39875. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  39876. }
  39877. // AkCleared returns if the "ak" field was cleared in this mutation.
  39878. func (m *WhatsappChannelMutation) AkCleared() bool {
  39879. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  39880. return ok
  39881. }
  39882. // ResetAk resets all changes to the "ak" field.
  39883. func (m *WhatsappChannelMutation) ResetAk() {
  39884. m.ak = nil
  39885. delete(m.clearedFields, whatsappchannel.FieldAk)
  39886. }
  39887. // SetSk sets the "sk" field.
  39888. func (m *WhatsappChannelMutation) SetSk(s string) {
  39889. m.sk = &s
  39890. }
  39891. // Sk returns the value of the "sk" field in the mutation.
  39892. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  39893. v := m.sk
  39894. if v == nil {
  39895. return
  39896. }
  39897. return *v, true
  39898. }
  39899. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  39900. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39902. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  39903. if !m.op.Is(OpUpdateOne) {
  39904. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  39905. }
  39906. if m.id == nil || m.oldValue == nil {
  39907. return v, errors.New("OldSk requires an ID field in the mutation")
  39908. }
  39909. oldValue, err := m.oldValue(ctx)
  39910. if err != nil {
  39911. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  39912. }
  39913. return oldValue.Sk, nil
  39914. }
  39915. // ResetSk resets all changes to the "sk" field.
  39916. func (m *WhatsappChannelMutation) ResetSk() {
  39917. m.sk = nil
  39918. }
  39919. // SetWaID sets the "wa_id" field.
  39920. func (m *WhatsappChannelMutation) SetWaID(s string) {
  39921. m.wa_id = &s
  39922. }
  39923. // WaID returns the value of the "wa_id" field in the mutation.
  39924. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  39925. v := m.wa_id
  39926. if v == nil {
  39927. return
  39928. }
  39929. return *v, true
  39930. }
  39931. // OldWaID returns the old "wa_id" 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) OldWaID(ctx context.Context) (v string, err error) {
  39935. if !m.op.Is(OpUpdateOne) {
  39936. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  39937. }
  39938. if m.id == nil || m.oldValue == nil {
  39939. return v, errors.New("OldWaID 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 OldWaID: %w", err)
  39944. }
  39945. return oldValue.WaID, nil
  39946. }
  39947. // ClearWaID clears the value of the "wa_id" field.
  39948. func (m *WhatsappChannelMutation) ClearWaID() {
  39949. m.wa_id = nil
  39950. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  39951. }
  39952. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  39953. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  39954. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  39955. return ok
  39956. }
  39957. // ResetWaID resets all changes to the "wa_id" field.
  39958. func (m *WhatsappChannelMutation) ResetWaID() {
  39959. m.wa_id = nil
  39960. delete(m.clearedFields, whatsappchannel.FieldWaID)
  39961. }
  39962. // SetWaName sets the "wa_name" field.
  39963. func (m *WhatsappChannelMutation) SetWaName(s string) {
  39964. m.wa_name = &s
  39965. }
  39966. // WaName returns the value of the "wa_name" field in the mutation.
  39967. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  39968. v := m.wa_name
  39969. if v == nil {
  39970. return
  39971. }
  39972. return *v, true
  39973. }
  39974. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  39975. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39977. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  39978. if !m.op.Is(OpUpdateOne) {
  39979. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  39980. }
  39981. if m.id == nil || m.oldValue == nil {
  39982. return v, errors.New("OldWaName requires an ID field in the mutation")
  39983. }
  39984. oldValue, err := m.oldValue(ctx)
  39985. if err != nil {
  39986. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  39987. }
  39988. return oldValue.WaName, nil
  39989. }
  39990. // ClearWaName clears the value of the "wa_name" field.
  39991. func (m *WhatsappChannelMutation) ClearWaName() {
  39992. m.wa_name = nil
  39993. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  39994. }
  39995. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  39996. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  39997. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  39998. return ok
  39999. }
  40000. // ResetWaName resets all changes to the "wa_name" field.
  40001. func (m *WhatsappChannelMutation) ResetWaName() {
  40002. m.wa_name = nil
  40003. delete(m.clearedFields, whatsappchannel.FieldWaName)
  40004. }
  40005. // SetWabaID sets the "waba_id" field.
  40006. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  40007. m.waba_id = &u
  40008. m.addwaba_id = nil
  40009. }
  40010. // WabaID returns the value of the "waba_id" field in the mutation.
  40011. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  40012. v := m.waba_id
  40013. if v == nil {
  40014. return
  40015. }
  40016. return *v, true
  40017. }
  40018. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  40019. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40021. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  40022. if !m.op.Is(OpUpdateOne) {
  40023. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  40024. }
  40025. if m.id == nil || m.oldValue == nil {
  40026. return v, errors.New("OldWabaID requires an ID field in the mutation")
  40027. }
  40028. oldValue, err := m.oldValue(ctx)
  40029. if err != nil {
  40030. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  40031. }
  40032. return oldValue.WabaID, nil
  40033. }
  40034. // AddWabaID adds u to the "waba_id" field.
  40035. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  40036. if m.addwaba_id != nil {
  40037. *m.addwaba_id += u
  40038. } else {
  40039. m.addwaba_id = &u
  40040. }
  40041. }
  40042. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  40043. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  40044. v := m.addwaba_id
  40045. if v == nil {
  40046. return
  40047. }
  40048. return *v, true
  40049. }
  40050. // ResetWabaID resets all changes to the "waba_id" field.
  40051. func (m *WhatsappChannelMutation) ResetWabaID() {
  40052. m.waba_id = nil
  40053. m.addwaba_id = nil
  40054. }
  40055. // SetBusinessID sets the "business_id" field.
  40056. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  40057. m.business_id = &u
  40058. m.addbusiness_id = nil
  40059. }
  40060. // BusinessID returns the value of the "business_id" field in the mutation.
  40061. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  40062. v := m.business_id
  40063. if v == nil {
  40064. return
  40065. }
  40066. return *v, true
  40067. }
  40068. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  40069. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40071. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  40072. if !m.op.Is(OpUpdateOne) {
  40073. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  40074. }
  40075. if m.id == nil || m.oldValue == nil {
  40076. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  40077. }
  40078. oldValue, err := m.oldValue(ctx)
  40079. if err != nil {
  40080. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  40081. }
  40082. return oldValue.BusinessID, nil
  40083. }
  40084. // AddBusinessID adds u to the "business_id" field.
  40085. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  40086. if m.addbusiness_id != nil {
  40087. *m.addbusiness_id += u
  40088. } else {
  40089. m.addbusiness_id = &u
  40090. }
  40091. }
  40092. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  40093. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  40094. v := m.addbusiness_id
  40095. if v == nil {
  40096. return
  40097. }
  40098. return *v, true
  40099. }
  40100. // ResetBusinessID resets all changes to the "business_id" field.
  40101. func (m *WhatsappChannelMutation) ResetBusinessID() {
  40102. m.business_id = nil
  40103. m.addbusiness_id = nil
  40104. }
  40105. // SetOrganizationID sets the "organization_id" field.
  40106. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  40107. m.organization_id = &u
  40108. m.addorganization_id = nil
  40109. }
  40110. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40111. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  40112. v := m.organization_id
  40113. if v == nil {
  40114. return
  40115. }
  40116. return *v, true
  40117. }
  40118. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  40119. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40121. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40122. if !m.op.Is(OpUpdateOne) {
  40123. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40124. }
  40125. if m.id == nil || m.oldValue == nil {
  40126. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40127. }
  40128. oldValue, err := m.oldValue(ctx)
  40129. if err != nil {
  40130. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40131. }
  40132. return oldValue.OrganizationID, nil
  40133. }
  40134. // AddOrganizationID adds u to the "organization_id" field.
  40135. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  40136. if m.addorganization_id != nil {
  40137. *m.addorganization_id += u
  40138. } else {
  40139. m.addorganization_id = &u
  40140. }
  40141. }
  40142. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40143. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  40144. v := m.addorganization_id
  40145. if v == nil {
  40146. return
  40147. }
  40148. return *v, true
  40149. }
  40150. // ClearOrganizationID clears the value of the "organization_id" field.
  40151. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  40152. m.organization_id = nil
  40153. m.addorganization_id = nil
  40154. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  40155. }
  40156. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40157. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  40158. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  40159. return ok
  40160. }
  40161. // ResetOrganizationID resets all changes to the "organization_id" field.
  40162. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  40163. m.organization_id = nil
  40164. m.addorganization_id = nil
  40165. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  40166. }
  40167. // SetVerifyAccount sets the "verify_account" field.
  40168. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  40169. m.verify_account = &s
  40170. }
  40171. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  40172. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  40173. v := m.verify_account
  40174. if v == nil {
  40175. return
  40176. }
  40177. return *v, true
  40178. }
  40179. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  40180. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40182. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  40183. if !m.op.Is(OpUpdateOne) {
  40184. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  40185. }
  40186. if m.id == nil || m.oldValue == nil {
  40187. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  40188. }
  40189. oldValue, err := m.oldValue(ctx)
  40190. if err != nil {
  40191. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  40192. }
  40193. return oldValue.VerifyAccount, nil
  40194. }
  40195. // ResetVerifyAccount resets all changes to the "verify_account" field.
  40196. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  40197. m.verify_account = nil
  40198. }
  40199. // Where appends a list predicates to the WhatsappChannelMutation builder.
  40200. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  40201. m.predicates = append(m.predicates, ps...)
  40202. }
  40203. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  40204. // users can use type-assertion to append predicates that do not depend on any generated package.
  40205. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  40206. p := make([]predicate.WhatsappChannel, len(ps))
  40207. for i := range ps {
  40208. p[i] = ps[i]
  40209. }
  40210. m.Where(p...)
  40211. }
  40212. // Op returns the operation name.
  40213. func (m *WhatsappChannelMutation) Op() Op {
  40214. return m.op
  40215. }
  40216. // SetOp allows setting the mutation operation.
  40217. func (m *WhatsappChannelMutation) SetOp(op Op) {
  40218. m.op = op
  40219. }
  40220. // Type returns the node type of this mutation (WhatsappChannel).
  40221. func (m *WhatsappChannelMutation) Type() string {
  40222. return m.typ
  40223. }
  40224. // Fields returns all fields that were changed during this mutation. Note that in
  40225. // order to get all numeric fields that were incremented/decremented, call
  40226. // AddedFields().
  40227. func (m *WhatsappChannelMutation) Fields() []string {
  40228. fields := make([]string, 0, 12)
  40229. if m.created_at != nil {
  40230. fields = append(fields, whatsappchannel.FieldCreatedAt)
  40231. }
  40232. if m.updated_at != nil {
  40233. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  40234. }
  40235. if m.status != nil {
  40236. fields = append(fields, whatsappchannel.FieldStatus)
  40237. }
  40238. if m.deleted_at != nil {
  40239. fields = append(fields, whatsappchannel.FieldDeletedAt)
  40240. }
  40241. if m.ak != nil {
  40242. fields = append(fields, whatsappchannel.FieldAk)
  40243. }
  40244. if m.sk != nil {
  40245. fields = append(fields, whatsappchannel.FieldSk)
  40246. }
  40247. if m.wa_id != nil {
  40248. fields = append(fields, whatsappchannel.FieldWaID)
  40249. }
  40250. if m.wa_name != nil {
  40251. fields = append(fields, whatsappchannel.FieldWaName)
  40252. }
  40253. if m.waba_id != nil {
  40254. fields = append(fields, whatsappchannel.FieldWabaID)
  40255. }
  40256. if m.business_id != nil {
  40257. fields = append(fields, whatsappchannel.FieldBusinessID)
  40258. }
  40259. if m.organization_id != nil {
  40260. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40261. }
  40262. if m.verify_account != nil {
  40263. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  40264. }
  40265. return fields
  40266. }
  40267. // Field returns the value of a field with the given name. The second boolean
  40268. // return value indicates that this field was not set, or was not defined in the
  40269. // schema.
  40270. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  40271. switch name {
  40272. case whatsappchannel.FieldCreatedAt:
  40273. return m.CreatedAt()
  40274. case whatsappchannel.FieldUpdatedAt:
  40275. return m.UpdatedAt()
  40276. case whatsappchannel.FieldStatus:
  40277. return m.Status()
  40278. case whatsappchannel.FieldDeletedAt:
  40279. return m.DeletedAt()
  40280. case whatsappchannel.FieldAk:
  40281. return m.Ak()
  40282. case whatsappchannel.FieldSk:
  40283. return m.Sk()
  40284. case whatsappchannel.FieldWaID:
  40285. return m.WaID()
  40286. case whatsappchannel.FieldWaName:
  40287. return m.WaName()
  40288. case whatsappchannel.FieldWabaID:
  40289. return m.WabaID()
  40290. case whatsappchannel.FieldBusinessID:
  40291. return m.BusinessID()
  40292. case whatsappchannel.FieldOrganizationID:
  40293. return m.OrganizationID()
  40294. case whatsappchannel.FieldVerifyAccount:
  40295. return m.VerifyAccount()
  40296. }
  40297. return nil, false
  40298. }
  40299. // OldField returns the old value of the field from the database. An error is
  40300. // returned if the mutation operation is not UpdateOne, or the query to the
  40301. // database failed.
  40302. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40303. switch name {
  40304. case whatsappchannel.FieldCreatedAt:
  40305. return m.OldCreatedAt(ctx)
  40306. case whatsappchannel.FieldUpdatedAt:
  40307. return m.OldUpdatedAt(ctx)
  40308. case whatsappchannel.FieldStatus:
  40309. return m.OldStatus(ctx)
  40310. case whatsappchannel.FieldDeletedAt:
  40311. return m.OldDeletedAt(ctx)
  40312. case whatsappchannel.FieldAk:
  40313. return m.OldAk(ctx)
  40314. case whatsappchannel.FieldSk:
  40315. return m.OldSk(ctx)
  40316. case whatsappchannel.FieldWaID:
  40317. return m.OldWaID(ctx)
  40318. case whatsappchannel.FieldWaName:
  40319. return m.OldWaName(ctx)
  40320. case whatsappchannel.FieldWabaID:
  40321. return m.OldWabaID(ctx)
  40322. case whatsappchannel.FieldBusinessID:
  40323. return m.OldBusinessID(ctx)
  40324. case whatsappchannel.FieldOrganizationID:
  40325. return m.OldOrganizationID(ctx)
  40326. case whatsappchannel.FieldVerifyAccount:
  40327. return m.OldVerifyAccount(ctx)
  40328. }
  40329. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  40330. }
  40331. // SetField sets the value of a field with the given name. It returns an error if
  40332. // the field is not defined in the schema, or if the type mismatched the field
  40333. // type.
  40334. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  40335. switch name {
  40336. case whatsappchannel.FieldCreatedAt:
  40337. v, ok := value.(time.Time)
  40338. if !ok {
  40339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40340. }
  40341. m.SetCreatedAt(v)
  40342. return nil
  40343. case whatsappchannel.FieldUpdatedAt:
  40344. v, ok := value.(time.Time)
  40345. if !ok {
  40346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40347. }
  40348. m.SetUpdatedAt(v)
  40349. return nil
  40350. case whatsappchannel.FieldStatus:
  40351. v, ok := value.(uint8)
  40352. if !ok {
  40353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40354. }
  40355. m.SetStatus(v)
  40356. return nil
  40357. case whatsappchannel.FieldDeletedAt:
  40358. v, ok := value.(time.Time)
  40359. if !ok {
  40360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40361. }
  40362. m.SetDeletedAt(v)
  40363. return nil
  40364. case whatsappchannel.FieldAk:
  40365. v, ok := value.(string)
  40366. if !ok {
  40367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40368. }
  40369. m.SetAk(v)
  40370. return nil
  40371. case whatsappchannel.FieldSk:
  40372. v, ok := value.(string)
  40373. if !ok {
  40374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40375. }
  40376. m.SetSk(v)
  40377. return nil
  40378. case whatsappchannel.FieldWaID:
  40379. v, ok := value.(string)
  40380. if !ok {
  40381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40382. }
  40383. m.SetWaID(v)
  40384. return nil
  40385. case whatsappchannel.FieldWaName:
  40386. v, ok := value.(string)
  40387. if !ok {
  40388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40389. }
  40390. m.SetWaName(v)
  40391. return nil
  40392. case whatsappchannel.FieldWabaID:
  40393. v, ok := value.(uint64)
  40394. if !ok {
  40395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40396. }
  40397. m.SetWabaID(v)
  40398. return nil
  40399. case whatsappchannel.FieldBusinessID:
  40400. v, ok := value.(uint64)
  40401. if !ok {
  40402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40403. }
  40404. m.SetBusinessID(v)
  40405. return nil
  40406. case whatsappchannel.FieldOrganizationID:
  40407. v, ok := value.(uint64)
  40408. if !ok {
  40409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40410. }
  40411. m.SetOrganizationID(v)
  40412. return nil
  40413. case whatsappchannel.FieldVerifyAccount:
  40414. v, ok := value.(string)
  40415. if !ok {
  40416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40417. }
  40418. m.SetVerifyAccount(v)
  40419. return nil
  40420. }
  40421. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40422. }
  40423. // AddedFields returns all numeric fields that were incremented/decremented during
  40424. // this mutation.
  40425. func (m *WhatsappChannelMutation) AddedFields() []string {
  40426. var fields []string
  40427. if m.addstatus != nil {
  40428. fields = append(fields, whatsappchannel.FieldStatus)
  40429. }
  40430. if m.addwaba_id != nil {
  40431. fields = append(fields, whatsappchannel.FieldWabaID)
  40432. }
  40433. if m.addbusiness_id != nil {
  40434. fields = append(fields, whatsappchannel.FieldBusinessID)
  40435. }
  40436. if m.addorganization_id != nil {
  40437. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40438. }
  40439. return fields
  40440. }
  40441. // AddedField returns the numeric value that was incremented/decremented on a field
  40442. // with the given name. The second boolean return value indicates that this field
  40443. // was not set, or was not defined in the schema.
  40444. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  40445. switch name {
  40446. case whatsappchannel.FieldStatus:
  40447. return m.AddedStatus()
  40448. case whatsappchannel.FieldWabaID:
  40449. return m.AddedWabaID()
  40450. case whatsappchannel.FieldBusinessID:
  40451. return m.AddedBusinessID()
  40452. case whatsappchannel.FieldOrganizationID:
  40453. return m.AddedOrganizationID()
  40454. }
  40455. return nil, false
  40456. }
  40457. // AddField adds the value to the field with the given name. It returns an error if
  40458. // the field is not defined in the schema, or if the type mismatched the field
  40459. // type.
  40460. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  40461. switch name {
  40462. case whatsappchannel.FieldStatus:
  40463. v, ok := value.(int8)
  40464. if !ok {
  40465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40466. }
  40467. m.AddStatus(v)
  40468. return nil
  40469. case whatsappchannel.FieldWabaID:
  40470. v, ok := value.(int64)
  40471. if !ok {
  40472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40473. }
  40474. m.AddWabaID(v)
  40475. return nil
  40476. case whatsappchannel.FieldBusinessID:
  40477. v, ok := value.(int64)
  40478. if !ok {
  40479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40480. }
  40481. m.AddBusinessID(v)
  40482. return nil
  40483. case whatsappchannel.FieldOrganizationID:
  40484. v, ok := value.(int64)
  40485. if !ok {
  40486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40487. }
  40488. m.AddOrganizationID(v)
  40489. return nil
  40490. }
  40491. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  40492. }
  40493. // ClearedFields returns all nullable fields that were cleared during this
  40494. // mutation.
  40495. func (m *WhatsappChannelMutation) ClearedFields() []string {
  40496. var fields []string
  40497. if m.FieldCleared(whatsappchannel.FieldStatus) {
  40498. fields = append(fields, whatsappchannel.FieldStatus)
  40499. }
  40500. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  40501. fields = append(fields, whatsappchannel.FieldDeletedAt)
  40502. }
  40503. if m.FieldCleared(whatsappchannel.FieldAk) {
  40504. fields = append(fields, whatsappchannel.FieldAk)
  40505. }
  40506. if m.FieldCleared(whatsappchannel.FieldWaID) {
  40507. fields = append(fields, whatsappchannel.FieldWaID)
  40508. }
  40509. if m.FieldCleared(whatsappchannel.FieldWaName) {
  40510. fields = append(fields, whatsappchannel.FieldWaName)
  40511. }
  40512. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  40513. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40514. }
  40515. return fields
  40516. }
  40517. // FieldCleared returns a boolean indicating if a field with the given name was
  40518. // cleared in this mutation.
  40519. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  40520. _, ok := m.clearedFields[name]
  40521. return ok
  40522. }
  40523. // ClearField clears the value of the field with the given name. It returns an
  40524. // error if the field is not defined in the schema.
  40525. func (m *WhatsappChannelMutation) ClearField(name string) error {
  40526. switch name {
  40527. case whatsappchannel.FieldStatus:
  40528. m.ClearStatus()
  40529. return nil
  40530. case whatsappchannel.FieldDeletedAt:
  40531. m.ClearDeletedAt()
  40532. return nil
  40533. case whatsappchannel.FieldAk:
  40534. m.ClearAk()
  40535. return nil
  40536. case whatsappchannel.FieldWaID:
  40537. m.ClearWaID()
  40538. return nil
  40539. case whatsappchannel.FieldWaName:
  40540. m.ClearWaName()
  40541. return nil
  40542. case whatsappchannel.FieldOrganizationID:
  40543. m.ClearOrganizationID()
  40544. return nil
  40545. }
  40546. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  40547. }
  40548. // ResetField resets all changes in the mutation for the field with the given name.
  40549. // It returns an error if the field is not defined in the schema.
  40550. func (m *WhatsappChannelMutation) ResetField(name string) error {
  40551. switch name {
  40552. case whatsappchannel.FieldCreatedAt:
  40553. m.ResetCreatedAt()
  40554. return nil
  40555. case whatsappchannel.FieldUpdatedAt:
  40556. m.ResetUpdatedAt()
  40557. return nil
  40558. case whatsappchannel.FieldStatus:
  40559. m.ResetStatus()
  40560. return nil
  40561. case whatsappchannel.FieldDeletedAt:
  40562. m.ResetDeletedAt()
  40563. return nil
  40564. case whatsappchannel.FieldAk:
  40565. m.ResetAk()
  40566. return nil
  40567. case whatsappchannel.FieldSk:
  40568. m.ResetSk()
  40569. return nil
  40570. case whatsappchannel.FieldWaID:
  40571. m.ResetWaID()
  40572. return nil
  40573. case whatsappchannel.FieldWaName:
  40574. m.ResetWaName()
  40575. return nil
  40576. case whatsappchannel.FieldWabaID:
  40577. m.ResetWabaID()
  40578. return nil
  40579. case whatsappchannel.FieldBusinessID:
  40580. m.ResetBusinessID()
  40581. return nil
  40582. case whatsappchannel.FieldOrganizationID:
  40583. m.ResetOrganizationID()
  40584. return nil
  40585. case whatsappchannel.FieldVerifyAccount:
  40586. m.ResetVerifyAccount()
  40587. return nil
  40588. }
  40589. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40590. }
  40591. // AddedEdges returns all edge names that were set/added in this mutation.
  40592. func (m *WhatsappChannelMutation) AddedEdges() []string {
  40593. edges := make([]string, 0, 0)
  40594. return edges
  40595. }
  40596. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40597. // name in this mutation.
  40598. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  40599. return nil
  40600. }
  40601. // RemovedEdges returns all edge names that were removed in this mutation.
  40602. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  40603. edges := make([]string, 0, 0)
  40604. return edges
  40605. }
  40606. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40607. // the given name in this mutation.
  40608. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  40609. return nil
  40610. }
  40611. // ClearedEdges returns all edge names that were cleared in this mutation.
  40612. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  40613. edges := make([]string, 0, 0)
  40614. return edges
  40615. }
  40616. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40617. // was cleared in this mutation.
  40618. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  40619. return false
  40620. }
  40621. // ClearEdge clears the value of the edge with the given name. It returns an error
  40622. // if that edge is not defined in the schema.
  40623. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  40624. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  40625. }
  40626. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40627. // It returns an error if the edge is not defined in the schema.
  40628. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  40629. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  40630. }
  40631. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  40632. type WorkExperienceMutation struct {
  40633. config
  40634. op Op
  40635. typ string
  40636. id *uint64
  40637. created_at *time.Time
  40638. updated_at *time.Time
  40639. deleted_at *time.Time
  40640. start_date *time.Time
  40641. end_date *time.Time
  40642. company *string
  40643. experience *string
  40644. organization_id *uint64
  40645. addorganization_id *int64
  40646. clearedFields map[string]struct{}
  40647. employee *uint64
  40648. clearedemployee bool
  40649. done bool
  40650. oldValue func(context.Context) (*WorkExperience, error)
  40651. predicates []predicate.WorkExperience
  40652. }
  40653. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  40654. // workexperienceOption allows management of the mutation configuration using functional options.
  40655. type workexperienceOption func(*WorkExperienceMutation)
  40656. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  40657. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  40658. m := &WorkExperienceMutation{
  40659. config: c,
  40660. op: op,
  40661. typ: TypeWorkExperience,
  40662. clearedFields: make(map[string]struct{}),
  40663. }
  40664. for _, opt := range opts {
  40665. opt(m)
  40666. }
  40667. return m
  40668. }
  40669. // withWorkExperienceID sets the ID field of the mutation.
  40670. func withWorkExperienceID(id uint64) workexperienceOption {
  40671. return func(m *WorkExperienceMutation) {
  40672. var (
  40673. err error
  40674. once sync.Once
  40675. value *WorkExperience
  40676. )
  40677. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  40678. once.Do(func() {
  40679. if m.done {
  40680. err = errors.New("querying old values post mutation is not allowed")
  40681. } else {
  40682. value, err = m.Client().WorkExperience.Get(ctx, id)
  40683. }
  40684. })
  40685. return value, err
  40686. }
  40687. m.id = &id
  40688. }
  40689. }
  40690. // withWorkExperience sets the old WorkExperience of the mutation.
  40691. func withWorkExperience(node *WorkExperience) workexperienceOption {
  40692. return func(m *WorkExperienceMutation) {
  40693. m.oldValue = func(context.Context) (*WorkExperience, error) {
  40694. return node, nil
  40695. }
  40696. m.id = &node.ID
  40697. }
  40698. }
  40699. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40700. // executed in a transaction (ent.Tx), a transactional client is returned.
  40701. func (m WorkExperienceMutation) Client() *Client {
  40702. client := &Client{config: m.config}
  40703. client.init()
  40704. return client
  40705. }
  40706. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40707. // it returns an error otherwise.
  40708. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  40709. if _, ok := m.driver.(*txDriver); !ok {
  40710. return nil, errors.New("ent: mutation is not running in a transaction")
  40711. }
  40712. tx := &Tx{config: m.config}
  40713. tx.init()
  40714. return tx, nil
  40715. }
  40716. // SetID sets the value of the id field. Note that this
  40717. // operation is only accepted on creation of WorkExperience entities.
  40718. func (m *WorkExperienceMutation) SetID(id uint64) {
  40719. m.id = &id
  40720. }
  40721. // ID returns the ID value in the mutation. Note that the ID is only available
  40722. // if it was provided to the builder or after it was returned from the database.
  40723. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  40724. if m.id == nil {
  40725. return
  40726. }
  40727. return *m.id, true
  40728. }
  40729. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40730. // That means, if the mutation is applied within a transaction with an isolation level such
  40731. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40732. // or updated by the mutation.
  40733. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  40734. switch {
  40735. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40736. id, exists := m.ID()
  40737. if exists {
  40738. return []uint64{id}, nil
  40739. }
  40740. fallthrough
  40741. case m.op.Is(OpUpdate | OpDelete):
  40742. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  40743. default:
  40744. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40745. }
  40746. }
  40747. // SetCreatedAt sets the "created_at" field.
  40748. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  40749. m.created_at = &t
  40750. }
  40751. // CreatedAt returns the value of the "created_at" field in the mutation.
  40752. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  40753. v := m.created_at
  40754. if v == nil {
  40755. return
  40756. }
  40757. return *v, true
  40758. }
  40759. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  40760. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40762. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40763. if !m.op.Is(OpUpdateOne) {
  40764. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40765. }
  40766. if m.id == nil || m.oldValue == nil {
  40767. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40768. }
  40769. oldValue, err := m.oldValue(ctx)
  40770. if err != nil {
  40771. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40772. }
  40773. return oldValue.CreatedAt, nil
  40774. }
  40775. // ResetCreatedAt resets all changes to the "created_at" field.
  40776. func (m *WorkExperienceMutation) ResetCreatedAt() {
  40777. m.created_at = nil
  40778. }
  40779. // SetUpdatedAt sets the "updated_at" field.
  40780. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  40781. m.updated_at = &t
  40782. }
  40783. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40784. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  40785. v := m.updated_at
  40786. if v == nil {
  40787. return
  40788. }
  40789. return *v, true
  40790. }
  40791. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40795. if !m.op.Is(OpUpdateOne) {
  40796. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40797. }
  40798. if m.id == nil || m.oldValue == nil {
  40799. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  40804. }
  40805. return oldValue.UpdatedAt, nil
  40806. }
  40807. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40808. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  40809. m.updated_at = nil
  40810. }
  40811. // SetDeletedAt sets the "deleted_at" field.
  40812. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  40813. m.deleted_at = &t
  40814. }
  40815. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40816. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  40817. v := m.deleted_at
  40818. if v == nil {
  40819. return
  40820. }
  40821. return *v, true
  40822. }
  40823. // OldDeletedAt returns the old "deleted_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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40827. if !m.op.Is(OpUpdateOne) {
  40828. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40829. }
  40830. if m.id == nil || m.oldValue == nil {
  40831. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  40836. }
  40837. return oldValue.DeletedAt, nil
  40838. }
  40839. // ClearDeletedAt clears the value of the "deleted_at" field.
  40840. func (m *WorkExperienceMutation) ClearDeletedAt() {
  40841. m.deleted_at = nil
  40842. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  40843. }
  40844. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40845. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  40846. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  40847. return ok
  40848. }
  40849. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40850. func (m *WorkExperienceMutation) ResetDeletedAt() {
  40851. m.deleted_at = nil
  40852. delete(m.clearedFields, workexperience.FieldDeletedAt)
  40853. }
  40854. // SetEmployeeID sets the "employee_id" field.
  40855. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  40856. m.employee = &u
  40857. }
  40858. // EmployeeID returns the value of the "employee_id" field in the mutation.
  40859. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  40860. v := m.employee
  40861. if v == nil {
  40862. return
  40863. }
  40864. return *v, true
  40865. }
  40866. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  40867. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40869. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  40870. if !m.op.Is(OpUpdateOne) {
  40871. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  40872. }
  40873. if m.id == nil || m.oldValue == nil {
  40874. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  40875. }
  40876. oldValue, err := m.oldValue(ctx)
  40877. if err != nil {
  40878. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  40879. }
  40880. return oldValue.EmployeeID, nil
  40881. }
  40882. // ResetEmployeeID resets all changes to the "employee_id" field.
  40883. func (m *WorkExperienceMutation) ResetEmployeeID() {
  40884. m.employee = nil
  40885. }
  40886. // SetStartDate sets the "start_date" field.
  40887. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  40888. m.start_date = &t
  40889. }
  40890. // StartDate returns the value of the "start_date" field in the mutation.
  40891. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  40892. v := m.start_date
  40893. if v == nil {
  40894. return
  40895. }
  40896. return *v, true
  40897. }
  40898. // OldStartDate returns the old "start_date" 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) OldStartDate(ctx context.Context) (v time.Time, err error) {
  40902. if !m.op.Is(OpUpdateOne) {
  40903. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  40904. }
  40905. if m.id == nil || m.oldValue == nil {
  40906. return v, errors.New("OldStartDate 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 OldStartDate: %w", err)
  40911. }
  40912. return oldValue.StartDate, nil
  40913. }
  40914. // ResetStartDate resets all changes to the "start_date" field.
  40915. func (m *WorkExperienceMutation) ResetStartDate() {
  40916. m.start_date = nil
  40917. }
  40918. // SetEndDate sets the "end_date" field.
  40919. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  40920. m.end_date = &t
  40921. }
  40922. // EndDate returns the value of the "end_date" field in the mutation.
  40923. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  40924. v := m.end_date
  40925. if v == nil {
  40926. return
  40927. }
  40928. return *v, true
  40929. }
  40930. // OldEndDate returns the old "end_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) OldEndDate(ctx context.Context) (v time.Time, err error) {
  40934. if !m.op.Is(OpUpdateOne) {
  40935. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  40936. }
  40937. if m.id == nil || m.oldValue == nil {
  40938. return v, errors.New("OldEndDate 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 OldEndDate: %w", err)
  40943. }
  40944. return oldValue.EndDate, nil
  40945. }
  40946. // ResetEndDate resets all changes to the "end_date" field.
  40947. func (m *WorkExperienceMutation) ResetEndDate() {
  40948. m.end_date = nil
  40949. }
  40950. // SetCompany sets the "company" field.
  40951. func (m *WorkExperienceMutation) SetCompany(s string) {
  40952. m.company = &s
  40953. }
  40954. // Company returns the value of the "company" field in the mutation.
  40955. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  40956. v := m.company
  40957. if v == nil {
  40958. return
  40959. }
  40960. return *v, true
  40961. }
  40962. // OldCompany returns the old "company" 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) OldCompany(ctx context.Context) (v string, err error) {
  40966. if !m.op.Is(OpUpdateOne) {
  40967. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  40968. }
  40969. if m.id == nil || m.oldValue == nil {
  40970. return v, errors.New("OldCompany 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 OldCompany: %w", err)
  40975. }
  40976. return oldValue.Company, nil
  40977. }
  40978. // ResetCompany resets all changes to the "company" field.
  40979. func (m *WorkExperienceMutation) ResetCompany() {
  40980. m.company = nil
  40981. }
  40982. // SetExperience sets the "experience" field.
  40983. func (m *WorkExperienceMutation) SetExperience(s string) {
  40984. m.experience = &s
  40985. }
  40986. // Experience returns the value of the "experience" field in the mutation.
  40987. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  40988. v := m.experience
  40989. if v == nil {
  40990. return
  40991. }
  40992. return *v, true
  40993. }
  40994. // OldExperience returns the old "experience" 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) OldExperience(ctx context.Context) (v string, err error) {
  40998. if !m.op.Is(OpUpdateOne) {
  40999. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  41000. }
  41001. if m.id == nil || m.oldValue == nil {
  41002. return v, errors.New("OldExperience 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 OldExperience: %w", err)
  41007. }
  41008. return oldValue.Experience, nil
  41009. }
  41010. // ResetExperience resets all changes to the "experience" field.
  41011. func (m *WorkExperienceMutation) ResetExperience() {
  41012. m.experience = nil
  41013. }
  41014. // SetOrganizationID sets the "organization_id" field.
  41015. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  41016. m.organization_id = &u
  41017. m.addorganization_id = nil
  41018. }
  41019. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41020. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  41021. v := m.organization_id
  41022. if v == nil {
  41023. return
  41024. }
  41025. return *v, true
  41026. }
  41027. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  41028. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41030. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41031. if !m.op.Is(OpUpdateOne) {
  41032. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41033. }
  41034. if m.id == nil || m.oldValue == nil {
  41035. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41036. }
  41037. oldValue, err := m.oldValue(ctx)
  41038. if err != nil {
  41039. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41040. }
  41041. return oldValue.OrganizationID, nil
  41042. }
  41043. // AddOrganizationID adds u to the "organization_id" field.
  41044. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  41045. if m.addorganization_id != nil {
  41046. *m.addorganization_id += u
  41047. } else {
  41048. m.addorganization_id = &u
  41049. }
  41050. }
  41051. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41052. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  41053. v := m.addorganization_id
  41054. if v == nil {
  41055. return
  41056. }
  41057. return *v, true
  41058. }
  41059. // ResetOrganizationID resets all changes to the "organization_id" field.
  41060. func (m *WorkExperienceMutation) ResetOrganizationID() {
  41061. m.organization_id = nil
  41062. m.addorganization_id = nil
  41063. }
  41064. // ClearEmployee clears the "employee" edge to the Employee entity.
  41065. func (m *WorkExperienceMutation) ClearEmployee() {
  41066. m.clearedemployee = true
  41067. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  41068. }
  41069. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  41070. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  41071. return m.clearedemployee
  41072. }
  41073. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  41074. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41075. // EmployeeID instead. It exists only for internal usage by the builders.
  41076. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  41077. if id := m.employee; id != nil {
  41078. ids = append(ids, *id)
  41079. }
  41080. return
  41081. }
  41082. // ResetEmployee resets all changes to the "employee" edge.
  41083. func (m *WorkExperienceMutation) ResetEmployee() {
  41084. m.employee = nil
  41085. m.clearedemployee = false
  41086. }
  41087. // Where appends a list predicates to the WorkExperienceMutation builder.
  41088. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  41089. m.predicates = append(m.predicates, ps...)
  41090. }
  41091. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  41092. // users can use type-assertion to append predicates that do not depend on any generated package.
  41093. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  41094. p := make([]predicate.WorkExperience, len(ps))
  41095. for i := range ps {
  41096. p[i] = ps[i]
  41097. }
  41098. m.Where(p...)
  41099. }
  41100. // Op returns the operation name.
  41101. func (m *WorkExperienceMutation) Op() Op {
  41102. return m.op
  41103. }
  41104. // SetOp allows setting the mutation operation.
  41105. func (m *WorkExperienceMutation) SetOp(op Op) {
  41106. m.op = op
  41107. }
  41108. // Type returns the node type of this mutation (WorkExperience).
  41109. func (m *WorkExperienceMutation) Type() string {
  41110. return m.typ
  41111. }
  41112. // Fields returns all fields that were changed during this mutation. Note that in
  41113. // order to get all numeric fields that were incremented/decremented, call
  41114. // AddedFields().
  41115. func (m *WorkExperienceMutation) Fields() []string {
  41116. fields := make([]string, 0, 9)
  41117. if m.created_at != nil {
  41118. fields = append(fields, workexperience.FieldCreatedAt)
  41119. }
  41120. if m.updated_at != nil {
  41121. fields = append(fields, workexperience.FieldUpdatedAt)
  41122. }
  41123. if m.deleted_at != nil {
  41124. fields = append(fields, workexperience.FieldDeletedAt)
  41125. }
  41126. if m.employee != nil {
  41127. fields = append(fields, workexperience.FieldEmployeeID)
  41128. }
  41129. if m.start_date != nil {
  41130. fields = append(fields, workexperience.FieldStartDate)
  41131. }
  41132. if m.end_date != nil {
  41133. fields = append(fields, workexperience.FieldEndDate)
  41134. }
  41135. if m.company != nil {
  41136. fields = append(fields, workexperience.FieldCompany)
  41137. }
  41138. if m.experience != nil {
  41139. fields = append(fields, workexperience.FieldExperience)
  41140. }
  41141. if m.organization_id != nil {
  41142. fields = append(fields, workexperience.FieldOrganizationID)
  41143. }
  41144. return fields
  41145. }
  41146. // Field returns the value of a field with the given name. The second boolean
  41147. // return value indicates that this field was not set, or was not defined in the
  41148. // schema.
  41149. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  41150. switch name {
  41151. case workexperience.FieldCreatedAt:
  41152. return m.CreatedAt()
  41153. case workexperience.FieldUpdatedAt:
  41154. return m.UpdatedAt()
  41155. case workexperience.FieldDeletedAt:
  41156. return m.DeletedAt()
  41157. case workexperience.FieldEmployeeID:
  41158. return m.EmployeeID()
  41159. case workexperience.FieldStartDate:
  41160. return m.StartDate()
  41161. case workexperience.FieldEndDate:
  41162. return m.EndDate()
  41163. case workexperience.FieldCompany:
  41164. return m.Company()
  41165. case workexperience.FieldExperience:
  41166. return m.Experience()
  41167. case workexperience.FieldOrganizationID:
  41168. return m.OrganizationID()
  41169. }
  41170. return nil, false
  41171. }
  41172. // OldField returns the old value of the field from the database. An error is
  41173. // returned if the mutation operation is not UpdateOne, or the query to the
  41174. // database failed.
  41175. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41176. switch name {
  41177. case workexperience.FieldCreatedAt:
  41178. return m.OldCreatedAt(ctx)
  41179. case workexperience.FieldUpdatedAt:
  41180. return m.OldUpdatedAt(ctx)
  41181. case workexperience.FieldDeletedAt:
  41182. return m.OldDeletedAt(ctx)
  41183. case workexperience.FieldEmployeeID:
  41184. return m.OldEmployeeID(ctx)
  41185. case workexperience.FieldStartDate:
  41186. return m.OldStartDate(ctx)
  41187. case workexperience.FieldEndDate:
  41188. return m.OldEndDate(ctx)
  41189. case workexperience.FieldCompany:
  41190. return m.OldCompany(ctx)
  41191. case workexperience.FieldExperience:
  41192. return m.OldExperience(ctx)
  41193. case workexperience.FieldOrganizationID:
  41194. return m.OldOrganizationID(ctx)
  41195. }
  41196. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  41197. }
  41198. // SetField sets the value of a field with the given name. It returns an error if
  41199. // the field is not defined in the schema, or if the type mismatched the field
  41200. // type.
  41201. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  41202. switch name {
  41203. case workexperience.FieldCreatedAt:
  41204. v, ok := value.(time.Time)
  41205. if !ok {
  41206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41207. }
  41208. m.SetCreatedAt(v)
  41209. return nil
  41210. case workexperience.FieldUpdatedAt:
  41211. v, ok := value.(time.Time)
  41212. if !ok {
  41213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41214. }
  41215. m.SetUpdatedAt(v)
  41216. return nil
  41217. case workexperience.FieldDeletedAt:
  41218. v, ok := value.(time.Time)
  41219. if !ok {
  41220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41221. }
  41222. m.SetDeletedAt(v)
  41223. return nil
  41224. case workexperience.FieldEmployeeID:
  41225. v, ok := value.(uint64)
  41226. if !ok {
  41227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41228. }
  41229. m.SetEmployeeID(v)
  41230. return nil
  41231. case workexperience.FieldStartDate:
  41232. v, ok := value.(time.Time)
  41233. if !ok {
  41234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41235. }
  41236. m.SetStartDate(v)
  41237. return nil
  41238. case workexperience.FieldEndDate:
  41239. v, ok := value.(time.Time)
  41240. if !ok {
  41241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41242. }
  41243. m.SetEndDate(v)
  41244. return nil
  41245. case workexperience.FieldCompany:
  41246. v, ok := value.(string)
  41247. if !ok {
  41248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41249. }
  41250. m.SetCompany(v)
  41251. return nil
  41252. case workexperience.FieldExperience:
  41253. v, ok := value.(string)
  41254. if !ok {
  41255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41256. }
  41257. m.SetExperience(v)
  41258. return nil
  41259. case workexperience.FieldOrganizationID:
  41260. v, ok := value.(uint64)
  41261. if !ok {
  41262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41263. }
  41264. m.SetOrganizationID(v)
  41265. return nil
  41266. }
  41267. return fmt.Errorf("unknown WorkExperience field %s", name)
  41268. }
  41269. // AddedFields returns all numeric fields that were incremented/decremented during
  41270. // this mutation.
  41271. func (m *WorkExperienceMutation) AddedFields() []string {
  41272. var fields []string
  41273. if m.addorganization_id != nil {
  41274. fields = append(fields, workexperience.FieldOrganizationID)
  41275. }
  41276. return fields
  41277. }
  41278. // AddedField returns the numeric value that was incremented/decremented on a field
  41279. // with the given name. The second boolean return value indicates that this field
  41280. // was not set, or was not defined in the schema.
  41281. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  41282. switch name {
  41283. case workexperience.FieldOrganizationID:
  41284. return m.AddedOrganizationID()
  41285. }
  41286. return nil, false
  41287. }
  41288. // AddField adds the value to the field with the given name. It returns an error if
  41289. // the field is not defined in the schema, or if the type mismatched the field
  41290. // type.
  41291. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  41292. switch name {
  41293. case workexperience.FieldOrganizationID:
  41294. v, ok := value.(int64)
  41295. if !ok {
  41296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41297. }
  41298. m.AddOrganizationID(v)
  41299. return nil
  41300. }
  41301. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  41302. }
  41303. // ClearedFields returns all nullable fields that were cleared during this
  41304. // mutation.
  41305. func (m *WorkExperienceMutation) ClearedFields() []string {
  41306. var fields []string
  41307. if m.FieldCleared(workexperience.FieldDeletedAt) {
  41308. fields = append(fields, workexperience.FieldDeletedAt)
  41309. }
  41310. return fields
  41311. }
  41312. // FieldCleared returns a boolean indicating if a field with the given name was
  41313. // cleared in this mutation.
  41314. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  41315. _, ok := m.clearedFields[name]
  41316. return ok
  41317. }
  41318. // ClearField clears the value of the field with the given name. It returns an
  41319. // error if the field is not defined in the schema.
  41320. func (m *WorkExperienceMutation) ClearField(name string) error {
  41321. switch name {
  41322. case workexperience.FieldDeletedAt:
  41323. m.ClearDeletedAt()
  41324. return nil
  41325. }
  41326. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  41327. }
  41328. // ResetField resets all changes in the mutation for the field with the given name.
  41329. // It returns an error if the field is not defined in the schema.
  41330. func (m *WorkExperienceMutation) ResetField(name string) error {
  41331. switch name {
  41332. case workexperience.FieldCreatedAt:
  41333. m.ResetCreatedAt()
  41334. return nil
  41335. case workexperience.FieldUpdatedAt:
  41336. m.ResetUpdatedAt()
  41337. return nil
  41338. case workexperience.FieldDeletedAt:
  41339. m.ResetDeletedAt()
  41340. return nil
  41341. case workexperience.FieldEmployeeID:
  41342. m.ResetEmployeeID()
  41343. return nil
  41344. case workexperience.FieldStartDate:
  41345. m.ResetStartDate()
  41346. return nil
  41347. case workexperience.FieldEndDate:
  41348. m.ResetEndDate()
  41349. return nil
  41350. case workexperience.FieldCompany:
  41351. m.ResetCompany()
  41352. return nil
  41353. case workexperience.FieldExperience:
  41354. m.ResetExperience()
  41355. return nil
  41356. case workexperience.FieldOrganizationID:
  41357. m.ResetOrganizationID()
  41358. return nil
  41359. }
  41360. return fmt.Errorf("unknown WorkExperience field %s", name)
  41361. }
  41362. // AddedEdges returns all edge names that were set/added in this mutation.
  41363. func (m *WorkExperienceMutation) AddedEdges() []string {
  41364. edges := make([]string, 0, 1)
  41365. if m.employee != nil {
  41366. edges = append(edges, workexperience.EdgeEmployee)
  41367. }
  41368. return edges
  41369. }
  41370. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41371. // name in this mutation.
  41372. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  41373. switch name {
  41374. case workexperience.EdgeEmployee:
  41375. if id := m.employee; id != nil {
  41376. return []ent.Value{*id}
  41377. }
  41378. }
  41379. return nil
  41380. }
  41381. // RemovedEdges returns all edge names that were removed in this mutation.
  41382. func (m *WorkExperienceMutation) RemovedEdges() []string {
  41383. edges := make([]string, 0, 1)
  41384. return edges
  41385. }
  41386. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41387. // the given name in this mutation.
  41388. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  41389. return nil
  41390. }
  41391. // ClearedEdges returns all edge names that were cleared in this mutation.
  41392. func (m *WorkExperienceMutation) ClearedEdges() []string {
  41393. edges := make([]string, 0, 1)
  41394. if m.clearedemployee {
  41395. edges = append(edges, workexperience.EdgeEmployee)
  41396. }
  41397. return edges
  41398. }
  41399. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41400. // was cleared in this mutation.
  41401. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  41402. switch name {
  41403. case workexperience.EdgeEmployee:
  41404. return m.clearedemployee
  41405. }
  41406. return false
  41407. }
  41408. // ClearEdge clears the value of the edge with the given name. It returns an error
  41409. // if that edge is not defined in the schema.
  41410. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  41411. switch name {
  41412. case workexperience.EdgeEmployee:
  41413. m.ClearEmployee()
  41414. return nil
  41415. }
  41416. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  41417. }
  41418. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41419. // It returns an error if the edge is not defined in the schema.
  41420. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  41421. switch name {
  41422. case workexperience.EdgeEmployee:
  41423. m.ResetEmployee()
  41424. return nil
  41425. }
  41426. return fmt.Errorf("unknown WorkExperience edge %s", name)
  41427. }
  41428. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  41429. type WpChatroomMutation struct {
  41430. config
  41431. op Op
  41432. typ string
  41433. id *uint64
  41434. created_at *time.Time
  41435. updated_at *time.Time
  41436. status *uint8
  41437. addstatus *int8
  41438. wx_wxid *string
  41439. chatroom_id *string
  41440. nickname *string
  41441. owner *string
  41442. avatar *string
  41443. member_list *[]string
  41444. appendmember_list []string
  41445. clearedFields map[string]struct{}
  41446. done bool
  41447. oldValue func(context.Context) (*WpChatroom, error)
  41448. predicates []predicate.WpChatroom
  41449. }
  41450. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  41451. // wpchatroomOption allows management of the mutation configuration using functional options.
  41452. type wpchatroomOption func(*WpChatroomMutation)
  41453. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  41454. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  41455. m := &WpChatroomMutation{
  41456. config: c,
  41457. op: op,
  41458. typ: TypeWpChatroom,
  41459. clearedFields: make(map[string]struct{}),
  41460. }
  41461. for _, opt := range opts {
  41462. opt(m)
  41463. }
  41464. return m
  41465. }
  41466. // withWpChatroomID sets the ID field of the mutation.
  41467. func withWpChatroomID(id uint64) wpchatroomOption {
  41468. return func(m *WpChatroomMutation) {
  41469. var (
  41470. err error
  41471. once sync.Once
  41472. value *WpChatroom
  41473. )
  41474. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  41475. once.Do(func() {
  41476. if m.done {
  41477. err = errors.New("querying old values post mutation is not allowed")
  41478. } else {
  41479. value, err = m.Client().WpChatroom.Get(ctx, id)
  41480. }
  41481. })
  41482. return value, err
  41483. }
  41484. m.id = &id
  41485. }
  41486. }
  41487. // withWpChatroom sets the old WpChatroom of the mutation.
  41488. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  41489. return func(m *WpChatroomMutation) {
  41490. m.oldValue = func(context.Context) (*WpChatroom, error) {
  41491. return node, nil
  41492. }
  41493. m.id = &node.ID
  41494. }
  41495. }
  41496. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41497. // executed in a transaction (ent.Tx), a transactional client is returned.
  41498. func (m WpChatroomMutation) Client() *Client {
  41499. client := &Client{config: m.config}
  41500. client.init()
  41501. return client
  41502. }
  41503. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41504. // it returns an error otherwise.
  41505. func (m WpChatroomMutation) Tx() (*Tx, error) {
  41506. if _, ok := m.driver.(*txDriver); !ok {
  41507. return nil, errors.New("ent: mutation is not running in a transaction")
  41508. }
  41509. tx := &Tx{config: m.config}
  41510. tx.init()
  41511. return tx, nil
  41512. }
  41513. // SetID sets the value of the id field. Note that this
  41514. // operation is only accepted on creation of WpChatroom entities.
  41515. func (m *WpChatroomMutation) SetID(id uint64) {
  41516. m.id = &id
  41517. }
  41518. // ID returns the ID value in the mutation. Note that the ID is only available
  41519. // if it was provided to the builder or after it was returned from the database.
  41520. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  41521. if m.id == nil {
  41522. return
  41523. }
  41524. return *m.id, true
  41525. }
  41526. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41527. // That means, if the mutation is applied within a transaction with an isolation level such
  41528. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41529. // or updated by the mutation.
  41530. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  41531. switch {
  41532. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41533. id, exists := m.ID()
  41534. if exists {
  41535. return []uint64{id}, nil
  41536. }
  41537. fallthrough
  41538. case m.op.Is(OpUpdate | OpDelete):
  41539. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  41540. default:
  41541. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41542. }
  41543. }
  41544. // SetCreatedAt sets the "created_at" field.
  41545. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  41546. m.created_at = &t
  41547. }
  41548. // CreatedAt returns the value of the "created_at" field in the mutation.
  41549. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  41550. v := m.created_at
  41551. if v == nil {
  41552. return
  41553. }
  41554. return *v, true
  41555. }
  41556. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  41557. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41559. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41560. if !m.op.Is(OpUpdateOne) {
  41561. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41562. }
  41563. if m.id == nil || m.oldValue == nil {
  41564. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41565. }
  41566. oldValue, err := m.oldValue(ctx)
  41567. if err != nil {
  41568. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41569. }
  41570. return oldValue.CreatedAt, nil
  41571. }
  41572. // ResetCreatedAt resets all changes to the "created_at" field.
  41573. func (m *WpChatroomMutation) ResetCreatedAt() {
  41574. m.created_at = nil
  41575. }
  41576. // SetUpdatedAt sets the "updated_at" field.
  41577. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  41578. m.updated_at = &t
  41579. }
  41580. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41581. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  41582. v := m.updated_at
  41583. if v == nil {
  41584. return
  41585. }
  41586. return *v, true
  41587. }
  41588. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41592. if !m.op.Is(OpUpdateOne) {
  41593. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41594. }
  41595. if m.id == nil || m.oldValue == nil {
  41596. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  41601. }
  41602. return oldValue.UpdatedAt, nil
  41603. }
  41604. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41605. func (m *WpChatroomMutation) ResetUpdatedAt() {
  41606. m.updated_at = nil
  41607. }
  41608. // SetStatus sets the "status" field.
  41609. func (m *WpChatroomMutation) SetStatus(u uint8) {
  41610. m.status = &u
  41611. m.addstatus = nil
  41612. }
  41613. // Status returns the value of the "status" field in the mutation.
  41614. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  41615. v := m.status
  41616. if v == nil {
  41617. return
  41618. }
  41619. return *v, true
  41620. }
  41621. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  41622. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41624. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41625. if !m.op.Is(OpUpdateOne) {
  41626. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41627. }
  41628. if m.id == nil || m.oldValue == nil {
  41629. return v, errors.New("OldStatus requires an ID field in the mutation")
  41630. }
  41631. oldValue, err := m.oldValue(ctx)
  41632. if err != nil {
  41633. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41634. }
  41635. return oldValue.Status, nil
  41636. }
  41637. // AddStatus adds u to the "status" field.
  41638. func (m *WpChatroomMutation) AddStatus(u int8) {
  41639. if m.addstatus != nil {
  41640. *m.addstatus += u
  41641. } else {
  41642. m.addstatus = &u
  41643. }
  41644. }
  41645. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41646. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  41647. v := m.addstatus
  41648. if v == nil {
  41649. return
  41650. }
  41651. return *v, true
  41652. }
  41653. // ClearStatus clears the value of the "status" field.
  41654. func (m *WpChatroomMutation) ClearStatus() {
  41655. m.status = nil
  41656. m.addstatus = nil
  41657. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  41658. }
  41659. // StatusCleared returns if the "status" field was cleared in this mutation.
  41660. func (m *WpChatroomMutation) StatusCleared() bool {
  41661. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  41662. return ok
  41663. }
  41664. // ResetStatus resets all changes to the "status" field.
  41665. func (m *WpChatroomMutation) ResetStatus() {
  41666. m.status = nil
  41667. m.addstatus = nil
  41668. delete(m.clearedFields, wpchatroom.FieldStatus)
  41669. }
  41670. // SetWxWxid sets the "wx_wxid" field.
  41671. func (m *WpChatroomMutation) SetWxWxid(s string) {
  41672. m.wx_wxid = &s
  41673. }
  41674. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  41675. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  41676. v := m.wx_wxid
  41677. if v == nil {
  41678. return
  41679. }
  41680. return *v, true
  41681. }
  41682. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  41683. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41685. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  41686. if !m.op.Is(OpUpdateOne) {
  41687. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  41688. }
  41689. if m.id == nil || m.oldValue == nil {
  41690. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  41691. }
  41692. oldValue, err := m.oldValue(ctx)
  41693. if err != nil {
  41694. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  41695. }
  41696. return oldValue.WxWxid, nil
  41697. }
  41698. // ResetWxWxid resets all changes to the "wx_wxid" field.
  41699. func (m *WpChatroomMutation) ResetWxWxid() {
  41700. m.wx_wxid = nil
  41701. }
  41702. // SetChatroomID sets the "chatroom_id" field.
  41703. func (m *WpChatroomMutation) SetChatroomID(s string) {
  41704. m.chatroom_id = &s
  41705. }
  41706. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  41707. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  41708. v := m.chatroom_id
  41709. if v == nil {
  41710. return
  41711. }
  41712. return *v, true
  41713. }
  41714. // OldChatroomID returns the old "chatroom_id" 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) OldChatroomID(ctx context.Context) (v string, err error) {
  41718. if !m.op.Is(OpUpdateOne) {
  41719. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  41720. }
  41721. if m.id == nil || m.oldValue == nil {
  41722. return v, errors.New("OldChatroomID 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 OldChatroomID: %w", err)
  41727. }
  41728. return oldValue.ChatroomID, nil
  41729. }
  41730. // ResetChatroomID resets all changes to the "chatroom_id" field.
  41731. func (m *WpChatroomMutation) ResetChatroomID() {
  41732. m.chatroom_id = nil
  41733. }
  41734. // SetNickname sets the "nickname" field.
  41735. func (m *WpChatroomMutation) SetNickname(s string) {
  41736. m.nickname = &s
  41737. }
  41738. // Nickname returns the value of the "nickname" field in the mutation.
  41739. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  41740. v := m.nickname
  41741. if v == nil {
  41742. return
  41743. }
  41744. return *v, true
  41745. }
  41746. // OldNickname returns the old "nickname" 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) OldNickname(ctx context.Context) (v string, err error) {
  41750. if !m.op.Is(OpUpdateOne) {
  41751. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41752. }
  41753. if m.id == nil || m.oldValue == nil {
  41754. return v, errors.New("OldNickname 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 OldNickname: %w", err)
  41759. }
  41760. return oldValue.Nickname, nil
  41761. }
  41762. // ResetNickname resets all changes to the "nickname" field.
  41763. func (m *WpChatroomMutation) ResetNickname() {
  41764. m.nickname = nil
  41765. }
  41766. // SetOwner sets the "owner" field.
  41767. func (m *WpChatroomMutation) SetOwner(s string) {
  41768. m.owner = &s
  41769. }
  41770. // Owner returns the value of the "owner" field in the mutation.
  41771. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  41772. v := m.owner
  41773. if v == nil {
  41774. return
  41775. }
  41776. return *v, true
  41777. }
  41778. // OldOwner returns the old "owner" 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) OldOwner(ctx context.Context) (v string, err error) {
  41782. if !m.op.Is(OpUpdateOne) {
  41783. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  41784. }
  41785. if m.id == nil || m.oldValue == nil {
  41786. return v, errors.New("OldOwner 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 OldOwner: %w", err)
  41791. }
  41792. return oldValue.Owner, nil
  41793. }
  41794. // ResetOwner resets all changes to the "owner" field.
  41795. func (m *WpChatroomMutation) ResetOwner() {
  41796. m.owner = nil
  41797. }
  41798. // SetAvatar sets the "avatar" field.
  41799. func (m *WpChatroomMutation) SetAvatar(s string) {
  41800. m.avatar = &s
  41801. }
  41802. // Avatar returns the value of the "avatar" field in the mutation.
  41803. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  41804. v := m.avatar
  41805. if v == nil {
  41806. return
  41807. }
  41808. return *v, true
  41809. }
  41810. // OldAvatar returns the old "avatar" 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) OldAvatar(ctx context.Context) (v string, err error) {
  41814. if !m.op.Is(OpUpdateOne) {
  41815. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41816. }
  41817. if m.id == nil || m.oldValue == nil {
  41818. return v, errors.New("OldAvatar 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 OldAvatar: %w", err)
  41823. }
  41824. return oldValue.Avatar, nil
  41825. }
  41826. // ResetAvatar resets all changes to the "avatar" field.
  41827. func (m *WpChatroomMutation) ResetAvatar() {
  41828. m.avatar = nil
  41829. }
  41830. // SetMemberList sets the "member_list" field.
  41831. func (m *WpChatroomMutation) SetMemberList(s []string) {
  41832. m.member_list = &s
  41833. m.appendmember_list = nil
  41834. }
  41835. // MemberList returns the value of the "member_list" field in the mutation.
  41836. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  41837. v := m.member_list
  41838. if v == nil {
  41839. return
  41840. }
  41841. return *v, true
  41842. }
  41843. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  41844. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41846. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  41847. if !m.op.Is(OpUpdateOne) {
  41848. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  41849. }
  41850. if m.id == nil || m.oldValue == nil {
  41851. return v, errors.New("OldMemberList requires an ID field in the mutation")
  41852. }
  41853. oldValue, err := m.oldValue(ctx)
  41854. if err != nil {
  41855. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  41856. }
  41857. return oldValue.MemberList, nil
  41858. }
  41859. // AppendMemberList adds s to the "member_list" field.
  41860. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  41861. m.appendmember_list = append(m.appendmember_list, s...)
  41862. }
  41863. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  41864. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  41865. if len(m.appendmember_list) == 0 {
  41866. return nil, false
  41867. }
  41868. return m.appendmember_list, true
  41869. }
  41870. // ResetMemberList resets all changes to the "member_list" field.
  41871. func (m *WpChatroomMutation) ResetMemberList() {
  41872. m.member_list = nil
  41873. m.appendmember_list = nil
  41874. }
  41875. // Where appends a list predicates to the WpChatroomMutation builder.
  41876. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  41877. m.predicates = append(m.predicates, ps...)
  41878. }
  41879. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  41880. // users can use type-assertion to append predicates that do not depend on any generated package.
  41881. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  41882. p := make([]predicate.WpChatroom, len(ps))
  41883. for i := range ps {
  41884. p[i] = ps[i]
  41885. }
  41886. m.Where(p...)
  41887. }
  41888. // Op returns the operation name.
  41889. func (m *WpChatroomMutation) Op() Op {
  41890. return m.op
  41891. }
  41892. // SetOp allows setting the mutation operation.
  41893. func (m *WpChatroomMutation) SetOp(op Op) {
  41894. m.op = op
  41895. }
  41896. // Type returns the node type of this mutation (WpChatroom).
  41897. func (m *WpChatroomMutation) Type() string {
  41898. return m.typ
  41899. }
  41900. // Fields returns all fields that were changed during this mutation. Note that in
  41901. // order to get all numeric fields that were incremented/decremented, call
  41902. // AddedFields().
  41903. func (m *WpChatroomMutation) Fields() []string {
  41904. fields := make([]string, 0, 9)
  41905. if m.created_at != nil {
  41906. fields = append(fields, wpchatroom.FieldCreatedAt)
  41907. }
  41908. if m.updated_at != nil {
  41909. fields = append(fields, wpchatroom.FieldUpdatedAt)
  41910. }
  41911. if m.status != nil {
  41912. fields = append(fields, wpchatroom.FieldStatus)
  41913. }
  41914. if m.wx_wxid != nil {
  41915. fields = append(fields, wpchatroom.FieldWxWxid)
  41916. }
  41917. if m.chatroom_id != nil {
  41918. fields = append(fields, wpchatroom.FieldChatroomID)
  41919. }
  41920. if m.nickname != nil {
  41921. fields = append(fields, wpchatroom.FieldNickname)
  41922. }
  41923. if m.owner != nil {
  41924. fields = append(fields, wpchatroom.FieldOwner)
  41925. }
  41926. if m.avatar != nil {
  41927. fields = append(fields, wpchatroom.FieldAvatar)
  41928. }
  41929. if m.member_list != nil {
  41930. fields = append(fields, wpchatroom.FieldMemberList)
  41931. }
  41932. return fields
  41933. }
  41934. // Field returns the value of a field with the given name. The second boolean
  41935. // return value indicates that this field was not set, or was not defined in the
  41936. // schema.
  41937. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  41938. switch name {
  41939. case wpchatroom.FieldCreatedAt:
  41940. return m.CreatedAt()
  41941. case wpchatroom.FieldUpdatedAt:
  41942. return m.UpdatedAt()
  41943. case wpchatroom.FieldStatus:
  41944. return m.Status()
  41945. case wpchatroom.FieldWxWxid:
  41946. return m.WxWxid()
  41947. case wpchatroom.FieldChatroomID:
  41948. return m.ChatroomID()
  41949. case wpchatroom.FieldNickname:
  41950. return m.Nickname()
  41951. case wpchatroom.FieldOwner:
  41952. return m.Owner()
  41953. case wpchatroom.FieldAvatar:
  41954. return m.Avatar()
  41955. case wpchatroom.FieldMemberList:
  41956. return m.MemberList()
  41957. }
  41958. return nil, false
  41959. }
  41960. // OldField returns the old value of the field from the database. An error is
  41961. // returned if the mutation operation is not UpdateOne, or the query to the
  41962. // database failed.
  41963. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41964. switch name {
  41965. case wpchatroom.FieldCreatedAt:
  41966. return m.OldCreatedAt(ctx)
  41967. case wpchatroom.FieldUpdatedAt:
  41968. return m.OldUpdatedAt(ctx)
  41969. case wpchatroom.FieldStatus:
  41970. return m.OldStatus(ctx)
  41971. case wpchatroom.FieldWxWxid:
  41972. return m.OldWxWxid(ctx)
  41973. case wpchatroom.FieldChatroomID:
  41974. return m.OldChatroomID(ctx)
  41975. case wpchatroom.FieldNickname:
  41976. return m.OldNickname(ctx)
  41977. case wpchatroom.FieldOwner:
  41978. return m.OldOwner(ctx)
  41979. case wpchatroom.FieldAvatar:
  41980. return m.OldAvatar(ctx)
  41981. case wpchatroom.FieldMemberList:
  41982. return m.OldMemberList(ctx)
  41983. }
  41984. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  41985. }
  41986. // SetField sets the value of a field with the given name. It returns an error if
  41987. // the field is not defined in the schema, or if the type mismatched the field
  41988. // type.
  41989. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  41990. switch name {
  41991. case wpchatroom.FieldCreatedAt:
  41992. v, ok := value.(time.Time)
  41993. if !ok {
  41994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41995. }
  41996. m.SetCreatedAt(v)
  41997. return nil
  41998. case wpchatroom.FieldUpdatedAt:
  41999. v, ok := value.(time.Time)
  42000. if !ok {
  42001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42002. }
  42003. m.SetUpdatedAt(v)
  42004. return nil
  42005. case wpchatroom.FieldStatus:
  42006. v, ok := value.(uint8)
  42007. if !ok {
  42008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42009. }
  42010. m.SetStatus(v)
  42011. return nil
  42012. case wpchatroom.FieldWxWxid:
  42013. v, ok := value.(string)
  42014. if !ok {
  42015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42016. }
  42017. m.SetWxWxid(v)
  42018. return nil
  42019. case wpchatroom.FieldChatroomID:
  42020. v, ok := value.(string)
  42021. if !ok {
  42022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42023. }
  42024. m.SetChatroomID(v)
  42025. return nil
  42026. case wpchatroom.FieldNickname:
  42027. v, ok := value.(string)
  42028. if !ok {
  42029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42030. }
  42031. m.SetNickname(v)
  42032. return nil
  42033. case wpchatroom.FieldOwner:
  42034. v, ok := value.(string)
  42035. if !ok {
  42036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42037. }
  42038. m.SetOwner(v)
  42039. return nil
  42040. case wpchatroom.FieldAvatar:
  42041. v, ok := value.(string)
  42042. if !ok {
  42043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42044. }
  42045. m.SetAvatar(v)
  42046. return nil
  42047. case wpchatroom.FieldMemberList:
  42048. v, ok := value.([]string)
  42049. if !ok {
  42050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42051. }
  42052. m.SetMemberList(v)
  42053. return nil
  42054. }
  42055. return fmt.Errorf("unknown WpChatroom field %s", name)
  42056. }
  42057. // AddedFields returns all numeric fields that were incremented/decremented during
  42058. // this mutation.
  42059. func (m *WpChatroomMutation) AddedFields() []string {
  42060. var fields []string
  42061. if m.addstatus != nil {
  42062. fields = append(fields, wpchatroom.FieldStatus)
  42063. }
  42064. return fields
  42065. }
  42066. // AddedField returns the numeric value that was incremented/decremented on a field
  42067. // with the given name. The second boolean return value indicates that this field
  42068. // was not set, or was not defined in the schema.
  42069. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  42070. switch name {
  42071. case wpchatroom.FieldStatus:
  42072. return m.AddedStatus()
  42073. }
  42074. return nil, false
  42075. }
  42076. // AddField adds the value to the field with the given name. It returns an error if
  42077. // the field is not defined in the schema, or if the type mismatched the field
  42078. // type.
  42079. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  42080. switch name {
  42081. case wpchatroom.FieldStatus:
  42082. v, ok := value.(int8)
  42083. if !ok {
  42084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42085. }
  42086. m.AddStatus(v)
  42087. return nil
  42088. }
  42089. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  42090. }
  42091. // ClearedFields returns all nullable fields that were cleared during this
  42092. // mutation.
  42093. func (m *WpChatroomMutation) ClearedFields() []string {
  42094. var fields []string
  42095. if m.FieldCleared(wpchatroom.FieldStatus) {
  42096. fields = append(fields, wpchatroom.FieldStatus)
  42097. }
  42098. return fields
  42099. }
  42100. // FieldCleared returns a boolean indicating if a field with the given name was
  42101. // cleared in this mutation.
  42102. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  42103. _, ok := m.clearedFields[name]
  42104. return ok
  42105. }
  42106. // ClearField clears the value of the field with the given name. It returns an
  42107. // error if the field is not defined in the schema.
  42108. func (m *WpChatroomMutation) ClearField(name string) error {
  42109. switch name {
  42110. case wpchatroom.FieldStatus:
  42111. m.ClearStatus()
  42112. return nil
  42113. }
  42114. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  42115. }
  42116. // ResetField resets all changes in the mutation for the field with the given name.
  42117. // It returns an error if the field is not defined in the schema.
  42118. func (m *WpChatroomMutation) ResetField(name string) error {
  42119. switch name {
  42120. case wpchatroom.FieldCreatedAt:
  42121. m.ResetCreatedAt()
  42122. return nil
  42123. case wpchatroom.FieldUpdatedAt:
  42124. m.ResetUpdatedAt()
  42125. return nil
  42126. case wpchatroom.FieldStatus:
  42127. m.ResetStatus()
  42128. return nil
  42129. case wpchatroom.FieldWxWxid:
  42130. m.ResetWxWxid()
  42131. return nil
  42132. case wpchatroom.FieldChatroomID:
  42133. m.ResetChatroomID()
  42134. return nil
  42135. case wpchatroom.FieldNickname:
  42136. m.ResetNickname()
  42137. return nil
  42138. case wpchatroom.FieldOwner:
  42139. m.ResetOwner()
  42140. return nil
  42141. case wpchatroom.FieldAvatar:
  42142. m.ResetAvatar()
  42143. return nil
  42144. case wpchatroom.FieldMemberList:
  42145. m.ResetMemberList()
  42146. return nil
  42147. }
  42148. return fmt.Errorf("unknown WpChatroom field %s", name)
  42149. }
  42150. // AddedEdges returns all edge names that were set/added in this mutation.
  42151. func (m *WpChatroomMutation) AddedEdges() []string {
  42152. edges := make([]string, 0, 0)
  42153. return edges
  42154. }
  42155. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42156. // name in this mutation.
  42157. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  42158. return nil
  42159. }
  42160. // RemovedEdges returns all edge names that were removed in this mutation.
  42161. func (m *WpChatroomMutation) RemovedEdges() []string {
  42162. edges := make([]string, 0, 0)
  42163. return edges
  42164. }
  42165. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42166. // the given name in this mutation.
  42167. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  42168. return nil
  42169. }
  42170. // ClearedEdges returns all edge names that were cleared in this mutation.
  42171. func (m *WpChatroomMutation) ClearedEdges() []string {
  42172. edges := make([]string, 0, 0)
  42173. return edges
  42174. }
  42175. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42176. // was cleared in this mutation.
  42177. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  42178. return false
  42179. }
  42180. // ClearEdge clears the value of the edge with the given name. It returns an error
  42181. // if that edge is not defined in the schema.
  42182. func (m *WpChatroomMutation) ClearEdge(name string) error {
  42183. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  42184. }
  42185. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42186. // It returns an error if the edge is not defined in the schema.
  42187. func (m *WpChatroomMutation) ResetEdge(name string) error {
  42188. return fmt.Errorf("unknown WpChatroom edge %s", name)
  42189. }
  42190. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  42191. type WpChatroomMemberMutation struct {
  42192. config
  42193. op Op
  42194. typ string
  42195. id *uint64
  42196. created_at *time.Time
  42197. updated_at *time.Time
  42198. status *uint8
  42199. addstatus *int8
  42200. wx_wxid *string
  42201. wxid *string
  42202. nickname *string
  42203. avatar *string
  42204. clearedFields map[string]struct{}
  42205. done bool
  42206. oldValue func(context.Context) (*WpChatroomMember, error)
  42207. predicates []predicate.WpChatroomMember
  42208. }
  42209. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  42210. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  42211. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  42212. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  42213. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  42214. m := &WpChatroomMemberMutation{
  42215. config: c,
  42216. op: op,
  42217. typ: TypeWpChatroomMember,
  42218. clearedFields: make(map[string]struct{}),
  42219. }
  42220. for _, opt := range opts {
  42221. opt(m)
  42222. }
  42223. return m
  42224. }
  42225. // withWpChatroomMemberID sets the ID field of the mutation.
  42226. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  42227. return func(m *WpChatroomMemberMutation) {
  42228. var (
  42229. err error
  42230. once sync.Once
  42231. value *WpChatroomMember
  42232. )
  42233. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  42234. once.Do(func() {
  42235. if m.done {
  42236. err = errors.New("querying old values post mutation is not allowed")
  42237. } else {
  42238. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  42239. }
  42240. })
  42241. return value, err
  42242. }
  42243. m.id = &id
  42244. }
  42245. }
  42246. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  42247. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  42248. return func(m *WpChatroomMemberMutation) {
  42249. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  42250. return node, nil
  42251. }
  42252. m.id = &node.ID
  42253. }
  42254. }
  42255. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42256. // executed in a transaction (ent.Tx), a transactional client is returned.
  42257. func (m WpChatroomMemberMutation) Client() *Client {
  42258. client := &Client{config: m.config}
  42259. client.init()
  42260. return client
  42261. }
  42262. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42263. // it returns an error otherwise.
  42264. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  42265. if _, ok := m.driver.(*txDriver); !ok {
  42266. return nil, errors.New("ent: mutation is not running in a transaction")
  42267. }
  42268. tx := &Tx{config: m.config}
  42269. tx.init()
  42270. return tx, nil
  42271. }
  42272. // SetID sets the value of the id field. Note that this
  42273. // operation is only accepted on creation of WpChatroomMember entities.
  42274. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  42275. m.id = &id
  42276. }
  42277. // ID returns the ID value in the mutation. Note that the ID is only available
  42278. // if it was provided to the builder or after it was returned from the database.
  42279. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  42280. if m.id == nil {
  42281. return
  42282. }
  42283. return *m.id, true
  42284. }
  42285. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42286. // That means, if the mutation is applied within a transaction with an isolation level such
  42287. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42288. // or updated by the mutation.
  42289. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  42290. switch {
  42291. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42292. id, exists := m.ID()
  42293. if exists {
  42294. return []uint64{id}, nil
  42295. }
  42296. fallthrough
  42297. case m.op.Is(OpUpdate | OpDelete):
  42298. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  42299. default:
  42300. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42301. }
  42302. }
  42303. // SetCreatedAt sets the "created_at" field.
  42304. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  42305. m.created_at = &t
  42306. }
  42307. // CreatedAt returns the value of the "created_at" field in the mutation.
  42308. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  42309. v := m.created_at
  42310. if v == nil {
  42311. return
  42312. }
  42313. return *v, true
  42314. }
  42315. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  42316. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42318. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42319. if !m.op.Is(OpUpdateOne) {
  42320. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42321. }
  42322. if m.id == nil || m.oldValue == nil {
  42323. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42324. }
  42325. oldValue, err := m.oldValue(ctx)
  42326. if err != nil {
  42327. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42328. }
  42329. return oldValue.CreatedAt, nil
  42330. }
  42331. // ResetCreatedAt resets all changes to the "created_at" field.
  42332. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  42333. m.created_at = nil
  42334. }
  42335. // SetUpdatedAt sets the "updated_at" field.
  42336. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  42337. m.updated_at = &t
  42338. }
  42339. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42340. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  42341. v := m.updated_at
  42342. if v == nil {
  42343. return
  42344. }
  42345. return *v, true
  42346. }
  42347. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42351. if !m.op.Is(OpUpdateOne) {
  42352. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42353. }
  42354. if m.id == nil || m.oldValue == nil {
  42355. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  42360. }
  42361. return oldValue.UpdatedAt, nil
  42362. }
  42363. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42364. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  42365. m.updated_at = nil
  42366. }
  42367. // SetStatus sets the "status" field.
  42368. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  42369. m.status = &u
  42370. m.addstatus = nil
  42371. }
  42372. // Status returns the value of the "status" field in the mutation.
  42373. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  42374. v := m.status
  42375. if v == nil {
  42376. return
  42377. }
  42378. return *v, true
  42379. }
  42380. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  42381. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42383. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42384. if !m.op.Is(OpUpdateOne) {
  42385. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42386. }
  42387. if m.id == nil || m.oldValue == nil {
  42388. return v, errors.New("OldStatus requires an ID field in the mutation")
  42389. }
  42390. oldValue, err := m.oldValue(ctx)
  42391. if err != nil {
  42392. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42393. }
  42394. return oldValue.Status, nil
  42395. }
  42396. // AddStatus adds u to the "status" field.
  42397. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  42398. if m.addstatus != nil {
  42399. *m.addstatus += u
  42400. } else {
  42401. m.addstatus = &u
  42402. }
  42403. }
  42404. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42405. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  42406. v := m.addstatus
  42407. if v == nil {
  42408. return
  42409. }
  42410. return *v, true
  42411. }
  42412. // ClearStatus clears the value of the "status" field.
  42413. func (m *WpChatroomMemberMutation) ClearStatus() {
  42414. m.status = nil
  42415. m.addstatus = nil
  42416. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  42417. }
  42418. // StatusCleared returns if the "status" field was cleared in this mutation.
  42419. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  42420. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  42421. return ok
  42422. }
  42423. // ResetStatus resets all changes to the "status" field.
  42424. func (m *WpChatroomMemberMutation) ResetStatus() {
  42425. m.status = nil
  42426. m.addstatus = nil
  42427. delete(m.clearedFields, wpchatroommember.FieldStatus)
  42428. }
  42429. // SetWxWxid sets the "wx_wxid" field.
  42430. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  42431. m.wx_wxid = &s
  42432. }
  42433. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  42434. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  42435. v := m.wx_wxid
  42436. if v == nil {
  42437. return
  42438. }
  42439. return *v, true
  42440. }
  42441. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  42442. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42444. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  42445. if !m.op.Is(OpUpdateOne) {
  42446. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  42447. }
  42448. if m.id == nil || m.oldValue == nil {
  42449. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  42450. }
  42451. oldValue, err := m.oldValue(ctx)
  42452. if err != nil {
  42453. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  42454. }
  42455. return oldValue.WxWxid, nil
  42456. }
  42457. // ResetWxWxid resets all changes to the "wx_wxid" field.
  42458. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  42459. m.wx_wxid = nil
  42460. }
  42461. // SetWxid sets the "wxid" field.
  42462. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  42463. m.wxid = &s
  42464. }
  42465. // Wxid returns the value of the "wxid" field in the mutation.
  42466. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  42467. v := m.wxid
  42468. if v == nil {
  42469. return
  42470. }
  42471. return *v, true
  42472. }
  42473. // OldWxid returns the old "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) OldWxid(ctx context.Context) (v string, err error) {
  42477. if !m.op.Is(OpUpdateOne) {
  42478. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  42479. }
  42480. if m.id == nil || m.oldValue == nil {
  42481. return v, errors.New("OldWxid 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 OldWxid: %w", err)
  42486. }
  42487. return oldValue.Wxid, nil
  42488. }
  42489. // ResetWxid resets all changes to the "wxid" field.
  42490. func (m *WpChatroomMemberMutation) ResetWxid() {
  42491. m.wxid = nil
  42492. }
  42493. // SetNickname sets the "nickname" field.
  42494. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  42495. m.nickname = &s
  42496. }
  42497. // Nickname returns the value of the "nickname" field in the mutation.
  42498. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  42499. v := m.nickname
  42500. if v == nil {
  42501. return
  42502. }
  42503. return *v, true
  42504. }
  42505. // OldNickname returns the old "nickname" 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) OldNickname(ctx context.Context) (v string, err error) {
  42509. if !m.op.Is(OpUpdateOne) {
  42510. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42511. }
  42512. if m.id == nil || m.oldValue == nil {
  42513. return v, errors.New("OldNickname 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 OldNickname: %w", err)
  42518. }
  42519. return oldValue.Nickname, nil
  42520. }
  42521. // ResetNickname resets all changes to the "nickname" field.
  42522. func (m *WpChatroomMemberMutation) ResetNickname() {
  42523. m.nickname = nil
  42524. }
  42525. // SetAvatar sets the "avatar" field.
  42526. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  42527. m.avatar = &s
  42528. }
  42529. // Avatar returns the value of the "avatar" field in the mutation.
  42530. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  42531. v := m.avatar
  42532. if v == nil {
  42533. return
  42534. }
  42535. return *v, true
  42536. }
  42537. // OldAvatar returns the old "avatar" 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) OldAvatar(ctx context.Context) (v string, err error) {
  42541. if !m.op.Is(OpUpdateOne) {
  42542. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42543. }
  42544. if m.id == nil || m.oldValue == nil {
  42545. return v, errors.New("OldAvatar 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 OldAvatar: %w", err)
  42550. }
  42551. return oldValue.Avatar, nil
  42552. }
  42553. // ResetAvatar resets all changes to the "avatar" field.
  42554. func (m *WpChatroomMemberMutation) ResetAvatar() {
  42555. m.avatar = nil
  42556. }
  42557. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  42558. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  42559. m.predicates = append(m.predicates, ps...)
  42560. }
  42561. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  42562. // users can use type-assertion to append predicates that do not depend on any generated package.
  42563. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  42564. p := make([]predicate.WpChatroomMember, len(ps))
  42565. for i := range ps {
  42566. p[i] = ps[i]
  42567. }
  42568. m.Where(p...)
  42569. }
  42570. // Op returns the operation name.
  42571. func (m *WpChatroomMemberMutation) Op() Op {
  42572. return m.op
  42573. }
  42574. // SetOp allows setting the mutation operation.
  42575. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  42576. m.op = op
  42577. }
  42578. // Type returns the node type of this mutation (WpChatroomMember).
  42579. func (m *WpChatroomMemberMutation) Type() string {
  42580. return m.typ
  42581. }
  42582. // Fields returns all fields that were changed during this mutation. Note that in
  42583. // order to get all numeric fields that were incremented/decremented, call
  42584. // AddedFields().
  42585. func (m *WpChatroomMemberMutation) Fields() []string {
  42586. fields := make([]string, 0, 7)
  42587. if m.created_at != nil {
  42588. fields = append(fields, wpchatroommember.FieldCreatedAt)
  42589. }
  42590. if m.updated_at != nil {
  42591. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  42592. }
  42593. if m.status != nil {
  42594. fields = append(fields, wpchatroommember.FieldStatus)
  42595. }
  42596. if m.wx_wxid != nil {
  42597. fields = append(fields, wpchatroommember.FieldWxWxid)
  42598. }
  42599. if m.wxid != nil {
  42600. fields = append(fields, wpchatroommember.FieldWxid)
  42601. }
  42602. if m.nickname != nil {
  42603. fields = append(fields, wpchatroommember.FieldNickname)
  42604. }
  42605. if m.avatar != nil {
  42606. fields = append(fields, wpchatroommember.FieldAvatar)
  42607. }
  42608. return fields
  42609. }
  42610. // Field returns the value of a field with the given name. The second boolean
  42611. // return value indicates that this field was not set, or was not defined in the
  42612. // schema.
  42613. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  42614. switch name {
  42615. case wpchatroommember.FieldCreatedAt:
  42616. return m.CreatedAt()
  42617. case wpchatroommember.FieldUpdatedAt:
  42618. return m.UpdatedAt()
  42619. case wpchatroommember.FieldStatus:
  42620. return m.Status()
  42621. case wpchatroommember.FieldWxWxid:
  42622. return m.WxWxid()
  42623. case wpchatroommember.FieldWxid:
  42624. return m.Wxid()
  42625. case wpchatroommember.FieldNickname:
  42626. return m.Nickname()
  42627. case wpchatroommember.FieldAvatar:
  42628. return m.Avatar()
  42629. }
  42630. return nil, false
  42631. }
  42632. // OldField returns the old value of the field from the database. An error is
  42633. // returned if the mutation operation is not UpdateOne, or the query to the
  42634. // database failed.
  42635. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42636. switch name {
  42637. case wpchatroommember.FieldCreatedAt:
  42638. return m.OldCreatedAt(ctx)
  42639. case wpchatroommember.FieldUpdatedAt:
  42640. return m.OldUpdatedAt(ctx)
  42641. case wpchatroommember.FieldStatus:
  42642. return m.OldStatus(ctx)
  42643. case wpchatroommember.FieldWxWxid:
  42644. return m.OldWxWxid(ctx)
  42645. case wpchatroommember.FieldWxid:
  42646. return m.OldWxid(ctx)
  42647. case wpchatroommember.FieldNickname:
  42648. return m.OldNickname(ctx)
  42649. case wpchatroommember.FieldAvatar:
  42650. return m.OldAvatar(ctx)
  42651. }
  42652. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  42653. }
  42654. // SetField sets the value of a field with the given name. It returns an error if
  42655. // the field is not defined in the schema, or if the type mismatched the field
  42656. // type.
  42657. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  42658. switch name {
  42659. case wpchatroommember.FieldCreatedAt:
  42660. v, ok := value.(time.Time)
  42661. if !ok {
  42662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42663. }
  42664. m.SetCreatedAt(v)
  42665. return nil
  42666. case wpchatroommember.FieldUpdatedAt:
  42667. v, ok := value.(time.Time)
  42668. if !ok {
  42669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42670. }
  42671. m.SetUpdatedAt(v)
  42672. return nil
  42673. case wpchatroommember.FieldStatus:
  42674. v, ok := value.(uint8)
  42675. if !ok {
  42676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42677. }
  42678. m.SetStatus(v)
  42679. return nil
  42680. case wpchatroommember.FieldWxWxid:
  42681. v, ok := value.(string)
  42682. if !ok {
  42683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42684. }
  42685. m.SetWxWxid(v)
  42686. return nil
  42687. case wpchatroommember.FieldWxid:
  42688. v, ok := value.(string)
  42689. if !ok {
  42690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42691. }
  42692. m.SetWxid(v)
  42693. return nil
  42694. case wpchatroommember.FieldNickname:
  42695. v, ok := value.(string)
  42696. if !ok {
  42697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42698. }
  42699. m.SetNickname(v)
  42700. return nil
  42701. case wpchatroommember.FieldAvatar:
  42702. v, ok := value.(string)
  42703. if !ok {
  42704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42705. }
  42706. m.SetAvatar(v)
  42707. return nil
  42708. }
  42709. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  42710. }
  42711. // AddedFields returns all numeric fields that were incremented/decremented during
  42712. // this mutation.
  42713. func (m *WpChatroomMemberMutation) AddedFields() []string {
  42714. var fields []string
  42715. if m.addstatus != nil {
  42716. fields = append(fields, wpchatroommember.FieldStatus)
  42717. }
  42718. return fields
  42719. }
  42720. // AddedField returns the numeric value that was incremented/decremented on a field
  42721. // with the given name. The second boolean return value indicates that this field
  42722. // was not set, or was not defined in the schema.
  42723. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  42724. switch name {
  42725. case wpchatroommember.FieldStatus:
  42726. return m.AddedStatus()
  42727. }
  42728. return nil, false
  42729. }
  42730. // AddField adds the value to the field with the given name. It returns an error if
  42731. // the field is not defined in the schema, or if the type mismatched the field
  42732. // type.
  42733. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  42734. switch name {
  42735. case wpchatroommember.FieldStatus:
  42736. v, ok := value.(int8)
  42737. if !ok {
  42738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42739. }
  42740. m.AddStatus(v)
  42741. return nil
  42742. }
  42743. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  42744. }
  42745. // ClearedFields returns all nullable fields that were cleared during this
  42746. // mutation.
  42747. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  42748. var fields []string
  42749. if m.FieldCleared(wpchatroommember.FieldStatus) {
  42750. fields = append(fields, wpchatroommember.FieldStatus)
  42751. }
  42752. return fields
  42753. }
  42754. // FieldCleared returns a boolean indicating if a field with the given name was
  42755. // cleared in this mutation.
  42756. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  42757. _, ok := m.clearedFields[name]
  42758. return ok
  42759. }
  42760. // ClearField clears the value of the field with the given name. It returns an
  42761. // error if the field is not defined in the schema.
  42762. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  42763. switch name {
  42764. case wpchatroommember.FieldStatus:
  42765. m.ClearStatus()
  42766. return nil
  42767. }
  42768. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  42769. }
  42770. // ResetField resets all changes in the mutation for the field with the given name.
  42771. // It returns an error if the field is not defined in the schema.
  42772. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  42773. switch name {
  42774. case wpchatroommember.FieldCreatedAt:
  42775. m.ResetCreatedAt()
  42776. return nil
  42777. case wpchatroommember.FieldUpdatedAt:
  42778. m.ResetUpdatedAt()
  42779. return nil
  42780. case wpchatroommember.FieldStatus:
  42781. m.ResetStatus()
  42782. return nil
  42783. case wpchatroommember.FieldWxWxid:
  42784. m.ResetWxWxid()
  42785. return nil
  42786. case wpchatroommember.FieldWxid:
  42787. m.ResetWxid()
  42788. return nil
  42789. case wpchatroommember.FieldNickname:
  42790. m.ResetNickname()
  42791. return nil
  42792. case wpchatroommember.FieldAvatar:
  42793. m.ResetAvatar()
  42794. return nil
  42795. }
  42796. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  42797. }
  42798. // AddedEdges returns all edge names that were set/added in this mutation.
  42799. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  42800. edges := make([]string, 0, 0)
  42801. return edges
  42802. }
  42803. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42804. // name in this mutation.
  42805. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  42806. return nil
  42807. }
  42808. // RemovedEdges returns all edge names that were removed in this mutation.
  42809. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  42810. edges := make([]string, 0, 0)
  42811. return edges
  42812. }
  42813. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42814. // the given name in this mutation.
  42815. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  42816. return nil
  42817. }
  42818. // ClearedEdges returns all edge names that were cleared in this mutation.
  42819. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  42820. edges := make([]string, 0, 0)
  42821. return edges
  42822. }
  42823. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42824. // was cleared in this mutation.
  42825. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  42826. return false
  42827. }
  42828. // ClearEdge clears the value of the edge with the given name. It returns an error
  42829. // if that edge is not defined in the schema.
  42830. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  42831. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  42832. }
  42833. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42834. // It returns an error if the edge is not defined in the schema.
  42835. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  42836. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  42837. }
  42838. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  42839. type WxMutation struct {
  42840. config
  42841. op Op
  42842. typ string
  42843. id *uint64
  42844. created_at *time.Time
  42845. updated_at *time.Time
  42846. status *uint8
  42847. addstatus *int8
  42848. deleted_at *time.Time
  42849. port *string
  42850. process_id *string
  42851. callback *string
  42852. wxid *string
  42853. account *string
  42854. nickname *string
  42855. tel *string
  42856. head_big *string
  42857. organization_id *uint64
  42858. addorganization_id *int64
  42859. api_base *string
  42860. api_key *string
  42861. allow_list *[]string
  42862. appendallow_list []string
  42863. group_allow_list *[]string
  42864. appendgroup_allow_list []string
  42865. block_list *[]string
  42866. appendblock_list []string
  42867. group_block_list *[]string
  42868. appendgroup_block_list []string
  42869. ctype *uint64
  42870. addctype *int64
  42871. clearedFields map[string]struct{}
  42872. server *uint64
  42873. clearedserver bool
  42874. agent *uint64
  42875. clearedagent bool
  42876. done bool
  42877. oldValue func(context.Context) (*Wx, error)
  42878. predicates []predicate.Wx
  42879. }
  42880. var _ ent.Mutation = (*WxMutation)(nil)
  42881. // wxOption allows management of the mutation configuration using functional options.
  42882. type wxOption func(*WxMutation)
  42883. // newWxMutation creates new mutation for the Wx entity.
  42884. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  42885. m := &WxMutation{
  42886. config: c,
  42887. op: op,
  42888. typ: TypeWx,
  42889. clearedFields: make(map[string]struct{}),
  42890. }
  42891. for _, opt := range opts {
  42892. opt(m)
  42893. }
  42894. return m
  42895. }
  42896. // withWxID sets the ID field of the mutation.
  42897. func withWxID(id uint64) wxOption {
  42898. return func(m *WxMutation) {
  42899. var (
  42900. err error
  42901. once sync.Once
  42902. value *Wx
  42903. )
  42904. m.oldValue = func(ctx context.Context) (*Wx, error) {
  42905. once.Do(func() {
  42906. if m.done {
  42907. err = errors.New("querying old values post mutation is not allowed")
  42908. } else {
  42909. value, err = m.Client().Wx.Get(ctx, id)
  42910. }
  42911. })
  42912. return value, err
  42913. }
  42914. m.id = &id
  42915. }
  42916. }
  42917. // withWx sets the old Wx of the mutation.
  42918. func withWx(node *Wx) wxOption {
  42919. return func(m *WxMutation) {
  42920. m.oldValue = func(context.Context) (*Wx, error) {
  42921. return node, nil
  42922. }
  42923. m.id = &node.ID
  42924. }
  42925. }
  42926. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42927. // executed in a transaction (ent.Tx), a transactional client is returned.
  42928. func (m WxMutation) Client() *Client {
  42929. client := &Client{config: m.config}
  42930. client.init()
  42931. return client
  42932. }
  42933. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42934. // it returns an error otherwise.
  42935. func (m WxMutation) Tx() (*Tx, error) {
  42936. if _, ok := m.driver.(*txDriver); !ok {
  42937. return nil, errors.New("ent: mutation is not running in a transaction")
  42938. }
  42939. tx := &Tx{config: m.config}
  42940. tx.init()
  42941. return tx, nil
  42942. }
  42943. // SetID sets the value of the id field. Note that this
  42944. // operation is only accepted on creation of Wx entities.
  42945. func (m *WxMutation) SetID(id uint64) {
  42946. m.id = &id
  42947. }
  42948. // ID returns the ID value in the mutation. Note that the ID is only available
  42949. // if it was provided to the builder or after it was returned from the database.
  42950. func (m *WxMutation) ID() (id uint64, exists bool) {
  42951. if m.id == nil {
  42952. return
  42953. }
  42954. return *m.id, true
  42955. }
  42956. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42957. // That means, if the mutation is applied within a transaction with an isolation level such
  42958. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42959. // or updated by the mutation.
  42960. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  42961. switch {
  42962. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42963. id, exists := m.ID()
  42964. if exists {
  42965. return []uint64{id}, nil
  42966. }
  42967. fallthrough
  42968. case m.op.Is(OpUpdate | OpDelete):
  42969. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  42970. default:
  42971. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42972. }
  42973. }
  42974. // SetCreatedAt sets the "created_at" field.
  42975. func (m *WxMutation) SetCreatedAt(t time.Time) {
  42976. m.created_at = &t
  42977. }
  42978. // CreatedAt returns the value of the "created_at" field in the mutation.
  42979. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  42980. v := m.created_at
  42981. if v == nil {
  42982. return
  42983. }
  42984. return *v, true
  42985. }
  42986. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  42987. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42989. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42990. if !m.op.Is(OpUpdateOne) {
  42991. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42992. }
  42993. if m.id == nil || m.oldValue == nil {
  42994. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42995. }
  42996. oldValue, err := m.oldValue(ctx)
  42997. if err != nil {
  42998. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42999. }
  43000. return oldValue.CreatedAt, nil
  43001. }
  43002. // ResetCreatedAt resets all changes to the "created_at" field.
  43003. func (m *WxMutation) ResetCreatedAt() {
  43004. m.created_at = nil
  43005. }
  43006. // SetUpdatedAt sets the "updated_at" field.
  43007. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  43008. m.updated_at = &t
  43009. }
  43010. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43011. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  43012. v := m.updated_at
  43013. if v == nil {
  43014. return
  43015. }
  43016. return *v, true
  43017. }
  43018. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43022. if !m.op.Is(OpUpdateOne) {
  43023. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43024. }
  43025. if m.id == nil || m.oldValue == nil {
  43026. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  43031. }
  43032. return oldValue.UpdatedAt, nil
  43033. }
  43034. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43035. func (m *WxMutation) ResetUpdatedAt() {
  43036. m.updated_at = nil
  43037. }
  43038. // SetStatus sets the "status" field.
  43039. func (m *WxMutation) SetStatus(u uint8) {
  43040. m.status = &u
  43041. m.addstatus = nil
  43042. }
  43043. // Status returns the value of the "status" field in the mutation.
  43044. func (m *WxMutation) Status() (r uint8, exists bool) {
  43045. v := m.status
  43046. if v == nil {
  43047. return
  43048. }
  43049. return *v, true
  43050. }
  43051. // OldStatus returns the old "status" field's value of the Wx entity.
  43052. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43054. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43055. if !m.op.Is(OpUpdateOne) {
  43056. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43057. }
  43058. if m.id == nil || m.oldValue == nil {
  43059. return v, errors.New("OldStatus requires an ID field in the mutation")
  43060. }
  43061. oldValue, err := m.oldValue(ctx)
  43062. if err != nil {
  43063. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43064. }
  43065. return oldValue.Status, nil
  43066. }
  43067. // AddStatus adds u to the "status" field.
  43068. func (m *WxMutation) AddStatus(u int8) {
  43069. if m.addstatus != nil {
  43070. *m.addstatus += u
  43071. } else {
  43072. m.addstatus = &u
  43073. }
  43074. }
  43075. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43076. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  43077. v := m.addstatus
  43078. if v == nil {
  43079. return
  43080. }
  43081. return *v, true
  43082. }
  43083. // ClearStatus clears the value of the "status" field.
  43084. func (m *WxMutation) ClearStatus() {
  43085. m.status = nil
  43086. m.addstatus = nil
  43087. m.clearedFields[wx.FieldStatus] = struct{}{}
  43088. }
  43089. // StatusCleared returns if the "status" field was cleared in this mutation.
  43090. func (m *WxMutation) StatusCleared() bool {
  43091. _, ok := m.clearedFields[wx.FieldStatus]
  43092. return ok
  43093. }
  43094. // ResetStatus resets all changes to the "status" field.
  43095. func (m *WxMutation) ResetStatus() {
  43096. m.status = nil
  43097. m.addstatus = nil
  43098. delete(m.clearedFields, wx.FieldStatus)
  43099. }
  43100. // SetDeletedAt sets the "deleted_at" field.
  43101. func (m *WxMutation) SetDeletedAt(t time.Time) {
  43102. m.deleted_at = &t
  43103. }
  43104. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43105. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  43106. v := m.deleted_at
  43107. if v == nil {
  43108. return
  43109. }
  43110. return *v, true
  43111. }
  43112. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  43113. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43115. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43116. if !m.op.Is(OpUpdateOne) {
  43117. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43118. }
  43119. if m.id == nil || m.oldValue == nil {
  43120. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43121. }
  43122. oldValue, err := m.oldValue(ctx)
  43123. if err != nil {
  43124. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43125. }
  43126. return oldValue.DeletedAt, nil
  43127. }
  43128. // ClearDeletedAt clears the value of the "deleted_at" field.
  43129. func (m *WxMutation) ClearDeletedAt() {
  43130. m.deleted_at = nil
  43131. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  43132. }
  43133. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43134. func (m *WxMutation) DeletedAtCleared() bool {
  43135. _, ok := m.clearedFields[wx.FieldDeletedAt]
  43136. return ok
  43137. }
  43138. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43139. func (m *WxMutation) ResetDeletedAt() {
  43140. m.deleted_at = nil
  43141. delete(m.clearedFields, wx.FieldDeletedAt)
  43142. }
  43143. // SetServerID sets the "server_id" field.
  43144. func (m *WxMutation) SetServerID(u uint64) {
  43145. m.server = &u
  43146. }
  43147. // ServerID returns the value of the "server_id" field in the mutation.
  43148. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  43149. v := m.server
  43150. if v == nil {
  43151. return
  43152. }
  43153. return *v, true
  43154. }
  43155. // OldServerID returns the old "server_id" field's value of the Wx entity.
  43156. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43158. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  43159. if !m.op.Is(OpUpdateOne) {
  43160. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  43161. }
  43162. if m.id == nil || m.oldValue == nil {
  43163. return v, errors.New("OldServerID requires an ID field in the mutation")
  43164. }
  43165. oldValue, err := m.oldValue(ctx)
  43166. if err != nil {
  43167. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  43168. }
  43169. return oldValue.ServerID, nil
  43170. }
  43171. // ClearServerID clears the value of the "server_id" field.
  43172. func (m *WxMutation) ClearServerID() {
  43173. m.server = nil
  43174. m.clearedFields[wx.FieldServerID] = struct{}{}
  43175. }
  43176. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  43177. func (m *WxMutation) ServerIDCleared() bool {
  43178. _, ok := m.clearedFields[wx.FieldServerID]
  43179. return ok
  43180. }
  43181. // ResetServerID resets all changes to the "server_id" field.
  43182. func (m *WxMutation) ResetServerID() {
  43183. m.server = nil
  43184. delete(m.clearedFields, wx.FieldServerID)
  43185. }
  43186. // SetPort sets the "port" field.
  43187. func (m *WxMutation) SetPort(s string) {
  43188. m.port = &s
  43189. }
  43190. // Port returns the value of the "port" field in the mutation.
  43191. func (m *WxMutation) Port() (r string, exists bool) {
  43192. v := m.port
  43193. if v == nil {
  43194. return
  43195. }
  43196. return *v, true
  43197. }
  43198. // OldPort returns the old "port" field's value of the Wx entity.
  43199. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43201. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  43202. if !m.op.Is(OpUpdateOne) {
  43203. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  43204. }
  43205. if m.id == nil || m.oldValue == nil {
  43206. return v, errors.New("OldPort requires an ID field in the mutation")
  43207. }
  43208. oldValue, err := m.oldValue(ctx)
  43209. if err != nil {
  43210. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  43211. }
  43212. return oldValue.Port, nil
  43213. }
  43214. // ResetPort resets all changes to the "port" field.
  43215. func (m *WxMutation) ResetPort() {
  43216. m.port = nil
  43217. }
  43218. // SetProcessID sets the "process_id" field.
  43219. func (m *WxMutation) SetProcessID(s string) {
  43220. m.process_id = &s
  43221. }
  43222. // ProcessID returns the value of the "process_id" field in the mutation.
  43223. func (m *WxMutation) ProcessID() (r string, exists bool) {
  43224. v := m.process_id
  43225. if v == nil {
  43226. return
  43227. }
  43228. return *v, true
  43229. }
  43230. // OldProcessID returns the old "process_id" 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) OldProcessID(ctx context.Context) (v string, err error) {
  43234. if !m.op.Is(OpUpdateOne) {
  43235. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  43236. }
  43237. if m.id == nil || m.oldValue == nil {
  43238. return v, errors.New("OldProcessID 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 OldProcessID: %w", err)
  43243. }
  43244. return oldValue.ProcessID, nil
  43245. }
  43246. // ResetProcessID resets all changes to the "process_id" field.
  43247. func (m *WxMutation) ResetProcessID() {
  43248. m.process_id = nil
  43249. }
  43250. // SetCallback sets the "callback" field.
  43251. func (m *WxMutation) SetCallback(s string) {
  43252. m.callback = &s
  43253. }
  43254. // Callback returns the value of the "callback" field in the mutation.
  43255. func (m *WxMutation) Callback() (r string, exists bool) {
  43256. v := m.callback
  43257. if v == nil {
  43258. return
  43259. }
  43260. return *v, true
  43261. }
  43262. // OldCallback returns the old "callback" 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) OldCallback(ctx context.Context) (v string, err error) {
  43266. if !m.op.Is(OpUpdateOne) {
  43267. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  43268. }
  43269. if m.id == nil || m.oldValue == nil {
  43270. return v, errors.New("OldCallback 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 OldCallback: %w", err)
  43275. }
  43276. return oldValue.Callback, nil
  43277. }
  43278. // ResetCallback resets all changes to the "callback" field.
  43279. func (m *WxMutation) ResetCallback() {
  43280. m.callback = nil
  43281. }
  43282. // SetWxid sets the "wxid" field.
  43283. func (m *WxMutation) SetWxid(s string) {
  43284. m.wxid = &s
  43285. }
  43286. // Wxid returns the value of the "wxid" field in the mutation.
  43287. func (m *WxMutation) Wxid() (r string, exists bool) {
  43288. v := m.wxid
  43289. if v == nil {
  43290. return
  43291. }
  43292. return *v, true
  43293. }
  43294. // OldWxid returns the old "wxid" 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) OldWxid(ctx context.Context) (v string, err error) {
  43298. if !m.op.Is(OpUpdateOne) {
  43299. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43300. }
  43301. if m.id == nil || m.oldValue == nil {
  43302. return v, errors.New("OldWxid 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 OldWxid: %w", err)
  43307. }
  43308. return oldValue.Wxid, nil
  43309. }
  43310. // ResetWxid resets all changes to the "wxid" field.
  43311. func (m *WxMutation) ResetWxid() {
  43312. m.wxid = nil
  43313. }
  43314. // SetAccount sets the "account" field.
  43315. func (m *WxMutation) SetAccount(s string) {
  43316. m.account = &s
  43317. }
  43318. // Account returns the value of the "account" field in the mutation.
  43319. func (m *WxMutation) Account() (r string, exists bool) {
  43320. v := m.account
  43321. if v == nil {
  43322. return
  43323. }
  43324. return *v, true
  43325. }
  43326. // OldAccount returns the old "account" 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) OldAccount(ctx context.Context) (v string, err error) {
  43330. if !m.op.Is(OpUpdateOne) {
  43331. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43332. }
  43333. if m.id == nil || m.oldValue == nil {
  43334. return v, errors.New("OldAccount 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 OldAccount: %w", err)
  43339. }
  43340. return oldValue.Account, nil
  43341. }
  43342. // ResetAccount resets all changes to the "account" field.
  43343. func (m *WxMutation) ResetAccount() {
  43344. m.account = nil
  43345. }
  43346. // SetNickname sets the "nickname" field.
  43347. func (m *WxMutation) SetNickname(s string) {
  43348. m.nickname = &s
  43349. }
  43350. // Nickname returns the value of the "nickname" field in the mutation.
  43351. func (m *WxMutation) Nickname() (r string, exists bool) {
  43352. v := m.nickname
  43353. if v == nil {
  43354. return
  43355. }
  43356. return *v, true
  43357. }
  43358. // OldNickname returns the old "nickname" 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) OldNickname(ctx context.Context) (v string, err error) {
  43362. if !m.op.Is(OpUpdateOne) {
  43363. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43364. }
  43365. if m.id == nil || m.oldValue == nil {
  43366. return v, errors.New("OldNickname 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 OldNickname: %w", err)
  43371. }
  43372. return oldValue.Nickname, nil
  43373. }
  43374. // ResetNickname resets all changes to the "nickname" field.
  43375. func (m *WxMutation) ResetNickname() {
  43376. m.nickname = nil
  43377. }
  43378. // SetTel sets the "tel" field.
  43379. func (m *WxMutation) SetTel(s string) {
  43380. m.tel = &s
  43381. }
  43382. // Tel returns the value of the "tel" field in the mutation.
  43383. func (m *WxMutation) Tel() (r string, exists bool) {
  43384. v := m.tel
  43385. if v == nil {
  43386. return
  43387. }
  43388. return *v, true
  43389. }
  43390. // OldTel returns the old "tel" 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) OldTel(ctx context.Context) (v string, err error) {
  43394. if !m.op.Is(OpUpdateOne) {
  43395. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  43396. }
  43397. if m.id == nil || m.oldValue == nil {
  43398. return v, errors.New("OldTel 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 OldTel: %w", err)
  43403. }
  43404. return oldValue.Tel, nil
  43405. }
  43406. // ResetTel resets all changes to the "tel" field.
  43407. func (m *WxMutation) ResetTel() {
  43408. m.tel = nil
  43409. }
  43410. // SetHeadBig sets the "head_big" field.
  43411. func (m *WxMutation) SetHeadBig(s string) {
  43412. m.head_big = &s
  43413. }
  43414. // HeadBig returns the value of the "head_big" field in the mutation.
  43415. func (m *WxMutation) HeadBig() (r string, exists bool) {
  43416. v := m.head_big
  43417. if v == nil {
  43418. return
  43419. }
  43420. return *v, true
  43421. }
  43422. // OldHeadBig returns the old "head_big" 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) OldHeadBig(ctx context.Context) (v string, err error) {
  43426. if !m.op.Is(OpUpdateOne) {
  43427. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  43428. }
  43429. if m.id == nil || m.oldValue == nil {
  43430. return v, errors.New("OldHeadBig 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 OldHeadBig: %w", err)
  43435. }
  43436. return oldValue.HeadBig, nil
  43437. }
  43438. // ResetHeadBig resets all changes to the "head_big" field.
  43439. func (m *WxMutation) ResetHeadBig() {
  43440. m.head_big = nil
  43441. }
  43442. // SetOrganizationID sets the "organization_id" field.
  43443. func (m *WxMutation) SetOrganizationID(u uint64) {
  43444. m.organization_id = &u
  43445. m.addorganization_id = nil
  43446. }
  43447. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43448. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  43449. v := m.organization_id
  43450. if v == nil {
  43451. return
  43452. }
  43453. return *v, true
  43454. }
  43455. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  43456. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43458. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43459. if !m.op.Is(OpUpdateOne) {
  43460. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43461. }
  43462. if m.id == nil || m.oldValue == nil {
  43463. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43464. }
  43465. oldValue, err := m.oldValue(ctx)
  43466. if err != nil {
  43467. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43468. }
  43469. return oldValue.OrganizationID, nil
  43470. }
  43471. // AddOrganizationID adds u to the "organization_id" field.
  43472. func (m *WxMutation) AddOrganizationID(u int64) {
  43473. if m.addorganization_id != nil {
  43474. *m.addorganization_id += u
  43475. } else {
  43476. m.addorganization_id = &u
  43477. }
  43478. }
  43479. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43480. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  43481. v := m.addorganization_id
  43482. if v == nil {
  43483. return
  43484. }
  43485. return *v, true
  43486. }
  43487. // ClearOrganizationID clears the value of the "organization_id" field.
  43488. func (m *WxMutation) ClearOrganizationID() {
  43489. m.organization_id = nil
  43490. m.addorganization_id = nil
  43491. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  43492. }
  43493. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  43494. func (m *WxMutation) OrganizationIDCleared() bool {
  43495. _, ok := m.clearedFields[wx.FieldOrganizationID]
  43496. return ok
  43497. }
  43498. // ResetOrganizationID resets all changes to the "organization_id" field.
  43499. func (m *WxMutation) ResetOrganizationID() {
  43500. m.organization_id = nil
  43501. m.addorganization_id = nil
  43502. delete(m.clearedFields, wx.FieldOrganizationID)
  43503. }
  43504. // SetAgentID sets the "agent_id" field.
  43505. func (m *WxMutation) SetAgentID(u uint64) {
  43506. m.agent = &u
  43507. }
  43508. // AgentID returns the value of the "agent_id" field in the mutation.
  43509. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  43510. v := m.agent
  43511. if v == nil {
  43512. return
  43513. }
  43514. return *v, true
  43515. }
  43516. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  43517. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43519. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  43520. if !m.op.Is(OpUpdateOne) {
  43521. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  43522. }
  43523. if m.id == nil || m.oldValue == nil {
  43524. return v, errors.New("OldAgentID requires an ID field in the mutation")
  43525. }
  43526. oldValue, err := m.oldValue(ctx)
  43527. if err != nil {
  43528. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  43529. }
  43530. return oldValue.AgentID, nil
  43531. }
  43532. // ResetAgentID resets all changes to the "agent_id" field.
  43533. func (m *WxMutation) ResetAgentID() {
  43534. m.agent = nil
  43535. }
  43536. // SetAPIBase sets the "api_base" field.
  43537. func (m *WxMutation) SetAPIBase(s string) {
  43538. m.api_base = &s
  43539. }
  43540. // APIBase returns the value of the "api_base" field in the mutation.
  43541. func (m *WxMutation) APIBase() (r string, exists bool) {
  43542. v := m.api_base
  43543. if v == nil {
  43544. return
  43545. }
  43546. return *v, true
  43547. }
  43548. // OldAPIBase returns the old "api_base" 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) OldAPIBase(ctx context.Context) (v string, err error) {
  43552. if !m.op.Is(OpUpdateOne) {
  43553. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43554. }
  43555. if m.id == nil || m.oldValue == nil {
  43556. return v, errors.New("OldAPIBase 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 OldAPIBase: %w", err)
  43561. }
  43562. return oldValue.APIBase, nil
  43563. }
  43564. // ClearAPIBase clears the value of the "api_base" field.
  43565. func (m *WxMutation) ClearAPIBase() {
  43566. m.api_base = nil
  43567. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  43568. }
  43569. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43570. func (m *WxMutation) APIBaseCleared() bool {
  43571. _, ok := m.clearedFields[wx.FieldAPIBase]
  43572. return ok
  43573. }
  43574. // ResetAPIBase resets all changes to the "api_base" field.
  43575. func (m *WxMutation) ResetAPIBase() {
  43576. m.api_base = nil
  43577. delete(m.clearedFields, wx.FieldAPIBase)
  43578. }
  43579. // SetAPIKey sets the "api_key" field.
  43580. func (m *WxMutation) SetAPIKey(s string) {
  43581. m.api_key = &s
  43582. }
  43583. // APIKey returns the value of the "api_key" field in the mutation.
  43584. func (m *WxMutation) APIKey() (r string, exists bool) {
  43585. v := m.api_key
  43586. if v == nil {
  43587. return
  43588. }
  43589. return *v, true
  43590. }
  43591. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  43592. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43594. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43595. if !m.op.Is(OpUpdateOne) {
  43596. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43597. }
  43598. if m.id == nil || m.oldValue == nil {
  43599. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43600. }
  43601. oldValue, err := m.oldValue(ctx)
  43602. if err != nil {
  43603. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43604. }
  43605. return oldValue.APIKey, nil
  43606. }
  43607. // ClearAPIKey clears the value of the "api_key" field.
  43608. func (m *WxMutation) ClearAPIKey() {
  43609. m.api_key = nil
  43610. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  43611. }
  43612. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43613. func (m *WxMutation) APIKeyCleared() bool {
  43614. _, ok := m.clearedFields[wx.FieldAPIKey]
  43615. return ok
  43616. }
  43617. // ResetAPIKey resets all changes to the "api_key" field.
  43618. func (m *WxMutation) ResetAPIKey() {
  43619. m.api_key = nil
  43620. delete(m.clearedFields, wx.FieldAPIKey)
  43621. }
  43622. // SetAllowList sets the "allow_list" field.
  43623. func (m *WxMutation) SetAllowList(s []string) {
  43624. m.allow_list = &s
  43625. m.appendallow_list = nil
  43626. }
  43627. // AllowList returns the value of the "allow_list" field in the mutation.
  43628. func (m *WxMutation) AllowList() (r []string, exists bool) {
  43629. v := m.allow_list
  43630. if v == nil {
  43631. return
  43632. }
  43633. return *v, true
  43634. }
  43635. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  43636. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43638. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  43639. if !m.op.Is(OpUpdateOne) {
  43640. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  43641. }
  43642. if m.id == nil || m.oldValue == nil {
  43643. return v, errors.New("OldAllowList requires an ID field in the mutation")
  43644. }
  43645. oldValue, err := m.oldValue(ctx)
  43646. if err != nil {
  43647. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  43648. }
  43649. return oldValue.AllowList, nil
  43650. }
  43651. // AppendAllowList adds s to the "allow_list" field.
  43652. func (m *WxMutation) AppendAllowList(s []string) {
  43653. m.appendallow_list = append(m.appendallow_list, s...)
  43654. }
  43655. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  43656. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  43657. if len(m.appendallow_list) == 0 {
  43658. return nil, false
  43659. }
  43660. return m.appendallow_list, true
  43661. }
  43662. // ResetAllowList resets all changes to the "allow_list" field.
  43663. func (m *WxMutation) ResetAllowList() {
  43664. m.allow_list = nil
  43665. m.appendallow_list = nil
  43666. }
  43667. // SetGroupAllowList sets the "group_allow_list" field.
  43668. func (m *WxMutation) SetGroupAllowList(s []string) {
  43669. m.group_allow_list = &s
  43670. m.appendgroup_allow_list = nil
  43671. }
  43672. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  43673. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  43674. v := m.group_allow_list
  43675. if v == nil {
  43676. return
  43677. }
  43678. return *v, true
  43679. }
  43680. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  43681. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43683. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  43684. if !m.op.Is(OpUpdateOne) {
  43685. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  43686. }
  43687. if m.id == nil || m.oldValue == nil {
  43688. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  43689. }
  43690. oldValue, err := m.oldValue(ctx)
  43691. if err != nil {
  43692. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  43693. }
  43694. return oldValue.GroupAllowList, nil
  43695. }
  43696. // AppendGroupAllowList adds s to the "group_allow_list" field.
  43697. func (m *WxMutation) AppendGroupAllowList(s []string) {
  43698. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  43699. }
  43700. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  43701. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  43702. if len(m.appendgroup_allow_list) == 0 {
  43703. return nil, false
  43704. }
  43705. return m.appendgroup_allow_list, true
  43706. }
  43707. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  43708. func (m *WxMutation) ResetGroupAllowList() {
  43709. m.group_allow_list = nil
  43710. m.appendgroup_allow_list = nil
  43711. }
  43712. // SetBlockList sets the "block_list" field.
  43713. func (m *WxMutation) SetBlockList(s []string) {
  43714. m.block_list = &s
  43715. m.appendblock_list = nil
  43716. }
  43717. // BlockList returns the value of the "block_list" field in the mutation.
  43718. func (m *WxMutation) BlockList() (r []string, exists bool) {
  43719. v := m.block_list
  43720. if v == nil {
  43721. return
  43722. }
  43723. return *v, true
  43724. }
  43725. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  43726. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43728. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  43729. if !m.op.Is(OpUpdateOne) {
  43730. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  43731. }
  43732. if m.id == nil || m.oldValue == nil {
  43733. return v, errors.New("OldBlockList requires an ID field in the mutation")
  43734. }
  43735. oldValue, err := m.oldValue(ctx)
  43736. if err != nil {
  43737. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  43738. }
  43739. return oldValue.BlockList, nil
  43740. }
  43741. // AppendBlockList adds s to the "block_list" field.
  43742. func (m *WxMutation) AppendBlockList(s []string) {
  43743. m.appendblock_list = append(m.appendblock_list, s...)
  43744. }
  43745. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  43746. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  43747. if len(m.appendblock_list) == 0 {
  43748. return nil, false
  43749. }
  43750. return m.appendblock_list, true
  43751. }
  43752. // ResetBlockList resets all changes to the "block_list" field.
  43753. func (m *WxMutation) ResetBlockList() {
  43754. m.block_list = nil
  43755. m.appendblock_list = nil
  43756. }
  43757. // SetGroupBlockList sets the "group_block_list" field.
  43758. func (m *WxMutation) SetGroupBlockList(s []string) {
  43759. m.group_block_list = &s
  43760. m.appendgroup_block_list = nil
  43761. }
  43762. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  43763. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  43764. v := m.group_block_list
  43765. if v == nil {
  43766. return
  43767. }
  43768. return *v, true
  43769. }
  43770. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  43771. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43773. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  43774. if !m.op.Is(OpUpdateOne) {
  43775. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  43776. }
  43777. if m.id == nil || m.oldValue == nil {
  43778. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  43779. }
  43780. oldValue, err := m.oldValue(ctx)
  43781. if err != nil {
  43782. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  43783. }
  43784. return oldValue.GroupBlockList, nil
  43785. }
  43786. // AppendGroupBlockList adds s to the "group_block_list" field.
  43787. func (m *WxMutation) AppendGroupBlockList(s []string) {
  43788. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  43789. }
  43790. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  43791. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  43792. if len(m.appendgroup_block_list) == 0 {
  43793. return nil, false
  43794. }
  43795. return m.appendgroup_block_list, true
  43796. }
  43797. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  43798. func (m *WxMutation) ResetGroupBlockList() {
  43799. m.group_block_list = nil
  43800. m.appendgroup_block_list = nil
  43801. }
  43802. // SetCtype sets the "ctype" field.
  43803. func (m *WxMutation) SetCtype(u uint64) {
  43804. m.ctype = &u
  43805. m.addctype = nil
  43806. }
  43807. // Ctype returns the value of the "ctype" field in the mutation.
  43808. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  43809. v := m.ctype
  43810. if v == nil {
  43811. return
  43812. }
  43813. return *v, true
  43814. }
  43815. // OldCtype returns the old "ctype" field's value of the Wx entity.
  43816. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43818. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  43819. if !m.op.Is(OpUpdateOne) {
  43820. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  43821. }
  43822. if m.id == nil || m.oldValue == nil {
  43823. return v, errors.New("OldCtype requires an ID field in the mutation")
  43824. }
  43825. oldValue, err := m.oldValue(ctx)
  43826. if err != nil {
  43827. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  43828. }
  43829. return oldValue.Ctype, nil
  43830. }
  43831. // AddCtype adds u to the "ctype" field.
  43832. func (m *WxMutation) AddCtype(u int64) {
  43833. if m.addctype != nil {
  43834. *m.addctype += u
  43835. } else {
  43836. m.addctype = &u
  43837. }
  43838. }
  43839. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  43840. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  43841. v := m.addctype
  43842. if v == nil {
  43843. return
  43844. }
  43845. return *v, true
  43846. }
  43847. // ClearCtype clears the value of the "ctype" field.
  43848. func (m *WxMutation) ClearCtype() {
  43849. m.ctype = nil
  43850. m.addctype = nil
  43851. m.clearedFields[wx.FieldCtype] = struct{}{}
  43852. }
  43853. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  43854. func (m *WxMutation) CtypeCleared() bool {
  43855. _, ok := m.clearedFields[wx.FieldCtype]
  43856. return ok
  43857. }
  43858. // ResetCtype resets all changes to the "ctype" field.
  43859. func (m *WxMutation) ResetCtype() {
  43860. m.ctype = nil
  43861. m.addctype = nil
  43862. delete(m.clearedFields, wx.FieldCtype)
  43863. }
  43864. // ClearServer clears the "server" edge to the Server entity.
  43865. func (m *WxMutation) ClearServer() {
  43866. m.clearedserver = true
  43867. m.clearedFields[wx.FieldServerID] = struct{}{}
  43868. }
  43869. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  43870. func (m *WxMutation) ServerCleared() bool {
  43871. return m.ServerIDCleared() || m.clearedserver
  43872. }
  43873. // ServerIDs returns the "server" edge IDs in the mutation.
  43874. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43875. // ServerID instead. It exists only for internal usage by the builders.
  43876. func (m *WxMutation) ServerIDs() (ids []uint64) {
  43877. if id := m.server; id != nil {
  43878. ids = append(ids, *id)
  43879. }
  43880. return
  43881. }
  43882. // ResetServer resets all changes to the "server" edge.
  43883. func (m *WxMutation) ResetServer() {
  43884. m.server = nil
  43885. m.clearedserver = false
  43886. }
  43887. // ClearAgent clears the "agent" edge to the Agent entity.
  43888. func (m *WxMutation) ClearAgent() {
  43889. m.clearedagent = true
  43890. m.clearedFields[wx.FieldAgentID] = struct{}{}
  43891. }
  43892. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  43893. func (m *WxMutation) AgentCleared() bool {
  43894. return m.clearedagent
  43895. }
  43896. // AgentIDs returns the "agent" edge IDs in the mutation.
  43897. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43898. // AgentID instead. It exists only for internal usage by the builders.
  43899. func (m *WxMutation) AgentIDs() (ids []uint64) {
  43900. if id := m.agent; id != nil {
  43901. ids = append(ids, *id)
  43902. }
  43903. return
  43904. }
  43905. // ResetAgent resets all changes to the "agent" edge.
  43906. func (m *WxMutation) ResetAgent() {
  43907. m.agent = nil
  43908. m.clearedagent = false
  43909. }
  43910. // Where appends a list predicates to the WxMutation builder.
  43911. func (m *WxMutation) Where(ps ...predicate.Wx) {
  43912. m.predicates = append(m.predicates, ps...)
  43913. }
  43914. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  43915. // users can use type-assertion to append predicates that do not depend on any generated package.
  43916. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  43917. p := make([]predicate.Wx, len(ps))
  43918. for i := range ps {
  43919. p[i] = ps[i]
  43920. }
  43921. m.Where(p...)
  43922. }
  43923. // Op returns the operation name.
  43924. func (m *WxMutation) Op() Op {
  43925. return m.op
  43926. }
  43927. // SetOp allows setting the mutation operation.
  43928. func (m *WxMutation) SetOp(op Op) {
  43929. m.op = op
  43930. }
  43931. // Type returns the node type of this mutation (Wx).
  43932. func (m *WxMutation) Type() string {
  43933. return m.typ
  43934. }
  43935. // Fields returns all fields that were changed during this mutation. Note that in
  43936. // order to get all numeric fields that were incremented/decremented, call
  43937. // AddedFields().
  43938. func (m *WxMutation) Fields() []string {
  43939. fields := make([]string, 0, 22)
  43940. if m.created_at != nil {
  43941. fields = append(fields, wx.FieldCreatedAt)
  43942. }
  43943. if m.updated_at != nil {
  43944. fields = append(fields, wx.FieldUpdatedAt)
  43945. }
  43946. if m.status != nil {
  43947. fields = append(fields, wx.FieldStatus)
  43948. }
  43949. if m.deleted_at != nil {
  43950. fields = append(fields, wx.FieldDeletedAt)
  43951. }
  43952. if m.server != nil {
  43953. fields = append(fields, wx.FieldServerID)
  43954. }
  43955. if m.port != nil {
  43956. fields = append(fields, wx.FieldPort)
  43957. }
  43958. if m.process_id != nil {
  43959. fields = append(fields, wx.FieldProcessID)
  43960. }
  43961. if m.callback != nil {
  43962. fields = append(fields, wx.FieldCallback)
  43963. }
  43964. if m.wxid != nil {
  43965. fields = append(fields, wx.FieldWxid)
  43966. }
  43967. if m.account != nil {
  43968. fields = append(fields, wx.FieldAccount)
  43969. }
  43970. if m.nickname != nil {
  43971. fields = append(fields, wx.FieldNickname)
  43972. }
  43973. if m.tel != nil {
  43974. fields = append(fields, wx.FieldTel)
  43975. }
  43976. if m.head_big != nil {
  43977. fields = append(fields, wx.FieldHeadBig)
  43978. }
  43979. if m.organization_id != nil {
  43980. fields = append(fields, wx.FieldOrganizationID)
  43981. }
  43982. if m.agent != nil {
  43983. fields = append(fields, wx.FieldAgentID)
  43984. }
  43985. if m.api_base != nil {
  43986. fields = append(fields, wx.FieldAPIBase)
  43987. }
  43988. if m.api_key != nil {
  43989. fields = append(fields, wx.FieldAPIKey)
  43990. }
  43991. if m.allow_list != nil {
  43992. fields = append(fields, wx.FieldAllowList)
  43993. }
  43994. if m.group_allow_list != nil {
  43995. fields = append(fields, wx.FieldGroupAllowList)
  43996. }
  43997. if m.block_list != nil {
  43998. fields = append(fields, wx.FieldBlockList)
  43999. }
  44000. if m.group_block_list != nil {
  44001. fields = append(fields, wx.FieldGroupBlockList)
  44002. }
  44003. if m.ctype != nil {
  44004. fields = append(fields, wx.FieldCtype)
  44005. }
  44006. return fields
  44007. }
  44008. // Field returns the value of a field with the given name. The second boolean
  44009. // return value indicates that this field was not set, or was not defined in the
  44010. // schema.
  44011. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  44012. switch name {
  44013. case wx.FieldCreatedAt:
  44014. return m.CreatedAt()
  44015. case wx.FieldUpdatedAt:
  44016. return m.UpdatedAt()
  44017. case wx.FieldStatus:
  44018. return m.Status()
  44019. case wx.FieldDeletedAt:
  44020. return m.DeletedAt()
  44021. case wx.FieldServerID:
  44022. return m.ServerID()
  44023. case wx.FieldPort:
  44024. return m.Port()
  44025. case wx.FieldProcessID:
  44026. return m.ProcessID()
  44027. case wx.FieldCallback:
  44028. return m.Callback()
  44029. case wx.FieldWxid:
  44030. return m.Wxid()
  44031. case wx.FieldAccount:
  44032. return m.Account()
  44033. case wx.FieldNickname:
  44034. return m.Nickname()
  44035. case wx.FieldTel:
  44036. return m.Tel()
  44037. case wx.FieldHeadBig:
  44038. return m.HeadBig()
  44039. case wx.FieldOrganizationID:
  44040. return m.OrganizationID()
  44041. case wx.FieldAgentID:
  44042. return m.AgentID()
  44043. case wx.FieldAPIBase:
  44044. return m.APIBase()
  44045. case wx.FieldAPIKey:
  44046. return m.APIKey()
  44047. case wx.FieldAllowList:
  44048. return m.AllowList()
  44049. case wx.FieldGroupAllowList:
  44050. return m.GroupAllowList()
  44051. case wx.FieldBlockList:
  44052. return m.BlockList()
  44053. case wx.FieldGroupBlockList:
  44054. return m.GroupBlockList()
  44055. case wx.FieldCtype:
  44056. return m.Ctype()
  44057. }
  44058. return nil, false
  44059. }
  44060. // OldField returns the old value of the field from the database. An error is
  44061. // returned if the mutation operation is not UpdateOne, or the query to the
  44062. // database failed.
  44063. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44064. switch name {
  44065. case wx.FieldCreatedAt:
  44066. return m.OldCreatedAt(ctx)
  44067. case wx.FieldUpdatedAt:
  44068. return m.OldUpdatedAt(ctx)
  44069. case wx.FieldStatus:
  44070. return m.OldStatus(ctx)
  44071. case wx.FieldDeletedAt:
  44072. return m.OldDeletedAt(ctx)
  44073. case wx.FieldServerID:
  44074. return m.OldServerID(ctx)
  44075. case wx.FieldPort:
  44076. return m.OldPort(ctx)
  44077. case wx.FieldProcessID:
  44078. return m.OldProcessID(ctx)
  44079. case wx.FieldCallback:
  44080. return m.OldCallback(ctx)
  44081. case wx.FieldWxid:
  44082. return m.OldWxid(ctx)
  44083. case wx.FieldAccount:
  44084. return m.OldAccount(ctx)
  44085. case wx.FieldNickname:
  44086. return m.OldNickname(ctx)
  44087. case wx.FieldTel:
  44088. return m.OldTel(ctx)
  44089. case wx.FieldHeadBig:
  44090. return m.OldHeadBig(ctx)
  44091. case wx.FieldOrganizationID:
  44092. return m.OldOrganizationID(ctx)
  44093. case wx.FieldAgentID:
  44094. return m.OldAgentID(ctx)
  44095. case wx.FieldAPIBase:
  44096. return m.OldAPIBase(ctx)
  44097. case wx.FieldAPIKey:
  44098. return m.OldAPIKey(ctx)
  44099. case wx.FieldAllowList:
  44100. return m.OldAllowList(ctx)
  44101. case wx.FieldGroupAllowList:
  44102. return m.OldGroupAllowList(ctx)
  44103. case wx.FieldBlockList:
  44104. return m.OldBlockList(ctx)
  44105. case wx.FieldGroupBlockList:
  44106. return m.OldGroupBlockList(ctx)
  44107. case wx.FieldCtype:
  44108. return m.OldCtype(ctx)
  44109. }
  44110. return nil, fmt.Errorf("unknown Wx field %s", name)
  44111. }
  44112. // SetField sets the value of a field with the given name. It returns an error if
  44113. // the field is not defined in the schema, or if the type mismatched the field
  44114. // type.
  44115. func (m *WxMutation) SetField(name string, value ent.Value) error {
  44116. switch name {
  44117. case wx.FieldCreatedAt:
  44118. v, ok := value.(time.Time)
  44119. if !ok {
  44120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44121. }
  44122. m.SetCreatedAt(v)
  44123. return nil
  44124. case wx.FieldUpdatedAt:
  44125. v, ok := value.(time.Time)
  44126. if !ok {
  44127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44128. }
  44129. m.SetUpdatedAt(v)
  44130. return nil
  44131. case wx.FieldStatus:
  44132. v, ok := value.(uint8)
  44133. if !ok {
  44134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44135. }
  44136. m.SetStatus(v)
  44137. return nil
  44138. case wx.FieldDeletedAt:
  44139. v, ok := value.(time.Time)
  44140. if !ok {
  44141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44142. }
  44143. m.SetDeletedAt(v)
  44144. return nil
  44145. case wx.FieldServerID:
  44146. v, ok := value.(uint64)
  44147. if !ok {
  44148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44149. }
  44150. m.SetServerID(v)
  44151. return nil
  44152. case wx.FieldPort:
  44153. v, ok := value.(string)
  44154. if !ok {
  44155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44156. }
  44157. m.SetPort(v)
  44158. return nil
  44159. case wx.FieldProcessID:
  44160. v, ok := value.(string)
  44161. if !ok {
  44162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44163. }
  44164. m.SetProcessID(v)
  44165. return nil
  44166. case wx.FieldCallback:
  44167. v, ok := value.(string)
  44168. if !ok {
  44169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44170. }
  44171. m.SetCallback(v)
  44172. return nil
  44173. case wx.FieldWxid:
  44174. v, ok := value.(string)
  44175. if !ok {
  44176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44177. }
  44178. m.SetWxid(v)
  44179. return nil
  44180. case wx.FieldAccount:
  44181. v, ok := value.(string)
  44182. if !ok {
  44183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44184. }
  44185. m.SetAccount(v)
  44186. return nil
  44187. case wx.FieldNickname:
  44188. v, ok := value.(string)
  44189. if !ok {
  44190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44191. }
  44192. m.SetNickname(v)
  44193. return nil
  44194. case wx.FieldTel:
  44195. v, ok := value.(string)
  44196. if !ok {
  44197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44198. }
  44199. m.SetTel(v)
  44200. return nil
  44201. case wx.FieldHeadBig:
  44202. v, ok := value.(string)
  44203. if !ok {
  44204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44205. }
  44206. m.SetHeadBig(v)
  44207. return nil
  44208. case wx.FieldOrganizationID:
  44209. v, ok := value.(uint64)
  44210. if !ok {
  44211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44212. }
  44213. m.SetOrganizationID(v)
  44214. return nil
  44215. case wx.FieldAgentID:
  44216. v, ok := value.(uint64)
  44217. if !ok {
  44218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44219. }
  44220. m.SetAgentID(v)
  44221. return nil
  44222. case wx.FieldAPIBase:
  44223. v, ok := value.(string)
  44224. if !ok {
  44225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44226. }
  44227. m.SetAPIBase(v)
  44228. return nil
  44229. case wx.FieldAPIKey:
  44230. v, ok := value.(string)
  44231. if !ok {
  44232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44233. }
  44234. m.SetAPIKey(v)
  44235. return nil
  44236. case wx.FieldAllowList:
  44237. v, ok := value.([]string)
  44238. if !ok {
  44239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44240. }
  44241. m.SetAllowList(v)
  44242. return nil
  44243. case wx.FieldGroupAllowList:
  44244. v, ok := value.([]string)
  44245. if !ok {
  44246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44247. }
  44248. m.SetGroupAllowList(v)
  44249. return nil
  44250. case wx.FieldBlockList:
  44251. v, ok := value.([]string)
  44252. if !ok {
  44253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44254. }
  44255. m.SetBlockList(v)
  44256. return nil
  44257. case wx.FieldGroupBlockList:
  44258. v, ok := value.([]string)
  44259. if !ok {
  44260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44261. }
  44262. m.SetGroupBlockList(v)
  44263. return nil
  44264. case wx.FieldCtype:
  44265. v, ok := value.(uint64)
  44266. if !ok {
  44267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44268. }
  44269. m.SetCtype(v)
  44270. return nil
  44271. }
  44272. return fmt.Errorf("unknown Wx field %s", name)
  44273. }
  44274. // AddedFields returns all numeric fields that were incremented/decremented during
  44275. // this mutation.
  44276. func (m *WxMutation) AddedFields() []string {
  44277. var fields []string
  44278. if m.addstatus != nil {
  44279. fields = append(fields, wx.FieldStatus)
  44280. }
  44281. if m.addorganization_id != nil {
  44282. fields = append(fields, wx.FieldOrganizationID)
  44283. }
  44284. if m.addctype != nil {
  44285. fields = append(fields, wx.FieldCtype)
  44286. }
  44287. return fields
  44288. }
  44289. // AddedField returns the numeric value that was incremented/decremented on a field
  44290. // with the given name. The second boolean return value indicates that this field
  44291. // was not set, or was not defined in the schema.
  44292. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  44293. switch name {
  44294. case wx.FieldStatus:
  44295. return m.AddedStatus()
  44296. case wx.FieldOrganizationID:
  44297. return m.AddedOrganizationID()
  44298. case wx.FieldCtype:
  44299. return m.AddedCtype()
  44300. }
  44301. return nil, false
  44302. }
  44303. // AddField adds the value to the field with the given name. It returns an error if
  44304. // the field is not defined in the schema, or if the type mismatched the field
  44305. // type.
  44306. func (m *WxMutation) AddField(name string, value ent.Value) error {
  44307. switch name {
  44308. case wx.FieldStatus:
  44309. v, ok := value.(int8)
  44310. if !ok {
  44311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44312. }
  44313. m.AddStatus(v)
  44314. return nil
  44315. case wx.FieldOrganizationID:
  44316. v, ok := value.(int64)
  44317. if !ok {
  44318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44319. }
  44320. m.AddOrganizationID(v)
  44321. return nil
  44322. case wx.FieldCtype:
  44323. v, ok := value.(int64)
  44324. if !ok {
  44325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44326. }
  44327. m.AddCtype(v)
  44328. return nil
  44329. }
  44330. return fmt.Errorf("unknown Wx numeric field %s", name)
  44331. }
  44332. // ClearedFields returns all nullable fields that were cleared during this
  44333. // mutation.
  44334. func (m *WxMutation) ClearedFields() []string {
  44335. var fields []string
  44336. if m.FieldCleared(wx.FieldStatus) {
  44337. fields = append(fields, wx.FieldStatus)
  44338. }
  44339. if m.FieldCleared(wx.FieldDeletedAt) {
  44340. fields = append(fields, wx.FieldDeletedAt)
  44341. }
  44342. if m.FieldCleared(wx.FieldServerID) {
  44343. fields = append(fields, wx.FieldServerID)
  44344. }
  44345. if m.FieldCleared(wx.FieldOrganizationID) {
  44346. fields = append(fields, wx.FieldOrganizationID)
  44347. }
  44348. if m.FieldCleared(wx.FieldAPIBase) {
  44349. fields = append(fields, wx.FieldAPIBase)
  44350. }
  44351. if m.FieldCleared(wx.FieldAPIKey) {
  44352. fields = append(fields, wx.FieldAPIKey)
  44353. }
  44354. if m.FieldCleared(wx.FieldCtype) {
  44355. fields = append(fields, wx.FieldCtype)
  44356. }
  44357. return fields
  44358. }
  44359. // FieldCleared returns a boolean indicating if a field with the given name was
  44360. // cleared in this mutation.
  44361. func (m *WxMutation) FieldCleared(name string) bool {
  44362. _, ok := m.clearedFields[name]
  44363. return ok
  44364. }
  44365. // ClearField clears the value of the field with the given name. It returns an
  44366. // error if the field is not defined in the schema.
  44367. func (m *WxMutation) ClearField(name string) error {
  44368. switch name {
  44369. case wx.FieldStatus:
  44370. m.ClearStatus()
  44371. return nil
  44372. case wx.FieldDeletedAt:
  44373. m.ClearDeletedAt()
  44374. return nil
  44375. case wx.FieldServerID:
  44376. m.ClearServerID()
  44377. return nil
  44378. case wx.FieldOrganizationID:
  44379. m.ClearOrganizationID()
  44380. return nil
  44381. case wx.FieldAPIBase:
  44382. m.ClearAPIBase()
  44383. return nil
  44384. case wx.FieldAPIKey:
  44385. m.ClearAPIKey()
  44386. return nil
  44387. case wx.FieldCtype:
  44388. m.ClearCtype()
  44389. return nil
  44390. }
  44391. return fmt.Errorf("unknown Wx nullable field %s", name)
  44392. }
  44393. // ResetField resets all changes in the mutation for the field with the given name.
  44394. // It returns an error if the field is not defined in the schema.
  44395. func (m *WxMutation) ResetField(name string) error {
  44396. switch name {
  44397. case wx.FieldCreatedAt:
  44398. m.ResetCreatedAt()
  44399. return nil
  44400. case wx.FieldUpdatedAt:
  44401. m.ResetUpdatedAt()
  44402. return nil
  44403. case wx.FieldStatus:
  44404. m.ResetStatus()
  44405. return nil
  44406. case wx.FieldDeletedAt:
  44407. m.ResetDeletedAt()
  44408. return nil
  44409. case wx.FieldServerID:
  44410. m.ResetServerID()
  44411. return nil
  44412. case wx.FieldPort:
  44413. m.ResetPort()
  44414. return nil
  44415. case wx.FieldProcessID:
  44416. m.ResetProcessID()
  44417. return nil
  44418. case wx.FieldCallback:
  44419. m.ResetCallback()
  44420. return nil
  44421. case wx.FieldWxid:
  44422. m.ResetWxid()
  44423. return nil
  44424. case wx.FieldAccount:
  44425. m.ResetAccount()
  44426. return nil
  44427. case wx.FieldNickname:
  44428. m.ResetNickname()
  44429. return nil
  44430. case wx.FieldTel:
  44431. m.ResetTel()
  44432. return nil
  44433. case wx.FieldHeadBig:
  44434. m.ResetHeadBig()
  44435. return nil
  44436. case wx.FieldOrganizationID:
  44437. m.ResetOrganizationID()
  44438. return nil
  44439. case wx.FieldAgentID:
  44440. m.ResetAgentID()
  44441. return nil
  44442. case wx.FieldAPIBase:
  44443. m.ResetAPIBase()
  44444. return nil
  44445. case wx.FieldAPIKey:
  44446. m.ResetAPIKey()
  44447. return nil
  44448. case wx.FieldAllowList:
  44449. m.ResetAllowList()
  44450. return nil
  44451. case wx.FieldGroupAllowList:
  44452. m.ResetGroupAllowList()
  44453. return nil
  44454. case wx.FieldBlockList:
  44455. m.ResetBlockList()
  44456. return nil
  44457. case wx.FieldGroupBlockList:
  44458. m.ResetGroupBlockList()
  44459. return nil
  44460. case wx.FieldCtype:
  44461. m.ResetCtype()
  44462. return nil
  44463. }
  44464. return fmt.Errorf("unknown Wx field %s", name)
  44465. }
  44466. // AddedEdges returns all edge names that were set/added in this mutation.
  44467. func (m *WxMutation) AddedEdges() []string {
  44468. edges := make([]string, 0, 2)
  44469. if m.server != nil {
  44470. edges = append(edges, wx.EdgeServer)
  44471. }
  44472. if m.agent != nil {
  44473. edges = append(edges, wx.EdgeAgent)
  44474. }
  44475. return edges
  44476. }
  44477. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44478. // name in this mutation.
  44479. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  44480. switch name {
  44481. case wx.EdgeServer:
  44482. if id := m.server; id != nil {
  44483. return []ent.Value{*id}
  44484. }
  44485. case wx.EdgeAgent:
  44486. if id := m.agent; id != nil {
  44487. return []ent.Value{*id}
  44488. }
  44489. }
  44490. return nil
  44491. }
  44492. // RemovedEdges returns all edge names that were removed in this mutation.
  44493. func (m *WxMutation) RemovedEdges() []string {
  44494. edges := make([]string, 0, 2)
  44495. return edges
  44496. }
  44497. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44498. // the given name in this mutation.
  44499. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  44500. return nil
  44501. }
  44502. // ClearedEdges returns all edge names that were cleared in this mutation.
  44503. func (m *WxMutation) ClearedEdges() []string {
  44504. edges := make([]string, 0, 2)
  44505. if m.clearedserver {
  44506. edges = append(edges, wx.EdgeServer)
  44507. }
  44508. if m.clearedagent {
  44509. edges = append(edges, wx.EdgeAgent)
  44510. }
  44511. return edges
  44512. }
  44513. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44514. // was cleared in this mutation.
  44515. func (m *WxMutation) EdgeCleared(name string) bool {
  44516. switch name {
  44517. case wx.EdgeServer:
  44518. return m.clearedserver
  44519. case wx.EdgeAgent:
  44520. return m.clearedagent
  44521. }
  44522. return false
  44523. }
  44524. // ClearEdge clears the value of the edge with the given name. It returns an error
  44525. // if that edge is not defined in the schema.
  44526. func (m *WxMutation) ClearEdge(name string) error {
  44527. switch name {
  44528. case wx.EdgeServer:
  44529. m.ClearServer()
  44530. return nil
  44531. case wx.EdgeAgent:
  44532. m.ClearAgent()
  44533. return nil
  44534. }
  44535. return fmt.Errorf("unknown Wx unique edge %s", name)
  44536. }
  44537. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44538. // It returns an error if the edge is not defined in the schema.
  44539. func (m *WxMutation) ResetEdge(name string) error {
  44540. switch name {
  44541. case wx.EdgeServer:
  44542. m.ResetServer()
  44543. return nil
  44544. case wx.EdgeAgent:
  44545. m.ResetAgent()
  44546. return nil
  44547. }
  44548. return fmt.Errorf("unknown Wx edge %s", name)
  44549. }
  44550. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  44551. type WxCardMutation struct {
  44552. config
  44553. op Op
  44554. typ string
  44555. id *uint64
  44556. created_at *time.Time
  44557. updated_at *time.Time
  44558. deleted_at *time.Time
  44559. user_id *uint64
  44560. adduser_id *int64
  44561. wx_user_id *uint64
  44562. addwx_user_id *int64
  44563. avatar *string
  44564. logo *string
  44565. name *string
  44566. company *string
  44567. address *string
  44568. phone *string
  44569. official_account *string
  44570. wechat_account *string
  44571. email *string
  44572. api_base *string
  44573. api_key *string
  44574. ai_info *string
  44575. intro *string
  44576. clearedFields map[string]struct{}
  44577. done bool
  44578. oldValue func(context.Context) (*WxCard, error)
  44579. predicates []predicate.WxCard
  44580. }
  44581. var _ ent.Mutation = (*WxCardMutation)(nil)
  44582. // wxcardOption allows management of the mutation configuration using functional options.
  44583. type wxcardOption func(*WxCardMutation)
  44584. // newWxCardMutation creates new mutation for the WxCard entity.
  44585. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  44586. m := &WxCardMutation{
  44587. config: c,
  44588. op: op,
  44589. typ: TypeWxCard,
  44590. clearedFields: make(map[string]struct{}),
  44591. }
  44592. for _, opt := range opts {
  44593. opt(m)
  44594. }
  44595. return m
  44596. }
  44597. // withWxCardID sets the ID field of the mutation.
  44598. func withWxCardID(id uint64) wxcardOption {
  44599. return func(m *WxCardMutation) {
  44600. var (
  44601. err error
  44602. once sync.Once
  44603. value *WxCard
  44604. )
  44605. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  44606. once.Do(func() {
  44607. if m.done {
  44608. err = errors.New("querying old values post mutation is not allowed")
  44609. } else {
  44610. value, err = m.Client().WxCard.Get(ctx, id)
  44611. }
  44612. })
  44613. return value, err
  44614. }
  44615. m.id = &id
  44616. }
  44617. }
  44618. // withWxCard sets the old WxCard of the mutation.
  44619. func withWxCard(node *WxCard) wxcardOption {
  44620. return func(m *WxCardMutation) {
  44621. m.oldValue = func(context.Context) (*WxCard, error) {
  44622. return node, nil
  44623. }
  44624. m.id = &node.ID
  44625. }
  44626. }
  44627. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44628. // executed in a transaction (ent.Tx), a transactional client is returned.
  44629. func (m WxCardMutation) Client() *Client {
  44630. client := &Client{config: m.config}
  44631. client.init()
  44632. return client
  44633. }
  44634. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44635. // it returns an error otherwise.
  44636. func (m WxCardMutation) Tx() (*Tx, error) {
  44637. if _, ok := m.driver.(*txDriver); !ok {
  44638. return nil, errors.New("ent: mutation is not running in a transaction")
  44639. }
  44640. tx := &Tx{config: m.config}
  44641. tx.init()
  44642. return tx, nil
  44643. }
  44644. // SetID sets the value of the id field. Note that this
  44645. // operation is only accepted on creation of WxCard entities.
  44646. func (m *WxCardMutation) SetID(id uint64) {
  44647. m.id = &id
  44648. }
  44649. // ID returns the ID value in the mutation. Note that the ID is only available
  44650. // if it was provided to the builder or after it was returned from the database.
  44651. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  44652. if m.id == nil {
  44653. return
  44654. }
  44655. return *m.id, true
  44656. }
  44657. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44658. // That means, if the mutation is applied within a transaction with an isolation level such
  44659. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44660. // or updated by the mutation.
  44661. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  44662. switch {
  44663. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44664. id, exists := m.ID()
  44665. if exists {
  44666. return []uint64{id}, nil
  44667. }
  44668. fallthrough
  44669. case m.op.Is(OpUpdate | OpDelete):
  44670. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  44671. default:
  44672. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44673. }
  44674. }
  44675. // SetCreatedAt sets the "created_at" field.
  44676. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  44677. m.created_at = &t
  44678. }
  44679. // CreatedAt returns the value of the "created_at" field in the mutation.
  44680. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  44681. v := m.created_at
  44682. if v == nil {
  44683. return
  44684. }
  44685. return *v, true
  44686. }
  44687. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  44688. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44690. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44691. if !m.op.Is(OpUpdateOne) {
  44692. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44693. }
  44694. if m.id == nil || m.oldValue == nil {
  44695. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44696. }
  44697. oldValue, err := m.oldValue(ctx)
  44698. if err != nil {
  44699. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44700. }
  44701. return oldValue.CreatedAt, nil
  44702. }
  44703. // ResetCreatedAt resets all changes to the "created_at" field.
  44704. func (m *WxCardMutation) ResetCreatedAt() {
  44705. m.created_at = nil
  44706. }
  44707. // SetUpdatedAt sets the "updated_at" field.
  44708. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  44709. m.updated_at = &t
  44710. }
  44711. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44712. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  44713. v := m.updated_at
  44714. if v == nil {
  44715. return
  44716. }
  44717. return *v, true
  44718. }
  44719. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44723. if !m.op.Is(OpUpdateOne) {
  44724. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44725. }
  44726. if m.id == nil || m.oldValue == nil {
  44727. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  44732. }
  44733. return oldValue.UpdatedAt, nil
  44734. }
  44735. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44736. func (m *WxCardMutation) ResetUpdatedAt() {
  44737. m.updated_at = nil
  44738. }
  44739. // SetDeletedAt sets the "deleted_at" field.
  44740. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  44741. m.deleted_at = &t
  44742. }
  44743. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44744. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  44745. v := m.deleted_at
  44746. if v == nil {
  44747. return
  44748. }
  44749. return *v, true
  44750. }
  44751. // OldDeletedAt returns the old "deleted_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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44755. if !m.op.Is(OpUpdateOne) {
  44756. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44757. }
  44758. if m.id == nil || m.oldValue == nil {
  44759. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  44764. }
  44765. return oldValue.DeletedAt, nil
  44766. }
  44767. // ClearDeletedAt clears the value of the "deleted_at" field.
  44768. func (m *WxCardMutation) ClearDeletedAt() {
  44769. m.deleted_at = nil
  44770. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  44771. }
  44772. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44773. func (m *WxCardMutation) DeletedAtCleared() bool {
  44774. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  44775. return ok
  44776. }
  44777. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44778. func (m *WxCardMutation) ResetDeletedAt() {
  44779. m.deleted_at = nil
  44780. delete(m.clearedFields, wxcard.FieldDeletedAt)
  44781. }
  44782. // SetUserID sets the "user_id" field.
  44783. func (m *WxCardMutation) SetUserID(u uint64) {
  44784. m.user_id = &u
  44785. m.adduser_id = nil
  44786. }
  44787. // UserID returns the value of the "user_id" field in the mutation.
  44788. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  44789. v := m.user_id
  44790. if v == nil {
  44791. return
  44792. }
  44793. return *v, true
  44794. }
  44795. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  44796. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44798. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  44799. if !m.op.Is(OpUpdateOne) {
  44800. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  44801. }
  44802. if m.id == nil || m.oldValue == nil {
  44803. return v, errors.New("OldUserID requires an ID field in the mutation")
  44804. }
  44805. oldValue, err := m.oldValue(ctx)
  44806. if err != nil {
  44807. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  44808. }
  44809. return oldValue.UserID, nil
  44810. }
  44811. // AddUserID adds u to the "user_id" field.
  44812. func (m *WxCardMutation) AddUserID(u int64) {
  44813. if m.adduser_id != nil {
  44814. *m.adduser_id += u
  44815. } else {
  44816. m.adduser_id = &u
  44817. }
  44818. }
  44819. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44820. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  44821. v := m.adduser_id
  44822. if v == nil {
  44823. return
  44824. }
  44825. return *v, true
  44826. }
  44827. // ClearUserID clears the value of the "user_id" field.
  44828. func (m *WxCardMutation) ClearUserID() {
  44829. m.user_id = nil
  44830. m.adduser_id = nil
  44831. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  44832. }
  44833. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44834. func (m *WxCardMutation) UserIDCleared() bool {
  44835. _, ok := m.clearedFields[wxcard.FieldUserID]
  44836. return ok
  44837. }
  44838. // ResetUserID resets all changes to the "user_id" field.
  44839. func (m *WxCardMutation) ResetUserID() {
  44840. m.user_id = nil
  44841. m.adduser_id = nil
  44842. delete(m.clearedFields, wxcard.FieldUserID)
  44843. }
  44844. // SetWxUserID sets the "wx_user_id" field.
  44845. func (m *WxCardMutation) SetWxUserID(u uint64) {
  44846. m.wx_user_id = &u
  44847. m.addwx_user_id = nil
  44848. }
  44849. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  44850. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  44851. v := m.wx_user_id
  44852. if v == nil {
  44853. return
  44854. }
  44855. return *v, true
  44856. }
  44857. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  44858. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44860. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  44861. if !m.op.Is(OpUpdateOne) {
  44862. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  44863. }
  44864. if m.id == nil || m.oldValue == nil {
  44865. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  44866. }
  44867. oldValue, err := m.oldValue(ctx)
  44868. if err != nil {
  44869. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  44870. }
  44871. return oldValue.WxUserID, nil
  44872. }
  44873. // AddWxUserID adds u to the "wx_user_id" field.
  44874. func (m *WxCardMutation) AddWxUserID(u int64) {
  44875. if m.addwx_user_id != nil {
  44876. *m.addwx_user_id += u
  44877. } else {
  44878. m.addwx_user_id = &u
  44879. }
  44880. }
  44881. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  44882. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  44883. v := m.addwx_user_id
  44884. if v == nil {
  44885. return
  44886. }
  44887. return *v, true
  44888. }
  44889. // ClearWxUserID clears the value of the "wx_user_id" field.
  44890. func (m *WxCardMutation) ClearWxUserID() {
  44891. m.wx_user_id = nil
  44892. m.addwx_user_id = nil
  44893. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  44894. }
  44895. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  44896. func (m *WxCardMutation) WxUserIDCleared() bool {
  44897. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  44898. return ok
  44899. }
  44900. // ResetWxUserID resets all changes to the "wx_user_id" field.
  44901. func (m *WxCardMutation) ResetWxUserID() {
  44902. m.wx_user_id = nil
  44903. m.addwx_user_id = nil
  44904. delete(m.clearedFields, wxcard.FieldWxUserID)
  44905. }
  44906. // SetAvatar sets the "avatar" field.
  44907. func (m *WxCardMutation) SetAvatar(s string) {
  44908. m.avatar = &s
  44909. }
  44910. // Avatar returns the value of the "avatar" field in the mutation.
  44911. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  44912. v := m.avatar
  44913. if v == nil {
  44914. return
  44915. }
  44916. return *v, true
  44917. }
  44918. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  44919. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44921. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44922. if !m.op.Is(OpUpdateOne) {
  44923. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44924. }
  44925. if m.id == nil || m.oldValue == nil {
  44926. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44927. }
  44928. oldValue, err := m.oldValue(ctx)
  44929. if err != nil {
  44930. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44931. }
  44932. return oldValue.Avatar, nil
  44933. }
  44934. // ResetAvatar resets all changes to the "avatar" field.
  44935. func (m *WxCardMutation) ResetAvatar() {
  44936. m.avatar = nil
  44937. }
  44938. // SetLogo sets the "logo" field.
  44939. func (m *WxCardMutation) SetLogo(s string) {
  44940. m.logo = &s
  44941. }
  44942. // Logo returns the value of the "logo" field in the mutation.
  44943. func (m *WxCardMutation) Logo() (r string, exists bool) {
  44944. v := m.logo
  44945. if v == nil {
  44946. return
  44947. }
  44948. return *v, true
  44949. }
  44950. // OldLogo returns the old "logo" 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) OldLogo(ctx context.Context) (v string, err error) {
  44954. if !m.op.Is(OpUpdateOne) {
  44955. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  44956. }
  44957. if m.id == nil || m.oldValue == nil {
  44958. return v, errors.New("OldLogo 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 OldLogo: %w", err)
  44963. }
  44964. return oldValue.Logo, nil
  44965. }
  44966. // ResetLogo resets all changes to the "logo" field.
  44967. func (m *WxCardMutation) ResetLogo() {
  44968. m.logo = nil
  44969. }
  44970. // SetName sets the "name" field.
  44971. func (m *WxCardMutation) SetName(s string) {
  44972. m.name = &s
  44973. }
  44974. // Name returns the value of the "name" field in the mutation.
  44975. func (m *WxCardMutation) Name() (r string, exists bool) {
  44976. v := m.name
  44977. if v == nil {
  44978. return
  44979. }
  44980. return *v, true
  44981. }
  44982. // OldName returns the old "name" 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) OldName(ctx context.Context) (v string, err error) {
  44986. if !m.op.Is(OpUpdateOne) {
  44987. return v, errors.New("OldName is only allowed on UpdateOne operations")
  44988. }
  44989. if m.id == nil || m.oldValue == nil {
  44990. return v, errors.New("OldName 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 OldName: %w", err)
  44995. }
  44996. return oldValue.Name, nil
  44997. }
  44998. // ResetName resets all changes to the "name" field.
  44999. func (m *WxCardMutation) ResetName() {
  45000. m.name = nil
  45001. }
  45002. // SetCompany sets the "company" field.
  45003. func (m *WxCardMutation) SetCompany(s string) {
  45004. m.company = &s
  45005. }
  45006. // Company returns the value of the "company" field in the mutation.
  45007. func (m *WxCardMutation) Company() (r string, exists bool) {
  45008. v := m.company
  45009. if v == nil {
  45010. return
  45011. }
  45012. return *v, true
  45013. }
  45014. // OldCompany returns the old "company" 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) OldCompany(ctx context.Context) (v string, err error) {
  45018. if !m.op.Is(OpUpdateOne) {
  45019. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  45020. }
  45021. if m.id == nil || m.oldValue == nil {
  45022. return v, errors.New("OldCompany 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 OldCompany: %w", err)
  45027. }
  45028. return oldValue.Company, nil
  45029. }
  45030. // ResetCompany resets all changes to the "company" field.
  45031. func (m *WxCardMutation) ResetCompany() {
  45032. m.company = nil
  45033. }
  45034. // SetAddress sets the "address" field.
  45035. func (m *WxCardMutation) SetAddress(s string) {
  45036. m.address = &s
  45037. }
  45038. // Address returns the value of the "address" field in the mutation.
  45039. func (m *WxCardMutation) Address() (r string, exists bool) {
  45040. v := m.address
  45041. if v == nil {
  45042. return
  45043. }
  45044. return *v, true
  45045. }
  45046. // OldAddress returns the old "address" 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) OldAddress(ctx context.Context) (v string, err error) {
  45050. if !m.op.Is(OpUpdateOne) {
  45051. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  45052. }
  45053. if m.id == nil || m.oldValue == nil {
  45054. return v, errors.New("OldAddress 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 OldAddress: %w", err)
  45059. }
  45060. return oldValue.Address, nil
  45061. }
  45062. // ResetAddress resets all changes to the "address" field.
  45063. func (m *WxCardMutation) ResetAddress() {
  45064. m.address = nil
  45065. }
  45066. // SetPhone sets the "phone" field.
  45067. func (m *WxCardMutation) SetPhone(s string) {
  45068. m.phone = &s
  45069. }
  45070. // Phone returns the value of the "phone" field in the mutation.
  45071. func (m *WxCardMutation) Phone() (r string, exists bool) {
  45072. v := m.phone
  45073. if v == nil {
  45074. return
  45075. }
  45076. return *v, true
  45077. }
  45078. // OldPhone returns the old "phone" 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) OldPhone(ctx context.Context) (v string, err error) {
  45082. if !m.op.Is(OpUpdateOne) {
  45083. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  45084. }
  45085. if m.id == nil || m.oldValue == nil {
  45086. return v, errors.New("OldPhone 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 OldPhone: %w", err)
  45091. }
  45092. return oldValue.Phone, nil
  45093. }
  45094. // ResetPhone resets all changes to the "phone" field.
  45095. func (m *WxCardMutation) ResetPhone() {
  45096. m.phone = nil
  45097. }
  45098. // SetOfficialAccount sets the "official_account" field.
  45099. func (m *WxCardMutation) SetOfficialAccount(s string) {
  45100. m.official_account = &s
  45101. }
  45102. // OfficialAccount returns the value of the "official_account" field in the mutation.
  45103. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  45104. v := m.official_account
  45105. if v == nil {
  45106. return
  45107. }
  45108. return *v, true
  45109. }
  45110. // OldOfficialAccount returns the old "official_account" 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) OldOfficialAccount(ctx context.Context) (v string, err error) {
  45114. if !m.op.Is(OpUpdateOne) {
  45115. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  45116. }
  45117. if m.id == nil || m.oldValue == nil {
  45118. return v, errors.New("OldOfficialAccount 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 OldOfficialAccount: %w", err)
  45123. }
  45124. return oldValue.OfficialAccount, nil
  45125. }
  45126. // ResetOfficialAccount resets all changes to the "official_account" field.
  45127. func (m *WxCardMutation) ResetOfficialAccount() {
  45128. m.official_account = nil
  45129. }
  45130. // SetWechatAccount sets the "wechat_account" field.
  45131. func (m *WxCardMutation) SetWechatAccount(s string) {
  45132. m.wechat_account = &s
  45133. }
  45134. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  45135. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  45136. v := m.wechat_account
  45137. if v == nil {
  45138. return
  45139. }
  45140. return *v, true
  45141. }
  45142. // OldWechatAccount returns the old "wechat_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) OldWechatAccount(ctx context.Context) (v string, err error) {
  45146. if !m.op.Is(OpUpdateOne) {
  45147. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  45148. }
  45149. if m.id == nil || m.oldValue == nil {
  45150. return v, errors.New("OldWechatAccount 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 OldWechatAccount: %w", err)
  45155. }
  45156. return oldValue.WechatAccount, nil
  45157. }
  45158. // ResetWechatAccount resets all changes to the "wechat_account" field.
  45159. func (m *WxCardMutation) ResetWechatAccount() {
  45160. m.wechat_account = nil
  45161. }
  45162. // SetEmail sets the "email" field.
  45163. func (m *WxCardMutation) SetEmail(s string) {
  45164. m.email = &s
  45165. }
  45166. // Email returns the value of the "email" field in the mutation.
  45167. func (m *WxCardMutation) Email() (r string, exists bool) {
  45168. v := m.email
  45169. if v == nil {
  45170. return
  45171. }
  45172. return *v, true
  45173. }
  45174. // OldEmail returns the old "email" 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) OldEmail(ctx context.Context) (v string, err error) {
  45178. if !m.op.Is(OpUpdateOne) {
  45179. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  45180. }
  45181. if m.id == nil || m.oldValue == nil {
  45182. return v, errors.New("OldEmail 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 OldEmail: %w", err)
  45187. }
  45188. return oldValue.Email, nil
  45189. }
  45190. // ClearEmail clears the value of the "email" field.
  45191. func (m *WxCardMutation) ClearEmail() {
  45192. m.email = nil
  45193. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  45194. }
  45195. // EmailCleared returns if the "email" field was cleared in this mutation.
  45196. func (m *WxCardMutation) EmailCleared() bool {
  45197. _, ok := m.clearedFields[wxcard.FieldEmail]
  45198. return ok
  45199. }
  45200. // ResetEmail resets all changes to the "email" field.
  45201. func (m *WxCardMutation) ResetEmail() {
  45202. m.email = nil
  45203. delete(m.clearedFields, wxcard.FieldEmail)
  45204. }
  45205. // SetAPIBase sets the "api_base" field.
  45206. func (m *WxCardMutation) SetAPIBase(s string) {
  45207. m.api_base = &s
  45208. }
  45209. // APIBase returns the value of the "api_base" field in the mutation.
  45210. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  45211. v := m.api_base
  45212. if v == nil {
  45213. return
  45214. }
  45215. return *v, true
  45216. }
  45217. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  45218. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45220. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  45221. if !m.op.Is(OpUpdateOne) {
  45222. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  45223. }
  45224. if m.id == nil || m.oldValue == nil {
  45225. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  45226. }
  45227. oldValue, err := m.oldValue(ctx)
  45228. if err != nil {
  45229. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  45230. }
  45231. return oldValue.APIBase, nil
  45232. }
  45233. // ClearAPIBase clears the value of the "api_base" field.
  45234. func (m *WxCardMutation) ClearAPIBase() {
  45235. m.api_base = nil
  45236. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  45237. }
  45238. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  45239. func (m *WxCardMutation) APIBaseCleared() bool {
  45240. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  45241. return ok
  45242. }
  45243. // ResetAPIBase resets all changes to the "api_base" field.
  45244. func (m *WxCardMutation) ResetAPIBase() {
  45245. m.api_base = nil
  45246. delete(m.clearedFields, wxcard.FieldAPIBase)
  45247. }
  45248. // SetAPIKey sets the "api_key" field.
  45249. func (m *WxCardMutation) SetAPIKey(s string) {
  45250. m.api_key = &s
  45251. }
  45252. // APIKey returns the value of the "api_key" field in the mutation.
  45253. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  45254. v := m.api_key
  45255. if v == nil {
  45256. return
  45257. }
  45258. return *v, true
  45259. }
  45260. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  45261. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45263. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  45264. if !m.op.Is(OpUpdateOne) {
  45265. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  45266. }
  45267. if m.id == nil || m.oldValue == nil {
  45268. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  45269. }
  45270. oldValue, err := m.oldValue(ctx)
  45271. if err != nil {
  45272. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  45273. }
  45274. return oldValue.APIKey, nil
  45275. }
  45276. // ClearAPIKey clears the value of the "api_key" field.
  45277. func (m *WxCardMutation) ClearAPIKey() {
  45278. m.api_key = nil
  45279. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  45280. }
  45281. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  45282. func (m *WxCardMutation) APIKeyCleared() bool {
  45283. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  45284. return ok
  45285. }
  45286. // ResetAPIKey resets all changes to the "api_key" field.
  45287. func (m *WxCardMutation) ResetAPIKey() {
  45288. m.api_key = nil
  45289. delete(m.clearedFields, wxcard.FieldAPIKey)
  45290. }
  45291. // SetAiInfo sets the "ai_info" field.
  45292. func (m *WxCardMutation) SetAiInfo(s string) {
  45293. m.ai_info = &s
  45294. }
  45295. // AiInfo returns the value of the "ai_info" field in the mutation.
  45296. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  45297. v := m.ai_info
  45298. if v == nil {
  45299. return
  45300. }
  45301. return *v, true
  45302. }
  45303. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  45304. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45306. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  45307. if !m.op.Is(OpUpdateOne) {
  45308. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  45309. }
  45310. if m.id == nil || m.oldValue == nil {
  45311. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  45312. }
  45313. oldValue, err := m.oldValue(ctx)
  45314. if err != nil {
  45315. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  45316. }
  45317. return oldValue.AiInfo, nil
  45318. }
  45319. // ClearAiInfo clears the value of the "ai_info" field.
  45320. func (m *WxCardMutation) ClearAiInfo() {
  45321. m.ai_info = nil
  45322. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  45323. }
  45324. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  45325. func (m *WxCardMutation) AiInfoCleared() bool {
  45326. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  45327. return ok
  45328. }
  45329. // ResetAiInfo resets all changes to the "ai_info" field.
  45330. func (m *WxCardMutation) ResetAiInfo() {
  45331. m.ai_info = nil
  45332. delete(m.clearedFields, wxcard.FieldAiInfo)
  45333. }
  45334. // SetIntro sets the "intro" field.
  45335. func (m *WxCardMutation) SetIntro(s string) {
  45336. m.intro = &s
  45337. }
  45338. // Intro returns the value of the "intro" field in the mutation.
  45339. func (m *WxCardMutation) Intro() (r string, exists bool) {
  45340. v := m.intro
  45341. if v == nil {
  45342. return
  45343. }
  45344. return *v, true
  45345. }
  45346. // OldIntro returns the old "intro" field's value of the WxCard entity.
  45347. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45349. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  45350. if !m.op.Is(OpUpdateOne) {
  45351. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  45352. }
  45353. if m.id == nil || m.oldValue == nil {
  45354. return v, errors.New("OldIntro requires an ID field in the mutation")
  45355. }
  45356. oldValue, err := m.oldValue(ctx)
  45357. if err != nil {
  45358. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  45359. }
  45360. return oldValue.Intro, nil
  45361. }
  45362. // ClearIntro clears the value of the "intro" field.
  45363. func (m *WxCardMutation) ClearIntro() {
  45364. m.intro = nil
  45365. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  45366. }
  45367. // IntroCleared returns if the "intro" field was cleared in this mutation.
  45368. func (m *WxCardMutation) IntroCleared() bool {
  45369. _, ok := m.clearedFields[wxcard.FieldIntro]
  45370. return ok
  45371. }
  45372. // ResetIntro resets all changes to the "intro" field.
  45373. func (m *WxCardMutation) ResetIntro() {
  45374. m.intro = nil
  45375. delete(m.clearedFields, wxcard.FieldIntro)
  45376. }
  45377. // Where appends a list predicates to the WxCardMutation builder.
  45378. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  45379. m.predicates = append(m.predicates, ps...)
  45380. }
  45381. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  45382. // users can use type-assertion to append predicates that do not depend on any generated package.
  45383. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  45384. p := make([]predicate.WxCard, len(ps))
  45385. for i := range ps {
  45386. p[i] = ps[i]
  45387. }
  45388. m.Where(p...)
  45389. }
  45390. // Op returns the operation name.
  45391. func (m *WxCardMutation) Op() Op {
  45392. return m.op
  45393. }
  45394. // SetOp allows setting the mutation operation.
  45395. func (m *WxCardMutation) SetOp(op Op) {
  45396. m.op = op
  45397. }
  45398. // Type returns the node type of this mutation (WxCard).
  45399. func (m *WxCardMutation) Type() string {
  45400. return m.typ
  45401. }
  45402. // Fields returns all fields that were changed during this mutation. Note that in
  45403. // order to get all numeric fields that were incremented/decremented, call
  45404. // AddedFields().
  45405. func (m *WxCardMutation) Fields() []string {
  45406. fields := make([]string, 0, 18)
  45407. if m.created_at != nil {
  45408. fields = append(fields, wxcard.FieldCreatedAt)
  45409. }
  45410. if m.updated_at != nil {
  45411. fields = append(fields, wxcard.FieldUpdatedAt)
  45412. }
  45413. if m.deleted_at != nil {
  45414. fields = append(fields, wxcard.FieldDeletedAt)
  45415. }
  45416. if m.user_id != nil {
  45417. fields = append(fields, wxcard.FieldUserID)
  45418. }
  45419. if m.wx_user_id != nil {
  45420. fields = append(fields, wxcard.FieldWxUserID)
  45421. }
  45422. if m.avatar != nil {
  45423. fields = append(fields, wxcard.FieldAvatar)
  45424. }
  45425. if m.logo != nil {
  45426. fields = append(fields, wxcard.FieldLogo)
  45427. }
  45428. if m.name != nil {
  45429. fields = append(fields, wxcard.FieldName)
  45430. }
  45431. if m.company != nil {
  45432. fields = append(fields, wxcard.FieldCompany)
  45433. }
  45434. if m.address != nil {
  45435. fields = append(fields, wxcard.FieldAddress)
  45436. }
  45437. if m.phone != nil {
  45438. fields = append(fields, wxcard.FieldPhone)
  45439. }
  45440. if m.official_account != nil {
  45441. fields = append(fields, wxcard.FieldOfficialAccount)
  45442. }
  45443. if m.wechat_account != nil {
  45444. fields = append(fields, wxcard.FieldWechatAccount)
  45445. }
  45446. if m.email != nil {
  45447. fields = append(fields, wxcard.FieldEmail)
  45448. }
  45449. if m.api_base != nil {
  45450. fields = append(fields, wxcard.FieldAPIBase)
  45451. }
  45452. if m.api_key != nil {
  45453. fields = append(fields, wxcard.FieldAPIKey)
  45454. }
  45455. if m.ai_info != nil {
  45456. fields = append(fields, wxcard.FieldAiInfo)
  45457. }
  45458. if m.intro != nil {
  45459. fields = append(fields, wxcard.FieldIntro)
  45460. }
  45461. return fields
  45462. }
  45463. // Field returns the value of a field with the given name. The second boolean
  45464. // return value indicates that this field was not set, or was not defined in the
  45465. // schema.
  45466. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  45467. switch name {
  45468. case wxcard.FieldCreatedAt:
  45469. return m.CreatedAt()
  45470. case wxcard.FieldUpdatedAt:
  45471. return m.UpdatedAt()
  45472. case wxcard.FieldDeletedAt:
  45473. return m.DeletedAt()
  45474. case wxcard.FieldUserID:
  45475. return m.UserID()
  45476. case wxcard.FieldWxUserID:
  45477. return m.WxUserID()
  45478. case wxcard.FieldAvatar:
  45479. return m.Avatar()
  45480. case wxcard.FieldLogo:
  45481. return m.Logo()
  45482. case wxcard.FieldName:
  45483. return m.Name()
  45484. case wxcard.FieldCompany:
  45485. return m.Company()
  45486. case wxcard.FieldAddress:
  45487. return m.Address()
  45488. case wxcard.FieldPhone:
  45489. return m.Phone()
  45490. case wxcard.FieldOfficialAccount:
  45491. return m.OfficialAccount()
  45492. case wxcard.FieldWechatAccount:
  45493. return m.WechatAccount()
  45494. case wxcard.FieldEmail:
  45495. return m.Email()
  45496. case wxcard.FieldAPIBase:
  45497. return m.APIBase()
  45498. case wxcard.FieldAPIKey:
  45499. return m.APIKey()
  45500. case wxcard.FieldAiInfo:
  45501. return m.AiInfo()
  45502. case wxcard.FieldIntro:
  45503. return m.Intro()
  45504. }
  45505. return nil, false
  45506. }
  45507. // OldField returns the old value of the field from the database. An error is
  45508. // returned if the mutation operation is not UpdateOne, or the query to the
  45509. // database failed.
  45510. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45511. switch name {
  45512. case wxcard.FieldCreatedAt:
  45513. return m.OldCreatedAt(ctx)
  45514. case wxcard.FieldUpdatedAt:
  45515. return m.OldUpdatedAt(ctx)
  45516. case wxcard.FieldDeletedAt:
  45517. return m.OldDeletedAt(ctx)
  45518. case wxcard.FieldUserID:
  45519. return m.OldUserID(ctx)
  45520. case wxcard.FieldWxUserID:
  45521. return m.OldWxUserID(ctx)
  45522. case wxcard.FieldAvatar:
  45523. return m.OldAvatar(ctx)
  45524. case wxcard.FieldLogo:
  45525. return m.OldLogo(ctx)
  45526. case wxcard.FieldName:
  45527. return m.OldName(ctx)
  45528. case wxcard.FieldCompany:
  45529. return m.OldCompany(ctx)
  45530. case wxcard.FieldAddress:
  45531. return m.OldAddress(ctx)
  45532. case wxcard.FieldPhone:
  45533. return m.OldPhone(ctx)
  45534. case wxcard.FieldOfficialAccount:
  45535. return m.OldOfficialAccount(ctx)
  45536. case wxcard.FieldWechatAccount:
  45537. return m.OldWechatAccount(ctx)
  45538. case wxcard.FieldEmail:
  45539. return m.OldEmail(ctx)
  45540. case wxcard.FieldAPIBase:
  45541. return m.OldAPIBase(ctx)
  45542. case wxcard.FieldAPIKey:
  45543. return m.OldAPIKey(ctx)
  45544. case wxcard.FieldAiInfo:
  45545. return m.OldAiInfo(ctx)
  45546. case wxcard.FieldIntro:
  45547. return m.OldIntro(ctx)
  45548. }
  45549. return nil, fmt.Errorf("unknown WxCard field %s", name)
  45550. }
  45551. // SetField sets the value of a field with the given name. It returns an error if
  45552. // the field is not defined in the schema, or if the type mismatched the field
  45553. // type.
  45554. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  45555. switch name {
  45556. case wxcard.FieldCreatedAt:
  45557. v, ok := value.(time.Time)
  45558. if !ok {
  45559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45560. }
  45561. m.SetCreatedAt(v)
  45562. return nil
  45563. case wxcard.FieldUpdatedAt:
  45564. v, ok := value.(time.Time)
  45565. if !ok {
  45566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45567. }
  45568. m.SetUpdatedAt(v)
  45569. return nil
  45570. case wxcard.FieldDeletedAt:
  45571. v, ok := value.(time.Time)
  45572. if !ok {
  45573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45574. }
  45575. m.SetDeletedAt(v)
  45576. return nil
  45577. case wxcard.FieldUserID:
  45578. v, ok := value.(uint64)
  45579. if !ok {
  45580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45581. }
  45582. m.SetUserID(v)
  45583. return nil
  45584. case wxcard.FieldWxUserID:
  45585. v, ok := value.(uint64)
  45586. if !ok {
  45587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45588. }
  45589. m.SetWxUserID(v)
  45590. return nil
  45591. case wxcard.FieldAvatar:
  45592. v, ok := value.(string)
  45593. if !ok {
  45594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45595. }
  45596. m.SetAvatar(v)
  45597. return nil
  45598. case wxcard.FieldLogo:
  45599. v, ok := value.(string)
  45600. if !ok {
  45601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45602. }
  45603. m.SetLogo(v)
  45604. return nil
  45605. case wxcard.FieldName:
  45606. v, ok := value.(string)
  45607. if !ok {
  45608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45609. }
  45610. m.SetName(v)
  45611. return nil
  45612. case wxcard.FieldCompany:
  45613. v, ok := value.(string)
  45614. if !ok {
  45615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45616. }
  45617. m.SetCompany(v)
  45618. return nil
  45619. case wxcard.FieldAddress:
  45620. v, ok := value.(string)
  45621. if !ok {
  45622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45623. }
  45624. m.SetAddress(v)
  45625. return nil
  45626. case wxcard.FieldPhone:
  45627. v, ok := value.(string)
  45628. if !ok {
  45629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45630. }
  45631. m.SetPhone(v)
  45632. return nil
  45633. case wxcard.FieldOfficialAccount:
  45634. v, ok := value.(string)
  45635. if !ok {
  45636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45637. }
  45638. m.SetOfficialAccount(v)
  45639. return nil
  45640. case wxcard.FieldWechatAccount:
  45641. v, ok := value.(string)
  45642. if !ok {
  45643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45644. }
  45645. m.SetWechatAccount(v)
  45646. return nil
  45647. case wxcard.FieldEmail:
  45648. v, ok := value.(string)
  45649. if !ok {
  45650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45651. }
  45652. m.SetEmail(v)
  45653. return nil
  45654. case wxcard.FieldAPIBase:
  45655. v, ok := value.(string)
  45656. if !ok {
  45657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45658. }
  45659. m.SetAPIBase(v)
  45660. return nil
  45661. case wxcard.FieldAPIKey:
  45662. v, ok := value.(string)
  45663. if !ok {
  45664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45665. }
  45666. m.SetAPIKey(v)
  45667. return nil
  45668. case wxcard.FieldAiInfo:
  45669. v, ok := value.(string)
  45670. if !ok {
  45671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45672. }
  45673. m.SetAiInfo(v)
  45674. return nil
  45675. case wxcard.FieldIntro:
  45676. v, ok := value.(string)
  45677. if !ok {
  45678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45679. }
  45680. m.SetIntro(v)
  45681. return nil
  45682. }
  45683. return fmt.Errorf("unknown WxCard field %s", name)
  45684. }
  45685. // AddedFields returns all numeric fields that were incremented/decremented during
  45686. // this mutation.
  45687. func (m *WxCardMutation) AddedFields() []string {
  45688. var fields []string
  45689. if m.adduser_id != nil {
  45690. fields = append(fields, wxcard.FieldUserID)
  45691. }
  45692. if m.addwx_user_id != nil {
  45693. fields = append(fields, wxcard.FieldWxUserID)
  45694. }
  45695. return fields
  45696. }
  45697. // AddedField returns the numeric value that was incremented/decremented on a field
  45698. // with the given name. The second boolean return value indicates that this field
  45699. // was not set, or was not defined in the schema.
  45700. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  45701. switch name {
  45702. case wxcard.FieldUserID:
  45703. return m.AddedUserID()
  45704. case wxcard.FieldWxUserID:
  45705. return m.AddedWxUserID()
  45706. }
  45707. return nil, false
  45708. }
  45709. // AddField adds the value to the field with the given name. It returns an error if
  45710. // the field is not defined in the schema, or if the type mismatched the field
  45711. // type.
  45712. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  45713. switch name {
  45714. case wxcard.FieldUserID:
  45715. v, ok := value.(int64)
  45716. if !ok {
  45717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45718. }
  45719. m.AddUserID(v)
  45720. return nil
  45721. case wxcard.FieldWxUserID:
  45722. v, ok := value.(int64)
  45723. if !ok {
  45724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45725. }
  45726. m.AddWxUserID(v)
  45727. return nil
  45728. }
  45729. return fmt.Errorf("unknown WxCard numeric field %s", name)
  45730. }
  45731. // ClearedFields returns all nullable fields that were cleared during this
  45732. // mutation.
  45733. func (m *WxCardMutation) ClearedFields() []string {
  45734. var fields []string
  45735. if m.FieldCleared(wxcard.FieldDeletedAt) {
  45736. fields = append(fields, wxcard.FieldDeletedAt)
  45737. }
  45738. if m.FieldCleared(wxcard.FieldUserID) {
  45739. fields = append(fields, wxcard.FieldUserID)
  45740. }
  45741. if m.FieldCleared(wxcard.FieldWxUserID) {
  45742. fields = append(fields, wxcard.FieldWxUserID)
  45743. }
  45744. if m.FieldCleared(wxcard.FieldEmail) {
  45745. fields = append(fields, wxcard.FieldEmail)
  45746. }
  45747. if m.FieldCleared(wxcard.FieldAPIBase) {
  45748. fields = append(fields, wxcard.FieldAPIBase)
  45749. }
  45750. if m.FieldCleared(wxcard.FieldAPIKey) {
  45751. fields = append(fields, wxcard.FieldAPIKey)
  45752. }
  45753. if m.FieldCleared(wxcard.FieldAiInfo) {
  45754. fields = append(fields, wxcard.FieldAiInfo)
  45755. }
  45756. if m.FieldCleared(wxcard.FieldIntro) {
  45757. fields = append(fields, wxcard.FieldIntro)
  45758. }
  45759. return fields
  45760. }
  45761. // FieldCleared returns a boolean indicating if a field with the given name was
  45762. // cleared in this mutation.
  45763. func (m *WxCardMutation) FieldCleared(name string) bool {
  45764. _, ok := m.clearedFields[name]
  45765. return ok
  45766. }
  45767. // ClearField clears the value of the field with the given name. It returns an
  45768. // error if the field is not defined in the schema.
  45769. func (m *WxCardMutation) ClearField(name string) error {
  45770. switch name {
  45771. case wxcard.FieldDeletedAt:
  45772. m.ClearDeletedAt()
  45773. return nil
  45774. case wxcard.FieldUserID:
  45775. m.ClearUserID()
  45776. return nil
  45777. case wxcard.FieldWxUserID:
  45778. m.ClearWxUserID()
  45779. return nil
  45780. case wxcard.FieldEmail:
  45781. m.ClearEmail()
  45782. return nil
  45783. case wxcard.FieldAPIBase:
  45784. m.ClearAPIBase()
  45785. return nil
  45786. case wxcard.FieldAPIKey:
  45787. m.ClearAPIKey()
  45788. return nil
  45789. case wxcard.FieldAiInfo:
  45790. m.ClearAiInfo()
  45791. return nil
  45792. case wxcard.FieldIntro:
  45793. m.ClearIntro()
  45794. return nil
  45795. }
  45796. return fmt.Errorf("unknown WxCard nullable field %s", name)
  45797. }
  45798. // ResetField resets all changes in the mutation for the field with the given name.
  45799. // It returns an error if the field is not defined in the schema.
  45800. func (m *WxCardMutation) ResetField(name string) error {
  45801. switch name {
  45802. case wxcard.FieldCreatedAt:
  45803. m.ResetCreatedAt()
  45804. return nil
  45805. case wxcard.FieldUpdatedAt:
  45806. m.ResetUpdatedAt()
  45807. return nil
  45808. case wxcard.FieldDeletedAt:
  45809. m.ResetDeletedAt()
  45810. return nil
  45811. case wxcard.FieldUserID:
  45812. m.ResetUserID()
  45813. return nil
  45814. case wxcard.FieldWxUserID:
  45815. m.ResetWxUserID()
  45816. return nil
  45817. case wxcard.FieldAvatar:
  45818. m.ResetAvatar()
  45819. return nil
  45820. case wxcard.FieldLogo:
  45821. m.ResetLogo()
  45822. return nil
  45823. case wxcard.FieldName:
  45824. m.ResetName()
  45825. return nil
  45826. case wxcard.FieldCompany:
  45827. m.ResetCompany()
  45828. return nil
  45829. case wxcard.FieldAddress:
  45830. m.ResetAddress()
  45831. return nil
  45832. case wxcard.FieldPhone:
  45833. m.ResetPhone()
  45834. return nil
  45835. case wxcard.FieldOfficialAccount:
  45836. m.ResetOfficialAccount()
  45837. return nil
  45838. case wxcard.FieldWechatAccount:
  45839. m.ResetWechatAccount()
  45840. return nil
  45841. case wxcard.FieldEmail:
  45842. m.ResetEmail()
  45843. return nil
  45844. case wxcard.FieldAPIBase:
  45845. m.ResetAPIBase()
  45846. return nil
  45847. case wxcard.FieldAPIKey:
  45848. m.ResetAPIKey()
  45849. return nil
  45850. case wxcard.FieldAiInfo:
  45851. m.ResetAiInfo()
  45852. return nil
  45853. case wxcard.FieldIntro:
  45854. m.ResetIntro()
  45855. return nil
  45856. }
  45857. return fmt.Errorf("unknown WxCard field %s", name)
  45858. }
  45859. // AddedEdges returns all edge names that were set/added in this mutation.
  45860. func (m *WxCardMutation) AddedEdges() []string {
  45861. edges := make([]string, 0, 0)
  45862. return edges
  45863. }
  45864. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45865. // name in this mutation.
  45866. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  45867. return nil
  45868. }
  45869. // RemovedEdges returns all edge names that were removed in this mutation.
  45870. func (m *WxCardMutation) RemovedEdges() []string {
  45871. edges := make([]string, 0, 0)
  45872. return edges
  45873. }
  45874. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45875. // the given name in this mutation.
  45876. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  45877. return nil
  45878. }
  45879. // ClearedEdges returns all edge names that were cleared in this mutation.
  45880. func (m *WxCardMutation) ClearedEdges() []string {
  45881. edges := make([]string, 0, 0)
  45882. return edges
  45883. }
  45884. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45885. // was cleared in this mutation.
  45886. func (m *WxCardMutation) EdgeCleared(name string) bool {
  45887. return false
  45888. }
  45889. // ClearEdge clears the value of the edge with the given name. It returns an error
  45890. // if that edge is not defined in the schema.
  45891. func (m *WxCardMutation) ClearEdge(name string) error {
  45892. return fmt.Errorf("unknown WxCard unique edge %s", name)
  45893. }
  45894. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45895. // It returns an error if the edge is not defined in the schema.
  45896. func (m *WxCardMutation) ResetEdge(name string) error {
  45897. return fmt.Errorf("unknown WxCard edge %s", name)
  45898. }
  45899. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  45900. type WxCardUserMutation struct {
  45901. config
  45902. op Op
  45903. typ string
  45904. id *uint64
  45905. created_at *time.Time
  45906. updated_at *time.Time
  45907. deleted_at *time.Time
  45908. wxid *string
  45909. account *string
  45910. avatar *string
  45911. nickname *string
  45912. remark *string
  45913. phone *string
  45914. open_id *string
  45915. union_id *string
  45916. session_key *string
  45917. is_vip *int
  45918. addis_vip *int
  45919. clearedFields map[string]struct{}
  45920. done bool
  45921. oldValue func(context.Context) (*WxCardUser, error)
  45922. predicates []predicate.WxCardUser
  45923. }
  45924. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  45925. // wxcarduserOption allows management of the mutation configuration using functional options.
  45926. type wxcarduserOption func(*WxCardUserMutation)
  45927. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  45928. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  45929. m := &WxCardUserMutation{
  45930. config: c,
  45931. op: op,
  45932. typ: TypeWxCardUser,
  45933. clearedFields: make(map[string]struct{}),
  45934. }
  45935. for _, opt := range opts {
  45936. opt(m)
  45937. }
  45938. return m
  45939. }
  45940. // withWxCardUserID sets the ID field of the mutation.
  45941. func withWxCardUserID(id uint64) wxcarduserOption {
  45942. return func(m *WxCardUserMutation) {
  45943. var (
  45944. err error
  45945. once sync.Once
  45946. value *WxCardUser
  45947. )
  45948. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  45949. once.Do(func() {
  45950. if m.done {
  45951. err = errors.New("querying old values post mutation is not allowed")
  45952. } else {
  45953. value, err = m.Client().WxCardUser.Get(ctx, id)
  45954. }
  45955. })
  45956. return value, err
  45957. }
  45958. m.id = &id
  45959. }
  45960. }
  45961. // withWxCardUser sets the old WxCardUser of the mutation.
  45962. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  45963. return func(m *WxCardUserMutation) {
  45964. m.oldValue = func(context.Context) (*WxCardUser, error) {
  45965. return node, nil
  45966. }
  45967. m.id = &node.ID
  45968. }
  45969. }
  45970. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45971. // executed in a transaction (ent.Tx), a transactional client is returned.
  45972. func (m WxCardUserMutation) Client() *Client {
  45973. client := &Client{config: m.config}
  45974. client.init()
  45975. return client
  45976. }
  45977. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45978. // it returns an error otherwise.
  45979. func (m WxCardUserMutation) Tx() (*Tx, error) {
  45980. if _, ok := m.driver.(*txDriver); !ok {
  45981. return nil, errors.New("ent: mutation is not running in a transaction")
  45982. }
  45983. tx := &Tx{config: m.config}
  45984. tx.init()
  45985. return tx, nil
  45986. }
  45987. // SetID sets the value of the id field. Note that this
  45988. // operation is only accepted on creation of WxCardUser entities.
  45989. func (m *WxCardUserMutation) SetID(id uint64) {
  45990. m.id = &id
  45991. }
  45992. // ID returns the ID value in the mutation. Note that the ID is only available
  45993. // if it was provided to the builder or after it was returned from the database.
  45994. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  45995. if m.id == nil {
  45996. return
  45997. }
  45998. return *m.id, true
  45999. }
  46000. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46001. // That means, if the mutation is applied within a transaction with an isolation level such
  46002. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46003. // or updated by the mutation.
  46004. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  46005. switch {
  46006. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46007. id, exists := m.ID()
  46008. if exists {
  46009. return []uint64{id}, nil
  46010. }
  46011. fallthrough
  46012. case m.op.Is(OpUpdate | OpDelete):
  46013. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  46014. default:
  46015. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46016. }
  46017. }
  46018. // SetCreatedAt sets the "created_at" field.
  46019. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  46020. m.created_at = &t
  46021. }
  46022. // CreatedAt returns the value of the "created_at" field in the mutation.
  46023. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  46024. v := m.created_at
  46025. if v == nil {
  46026. return
  46027. }
  46028. return *v, true
  46029. }
  46030. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  46031. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46033. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46034. if !m.op.Is(OpUpdateOne) {
  46035. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46036. }
  46037. if m.id == nil || m.oldValue == nil {
  46038. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46039. }
  46040. oldValue, err := m.oldValue(ctx)
  46041. if err != nil {
  46042. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46043. }
  46044. return oldValue.CreatedAt, nil
  46045. }
  46046. // ResetCreatedAt resets all changes to the "created_at" field.
  46047. func (m *WxCardUserMutation) ResetCreatedAt() {
  46048. m.created_at = nil
  46049. }
  46050. // SetUpdatedAt sets the "updated_at" field.
  46051. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  46052. m.updated_at = &t
  46053. }
  46054. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46055. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  46056. v := m.updated_at
  46057. if v == nil {
  46058. return
  46059. }
  46060. return *v, true
  46061. }
  46062. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46066. if !m.op.Is(OpUpdateOne) {
  46067. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46068. }
  46069. if m.id == nil || m.oldValue == nil {
  46070. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  46075. }
  46076. return oldValue.UpdatedAt, nil
  46077. }
  46078. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46079. func (m *WxCardUserMutation) ResetUpdatedAt() {
  46080. m.updated_at = nil
  46081. }
  46082. // SetDeletedAt sets the "deleted_at" field.
  46083. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  46084. m.deleted_at = &t
  46085. }
  46086. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46087. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  46088. v := m.deleted_at
  46089. if v == nil {
  46090. return
  46091. }
  46092. return *v, true
  46093. }
  46094. // OldDeletedAt returns the old "deleted_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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46098. if !m.op.Is(OpUpdateOne) {
  46099. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46100. }
  46101. if m.id == nil || m.oldValue == nil {
  46102. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  46107. }
  46108. return oldValue.DeletedAt, nil
  46109. }
  46110. // ClearDeletedAt clears the value of the "deleted_at" field.
  46111. func (m *WxCardUserMutation) ClearDeletedAt() {
  46112. m.deleted_at = nil
  46113. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  46114. }
  46115. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46116. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  46117. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  46118. return ok
  46119. }
  46120. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46121. func (m *WxCardUserMutation) ResetDeletedAt() {
  46122. m.deleted_at = nil
  46123. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  46124. }
  46125. // SetWxid sets the "wxid" field.
  46126. func (m *WxCardUserMutation) SetWxid(s string) {
  46127. m.wxid = &s
  46128. }
  46129. // Wxid returns the value of the "wxid" field in the mutation.
  46130. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  46131. v := m.wxid
  46132. if v == nil {
  46133. return
  46134. }
  46135. return *v, true
  46136. }
  46137. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  46138. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46140. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  46141. if !m.op.Is(OpUpdateOne) {
  46142. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46143. }
  46144. if m.id == nil || m.oldValue == nil {
  46145. return v, errors.New("OldWxid requires an ID field in the mutation")
  46146. }
  46147. oldValue, err := m.oldValue(ctx)
  46148. if err != nil {
  46149. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46150. }
  46151. return oldValue.Wxid, nil
  46152. }
  46153. // ResetWxid resets all changes to the "wxid" field.
  46154. func (m *WxCardUserMutation) ResetWxid() {
  46155. m.wxid = nil
  46156. }
  46157. // SetAccount sets the "account" field.
  46158. func (m *WxCardUserMutation) SetAccount(s string) {
  46159. m.account = &s
  46160. }
  46161. // Account returns the value of the "account" field in the mutation.
  46162. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  46163. v := m.account
  46164. if v == nil {
  46165. return
  46166. }
  46167. return *v, true
  46168. }
  46169. // OldAccount returns the old "account" 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) OldAccount(ctx context.Context) (v string, err error) {
  46173. if !m.op.Is(OpUpdateOne) {
  46174. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  46175. }
  46176. if m.id == nil || m.oldValue == nil {
  46177. return v, errors.New("OldAccount 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 OldAccount: %w", err)
  46182. }
  46183. return oldValue.Account, nil
  46184. }
  46185. // ResetAccount resets all changes to the "account" field.
  46186. func (m *WxCardUserMutation) ResetAccount() {
  46187. m.account = nil
  46188. }
  46189. // SetAvatar sets the "avatar" field.
  46190. func (m *WxCardUserMutation) SetAvatar(s string) {
  46191. m.avatar = &s
  46192. }
  46193. // Avatar returns the value of the "avatar" field in the mutation.
  46194. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  46195. v := m.avatar
  46196. if v == nil {
  46197. return
  46198. }
  46199. return *v, true
  46200. }
  46201. // OldAvatar returns the old "avatar" 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) OldAvatar(ctx context.Context) (v string, err error) {
  46205. if !m.op.Is(OpUpdateOne) {
  46206. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46207. }
  46208. if m.id == nil || m.oldValue == nil {
  46209. return v, errors.New("OldAvatar 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 OldAvatar: %w", err)
  46214. }
  46215. return oldValue.Avatar, nil
  46216. }
  46217. // ResetAvatar resets all changes to the "avatar" field.
  46218. func (m *WxCardUserMutation) ResetAvatar() {
  46219. m.avatar = nil
  46220. }
  46221. // SetNickname sets the "nickname" field.
  46222. func (m *WxCardUserMutation) SetNickname(s string) {
  46223. m.nickname = &s
  46224. }
  46225. // Nickname returns the value of the "nickname" field in the mutation.
  46226. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  46227. v := m.nickname
  46228. if v == nil {
  46229. return
  46230. }
  46231. return *v, true
  46232. }
  46233. // OldNickname returns the old "nickname" 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) OldNickname(ctx context.Context) (v string, err error) {
  46237. if !m.op.Is(OpUpdateOne) {
  46238. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46239. }
  46240. if m.id == nil || m.oldValue == nil {
  46241. return v, errors.New("OldNickname 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 OldNickname: %w", err)
  46246. }
  46247. return oldValue.Nickname, nil
  46248. }
  46249. // ResetNickname resets all changes to the "nickname" field.
  46250. func (m *WxCardUserMutation) ResetNickname() {
  46251. m.nickname = nil
  46252. }
  46253. // SetRemark sets the "remark" field.
  46254. func (m *WxCardUserMutation) SetRemark(s string) {
  46255. m.remark = &s
  46256. }
  46257. // Remark returns the value of the "remark" field in the mutation.
  46258. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  46259. v := m.remark
  46260. if v == nil {
  46261. return
  46262. }
  46263. return *v, true
  46264. }
  46265. // OldRemark returns the old "remark" 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) OldRemark(ctx context.Context) (v string, err error) {
  46269. if !m.op.Is(OpUpdateOne) {
  46270. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  46271. }
  46272. if m.id == nil || m.oldValue == nil {
  46273. return v, errors.New("OldRemark 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 OldRemark: %w", err)
  46278. }
  46279. return oldValue.Remark, nil
  46280. }
  46281. // ResetRemark resets all changes to the "remark" field.
  46282. func (m *WxCardUserMutation) ResetRemark() {
  46283. m.remark = nil
  46284. }
  46285. // SetPhone sets the "phone" field.
  46286. func (m *WxCardUserMutation) SetPhone(s string) {
  46287. m.phone = &s
  46288. }
  46289. // Phone returns the value of the "phone" field in the mutation.
  46290. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  46291. v := m.phone
  46292. if v == nil {
  46293. return
  46294. }
  46295. return *v, true
  46296. }
  46297. // OldPhone returns the old "phone" 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) OldPhone(ctx context.Context) (v string, err error) {
  46301. if !m.op.Is(OpUpdateOne) {
  46302. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  46303. }
  46304. if m.id == nil || m.oldValue == nil {
  46305. return v, errors.New("OldPhone 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 OldPhone: %w", err)
  46310. }
  46311. return oldValue.Phone, nil
  46312. }
  46313. // ResetPhone resets all changes to the "phone" field.
  46314. func (m *WxCardUserMutation) ResetPhone() {
  46315. m.phone = nil
  46316. }
  46317. // SetOpenID sets the "open_id" field.
  46318. func (m *WxCardUserMutation) SetOpenID(s string) {
  46319. m.open_id = &s
  46320. }
  46321. // OpenID returns the value of the "open_id" field in the mutation.
  46322. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  46323. v := m.open_id
  46324. if v == nil {
  46325. return
  46326. }
  46327. return *v, true
  46328. }
  46329. // OldOpenID returns the old "open_id" 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) OldOpenID(ctx context.Context) (v string, err error) {
  46333. if !m.op.Is(OpUpdateOne) {
  46334. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  46335. }
  46336. if m.id == nil || m.oldValue == nil {
  46337. return v, errors.New("OldOpenID 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 OldOpenID: %w", err)
  46342. }
  46343. return oldValue.OpenID, nil
  46344. }
  46345. // ResetOpenID resets all changes to the "open_id" field.
  46346. func (m *WxCardUserMutation) ResetOpenID() {
  46347. m.open_id = nil
  46348. }
  46349. // SetUnionID sets the "union_id" field.
  46350. func (m *WxCardUserMutation) SetUnionID(s string) {
  46351. m.union_id = &s
  46352. }
  46353. // UnionID returns the value of the "union_id" field in the mutation.
  46354. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  46355. v := m.union_id
  46356. if v == nil {
  46357. return
  46358. }
  46359. return *v, true
  46360. }
  46361. // OldUnionID returns the old "union_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) OldUnionID(ctx context.Context) (v string, err error) {
  46365. if !m.op.Is(OpUpdateOne) {
  46366. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  46367. }
  46368. if m.id == nil || m.oldValue == nil {
  46369. return v, errors.New("OldUnionID 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 OldUnionID: %w", err)
  46374. }
  46375. return oldValue.UnionID, nil
  46376. }
  46377. // ResetUnionID resets all changes to the "union_id" field.
  46378. func (m *WxCardUserMutation) ResetUnionID() {
  46379. m.union_id = nil
  46380. }
  46381. // SetSessionKey sets the "session_key" field.
  46382. func (m *WxCardUserMutation) SetSessionKey(s string) {
  46383. m.session_key = &s
  46384. }
  46385. // SessionKey returns the value of the "session_key" field in the mutation.
  46386. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  46387. v := m.session_key
  46388. if v == nil {
  46389. return
  46390. }
  46391. return *v, true
  46392. }
  46393. // OldSessionKey returns the old "session_key" 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) OldSessionKey(ctx context.Context) (v string, err error) {
  46397. if !m.op.Is(OpUpdateOne) {
  46398. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  46399. }
  46400. if m.id == nil || m.oldValue == nil {
  46401. return v, errors.New("OldSessionKey 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 OldSessionKey: %w", err)
  46406. }
  46407. return oldValue.SessionKey, nil
  46408. }
  46409. // ResetSessionKey resets all changes to the "session_key" field.
  46410. func (m *WxCardUserMutation) ResetSessionKey() {
  46411. m.session_key = nil
  46412. }
  46413. // SetIsVip sets the "is_vip" field.
  46414. func (m *WxCardUserMutation) SetIsVip(i int) {
  46415. m.is_vip = &i
  46416. m.addis_vip = nil
  46417. }
  46418. // IsVip returns the value of the "is_vip" field in the mutation.
  46419. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  46420. v := m.is_vip
  46421. if v == nil {
  46422. return
  46423. }
  46424. return *v, true
  46425. }
  46426. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  46427. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46429. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  46430. if !m.op.Is(OpUpdateOne) {
  46431. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  46432. }
  46433. if m.id == nil || m.oldValue == nil {
  46434. return v, errors.New("OldIsVip requires an ID field in the mutation")
  46435. }
  46436. oldValue, err := m.oldValue(ctx)
  46437. if err != nil {
  46438. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  46439. }
  46440. return oldValue.IsVip, nil
  46441. }
  46442. // AddIsVip adds i to the "is_vip" field.
  46443. func (m *WxCardUserMutation) AddIsVip(i int) {
  46444. if m.addis_vip != nil {
  46445. *m.addis_vip += i
  46446. } else {
  46447. m.addis_vip = &i
  46448. }
  46449. }
  46450. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  46451. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  46452. v := m.addis_vip
  46453. if v == nil {
  46454. return
  46455. }
  46456. return *v, true
  46457. }
  46458. // ResetIsVip resets all changes to the "is_vip" field.
  46459. func (m *WxCardUserMutation) ResetIsVip() {
  46460. m.is_vip = nil
  46461. m.addis_vip = nil
  46462. }
  46463. // Where appends a list predicates to the WxCardUserMutation builder.
  46464. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  46465. m.predicates = append(m.predicates, ps...)
  46466. }
  46467. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  46468. // users can use type-assertion to append predicates that do not depend on any generated package.
  46469. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  46470. p := make([]predicate.WxCardUser, len(ps))
  46471. for i := range ps {
  46472. p[i] = ps[i]
  46473. }
  46474. m.Where(p...)
  46475. }
  46476. // Op returns the operation name.
  46477. func (m *WxCardUserMutation) Op() Op {
  46478. return m.op
  46479. }
  46480. // SetOp allows setting the mutation operation.
  46481. func (m *WxCardUserMutation) SetOp(op Op) {
  46482. m.op = op
  46483. }
  46484. // Type returns the node type of this mutation (WxCardUser).
  46485. func (m *WxCardUserMutation) Type() string {
  46486. return m.typ
  46487. }
  46488. // Fields returns all fields that were changed during this mutation. Note that in
  46489. // order to get all numeric fields that were incremented/decremented, call
  46490. // AddedFields().
  46491. func (m *WxCardUserMutation) Fields() []string {
  46492. fields := make([]string, 0, 13)
  46493. if m.created_at != nil {
  46494. fields = append(fields, wxcarduser.FieldCreatedAt)
  46495. }
  46496. if m.updated_at != nil {
  46497. fields = append(fields, wxcarduser.FieldUpdatedAt)
  46498. }
  46499. if m.deleted_at != nil {
  46500. fields = append(fields, wxcarduser.FieldDeletedAt)
  46501. }
  46502. if m.wxid != nil {
  46503. fields = append(fields, wxcarduser.FieldWxid)
  46504. }
  46505. if m.account != nil {
  46506. fields = append(fields, wxcarduser.FieldAccount)
  46507. }
  46508. if m.avatar != nil {
  46509. fields = append(fields, wxcarduser.FieldAvatar)
  46510. }
  46511. if m.nickname != nil {
  46512. fields = append(fields, wxcarduser.FieldNickname)
  46513. }
  46514. if m.remark != nil {
  46515. fields = append(fields, wxcarduser.FieldRemark)
  46516. }
  46517. if m.phone != nil {
  46518. fields = append(fields, wxcarduser.FieldPhone)
  46519. }
  46520. if m.open_id != nil {
  46521. fields = append(fields, wxcarduser.FieldOpenID)
  46522. }
  46523. if m.union_id != nil {
  46524. fields = append(fields, wxcarduser.FieldUnionID)
  46525. }
  46526. if m.session_key != nil {
  46527. fields = append(fields, wxcarduser.FieldSessionKey)
  46528. }
  46529. if m.is_vip != nil {
  46530. fields = append(fields, wxcarduser.FieldIsVip)
  46531. }
  46532. return fields
  46533. }
  46534. // Field returns the value of a field with the given name. The second boolean
  46535. // return value indicates that this field was not set, or was not defined in the
  46536. // schema.
  46537. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  46538. switch name {
  46539. case wxcarduser.FieldCreatedAt:
  46540. return m.CreatedAt()
  46541. case wxcarduser.FieldUpdatedAt:
  46542. return m.UpdatedAt()
  46543. case wxcarduser.FieldDeletedAt:
  46544. return m.DeletedAt()
  46545. case wxcarduser.FieldWxid:
  46546. return m.Wxid()
  46547. case wxcarduser.FieldAccount:
  46548. return m.Account()
  46549. case wxcarduser.FieldAvatar:
  46550. return m.Avatar()
  46551. case wxcarduser.FieldNickname:
  46552. return m.Nickname()
  46553. case wxcarduser.FieldRemark:
  46554. return m.Remark()
  46555. case wxcarduser.FieldPhone:
  46556. return m.Phone()
  46557. case wxcarduser.FieldOpenID:
  46558. return m.OpenID()
  46559. case wxcarduser.FieldUnionID:
  46560. return m.UnionID()
  46561. case wxcarduser.FieldSessionKey:
  46562. return m.SessionKey()
  46563. case wxcarduser.FieldIsVip:
  46564. return m.IsVip()
  46565. }
  46566. return nil, false
  46567. }
  46568. // OldField returns the old value of the field from the database. An error is
  46569. // returned if the mutation operation is not UpdateOne, or the query to the
  46570. // database failed.
  46571. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46572. switch name {
  46573. case wxcarduser.FieldCreatedAt:
  46574. return m.OldCreatedAt(ctx)
  46575. case wxcarduser.FieldUpdatedAt:
  46576. return m.OldUpdatedAt(ctx)
  46577. case wxcarduser.FieldDeletedAt:
  46578. return m.OldDeletedAt(ctx)
  46579. case wxcarduser.FieldWxid:
  46580. return m.OldWxid(ctx)
  46581. case wxcarduser.FieldAccount:
  46582. return m.OldAccount(ctx)
  46583. case wxcarduser.FieldAvatar:
  46584. return m.OldAvatar(ctx)
  46585. case wxcarduser.FieldNickname:
  46586. return m.OldNickname(ctx)
  46587. case wxcarduser.FieldRemark:
  46588. return m.OldRemark(ctx)
  46589. case wxcarduser.FieldPhone:
  46590. return m.OldPhone(ctx)
  46591. case wxcarduser.FieldOpenID:
  46592. return m.OldOpenID(ctx)
  46593. case wxcarduser.FieldUnionID:
  46594. return m.OldUnionID(ctx)
  46595. case wxcarduser.FieldSessionKey:
  46596. return m.OldSessionKey(ctx)
  46597. case wxcarduser.FieldIsVip:
  46598. return m.OldIsVip(ctx)
  46599. }
  46600. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  46601. }
  46602. // SetField sets the value of a field with the given name. It returns an error if
  46603. // the field is not defined in the schema, or if the type mismatched the field
  46604. // type.
  46605. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  46606. switch name {
  46607. case wxcarduser.FieldCreatedAt:
  46608. v, ok := value.(time.Time)
  46609. if !ok {
  46610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46611. }
  46612. m.SetCreatedAt(v)
  46613. return nil
  46614. case wxcarduser.FieldUpdatedAt:
  46615. v, ok := value.(time.Time)
  46616. if !ok {
  46617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46618. }
  46619. m.SetUpdatedAt(v)
  46620. return nil
  46621. case wxcarduser.FieldDeletedAt:
  46622. v, ok := value.(time.Time)
  46623. if !ok {
  46624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46625. }
  46626. m.SetDeletedAt(v)
  46627. return nil
  46628. case wxcarduser.FieldWxid:
  46629. v, ok := value.(string)
  46630. if !ok {
  46631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46632. }
  46633. m.SetWxid(v)
  46634. return nil
  46635. case wxcarduser.FieldAccount:
  46636. v, ok := value.(string)
  46637. if !ok {
  46638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46639. }
  46640. m.SetAccount(v)
  46641. return nil
  46642. case wxcarduser.FieldAvatar:
  46643. v, ok := value.(string)
  46644. if !ok {
  46645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46646. }
  46647. m.SetAvatar(v)
  46648. return nil
  46649. case wxcarduser.FieldNickname:
  46650. v, ok := value.(string)
  46651. if !ok {
  46652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46653. }
  46654. m.SetNickname(v)
  46655. return nil
  46656. case wxcarduser.FieldRemark:
  46657. v, ok := value.(string)
  46658. if !ok {
  46659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46660. }
  46661. m.SetRemark(v)
  46662. return nil
  46663. case wxcarduser.FieldPhone:
  46664. v, ok := value.(string)
  46665. if !ok {
  46666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46667. }
  46668. m.SetPhone(v)
  46669. return nil
  46670. case wxcarduser.FieldOpenID:
  46671. v, ok := value.(string)
  46672. if !ok {
  46673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46674. }
  46675. m.SetOpenID(v)
  46676. return nil
  46677. case wxcarduser.FieldUnionID:
  46678. v, ok := value.(string)
  46679. if !ok {
  46680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46681. }
  46682. m.SetUnionID(v)
  46683. return nil
  46684. case wxcarduser.FieldSessionKey:
  46685. v, ok := value.(string)
  46686. if !ok {
  46687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46688. }
  46689. m.SetSessionKey(v)
  46690. return nil
  46691. case wxcarduser.FieldIsVip:
  46692. v, ok := value.(int)
  46693. if !ok {
  46694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46695. }
  46696. m.SetIsVip(v)
  46697. return nil
  46698. }
  46699. return fmt.Errorf("unknown WxCardUser field %s", name)
  46700. }
  46701. // AddedFields returns all numeric fields that were incremented/decremented during
  46702. // this mutation.
  46703. func (m *WxCardUserMutation) AddedFields() []string {
  46704. var fields []string
  46705. if m.addis_vip != nil {
  46706. fields = append(fields, wxcarduser.FieldIsVip)
  46707. }
  46708. return fields
  46709. }
  46710. // AddedField returns the numeric value that was incremented/decremented on a field
  46711. // with the given name. The second boolean return value indicates that this field
  46712. // was not set, or was not defined in the schema.
  46713. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  46714. switch name {
  46715. case wxcarduser.FieldIsVip:
  46716. return m.AddedIsVip()
  46717. }
  46718. return nil, false
  46719. }
  46720. // AddField adds the value to the field with the given name. It returns an error if
  46721. // the field is not defined in the schema, or if the type mismatched the field
  46722. // type.
  46723. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  46724. switch name {
  46725. case wxcarduser.FieldIsVip:
  46726. v, ok := value.(int)
  46727. if !ok {
  46728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46729. }
  46730. m.AddIsVip(v)
  46731. return nil
  46732. }
  46733. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  46734. }
  46735. // ClearedFields returns all nullable fields that were cleared during this
  46736. // mutation.
  46737. func (m *WxCardUserMutation) ClearedFields() []string {
  46738. var fields []string
  46739. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  46740. fields = append(fields, wxcarduser.FieldDeletedAt)
  46741. }
  46742. return fields
  46743. }
  46744. // FieldCleared returns a boolean indicating if a field with the given name was
  46745. // cleared in this mutation.
  46746. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  46747. _, ok := m.clearedFields[name]
  46748. return ok
  46749. }
  46750. // ClearField clears the value of the field with the given name. It returns an
  46751. // error if the field is not defined in the schema.
  46752. func (m *WxCardUserMutation) ClearField(name string) error {
  46753. switch name {
  46754. case wxcarduser.FieldDeletedAt:
  46755. m.ClearDeletedAt()
  46756. return nil
  46757. }
  46758. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  46759. }
  46760. // ResetField resets all changes in the mutation for the field with the given name.
  46761. // It returns an error if the field is not defined in the schema.
  46762. func (m *WxCardUserMutation) ResetField(name string) error {
  46763. switch name {
  46764. case wxcarduser.FieldCreatedAt:
  46765. m.ResetCreatedAt()
  46766. return nil
  46767. case wxcarduser.FieldUpdatedAt:
  46768. m.ResetUpdatedAt()
  46769. return nil
  46770. case wxcarduser.FieldDeletedAt:
  46771. m.ResetDeletedAt()
  46772. return nil
  46773. case wxcarduser.FieldWxid:
  46774. m.ResetWxid()
  46775. return nil
  46776. case wxcarduser.FieldAccount:
  46777. m.ResetAccount()
  46778. return nil
  46779. case wxcarduser.FieldAvatar:
  46780. m.ResetAvatar()
  46781. return nil
  46782. case wxcarduser.FieldNickname:
  46783. m.ResetNickname()
  46784. return nil
  46785. case wxcarduser.FieldRemark:
  46786. m.ResetRemark()
  46787. return nil
  46788. case wxcarduser.FieldPhone:
  46789. m.ResetPhone()
  46790. return nil
  46791. case wxcarduser.FieldOpenID:
  46792. m.ResetOpenID()
  46793. return nil
  46794. case wxcarduser.FieldUnionID:
  46795. m.ResetUnionID()
  46796. return nil
  46797. case wxcarduser.FieldSessionKey:
  46798. m.ResetSessionKey()
  46799. return nil
  46800. case wxcarduser.FieldIsVip:
  46801. m.ResetIsVip()
  46802. return nil
  46803. }
  46804. return fmt.Errorf("unknown WxCardUser field %s", name)
  46805. }
  46806. // AddedEdges returns all edge names that were set/added in this mutation.
  46807. func (m *WxCardUserMutation) AddedEdges() []string {
  46808. edges := make([]string, 0, 0)
  46809. return edges
  46810. }
  46811. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46812. // name in this mutation.
  46813. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  46814. return nil
  46815. }
  46816. // RemovedEdges returns all edge names that were removed in this mutation.
  46817. func (m *WxCardUserMutation) RemovedEdges() []string {
  46818. edges := make([]string, 0, 0)
  46819. return edges
  46820. }
  46821. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46822. // the given name in this mutation.
  46823. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  46824. return nil
  46825. }
  46826. // ClearedEdges returns all edge names that were cleared in this mutation.
  46827. func (m *WxCardUserMutation) ClearedEdges() []string {
  46828. edges := make([]string, 0, 0)
  46829. return edges
  46830. }
  46831. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46832. // was cleared in this mutation.
  46833. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  46834. return false
  46835. }
  46836. // ClearEdge clears the value of the edge with the given name. It returns an error
  46837. // if that edge is not defined in the schema.
  46838. func (m *WxCardUserMutation) ClearEdge(name string) error {
  46839. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  46840. }
  46841. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46842. // It returns an error if the edge is not defined in the schema.
  46843. func (m *WxCardUserMutation) ResetEdge(name string) error {
  46844. return fmt.Errorf("unknown WxCardUser edge %s", name)
  46845. }
  46846. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  46847. type WxCardVisitMutation struct {
  46848. config
  46849. op Op
  46850. typ string
  46851. id *uint64
  46852. created_at *time.Time
  46853. updated_at *time.Time
  46854. deleted_at *time.Time
  46855. user_id *uint64
  46856. adduser_id *int64
  46857. bot_id *uint64
  46858. addbot_id *int64
  46859. bot_type *uint8
  46860. addbot_type *int8
  46861. clearedFields map[string]struct{}
  46862. done bool
  46863. oldValue func(context.Context) (*WxCardVisit, error)
  46864. predicates []predicate.WxCardVisit
  46865. }
  46866. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  46867. // wxcardvisitOption allows management of the mutation configuration using functional options.
  46868. type wxcardvisitOption func(*WxCardVisitMutation)
  46869. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  46870. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  46871. m := &WxCardVisitMutation{
  46872. config: c,
  46873. op: op,
  46874. typ: TypeWxCardVisit,
  46875. clearedFields: make(map[string]struct{}),
  46876. }
  46877. for _, opt := range opts {
  46878. opt(m)
  46879. }
  46880. return m
  46881. }
  46882. // withWxCardVisitID sets the ID field of the mutation.
  46883. func withWxCardVisitID(id uint64) wxcardvisitOption {
  46884. return func(m *WxCardVisitMutation) {
  46885. var (
  46886. err error
  46887. once sync.Once
  46888. value *WxCardVisit
  46889. )
  46890. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  46891. once.Do(func() {
  46892. if m.done {
  46893. err = errors.New("querying old values post mutation is not allowed")
  46894. } else {
  46895. value, err = m.Client().WxCardVisit.Get(ctx, id)
  46896. }
  46897. })
  46898. return value, err
  46899. }
  46900. m.id = &id
  46901. }
  46902. }
  46903. // withWxCardVisit sets the old WxCardVisit of the mutation.
  46904. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  46905. return func(m *WxCardVisitMutation) {
  46906. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  46907. return node, nil
  46908. }
  46909. m.id = &node.ID
  46910. }
  46911. }
  46912. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46913. // executed in a transaction (ent.Tx), a transactional client is returned.
  46914. func (m WxCardVisitMutation) Client() *Client {
  46915. client := &Client{config: m.config}
  46916. client.init()
  46917. return client
  46918. }
  46919. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46920. // it returns an error otherwise.
  46921. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  46922. if _, ok := m.driver.(*txDriver); !ok {
  46923. return nil, errors.New("ent: mutation is not running in a transaction")
  46924. }
  46925. tx := &Tx{config: m.config}
  46926. tx.init()
  46927. return tx, nil
  46928. }
  46929. // SetID sets the value of the id field. Note that this
  46930. // operation is only accepted on creation of WxCardVisit entities.
  46931. func (m *WxCardVisitMutation) SetID(id uint64) {
  46932. m.id = &id
  46933. }
  46934. // ID returns the ID value in the mutation. Note that the ID is only available
  46935. // if it was provided to the builder or after it was returned from the database.
  46936. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  46937. if m.id == nil {
  46938. return
  46939. }
  46940. return *m.id, true
  46941. }
  46942. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46943. // That means, if the mutation is applied within a transaction with an isolation level such
  46944. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46945. // or updated by the mutation.
  46946. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  46947. switch {
  46948. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46949. id, exists := m.ID()
  46950. if exists {
  46951. return []uint64{id}, nil
  46952. }
  46953. fallthrough
  46954. case m.op.Is(OpUpdate | OpDelete):
  46955. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  46956. default:
  46957. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46958. }
  46959. }
  46960. // SetCreatedAt sets the "created_at" field.
  46961. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  46962. m.created_at = &t
  46963. }
  46964. // CreatedAt returns the value of the "created_at" field in the mutation.
  46965. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  46966. v := m.created_at
  46967. if v == nil {
  46968. return
  46969. }
  46970. return *v, true
  46971. }
  46972. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  46973. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46975. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46976. if !m.op.Is(OpUpdateOne) {
  46977. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46978. }
  46979. if m.id == nil || m.oldValue == nil {
  46980. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46981. }
  46982. oldValue, err := m.oldValue(ctx)
  46983. if err != nil {
  46984. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46985. }
  46986. return oldValue.CreatedAt, nil
  46987. }
  46988. // ResetCreatedAt resets all changes to the "created_at" field.
  46989. func (m *WxCardVisitMutation) ResetCreatedAt() {
  46990. m.created_at = nil
  46991. }
  46992. // SetUpdatedAt sets the "updated_at" field.
  46993. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  46994. m.updated_at = &t
  46995. }
  46996. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46997. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  46998. v := m.updated_at
  46999. if v == nil {
  47000. return
  47001. }
  47002. return *v, true
  47003. }
  47004. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47008. if !m.op.Is(OpUpdateOne) {
  47009. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47010. }
  47011. if m.id == nil || m.oldValue == nil {
  47012. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  47017. }
  47018. return oldValue.UpdatedAt, nil
  47019. }
  47020. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47021. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  47022. m.updated_at = nil
  47023. }
  47024. // SetDeletedAt sets the "deleted_at" field.
  47025. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  47026. m.deleted_at = &t
  47027. }
  47028. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47029. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  47030. v := m.deleted_at
  47031. if v == nil {
  47032. return
  47033. }
  47034. return *v, true
  47035. }
  47036. // OldDeletedAt returns the old "deleted_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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47040. if !m.op.Is(OpUpdateOne) {
  47041. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47042. }
  47043. if m.id == nil || m.oldValue == nil {
  47044. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  47049. }
  47050. return oldValue.DeletedAt, nil
  47051. }
  47052. // ClearDeletedAt clears the value of the "deleted_at" field.
  47053. func (m *WxCardVisitMutation) ClearDeletedAt() {
  47054. m.deleted_at = nil
  47055. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  47056. }
  47057. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47058. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  47059. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  47060. return ok
  47061. }
  47062. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47063. func (m *WxCardVisitMutation) ResetDeletedAt() {
  47064. m.deleted_at = nil
  47065. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  47066. }
  47067. // SetUserID sets the "user_id" field.
  47068. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  47069. m.user_id = &u
  47070. m.adduser_id = nil
  47071. }
  47072. // UserID returns the value of the "user_id" field in the mutation.
  47073. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  47074. v := m.user_id
  47075. if v == nil {
  47076. return
  47077. }
  47078. return *v, true
  47079. }
  47080. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  47081. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47083. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  47084. if !m.op.Is(OpUpdateOne) {
  47085. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  47086. }
  47087. if m.id == nil || m.oldValue == nil {
  47088. return v, errors.New("OldUserID requires an ID field in the mutation")
  47089. }
  47090. oldValue, err := m.oldValue(ctx)
  47091. if err != nil {
  47092. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  47093. }
  47094. return oldValue.UserID, nil
  47095. }
  47096. // AddUserID adds u to the "user_id" field.
  47097. func (m *WxCardVisitMutation) AddUserID(u int64) {
  47098. if m.adduser_id != nil {
  47099. *m.adduser_id += u
  47100. } else {
  47101. m.adduser_id = &u
  47102. }
  47103. }
  47104. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  47105. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  47106. v := m.adduser_id
  47107. if v == nil {
  47108. return
  47109. }
  47110. return *v, true
  47111. }
  47112. // ClearUserID clears the value of the "user_id" field.
  47113. func (m *WxCardVisitMutation) ClearUserID() {
  47114. m.user_id = nil
  47115. m.adduser_id = nil
  47116. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  47117. }
  47118. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  47119. func (m *WxCardVisitMutation) UserIDCleared() bool {
  47120. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  47121. return ok
  47122. }
  47123. // ResetUserID resets all changes to the "user_id" field.
  47124. func (m *WxCardVisitMutation) ResetUserID() {
  47125. m.user_id = nil
  47126. m.adduser_id = nil
  47127. delete(m.clearedFields, wxcardvisit.FieldUserID)
  47128. }
  47129. // SetBotID sets the "bot_id" field.
  47130. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  47131. m.bot_id = &u
  47132. m.addbot_id = nil
  47133. }
  47134. // BotID returns the value of the "bot_id" field in the mutation.
  47135. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  47136. v := m.bot_id
  47137. if v == nil {
  47138. return
  47139. }
  47140. return *v, true
  47141. }
  47142. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  47143. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47145. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  47146. if !m.op.Is(OpUpdateOne) {
  47147. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  47148. }
  47149. if m.id == nil || m.oldValue == nil {
  47150. return v, errors.New("OldBotID requires an ID field in the mutation")
  47151. }
  47152. oldValue, err := m.oldValue(ctx)
  47153. if err != nil {
  47154. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  47155. }
  47156. return oldValue.BotID, nil
  47157. }
  47158. // AddBotID adds u to the "bot_id" field.
  47159. func (m *WxCardVisitMutation) AddBotID(u int64) {
  47160. if m.addbot_id != nil {
  47161. *m.addbot_id += u
  47162. } else {
  47163. m.addbot_id = &u
  47164. }
  47165. }
  47166. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  47167. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  47168. v := m.addbot_id
  47169. if v == nil {
  47170. return
  47171. }
  47172. return *v, true
  47173. }
  47174. // ResetBotID resets all changes to the "bot_id" field.
  47175. func (m *WxCardVisitMutation) ResetBotID() {
  47176. m.bot_id = nil
  47177. m.addbot_id = nil
  47178. }
  47179. // SetBotType sets the "bot_type" field.
  47180. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  47181. m.bot_type = &u
  47182. m.addbot_type = nil
  47183. }
  47184. // BotType returns the value of the "bot_type" field in the mutation.
  47185. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  47186. v := m.bot_type
  47187. if v == nil {
  47188. return
  47189. }
  47190. return *v, true
  47191. }
  47192. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  47193. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47195. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  47196. if !m.op.Is(OpUpdateOne) {
  47197. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  47198. }
  47199. if m.id == nil || m.oldValue == nil {
  47200. return v, errors.New("OldBotType requires an ID field in the mutation")
  47201. }
  47202. oldValue, err := m.oldValue(ctx)
  47203. if err != nil {
  47204. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  47205. }
  47206. return oldValue.BotType, nil
  47207. }
  47208. // AddBotType adds u to the "bot_type" field.
  47209. func (m *WxCardVisitMutation) AddBotType(u int8) {
  47210. if m.addbot_type != nil {
  47211. *m.addbot_type += u
  47212. } else {
  47213. m.addbot_type = &u
  47214. }
  47215. }
  47216. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  47217. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  47218. v := m.addbot_type
  47219. if v == nil {
  47220. return
  47221. }
  47222. return *v, true
  47223. }
  47224. // ResetBotType resets all changes to the "bot_type" field.
  47225. func (m *WxCardVisitMutation) ResetBotType() {
  47226. m.bot_type = nil
  47227. m.addbot_type = nil
  47228. }
  47229. // Where appends a list predicates to the WxCardVisitMutation builder.
  47230. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  47231. m.predicates = append(m.predicates, ps...)
  47232. }
  47233. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  47234. // users can use type-assertion to append predicates that do not depend on any generated package.
  47235. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  47236. p := make([]predicate.WxCardVisit, len(ps))
  47237. for i := range ps {
  47238. p[i] = ps[i]
  47239. }
  47240. m.Where(p...)
  47241. }
  47242. // Op returns the operation name.
  47243. func (m *WxCardVisitMutation) Op() Op {
  47244. return m.op
  47245. }
  47246. // SetOp allows setting the mutation operation.
  47247. func (m *WxCardVisitMutation) SetOp(op Op) {
  47248. m.op = op
  47249. }
  47250. // Type returns the node type of this mutation (WxCardVisit).
  47251. func (m *WxCardVisitMutation) Type() string {
  47252. return m.typ
  47253. }
  47254. // Fields returns all fields that were changed during this mutation. Note that in
  47255. // order to get all numeric fields that were incremented/decremented, call
  47256. // AddedFields().
  47257. func (m *WxCardVisitMutation) Fields() []string {
  47258. fields := make([]string, 0, 6)
  47259. if m.created_at != nil {
  47260. fields = append(fields, wxcardvisit.FieldCreatedAt)
  47261. }
  47262. if m.updated_at != nil {
  47263. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  47264. }
  47265. if m.deleted_at != nil {
  47266. fields = append(fields, wxcardvisit.FieldDeletedAt)
  47267. }
  47268. if m.user_id != nil {
  47269. fields = append(fields, wxcardvisit.FieldUserID)
  47270. }
  47271. if m.bot_id != nil {
  47272. fields = append(fields, wxcardvisit.FieldBotID)
  47273. }
  47274. if m.bot_type != nil {
  47275. fields = append(fields, wxcardvisit.FieldBotType)
  47276. }
  47277. return fields
  47278. }
  47279. // Field returns the value of a field with the given name. The second boolean
  47280. // return value indicates that this field was not set, or was not defined in the
  47281. // schema.
  47282. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  47283. switch name {
  47284. case wxcardvisit.FieldCreatedAt:
  47285. return m.CreatedAt()
  47286. case wxcardvisit.FieldUpdatedAt:
  47287. return m.UpdatedAt()
  47288. case wxcardvisit.FieldDeletedAt:
  47289. return m.DeletedAt()
  47290. case wxcardvisit.FieldUserID:
  47291. return m.UserID()
  47292. case wxcardvisit.FieldBotID:
  47293. return m.BotID()
  47294. case wxcardvisit.FieldBotType:
  47295. return m.BotType()
  47296. }
  47297. return nil, false
  47298. }
  47299. // OldField returns the old value of the field from the database. An error is
  47300. // returned if the mutation operation is not UpdateOne, or the query to the
  47301. // database failed.
  47302. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47303. switch name {
  47304. case wxcardvisit.FieldCreatedAt:
  47305. return m.OldCreatedAt(ctx)
  47306. case wxcardvisit.FieldUpdatedAt:
  47307. return m.OldUpdatedAt(ctx)
  47308. case wxcardvisit.FieldDeletedAt:
  47309. return m.OldDeletedAt(ctx)
  47310. case wxcardvisit.FieldUserID:
  47311. return m.OldUserID(ctx)
  47312. case wxcardvisit.FieldBotID:
  47313. return m.OldBotID(ctx)
  47314. case wxcardvisit.FieldBotType:
  47315. return m.OldBotType(ctx)
  47316. }
  47317. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  47318. }
  47319. // SetField sets the value of a field with the given name. It returns an error if
  47320. // the field is not defined in the schema, or if the type mismatched the field
  47321. // type.
  47322. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  47323. switch name {
  47324. case wxcardvisit.FieldCreatedAt:
  47325. v, ok := value.(time.Time)
  47326. if !ok {
  47327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47328. }
  47329. m.SetCreatedAt(v)
  47330. return nil
  47331. case wxcardvisit.FieldUpdatedAt:
  47332. v, ok := value.(time.Time)
  47333. if !ok {
  47334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47335. }
  47336. m.SetUpdatedAt(v)
  47337. return nil
  47338. case wxcardvisit.FieldDeletedAt:
  47339. v, ok := value.(time.Time)
  47340. if !ok {
  47341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47342. }
  47343. m.SetDeletedAt(v)
  47344. return nil
  47345. case wxcardvisit.FieldUserID:
  47346. v, ok := value.(uint64)
  47347. if !ok {
  47348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47349. }
  47350. m.SetUserID(v)
  47351. return nil
  47352. case wxcardvisit.FieldBotID:
  47353. v, ok := value.(uint64)
  47354. if !ok {
  47355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47356. }
  47357. m.SetBotID(v)
  47358. return nil
  47359. case wxcardvisit.FieldBotType:
  47360. v, ok := value.(uint8)
  47361. if !ok {
  47362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47363. }
  47364. m.SetBotType(v)
  47365. return nil
  47366. }
  47367. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47368. }
  47369. // AddedFields returns all numeric fields that were incremented/decremented during
  47370. // this mutation.
  47371. func (m *WxCardVisitMutation) AddedFields() []string {
  47372. var fields []string
  47373. if m.adduser_id != nil {
  47374. fields = append(fields, wxcardvisit.FieldUserID)
  47375. }
  47376. if m.addbot_id != nil {
  47377. fields = append(fields, wxcardvisit.FieldBotID)
  47378. }
  47379. if m.addbot_type != nil {
  47380. fields = append(fields, wxcardvisit.FieldBotType)
  47381. }
  47382. return fields
  47383. }
  47384. // AddedField returns the numeric value that was incremented/decremented on a field
  47385. // with the given name. The second boolean return value indicates that this field
  47386. // was not set, or was not defined in the schema.
  47387. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  47388. switch name {
  47389. case wxcardvisit.FieldUserID:
  47390. return m.AddedUserID()
  47391. case wxcardvisit.FieldBotID:
  47392. return m.AddedBotID()
  47393. case wxcardvisit.FieldBotType:
  47394. return m.AddedBotType()
  47395. }
  47396. return nil, false
  47397. }
  47398. // AddField adds the value to the field with the given name. It returns an error if
  47399. // the field is not defined in the schema, or if the type mismatched the field
  47400. // type.
  47401. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  47402. switch name {
  47403. case wxcardvisit.FieldUserID:
  47404. v, ok := value.(int64)
  47405. if !ok {
  47406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47407. }
  47408. m.AddUserID(v)
  47409. return nil
  47410. case wxcardvisit.FieldBotID:
  47411. v, ok := value.(int64)
  47412. if !ok {
  47413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47414. }
  47415. m.AddBotID(v)
  47416. return nil
  47417. case wxcardvisit.FieldBotType:
  47418. v, ok := value.(int8)
  47419. if !ok {
  47420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47421. }
  47422. m.AddBotType(v)
  47423. return nil
  47424. }
  47425. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  47426. }
  47427. // ClearedFields returns all nullable fields that were cleared during this
  47428. // mutation.
  47429. func (m *WxCardVisitMutation) ClearedFields() []string {
  47430. var fields []string
  47431. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  47432. fields = append(fields, wxcardvisit.FieldDeletedAt)
  47433. }
  47434. if m.FieldCleared(wxcardvisit.FieldUserID) {
  47435. fields = append(fields, wxcardvisit.FieldUserID)
  47436. }
  47437. return fields
  47438. }
  47439. // FieldCleared returns a boolean indicating if a field with the given name was
  47440. // cleared in this mutation.
  47441. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  47442. _, ok := m.clearedFields[name]
  47443. return ok
  47444. }
  47445. // ClearField clears the value of the field with the given name. It returns an
  47446. // error if the field is not defined in the schema.
  47447. func (m *WxCardVisitMutation) ClearField(name string) error {
  47448. switch name {
  47449. case wxcardvisit.FieldDeletedAt:
  47450. m.ClearDeletedAt()
  47451. return nil
  47452. case wxcardvisit.FieldUserID:
  47453. m.ClearUserID()
  47454. return nil
  47455. }
  47456. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  47457. }
  47458. // ResetField resets all changes in the mutation for the field with the given name.
  47459. // It returns an error if the field is not defined in the schema.
  47460. func (m *WxCardVisitMutation) ResetField(name string) error {
  47461. switch name {
  47462. case wxcardvisit.FieldCreatedAt:
  47463. m.ResetCreatedAt()
  47464. return nil
  47465. case wxcardvisit.FieldUpdatedAt:
  47466. m.ResetUpdatedAt()
  47467. return nil
  47468. case wxcardvisit.FieldDeletedAt:
  47469. m.ResetDeletedAt()
  47470. return nil
  47471. case wxcardvisit.FieldUserID:
  47472. m.ResetUserID()
  47473. return nil
  47474. case wxcardvisit.FieldBotID:
  47475. m.ResetBotID()
  47476. return nil
  47477. case wxcardvisit.FieldBotType:
  47478. m.ResetBotType()
  47479. return nil
  47480. }
  47481. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47482. }
  47483. // AddedEdges returns all edge names that were set/added in this mutation.
  47484. func (m *WxCardVisitMutation) AddedEdges() []string {
  47485. edges := make([]string, 0, 0)
  47486. return edges
  47487. }
  47488. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47489. // name in this mutation.
  47490. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  47491. return nil
  47492. }
  47493. // RemovedEdges returns all edge names that were removed in this mutation.
  47494. func (m *WxCardVisitMutation) RemovedEdges() []string {
  47495. edges := make([]string, 0, 0)
  47496. return edges
  47497. }
  47498. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47499. // the given name in this mutation.
  47500. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  47501. return nil
  47502. }
  47503. // ClearedEdges returns all edge names that were cleared in this mutation.
  47504. func (m *WxCardVisitMutation) ClearedEdges() []string {
  47505. edges := make([]string, 0, 0)
  47506. return edges
  47507. }
  47508. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47509. // was cleared in this mutation.
  47510. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  47511. return false
  47512. }
  47513. // ClearEdge clears the value of the edge with the given name. It returns an error
  47514. // if that edge is not defined in the schema.
  47515. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  47516. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  47517. }
  47518. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47519. // It returns an error if the edge is not defined in the schema.
  47520. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  47521. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  47522. }
  47523. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  47524. type XunjiMutation struct {
  47525. config
  47526. op Op
  47527. typ string
  47528. id *uint64
  47529. created_at *time.Time
  47530. updated_at *time.Time
  47531. status *uint8
  47532. addstatus *int8
  47533. deleted_at *time.Time
  47534. app_key *string
  47535. app_secret *string
  47536. token *string
  47537. encoding_key *string
  47538. organization_id *uint64
  47539. addorganization_id *int64
  47540. clearedFields map[string]struct{}
  47541. done bool
  47542. oldValue func(context.Context) (*Xunji, error)
  47543. predicates []predicate.Xunji
  47544. }
  47545. var _ ent.Mutation = (*XunjiMutation)(nil)
  47546. // xunjiOption allows management of the mutation configuration using functional options.
  47547. type xunjiOption func(*XunjiMutation)
  47548. // newXunjiMutation creates new mutation for the Xunji entity.
  47549. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  47550. m := &XunjiMutation{
  47551. config: c,
  47552. op: op,
  47553. typ: TypeXunji,
  47554. clearedFields: make(map[string]struct{}),
  47555. }
  47556. for _, opt := range opts {
  47557. opt(m)
  47558. }
  47559. return m
  47560. }
  47561. // withXunjiID sets the ID field of the mutation.
  47562. func withXunjiID(id uint64) xunjiOption {
  47563. return func(m *XunjiMutation) {
  47564. var (
  47565. err error
  47566. once sync.Once
  47567. value *Xunji
  47568. )
  47569. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  47570. once.Do(func() {
  47571. if m.done {
  47572. err = errors.New("querying old values post mutation is not allowed")
  47573. } else {
  47574. value, err = m.Client().Xunji.Get(ctx, id)
  47575. }
  47576. })
  47577. return value, err
  47578. }
  47579. m.id = &id
  47580. }
  47581. }
  47582. // withXunji sets the old Xunji of the mutation.
  47583. func withXunji(node *Xunji) xunjiOption {
  47584. return func(m *XunjiMutation) {
  47585. m.oldValue = func(context.Context) (*Xunji, error) {
  47586. return node, nil
  47587. }
  47588. m.id = &node.ID
  47589. }
  47590. }
  47591. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47592. // executed in a transaction (ent.Tx), a transactional client is returned.
  47593. func (m XunjiMutation) Client() *Client {
  47594. client := &Client{config: m.config}
  47595. client.init()
  47596. return client
  47597. }
  47598. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47599. // it returns an error otherwise.
  47600. func (m XunjiMutation) Tx() (*Tx, error) {
  47601. if _, ok := m.driver.(*txDriver); !ok {
  47602. return nil, errors.New("ent: mutation is not running in a transaction")
  47603. }
  47604. tx := &Tx{config: m.config}
  47605. tx.init()
  47606. return tx, nil
  47607. }
  47608. // SetID sets the value of the id field. Note that this
  47609. // operation is only accepted on creation of Xunji entities.
  47610. func (m *XunjiMutation) SetID(id uint64) {
  47611. m.id = &id
  47612. }
  47613. // ID returns the ID value in the mutation. Note that the ID is only available
  47614. // if it was provided to the builder or after it was returned from the database.
  47615. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  47616. if m.id == nil {
  47617. return
  47618. }
  47619. return *m.id, true
  47620. }
  47621. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47622. // That means, if the mutation is applied within a transaction with an isolation level such
  47623. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47624. // or updated by the mutation.
  47625. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  47626. switch {
  47627. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47628. id, exists := m.ID()
  47629. if exists {
  47630. return []uint64{id}, nil
  47631. }
  47632. fallthrough
  47633. case m.op.Is(OpUpdate | OpDelete):
  47634. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  47635. default:
  47636. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47637. }
  47638. }
  47639. // SetCreatedAt sets the "created_at" field.
  47640. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  47641. m.created_at = &t
  47642. }
  47643. // CreatedAt returns the value of the "created_at" field in the mutation.
  47644. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  47645. v := m.created_at
  47646. if v == nil {
  47647. return
  47648. }
  47649. return *v, true
  47650. }
  47651. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  47652. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47654. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47655. if !m.op.Is(OpUpdateOne) {
  47656. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47657. }
  47658. if m.id == nil || m.oldValue == nil {
  47659. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47660. }
  47661. oldValue, err := m.oldValue(ctx)
  47662. if err != nil {
  47663. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47664. }
  47665. return oldValue.CreatedAt, nil
  47666. }
  47667. // ResetCreatedAt resets all changes to the "created_at" field.
  47668. func (m *XunjiMutation) ResetCreatedAt() {
  47669. m.created_at = nil
  47670. }
  47671. // SetUpdatedAt sets the "updated_at" field.
  47672. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  47673. m.updated_at = &t
  47674. }
  47675. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47676. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  47677. v := m.updated_at
  47678. if v == nil {
  47679. return
  47680. }
  47681. return *v, true
  47682. }
  47683. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47687. if !m.op.Is(OpUpdateOne) {
  47688. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47689. }
  47690. if m.id == nil || m.oldValue == nil {
  47691. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  47696. }
  47697. return oldValue.UpdatedAt, nil
  47698. }
  47699. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47700. func (m *XunjiMutation) ResetUpdatedAt() {
  47701. m.updated_at = nil
  47702. }
  47703. // SetStatus sets the "status" field.
  47704. func (m *XunjiMutation) SetStatus(u uint8) {
  47705. m.status = &u
  47706. m.addstatus = nil
  47707. }
  47708. // Status returns the value of the "status" field in the mutation.
  47709. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  47710. v := m.status
  47711. if v == nil {
  47712. return
  47713. }
  47714. return *v, true
  47715. }
  47716. // OldStatus returns the old "status" field's value of the Xunji entity.
  47717. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47719. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  47720. if !m.op.Is(OpUpdateOne) {
  47721. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  47722. }
  47723. if m.id == nil || m.oldValue == nil {
  47724. return v, errors.New("OldStatus requires an ID field in the mutation")
  47725. }
  47726. oldValue, err := m.oldValue(ctx)
  47727. if err != nil {
  47728. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  47729. }
  47730. return oldValue.Status, nil
  47731. }
  47732. // AddStatus adds u to the "status" field.
  47733. func (m *XunjiMutation) AddStatus(u int8) {
  47734. if m.addstatus != nil {
  47735. *m.addstatus += u
  47736. } else {
  47737. m.addstatus = &u
  47738. }
  47739. }
  47740. // AddedStatus returns the value that was added to the "status" field in this mutation.
  47741. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  47742. v := m.addstatus
  47743. if v == nil {
  47744. return
  47745. }
  47746. return *v, true
  47747. }
  47748. // ClearStatus clears the value of the "status" field.
  47749. func (m *XunjiMutation) ClearStatus() {
  47750. m.status = nil
  47751. m.addstatus = nil
  47752. m.clearedFields[xunji.FieldStatus] = struct{}{}
  47753. }
  47754. // StatusCleared returns if the "status" field was cleared in this mutation.
  47755. func (m *XunjiMutation) StatusCleared() bool {
  47756. _, ok := m.clearedFields[xunji.FieldStatus]
  47757. return ok
  47758. }
  47759. // ResetStatus resets all changes to the "status" field.
  47760. func (m *XunjiMutation) ResetStatus() {
  47761. m.status = nil
  47762. m.addstatus = nil
  47763. delete(m.clearedFields, xunji.FieldStatus)
  47764. }
  47765. // SetDeletedAt sets the "deleted_at" field.
  47766. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  47767. m.deleted_at = &t
  47768. }
  47769. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47770. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  47771. v := m.deleted_at
  47772. if v == nil {
  47773. return
  47774. }
  47775. return *v, true
  47776. }
  47777. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  47778. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47780. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47781. if !m.op.Is(OpUpdateOne) {
  47782. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47783. }
  47784. if m.id == nil || m.oldValue == nil {
  47785. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47786. }
  47787. oldValue, err := m.oldValue(ctx)
  47788. if err != nil {
  47789. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47790. }
  47791. return oldValue.DeletedAt, nil
  47792. }
  47793. // ClearDeletedAt clears the value of the "deleted_at" field.
  47794. func (m *XunjiMutation) ClearDeletedAt() {
  47795. m.deleted_at = nil
  47796. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  47797. }
  47798. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47799. func (m *XunjiMutation) DeletedAtCleared() bool {
  47800. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  47801. return ok
  47802. }
  47803. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47804. func (m *XunjiMutation) ResetDeletedAt() {
  47805. m.deleted_at = nil
  47806. delete(m.clearedFields, xunji.FieldDeletedAt)
  47807. }
  47808. // SetAppKey sets the "app_key" field.
  47809. func (m *XunjiMutation) SetAppKey(s string) {
  47810. m.app_key = &s
  47811. }
  47812. // AppKey returns the value of the "app_key" field in the mutation.
  47813. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  47814. v := m.app_key
  47815. if v == nil {
  47816. return
  47817. }
  47818. return *v, true
  47819. }
  47820. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  47821. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47823. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  47824. if !m.op.Is(OpUpdateOne) {
  47825. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  47826. }
  47827. if m.id == nil || m.oldValue == nil {
  47828. return v, errors.New("OldAppKey requires an ID field in the mutation")
  47829. }
  47830. oldValue, err := m.oldValue(ctx)
  47831. if err != nil {
  47832. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  47833. }
  47834. return oldValue.AppKey, nil
  47835. }
  47836. // ClearAppKey clears the value of the "app_key" field.
  47837. func (m *XunjiMutation) ClearAppKey() {
  47838. m.app_key = nil
  47839. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  47840. }
  47841. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  47842. func (m *XunjiMutation) AppKeyCleared() bool {
  47843. _, ok := m.clearedFields[xunji.FieldAppKey]
  47844. return ok
  47845. }
  47846. // ResetAppKey resets all changes to the "app_key" field.
  47847. func (m *XunjiMutation) ResetAppKey() {
  47848. m.app_key = nil
  47849. delete(m.clearedFields, xunji.FieldAppKey)
  47850. }
  47851. // SetAppSecret sets the "app_secret" field.
  47852. func (m *XunjiMutation) SetAppSecret(s string) {
  47853. m.app_secret = &s
  47854. }
  47855. // AppSecret returns the value of the "app_secret" field in the mutation.
  47856. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  47857. v := m.app_secret
  47858. if v == nil {
  47859. return
  47860. }
  47861. return *v, true
  47862. }
  47863. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  47864. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47866. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  47867. if !m.op.Is(OpUpdateOne) {
  47868. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  47869. }
  47870. if m.id == nil || m.oldValue == nil {
  47871. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  47872. }
  47873. oldValue, err := m.oldValue(ctx)
  47874. if err != nil {
  47875. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  47876. }
  47877. return oldValue.AppSecret, nil
  47878. }
  47879. // ClearAppSecret clears the value of the "app_secret" field.
  47880. func (m *XunjiMutation) ClearAppSecret() {
  47881. m.app_secret = nil
  47882. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  47883. }
  47884. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  47885. func (m *XunjiMutation) AppSecretCleared() bool {
  47886. _, ok := m.clearedFields[xunji.FieldAppSecret]
  47887. return ok
  47888. }
  47889. // ResetAppSecret resets all changes to the "app_secret" field.
  47890. func (m *XunjiMutation) ResetAppSecret() {
  47891. m.app_secret = nil
  47892. delete(m.clearedFields, xunji.FieldAppSecret)
  47893. }
  47894. // SetToken sets the "token" field.
  47895. func (m *XunjiMutation) SetToken(s string) {
  47896. m.token = &s
  47897. }
  47898. // Token returns the value of the "token" field in the mutation.
  47899. func (m *XunjiMutation) Token() (r string, exists bool) {
  47900. v := m.token
  47901. if v == nil {
  47902. return
  47903. }
  47904. return *v, true
  47905. }
  47906. // OldToken returns the old "token" field's value of the Xunji entity.
  47907. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47909. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  47910. if !m.op.Is(OpUpdateOne) {
  47911. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  47912. }
  47913. if m.id == nil || m.oldValue == nil {
  47914. return v, errors.New("OldToken requires an ID field in the mutation")
  47915. }
  47916. oldValue, err := m.oldValue(ctx)
  47917. if err != nil {
  47918. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  47919. }
  47920. return oldValue.Token, nil
  47921. }
  47922. // ClearToken clears the value of the "token" field.
  47923. func (m *XunjiMutation) ClearToken() {
  47924. m.token = nil
  47925. m.clearedFields[xunji.FieldToken] = struct{}{}
  47926. }
  47927. // TokenCleared returns if the "token" field was cleared in this mutation.
  47928. func (m *XunjiMutation) TokenCleared() bool {
  47929. _, ok := m.clearedFields[xunji.FieldToken]
  47930. return ok
  47931. }
  47932. // ResetToken resets all changes to the "token" field.
  47933. func (m *XunjiMutation) ResetToken() {
  47934. m.token = nil
  47935. delete(m.clearedFields, xunji.FieldToken)
  47936. }
  47937. // SetEncodingKey sets the "encoding_key" field.
  47938. func (m *XunjiMutation) SetEncodingKey(s string) {
  47939. m.encoding_key = &s
  47940. }
  47941. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  47942. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  47943. v := m.encoding_key
  47944. if v == nil {
  47945. return
  47946. }
  47947. return *v, true
  47948. }
  47949. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  47950. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47952. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  47953. if !m.op.Is(OpUpdateOne) {
  47954. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  47955. }
  47956. if m.id == nil || m.oldValue == nil {
  47957. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  47958. }
  47959. oldValue, err := m.oldValue(ctx)
  47960. if err != nil {
  47961. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  47962. }
  47963. return oldValue.EncodingKey, nil
  47964. }
  47965. // ClearEncodingKey clears the value of the "encoding_key" field.
  47966. func (m *XunjiMutation) ClearEncodingKey() {
  47967. m.encoding_key = nil
  47968. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  47969. }
  47970. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  47971. func (m *XunjiMutation) EncodingKeyCleared() bool {
  47972. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  47973. return ok
  47974. }
  47975. // ResetEncodingKey resets all changes to the "encoding_key" field.
  47976. func (m *XunjiMutation) ResetEncodingKey() {
  47977. m.encoding_key = nil
  47978. delete(m.clearedFields, xunji.FieldEncodingKey)
  47979. }
  47980. // SetOrganizationID sets the "organization_id" field.
  47981. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  47982. m.organization_id = &u
  47983. m.addorganization_id = nil
  47984. }
  47985. // OrganizationID returns the value of the "organization_id" field in the mutation.
  47986. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  47987. v := m.organization_id
  47988. if v == nil {
  47989. return
  47990. }
  47991. return *v, true
  47992. }
  47993. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  47994. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47996. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  47997. if !m.op.Is(OpUpdateOne) {
  47998. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  47999. }
  48000. if m.id == nil || m.oldValue == nil {
  48001. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  48002. }
  48003. oldValue, err := m.oldValue(ctx)
  48004. if err != nil {
  48005. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  48006. }
  48007. return oldValue.OrganizationID, nil
  48008. }
  48009. // AddOrganizationID adds u to the "organization_id" field.
  48010. func (m *XunjiMutation) AddOrganizationID(u int64) {
  48011. if m.addorganization_id != nil {
  48012. *m.addorganization_id += u
  48013. } else {
  48014. m.addorganization_id = &u
  48015. }
  48016. }
  48017. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  48018. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  48019. v := m.addorganization_id
  48020. if v == nil {
  48021. return
  48022. }
  48023. return *v, true
  48024. }
  48025. // ResetOrganizationID resets all changes to the "organization_id" field.
  48026. func (m *XunjiMutation) ResetOrganizationID() {
  48027. m.organization_id = nil
  48028. m.addorganization_id = nil
  48029. }
  48030. // Where appends a list predicates to the XunjiMutation builder.
  48031. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  48032. m.predicates = append(m.predicates, ps...)
  48033. }
  48034. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  48035. // users can use type-assertion to append predicates that do not depend on any generated package.
  48036. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  48037. p := make([]predicate.Xunji, len(ps))
  48038. for i := range ps {
  48039. p[i] = ps[i]
  48040. }
  48041. m.Where(p...)
  48042. }
  48043. // Op returns the operation name.
  48044. func (m *XunjiMutation) Op() Op {
  48045. return m.op
  48046. }
  48047. // SetOp allows setting the mutation operation.
  48048. func (m *XunjiMutation) SetOp(op Op) {
  48049. m.op = op
  48050. }
  48051. // Type returns the node type of this mutation (Xunji).
  48052. func (m *XunjiMutation) Type() string {
  48053. return m.typ
  48054. }
  48055. // Fields returns all fields that were changed during this mutation. Note that in
  48056. // order to get all numeric fields that were incremented/decremented, call
  48057. // AddedFields().
  48058. func (m *XunjiMutation) Fields() []string {
  48059. fields := make([]string, 0, 9)
  48060. if m.created_at != nil {
  48061. fields = append(fields, xunji.FieldCreatedAt)
  48062. }
  48063. if m.updated_at != nil {
  48064. fields = append(fields, xunji.FieldUpdatedAt)
  48065. }
  48066. if m.status != nil {
  48067. fields = append(fields, xunji.FieldStatus)
  48068. }
  48069. if m.deleted_at != nil {
  48070. fields = append(fields, xunji.FieldDeletedAt)
  48071. }
  48072. if m.app_key != nil {
  48073. fields = append(fields, xunji.FieldAppKey)
  48074. }
  48075. if m.app_secret != nil {
  48076. fields = append(fields, xunji.FieldAppSecret)
  48077. }
  48078. if m.token != nil {
  48079. fields = append(fields, xunji.FieldToken)
  48080. }
  48081. if m.encoding_key != nil {
  48082. fields = append(fields, xunji.FieldEncodingKey)
  48083. }
  48084. if m.organization_id != nil {
  48085. fields = append(fields, xunji.FieldOrganizationID)
  48086. }
  48087. return fields
  48088. }
  48089. // Field returns the value of a field with the given name. The second boolean
  48090. // return value indicates that this field was not set, or was not defined in the
  48091. // schema.
  48092. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  48093. switch name {
  48094. case xunji.FieldCreatedAt:
  48095. return m.CreatedAt()
  48096. case xunji.FieldUpdatedAt:
  48097. return m.UpdatedAt()
  48098. case xunji.FieldStatus:
  48099. return m.Status()
  48100. case xunji.FieldDeletedAt:
  48101. return m.DeletedAt()
  48102. case xunji.FieldAppKey:
  48103. return m.AppKey()
  48104. case xunji.FieldAppSecret:
  48105. return m.AppSecret()
  48106. case xunji.FieldToken:
  48107. return m.Token()
  48108. case xunji.FieldEncodingKey:
  48109. return m.EncodingKey()
  48110. case xunji.FieldOrganizationID:
  48111. return m.OrganizationID()
  48112. }
  48113. return nil, false
  48114. }
  48115. // OldField returns the old value of the field from the database. An error is
  48116. // returned if the mutation operation is not UpdateOne, or the query to the
  48117. // database failed.
  48118. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48119. switch name {
  48120. case xunji.FieldCreatedAt:
  48121. return m.OldCreatedAt(ctx)
  48122. case xunji.FieldUpdatedAt:
  48123. return m.OldUpdatedAt(ctx)
  48124. case xunji.FieldStatus:
  48125. return m.OldStatus(ctx)
  48126. case xunji.FieldDeletedAt:
  48127. return m.OldDeletedAt(ctx)
  48128. case xunji.FieldAppKey:
  48129. return m.OldAppKey(ctx)
  48130. case xunji.FieldAppSecret:
  48131. return m.OldAppSecret(ctx)
  48132. case xunji.FieldToken:
  48133. return m.OldToken(ctx)
  48134. case xunji.FieldEncodingKey:
  48135. return m.OldEncodingKey(ctx)
  48136. case xunji.FieldOrganizationID:
  48137. return m.OldOrganizationID(ctx)
  48138. }
  48139. return nil, fmt.Errorf("unknown Xunji field %s", name)
  48140. }
  48141. // SetField sets the value of a field with the given name. It returns an error if
  48142. // the field is not defined in the schema, or if the type mismatched the field
  48143. // type.
  48144. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  48145. switch name {
  48146. case xunji.FieldCreatedAt:
  48147. v, ok := value.(time.Time)
  48148. if !ok {
  48149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48150. }
  48151. m.SetCreatedAt(v)
  48152. return nil
  48153. case xunji.FieldUpdatedAt:
  48154. v, ok := value.(time.Time)
  48155. if !ok {
  48156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48157. }
  48158. m.SetUpdatedAt(v)
  48159. return nil
  48160. case xunji.FieldStatus:
  48161. v, ok := value.(uint8)
  48162. if !ok {
  48163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48164. }
  48165. m.SetStatus(v)
  48166. return nil
  48167. case xunji.FieldDeletedAt:
  48168. v, ok := value.(time.Time)
  48169. if !ok {
  48170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48171. }
  48172. m.SetDeletedAt(v)
  48173. return nil
  48174. case xunji.FieldAppKey:
  48175. v, ok := value.(string)
  48176. if !ok {
  48177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48178. }
  48179. m.SetAppKey(v)
  48180. return nil
  48181. case xunji.FieldAppSecret:
  48182. v, ok := value.(string)
  48183. if !ok {
  48184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48185. }
  48186. m.SetAppSecret(v)
  48187. return nil
  48188. case xunji.FieldToken:
  48189. v, ok := value.(string)
  48190. if !ok {
  48191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48192. }
  48193. m.SetToken(v)
  48194. return nil
  48195. case xunji.FieldEncodingKey:
  48196. v, ok := value.(string)
  48197. if !ok {
  48198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48199. }
  48200. m.SetEncodingKey(v)
  48201. return nil
  48202. case xunji.FieldOrganizationID:
  48203. v, ok := value.(uint64)
  48204. if !ok {
  48205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48206. }
  48207. m.SetOrganizationID(v)
  48208. return nil
  48209. }
  48210. return fmt.Errorf("unknown Xunji field %s", name)
  48211. }
  48212. // AddedFields returns all numeric fields that were incremented/decremented during
  48213. // this mutation.
  48214. func (m *XunjiMutation) AddedFields() []string {
  48215. var fields []string
  48216. if m.addstatus != nil {
  48217. fields = append(fields, xunji.FieldStatus)
  48218. }
  48219. if m.addorganization_id != nil {
  48220. fields = append(fields, xunji.FieldOrganizationID)
  48221. }
  48222. return fields
  48223. }
  48224. // AddedField returns the numeric value that was incremented/decremented on a field
  48225. // with the given name. The second boolean return value indicates that this field
  48226. // was not set, or was not defined in the schema.
  48227. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  48228. switch name {
  48229. case xunji.FieldStatus:
  48230. return m.AddedStatus()
  48231. case xunji.FieldOrganizationID:
  48232. return m.AddedOrganizationID()
  48233. }
  48234. return nil, false
  48235. }
  48236. // AddField adds the value to the field with the given name. It returns an error if
  48237. // the field is not defined in the schema, or if the type mismatched the field
  48238. // type.
  48239. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  48240. switch name {
  48241. case xunji.FieldStatus:
  48242. v, ok := value.(int8)
  48243. if !ok {
  48244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48245. }
  48246. m.AddStatus(v)
  48247. return nil
  48248. case xunji.FieldOrganizationID:
  48249. v, ok := value.(int64)
  48250. if !ok {
  48251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48252. }
  48253. m.AddOrganizationID(v)
  48254. return nil
  48255. }
  48256. return fmt.Errorf("unknown Xunji numeric field %s", name)
  48257. }
  48258. // ClearedFields returns all nullable fields that were cleared during this
  48259. // mutation.
  48260. func (m *XunjiMutation) ClearedFields() []string {
  48261. var fields []string
  48262. if m.FieldCleared(xunji.FieldStatus) {
  48263. fields = append(fields, xunji.FieldStatus)
  48264. }
  48265. if m.FieldCleared(xunji.FieldDeletedAt) {
  48266. fields = append(fields, xunji.FieldDeletedAt)
  48267. }
  48268. if m.FieldCleared(xunji.FieldAppKey) {
  48269. fields = append(fields, xunji.FieldAppKey)
  48270. }
  48271. if m.FieldCleared(xunji.FieldAppSecret) {
  48272. fields = append(fields, xunji.FieldAppSecret)
  48273. }
  48274. if m.FieldCleared(xunji.FieldToken) {
  48275. fields = append(fields, xunji.FieldToken)
  48276. }
  48277. if m.FieldCleared(xunji.FieldEncodingKey) {
  48278. fields = append(fields, xunji.FieldEncodingKey)
  48279. }
  48280. return fields
  48281. }
  48282. // FieldCleared returns a boolean indicating if a field with the given name was
  48283. // cleared in this mutation.
  48284. func (m *XunjiMutation) FieldCleared(name string) bool {
  48285. _, ok := m.clearedFields[name]
  48286. return ok
  48287. }
  48288. // ClearField clears the value of the field with the given name. It returns an
  48289. // error if the field is not defined in the schema.
  48290. func (m *XunjiMutation) ClearField(name string) error {
  48291. switch name {
  48292. case xunji.FieldStatus:
  48293. m.ClearStatus()
  48294. return nil
  48295. case xunji.FieldDeletedAt:
  48296. m.ClearDeletedAt()
  48297. return nil
  48298. case xunji.FieldAppKey:
  48299. m.ClearAppKey()
  48300. return nil
  48301. case xunji.FieldAppSecret:
  48302. m.ClearAppSecret()
  48303. return nil
  48304. case xunji.FieldToken:
  48305. m.ClearToken()
  48306. return nil
  48307. case xunji.FieldEncodingKey:
  48308. m.ClearEncodingKey()
  48309. return nil
  48310. }
  48311. return fmt.Errorf("unknown Xunji nullable field %s", name)
  48312. }
  48313. // ResetField resets all changes in the mutation for the field with the given name.
  48314. // It returns an error if the field is not defined in the schema.
  48315. func (m *XunjiMutation) ResetField(name string) error {
  48316. switch name {
  48317. case xunji.FieldCreatedAt:
  48318. m.ResetCreatedAt()
  48319. return nil
  48320. case xunji.FieldUpdatedAt:
  48321. m.ResetUpdatedAt()
  48322. return nil
  48323. case xunji.FieldStatus:
  48324. m.ResetStatus()
  48325. return nil
  48326. case xunji.FieldDeletedAt:
  48327. m.ResetDeletedAt()
  48328. return nil
  48329. case xunji.FieldAppKey:
  48330. m.ResetAppKey()
  48331. return nil
  48332. case xunji.FieldAppSecret:
  48333. m.ResetAppSecret()
  48334. return nil
  48335. case xunji.FieldToken:
  48336. m.ResetToken()
  48337. return nil
  48338. case xunji.FieldEncodingKey:
  48339. m.ResetEncodingKey()
  48340. return nil
  48341. case xunji.FieldOrganizationID:
  48342. m.ResetOrganizationID()
  48343. return nil
  48344. }
  48345. return fmt.Errorf("unknown Xunji field %s", name)
  48346. }
  48347. // AddedEdges returns all edge names that were set/added in this mutation.
  48348. func (m *XunjiMutation) AddedEdges() []string {
  48349. edges := make([]string, 0, 0)
  48350. return edges
  48351. }
  48352. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48353. // name in this mutation.
  48354. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  48355. return nil
  48356. }
  48357. // RemovedEdges returns all edge names that were removed in this mutation.
  48358. func (m *XunjiMutation) RemovedEdges() []string {
  48359. edges := make([]string, 0, 0)
  48360. return edges
  48361. }
  48362. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48363. // the given name in this mutation.
  48364. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  48365. return nil
  48366. }
  48367. // ClearedEdges returns all edge names that were cleared in this mutation.
  48368. func (m *XunjiMutation) ClearedEdges() []string {
  48369. edges := make([]string, 0, 0)
  48370. return edges
  48371. }
  48372. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48373. // was cleared in this mutation.
  48374. func (m *XunjiMutation) EdgeCleared(name string) bool {
  48375. return false
  48376. }
  48377. // ClearEdge clears the value of the edge with the given name. It returns an error
  48378. // if that edge is not defined in the schema.
  48379. func (m *XunjiMutation) ClearEdge(name string) error {
  48380. return fmt.Errorf("unknown Xunji unique edge %s", name)
  48381. }
  48382. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48383. // It returns an error if the edge is not defined in the schema.
  48384. func (m *XunjiMutation) ResetEdge(name string) error {
  48385. return fmt.Errorf("unknown Xunji edge %s", name)
  48386. }
  48387. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  48388. type XunjiServiceMutation struct {
  48389. config
  48390. op Op
  48391. typ string
  48392. id *uint64
  48393. created_at *time.Time
  48394. updated_at *time.Time
  48395. status *uint8
  48396. addstatus *int8
  48397. deleted_at *time.Time
  48398. xunji_id *uint64
  48399. addxunji_id *int64
  48400. organization_id *uint64
  48401. addorganization_id *int64
  48402. wxid *string
  48403. api_base *string
  48404. api_key *string
  48405. clearedFields map[string]struct{}
  48406. agent *uint64
  48407. clearedagent bool
  48408. done bool
  48409. oldValue func(context.Context) (*XunjiService, error)
  48410. predicates []predicate.XunjiService
  48411. }
  48412. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  48413. // xunjiserviceOption allows management of the mutation configuration using functional options.
  48414. type xunjiserviceOption func(*XunjiServiceMutation)
  48415. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  48416. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  48417. m := &XunjiServiceMutation{
  48418. config: c,
  48419. op: op,
  48420. typ: TypeXunjiService,
  48421. clearedFields: make(map[string]struct{}),
  48422. }
  48423. for _, opt := range opts {
  48424. opt(m)
  48425. }
  48426. return m
  48427. }
  48428. // withXunjiServiceID sets the ID field of the mutation.
  48429. func withXunjiServiceID(id uint64) xunjiserviceOption {
  48430. return func(m *XunjiServiceMutation) {
  48431. var (
  48432. err error
  48433. once sync.Once
  48434. value *XunjiService
  48435. )
  48436. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  48437. once.Do(func() {
  48438. if m.done {
  48439. err = errors.New("querying old values post mutation is not allowed")
  48440. } else {
  48441. value, err = m.Client().XunjiService.Get(ctx, id)
  48442. }
  48443. })
  48444. return value, err
  48445. }
  48446. m.id = &id
  48447. }
  48448. }
  48449. // withXunjiService sets the old XunjiService of the mutation.
  48450. func withXunjiService(node *XunjiService) xunjiserviceOption {
  48451. return func(m *XunjiServiceMutation) {
  48452. m.oldValue = func(context.Context) (*XunjiService, error) {
  48453. return node, nil
  48454. }
  48455. m.id = &node.ID
  48456. }
  48457. }
  48458. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48459. // executed in a transaction (ent.Tx), a transactional client is returned.
  48460. func (m XunjiServiceMutation) Client() *Client {
  48461. client := &Client{config: m.config}
  48462. client.init()
  48463. return client
  48464. }
  48465. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48466. // it returns an error otherwise.
  48467. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  48468. if _, ok := m.driver.(*txDriver); !ok {
  48469. return nil, errors.New("ent: mutation is not running in a transaction")
  48470. }
  48471. tx := &Tx{config: m.config}
  48472. tx.init()
  48473. return tx, nil
  48474. }
  48475. // SetID sets the value of the id field. Note that this
  48476. // operation is only accepted on creation of XunjiService entities.
  48477. func (m *XunjiServiceMutation) SetID(id uint64) {
  48478. m.id = &id
  48479. }
  48480. // ID returns the ID value in the mutation. Note that the ID is only available
  48481. // if it was provided to the builder or after it was returned from the database.
  48482. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  48483. if m.id == nil {
  48484. return
  48485. }
  48486. return *m.id, true
  48487. }
  48488. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48489. // That means, if the mutation is applied within a transaction with an isolation level such
  48490. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48491. // or updated by the mutation.
  48492. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  48493. switch {
  48494. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48495. id, exists := m.ID()
  48496. if exists {
  48497. return []uint64{id}, nil
  48498. }
  48499. fallthrough
  48500. case m.op.Is(OpUpdate | OpDelete):
  48501. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  48502. default:
  48503. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48504. }
  48505. }
  48506. // SetCreatedAt sets the "created_at" field.
  48507. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  48508. m.created_at = &t
  48509. }
  48510. // CreatedAt returns the value of the "created_at" field in the mutation.
  48511. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  48512. v := m.created_at
  48513. if v == nil {
  48514. return
  48515. }
  48516. return *v, true
  48517. }
  48518. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  48519. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48521. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48522. if !m.op.Is(OpUpdateOne) {
  48523. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48524. }
  48525. if m.id == nil || m.oldValue == nil {
  48526. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48527. }
  48528. oldValue, err := m.oldValue(ctx)
  48529. if err != nil {
  48530. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48531. }
  48532. return oldValue.CreatedAt, nil
  48533. }
  48534. // ResetCreatedAt resets all changes to the "created_at" field.
  48535. func (m *XunjiServiceMutation) ResetCreatedAt() {
  48536. m.created_at = nil
  48537. }
  48538. // SetUpdatedAt sets the "updated_at" field.
  48539. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  48540. m.updated_at = &t
  48541. }
  48542. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48543. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  48544. v := m.updated_at
  48545. if v == nil {
  48546. return
  48547. }
  48548. return *v, true
  48549. }
  48550. // OldUpdatedAt returns the old "updated_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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48554. if !m.op.Is(OpUpdateOne) {
  48555. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48556. }
  48557. if m.id == nil || m.oldValue == nil {
  48558. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  48563. }
  48564. return oldValue.UpdatedAt, nil
  48565. }
  48566. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48567. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  48568. m.updated_at = nil
  48569. }
  48570. // SetStatus sets the "status" field.
  48571. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  48572. m.status = &u
  48573. m.addstatus = nil
  48574. }
  48575. // Status returns the value of the "status" field in the mutation.
  48576. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  48577. v := m.status
  48578. if v == nil {
  48579. return
  48580. }
  48581. return *v, true
  48582. }
  48583. // OldStatus returns the old "status" field's value of the XunjiService entity.
  48584. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48586. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  48587. if !m.op.Is(OpUpdateOne) {
  48588. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  48589. }
  48590. if m.id == nil || m.oldValue == nil {
  48591. return v, errors.New("OldStatus requires an ID field in the mutation")
  48592. }
  48593. oldValue, err := m.oldValue(ctx)
  48594. if err != nil {
  48595. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  48596. }
  48597. return oldValue.Status, nil
  48598. }
  48599. // AddStatus adds u to the "status" field.
  48600. func (m *XunjiServiceMutation) AddStatus(u int8) {
  48601. if m.addstatus != nil {
  48602. *m.addstatus += u
  48603. } else {
  48604. m.addstatus = &u
  48605. }
  48606. }
  48607. // AddedStatus returns the value that was added to the "status" field in this mutation.
  48608. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  48609. v := m.addstatus
  48610. if v == nil {
  48611. return
  48612. }
  48613. return *v, true
  48614. }
  48615. // ClearStatus clears the value of the "status" field.
  48616. func (m *XunjiServiceMutation) ClearStatus() {
  48617. m.status = nil
  48618. m.addstatus = nil
  48619. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  48620. }
  48621. // StatusCleared returns if the "status" field was cleared in this mutation.
  48622. func (m *XunjiServiceMutation) StatusCleared() bool {
  48623. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  48624. return ok
  48625. }
  48626. // ResetStatus resets all changes to the "status" field.
  48627. func (m *XunjiServiceMutation) ResetStatus() {
  48628. m.status = nil
  48629. m.addstatus = nil
  48630. delete(m.clearedFields, xunjiservice.FieldStatus)
  48631. }
  48632. // SetDeletedAt sets the "deleted_at" field.
  48633. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  48634. m.deleted_at = &t
  48635. }
  48636. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48637. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  48638. v := m.deleted_at
  48639. if v == nil {
  48640. return
  48641. }
  48642. return *v, true
  48643. }
  48644. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  48645. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48647. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48648. if !m.op.Is(OpUpdateOne) {
  48649. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48650. }
  48651. if m.id == nil || m.oldValue == nil {
  48652. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48653. }
  48654. oldValue, err := m.oldValue(ctx)
  48655. if err != nil {
  48656. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48657. }
  48658. return oldValue.DeletedAt, nil
  48659. }
  48660. // ClearDeletedAt clears the value of the "deleted_at" field.
  48661. func (m *XunjiServiceMutation) ClearDeletedAt() {
  48662. m.deleted_at = nil
  48663. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  48664. }
  48665. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48666. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  48667. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  48668. return ok
  48669. }
  48670. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48671. func (m *XunjiServiceMutation) ResetDeletedAt() {
  48672. m.deleted_at = nil
  48673. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  48674. }
  48675. // SetXunjiID sets the "xunji_id" field.
  48676. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  48677. m.xunji_id = &u
  48678. m.addxunji_id = nil
  48679. }
  48680. // XunjiID returns the value of the "xunji_id" field in the mutation.
  48681. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  48682. v := m.xunji_id
  48683. if v == nil {
  48684. return
  48685. }
  48686. return *v, true
  48687. }
  48688. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  48689. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48691. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  48692. if !m.op.Is(OpUpdateOne) {
  48693. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  48694. }
  48695. if m.id == nil || m.oldValue == nil {
  48696. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  48697. }
  48698. oldValue, err := m.oldValue(ctx)
  48699. if err != nil {
  48700. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  48701. }
  48702. return oldValue.XunjiID, nil
  48703. }
  48704. // AddXunjiID adds u to the "xunji_id" field.
  48705. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  48706. if m.addxunji_id != nil {
  48707. *m.addxunji_id += u
  48708. } else {
  48709. m.addxunji_id = &u
  48710. }
  48711. }
  48712. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  48713. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  48714. v := m.addxunji_id
  48715. if v == nil {
  48716. return
  48717. }
  48718. return *v, true
  48719. }
  48720. // ResetXunjiID resets all changes to the "xunji_id" field.
  48721. func (m *XunjiServiceMutation) ResetXunjiID() {
  48722. m.xunji_id = nil
  48723. m.addxunji_id = nil
  48724. }
  48725. // SetAgentID sets the "agent_id" field.
  48726. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  48727. m.agent = &u
  48728. }
  48729. // AgentID returns the value of the "agent_id" field in the mutation.
  48730. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  48731. v := m.agent
  48732. if v == nil {
  48733. return
  48734. }
  48735. return *v, true
  48736. }
  48737. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  48738. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48740. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  48741. if !m.op.Is(OpUpdateOne) {
  48742. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  48743. }
  48744. if m.id == nil || m.oldValue == nil {
  48745. return v, errors.New("OldAgentID requires an ID field in the mutation")
  48746. }
  48747. oldValue, err := m.oldValue(ctx)
  48748. if err != nil {
  48749. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  48750. }
  48751. return oldValue.AgentID, nil
  48752. }
  48753. // ResetAgentID resets all changes to the "agent_id" field.
  48754. func (m *XunjiServiceMutation) ResetAgentID() {
  48755. m.agent = nil
  48756. }
  48757. // SetOrganizationID sets the "organization_id" field.
  48758. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  48759. m.organization_id = &u
  48760. m.addorganization_id = nil
  48761. }
  48762. // OrganizationID returns the value of the "organization_id" field in the mutation.
  48763. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  48764. v := m.organization_id
  48765. if v == nil {
  48766. return
  48767. }
  48768. return *v, true
  48769. }
  48770. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  48771. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48773. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  48774. if !m.op.Is(OpUpdateOne) {
  48775. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  48776. }
  48777. if m.id == nil || m.oldValue == nil {
  48778. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  48779. }
  48780. oldValue, err := m.oldValue(ctx)
  48781. if err != nil {
  48782. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  48783. }
  48784. return oldValue.OrganizationID, nil
  48785. }
  48786. // AddOrganizationID adds u to the "organization_id" field.
  48787. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  48788. if m.addorganization_id != nil {
  48789. *m.addorganization_id += u
  48790. } else {
  48791. m.addorganization_id = &u
  48792. }
  48793. }
  48794. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  48795. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  48796. v := m.addorganization_id
  48797. if v == nil {
  48798. return
  48799. }
  48800. return *v, true
  48801. }
  48802. // ResetOrganizationID resets all changes to the "organization_id" field.
  48803. func (m *XunjiServiceMutation) ResetOrganizationID() {
  48804. m.organization_id = nil
  48805. m.addorganization_id = nil
  48806. }
  48807. // SetWxid sets the "wxid" field.
  48808. func (m *XunjiServiceMutation) SetWxid(s string) {
  48809. m.wxid = &s
  48810. }
  48811. // Wxid returns the value of the "wxid" field in the mutation.
  48812. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  48813. v := m.wxid
  48814. if v == nil {
  48815. return
  48816. }
  48817. return *v, true
  48818. }
  48819. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  48820. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48822. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  48823. if !m.op.Is(OpUpdateOne) {
  48824. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  48825. }
  48826. if m.id == nil || m.oldValue == nil {
  48827. return v, errors.New("OldWxid requires an ID field in the mutation")
  48828. }
  48829. oldValue, err := m.oldValue(ctx)
  48830. if err != nil {
  48831. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  48832. }
  48833. return oldValue.Wxid, nil
  48834. }
  48835. // ResetWxid resets all changes to the "wxid" field.
  48836. func (m *XunjiServiceMutation) ResetWxid() {
  48837. m.wxid = nil
  48838. }
  48839. // SetAPIBase sets the "api_base" field.
  48840. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  48841. m.api_base = &s
  48842. }
  48843. // APIBase returns the value of the "api_base" field in the mutation.
  48844. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  48845. v := m.api_base
  48846. if v == nil {
  48847. return
  48848. }
  48849. return *v, true
  48850. }
  48851. // OldAPIBase returns the old "api_base" 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) OldAPIBase(ctx context.Context) (v string, err error) {
  48855. if !m.op.Is(OpUpdateOne) {
  48856. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  48857. }
  48858. if m.id == nil || m.oldValue == nil {
  48859. return v, errors.New("OldAPIBase 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 OldAPIBase: %w", err)
  48864. }
  48865. return oldValue.APIBase, nil
  48866. }
  48867. // ClearAPIBase clears the value of the "api_base" field.
  48868. func (m *XunjiServiceMutation) ClearAPIBase() {
  48869. m.api_base = nil
  48870. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  48871. }
  48872. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  48873. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  48874. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  48875. return ok
  48876. }
  48877. // ResetAPIBase resets all changes to the "api_base" field.
  48878. func (m *XunjiServiceMutation) ResetAPIBase() {
  48879. m.api_base = nil
  48880. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  48881. }
  48882. // SetAPIKey sets the "api_key" field.
  48883. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  48884. m.api_key = &s
  48885. }
  48886. // APIKey returns the value of the "api_key" field in the mutation.
  48887. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  48888. v := m.api_key
  48889. if v == nil {
  48890. return
  48891. }
  48892. return *v, true
  48893. }
  48894. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  48895. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48897. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  48898. if !m.op.Is(OpUpdateOne) {
  48899. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  48900. }
  48901. if m.id == nil || m.oldValue == nil {
  48902. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  48903. }
  48904. oldValue, err := m.oldValue(ctx)
  48905. if err != nil {
  48906. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  48907. }
  48908. return oldValue.APIKey, nil
  48909. }
  48910. // ClearAPIKey clears the value of the "api_key" field.
  48911. func (m *XunjiServiceMutation) ClearAPIKey() {
  48912. m.api_key = nil
  48913. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  48914. }
  48915. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  48916. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  48917. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  48918. return ok
  48919. }
  48920. // ResetAPIKey resets all changes to the "api_key" field.
  48921. func (m *XunjiServiceMutation) ResetAPIKey() {
  48922. m.api_key = nil
  48923. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  48924. }
  48925. // ClearAgent clears the "agent" edge to the Agent entity.
  48926. func (m *XunjiServiceMutation) ClearAgent() {
  48927. m.clearedagent = true
  48928. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  48929. }
  48930. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  48931. func (m *XunjiServiceMutation) AgentCleared() bool {
  48932. return m.clearedagent
  48933. }
  48934. // AgentIDs returns the "agent" edge IDs in the mutation.
  48935. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  48936. // AgentID instead. It exists only for internal usage by the builders.
  48937. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  48938. if id := m.agent; id != nil {
  48939. ids = append(ids, *id)
  48940. }
  48941. return
  48942. }
  48943. // ResetAgent resets all changes to the "agent" edge.
  48944. func (m *XunjiServiceMutation) ResetAgent() {
  48945. m.agent = nil
  48946. m.clearedagent = false
  48947. }
  48948. // Where appends a list predicates to the XunjiServiceMutation builder.
  48949. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  48950. m.predicates = append(m.predicates, ps...)
  48951. }
  48952. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  48953. // users can use type-assertion to append predicates that do not depend on any generated package.
  48954. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  48955. p := make([]predicate.XunjiService, len(ps))
  48956. for i := range ps {
  48957. p[i] = ps[i]
  48958. }
  48959. m.Where(p...)
  48960. }
  48961. // Op returns the operation name.
  48962. func (m *XunjiServiceMutation) Op() Op {
  48963. return m.op
  48964. }
  48965. // SetOp allows setting the mutation operation.
  48966. func (m *XunjiServiceMutation) SetOp(op Op) {
  48967. m.op = op
  48968. }
  48969. // Type returns the node type of this mutation (XunjiService).
  48970. func (m *XunjiServiceMutation) Type() string {
  48971. return m.typ
  48972. }
  48973. // Fields returns all fields that were changed during this mutation. Note that in
  48974. // order to get all numeric fields that were incremented/decremented, call
  48975. // AddedFields().
  48976. func (m *XunjiServiceMutation) Fields() []string {
  48977. fields := make([]string, 0, 10)
  48978. if m.created_at != nil {
  48979. fields = append(fields, xunjiservice.FieldCreatedAt)
  48980. }
  48981. if m.updated_at != nil {
  48982. fields = append(fields, xunjiservice.FieldUpdatedAt)
  48983. }
  48984. if m.status != nil {
  48985. fields = append(fields, xunjiservice.FieldStatus)
  48986. }
  48987. if m.deleted_at != nil {
  48988. fields = append(fields, xunjiservice.FieldDeletedAt)
  48989. }
  48990. if m.xunji_id != nil {
  48991. fields = append(fields, xunjiservice.FieldXunjiID)
  48992. }
  48993. if m.agent != nil {
  48994. fields = append(fields, xunjiservice.FieldAgentID)
  48995. }
  48996. if m.organization_id != nil {
  48997. fields = append(fields, xunjiservice.FieldOrganizationID)
  48998. }
  48999. if m.wxid != nil {
  49000. fields = append(fields, xunjiservice.FieldWxid)
  49001. }
  49002. if m.api_base != nil {
  49003. fields = append(fields, xunjiservice.FieldAPIBase)
  49004. }
  49005. if m.api_key != nil {
  49006. fields = append(fields, xunjiservice.FieldAPIKey)
  49007. }
  49008. return fields
  49009. }
  49010. // Field returns the value of a field with the given name. The second boolean
  49011. // return value indicates that this field was not set, or was not defined in the
  49012. // schema.
  49013. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  49014. switch name {
  49015. case xunjiservice.FieldCreatedAt:
  49016. return m.CreatedAt()
  49017. case xunjiservice.FieldUpdatedAt:
  49018. return m.UpdatedAt()
  49019. case xunjiservice.FieldStatus:
  49020. return m.Status()
  49021. case xunjiservice.FieldDeletedAt:
  49022. return m.DeletedAt()
  49023. case xunjiservice.FieldXunjiID:
  49024. return m.XunjiID()
  49025. case xunjiservice.FieldAgentID:
  49026. return m.AgentID()
  49027. case xunjiservice.FieldOrganizationID:
  49028. return m.OrganizationID()
  49029. case xunjiservice.FieldWxid:
  49030. return m.Wxid()
  49031. case xunjiservice.FieldAPIBase:
  49032. return m.APIBase()
  49033. case xunjiservice.FieldAPIKey:
  49034. return m.APIKey()
  49035. }
  49036. return nil, false
  49037. }
  49038. // OldField returns the old value of the field from the database. An error is
  49039. // returned if the mutation operation is not UpdateOne, or the query to the
  49040. // database failed.
  49041. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49042. switch name {
  49043. case xunjiservice.FieldCreatedAt:
  49044. return m.OldCreatedAt(ctx)
  49045. case xunjiservice.FieldUpdatedAt:
  49046. return m.OldUpdatedAt(ctx)
  49047. case xunjiservice.FieldStatus:
  49048. return m.OldStatus(ctx)
  49049. case xunjiservice.FieldDeletedAt:
  49050. return m.OldDeletedAt(ctx)
  49051. case xunjiservice.FieldXunjiID:
  49052. return m.OldXunjiID(ctx)
  49053. case xunjiservice.FieldAgentID:
  49054. return m.OldAgentID(ctx)
  49055. case xunjiservice.FieldOrganizationID:
  49056. return m.OldOrganizationID(ctx)
  49057. case xunjiservice.FieldWxid:
  49058. return m.OldWxid(ctx)
  49059. case xunjiservice.FieldAPIBase:
  49060. return m.OldAPIBase(ctx)
  49061. case xunjiservice.FieldAPIKey:
  49062. return m.OldAPIKey(ctx)
  49063. }
  49064. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  49065. }
  49066. // SetField sets the value of a field with the given name. It returns an error if
  49067. // the field is not defined in the schema, or if the type mismatched the field
  49068. // type.
  49069. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  49070. switch name {
  49071. case xunjiservice.FieldCreatedAt:
  49072. v, ok := value.(time.Time)
  49073. if !ok {
  49074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49075. }
  49076. m.SetCreatedAt(v)
  49077. return nil
  49078. case xunjiservice.FieldUpdatedAt:
  49079. v, ok := value.(time.Time)
  49080. if !ok {
  49081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49082. }
  49083. m.SetUpdatedAt(v)
  49084. return nil
  49085. case xunjiservice.FieldStatus:
  49086. v, ok := value.(uint8)
  49087. if !ok {
  49088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49089. }
  49090. m.SetStatus(v)
  49091. return nil
  49092. case xunjiservice.FieldDeletedAt:
  49093. v, ok := value.(time.Time)
  49094. if !ok {
  49095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49096. }
  49097. m.SetDeletedAt(v)
  49098. return nil
  49099. case xunjiservice.FieldXunjiID:
  49100. v, ok := value.(uint64)
  49101. if !ok {
  49102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49103. }
  49104. m.SetXunjiID(v)
  49105. return nil
  49106. case xunjiservice.FieldAgentID:
  49107. v, ok := value.(uint64)
  49108. if !ok {
  49109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49110. }
  49111. m.SetAgentID(v)
  49112. return nil
  49113. case xunjiservice.FieldOrganizationID:
  49114. v, ok := value.(uint64)
  49115. if !ok {
  49116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49117. }
  49118. m.SetOrganizationID(v)
  49119. return nil
  49120. case xunjiservice.FieldWxid:
  49121. v, ok := value.(string)
  49122. if !ok {
  49123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49124. }
  49125. m.SetWxid(v)
  49126. return nil
  49127. case xunjiservice.FieldAPIBase:
  49128. v, ok := value.(string)
  49129. if !ok {
  49130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49131. }
  49132. m.SetAPIBase(v)
  49133. return nil
  49134. case xunjiservice.FieldAPIKey:
  49135. v, ok := value.(string)
  49136. if !ok {
  49137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49138. }
  49139. m.SetAPIKey(v)
  49140. return nil
  49141. }
  49142. return fmt.Errorf("unknown XunjiService field %s", name)
  49143. }
  49144. // AddedFields returns all numeric fields that were incremented/decremented during
  49145. // this mutation.
  49146. func (m *XunjiServiceMutation) AddedFields() []string {
  49147. var fields []string
  49148. if m.addstatus != nil {
  49149. fields = append(fields, xunjiservice.FieldStatus)
  49150. }
  49151. if m.addxunji_id != nil {
  49152. fields = append(fields, xunjiservice.FieldXunjiID)
  49153. }
  49154. if m.addorganization_id != nil {
  49155. fields = append(fields, xunjiservice.FieldOrganizationID)
  49156. }
  49157. return fields
  49158. }
  49159. // AddedField returns the numeric value that was incremented/decremented on a field
  49160. // with the given name. The second boolean return value indicates that this field
  49161. // was not set, or was not defined in the schema.
  49162. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  49163. switch name {
  49164. case xunjiservice.FieldStatus:
  49165. return m.AddedStatus()
  49166. case xunjiservice.FieldXunjiID:
  49167. return m.AddedXunjiID()
  49168. case xunjiservice.FieldOrganizationID:
  49169. return m.AddedOrganizationID()
  49170. }
  49171. return nil, false
  49172. }
  49173. // AddField adds the value to the field with the given name. It returns an error if
  49174. // the field is not defined in the schema, or if the type mismatched the field
  49175. // type.
  49176. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  49177. switch name {
  49178. case xunjiservice.FieldStatus:
  49179. v, ok := value.(int8)
  49180. if !ok {
  49181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49182. }
  49183. m.AddStatus(v)
  49184. return nil
  49185. case xunjiservice.FieldXunjiID:
  49186. v, ok := value.(int64)
  49187. if !ok {
  49188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49189. }
  49190. m.AddXunjiID(v)
  49191. return nil
  49192. case xunjiservice.FieldOrganizationID:
  49193. v, ok := value.(int64)
  49194. if !ok {
  49195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49196. }
  49197. m.AddOrganizationID(v)
  49198. return nil
  49199. }
  49200. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  49201. }
  49202. // ClearedFields returns all nullable fields that were cleared during this
  49203. // mutation.
  49204. func (m *XunjiServiceMutation) ClearedFields() []string {
  49205. var fields []string
  49206. if m.FieldCleared(xunjiservice.FieldStatus) {
  49207. fields = append(fields, xunjiservice.FieldStatus)
  49208. }
  49209. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  49210. fields = append(fields, xunjiservice.FieldDeletedAt)
  49211. }
  49212. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  49213. fields = append(fields, xunjiservice.FieldAPIBase)
  49214. }
  49215. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  49216. fields = append(fields, xunjiservice.FieldAPIKey)
  49217. }
  49218. return fields
  49219. }
  49220. // FieldCleared returns a boolean indicating if a field with the given name was
  49221. // cleared in this mutation.
  49222. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  49223. _, ok := m.clearedFields[name]
  49224. return ok
  49225. }
  49226. // ClearField clears the value of the field with the given name. It returns an
  49227. // error if the field is not defined in the schema.
  49228. func (m *XunjiServiceMutation) ClearField(name string) error {
  49229. switch name {
  49230. case xunjiservice.FieldStatus:
  49231. m.ClearStatus()
  49232. return nil
  49233. case xunjiservice.FieldDeletedAt:
  49234. m.ClearDeletedAt()
  49235. return nil
  49236. case xunjiservice.FieldAPIBase:
  49237. m.ClearAPIBase()
  49238. return nil
  49239. case xunjiservice.FieldAPIKey:
  49240. m.ClearAPIKey()
  49241. return nil
  49242. }
  49243. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  49244. }
  49245. // ResetField resets all changes in the mutation for the field with the given name.
  49246. // It returns an error if the field is not defined in the schema.
  49247. func (m *XunjiServiceMutation) ResetField(name string) error {
  49248. switch name {
  49249. case xunjiservice.FieldCreatedAt:
  49250. m.ResetCreatedAt()
  49251. return nil
  49252. case xunjiservice.FieldUpdatedAt:
  49253. m.ResetUpdatedAt()
  49254. return nil
  49255. case xunjiservice.FieldStatus:
  49256. m.ResetStatus()
  49257. return nil
  49258. case xunjiservice.FieldDeletedAt:
  49259. m.ResetDeletedAt()
  49260. return nil
  49261. case xunjiservice.FieldXunjiID:
  49262. m.ResetXunjiID()
  49263. return nil
  49264. case xunjiservice.FieldAgentID:
  49265. m.ResetAgentID()
  49266. return nil
  49267. case xunjiservice.FieldOrganizationID:
  49268. m.ResetOrganizationID()
  49269. return nil
  49270. case xunjiservice.FieldWxid:
  49271. m.ResetWxid()
  49272. return nil
  49273. case xunjiservice.FieldAPIBase:
  49274. m.ResetAPIBase()
  49275. return nil
  49276. case xunjiservice.FieldAPIKey:
  49277. m.ResetAPIKey()
  49278. return nil
  49279. }
  49280. return fmt.Errorf("unknown XunjiService field %s", name)
  49281. }
  49282. // AddedEdges returns all edge names that were set/added in this mutation.
  49283. func (m *XunjiServiceMutation) AddedEdges() []string {
  49284. edges := make([]string, 0, 1)
  49285. if m.agent != nil {
  49286. edges = append(edges, xunjiservice.EdgeAgent)
  49287. }
  49288. return edges
  49289. }
  49290. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49291. // name in this mutation.
  49292. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  49293. switch name {
  49294. case xunjiservice.EdgeAgent:
  49295. if id := m.agent; id != nil {
  49296. return []ent.Value{*id}
  49297. }
  49298. }
  49299. return nil
  49300. }
  49301. // RemovedEdges returns all edge names that were removed in this mutation.
  49302. func (m *XunjiServiceMutation) RemovedEdges() []string {
  49303. edges := make([]string, 0, 1)
  49304. return edges
  49305. }
  49306. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49307. // the given name in this mutation.
  49308. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  49309. return nil
  49310. }
  49311. // ClearedEdges returns all edge names that were cleared in this mutation.
  49312. func (m *XunjiServiceMutation) ClearedEdges() []string {
  49313. edges := make([]string, 0, 1)
  49314. if m.clearedagent {
  49315. edges = append(edges, xunjiservice.EdgeAgent)
  49316. }
  49317. return edges
  49318. }
  49319. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49320. // was cleared in this mutation.
  49321. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  49322. switch name {
  49323. case xunjiservice.EdgeAgent:
  49324. return m.clearedagent
  49325. }
  49326. return false
  49327. }
  49328. // ClearEdge clears the value of the edge with the given name. It returns an error
  49329. // if that edge is not defined in the schema.
  49330. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  49331. switch name {
  49332. case xunjiservice.EdgeAgent:
  49333. m.ClearAgent()
  49334. return nil
  49335. }
  49336. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  49337. }
  49338. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49339. // It returns an error if the edge is not defined in the schema.
  49340. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  49341. switch name {
  49342. case xunjiservice.EdgeAgent:
  49343. m.ResetAgent()
  49344. return nil
  49345. }
  49346. return fmt.Errorf("unknown XunjiService edge %s", name)
  49347. }